snowplow / snowplow-javascript-tracker

Snowplow event tracker for client-side and server-side JavaScript. Add analytics to your websites, web apps and servers.
http://snowplowanalytics.com
BSD 3-Clause "New" or "Revised" License
550 stars 222 forks source link

ContextGeneratorEvent["event"] shouldn't be typed as SelfDescribingJson #838

Closed amoshydra closed 4 years ago

amoshydra commented 4 years ago

Describe the bug

The first argument of ContextGenerator, event does not match the type definition of SelfDescribingJson. SelfDescribingJson contains properties data and scheme, but event does not.

Consequently it implies that both data and schema exists in the event value. But in usage, they do not exist.

image

In actual usage the args.event payload looks more like this: https://github.com/snowplow/snowplow/wiki/snowplow-tracker-protocol#3-snowplow-events

{
  "uid": "aeb1691c5a0ee5a6",
  "vid": "2",
  "tid": "508780",
  "aid": "1",
  "tv": "js-0.5.2",

  "e": "se",
  "se_ca": "ecomm",
  "se_ac": "add-to-basket",
  "se_la": "178",
  "se_pr": "1",
  "se_va": "14.99"
}

References for the type and interfaces mentioned: https://github.com/snowplow/snowplow-javascript-tracker/blob/abb0d37ee512a5efb9ed0d2e56d50ecd6ae6787e/core/src/contexts.ts#L36-L47

https://github.com/snowplow/snowplow-javascript-tracker/blob/abb0d37ee512a5efb9ed0d2e56d50ecd6ae6787e/core/src/core.ts#L21-L28

To Reproduce N/A

Expected behavior

Should event be Record<string, unknown> instead?

Screenshots N/A

Desktop (please complete the following information): N/A

Smartphone (please complete the following information): N/A

Additional context snowplow-tracker-core@0.9.1

paulboocock commented 4 years ago

Thanks for the report. You are very much correct and I've fixed this in the current working branch. I'll be releasing 0.9.2 shortly with this fix.