@shware/analytics 16.2.2 → 16.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/schema/index.cjs +9 -7
  2. package/dist/schema/index.cjs.map +1 -1
  3. package/dist/schema/index.d.cts.map +1 -1
  4. package/dist/schema/index.d.mts.map +1 -1
  5. package/dist/schema/index.mjs +9 -7
  6. package/dist/schema/index.mjs.map +1 -1
  7. package/dist/server/event-time.cjs +14 -0
  8. package/dist/server/event-time.cjs.map +1 -0
  9. package/dist/server/event-time.d.cts +8 -0
  10. package/dist/server/event-time.d.cts.map +1 -0
  11. package/dist/server/event-time.d.mts +8 -0
  12. package/dist/server/event-time.d.mts.map +1 -0
  13. package/dist/server/event-time.mjs +13 -0
  14. package/dist/server/event-time.mjs.map +1 -0
  15. package/dist/server/meta-capi.cjs +4 -3
  16. package/dist/server/meta-capi.cjs.map +1 -1
  17. package/dist/server/meta-capi.d.cts.map +1 -1
  18. package/dist/server/meta-capi.d.mts.map +1 -1
  19. package/dist/server/meta-capi.mjs +4 -3
  20. package/dist/server/meta-capi.mjs.map +1 -1
  21. package/dist/server/microsoft-conversions-api.cjs +2 -1
  22. package/dist/server/microsoft-conversions-api.cjs.map +1 -1
  23. package/dist/server/microsoft-conversions-api.d.cts.map +1 -1
  24. package/dist/server/microsoft-conversions-api.d.mts.map +1 -1
  25. package/dist/server/microsoft-conversions-api.mjs +2 -1
  26. package/dist/server/microsoft-conversions-api.mjs.map +1 -1
  27. package/dist/server/reddit-conversions-api.cjs +2 -1
  28. package/dist/server/reddit-conversions-api.cjs.map +1 -1
  29. package/dist/server/reddit-conversions-api.d.cts.map +1 -1
  30. package/dist/server/reddit-conversions-api.d.mts.map +1 -1
  31. package/dist/server/reddit-conversions-api.mjs +2 -1
  32. package/dist/server/reddit-conversions-api.mjs.map +1 -1
  33. package/dist/visitor/id.cjs +5 -2
  34. package/dist/visitor/id.cjs.map +1 -1
  35. package/dist/visitor/id.d.cts +4 -1
  36. package/dist/visitor/id.d.cts.map +1 -1
  37. package/dist/visitor/id.d.mts +4 -1
  38. package/dist/visitor/id.d.mts.map +1 -1
  39. package/dist/visitor/id.mjs +6 -3
  40. package/dist/visitor/id.mjs.map +1 -1
  41. package/package.json +1 -1
@@ -2,7 +2,10 @@
2
2
  * This visitor's id: generated here on the first visit (uuidv7) and kept in `config.storage`, so
3
3
  * it exists the moment the page loads. The first events, and the beacon of a visit left within a
4
4
  * second, go out without waiting for a round trip; the server creates the visitor from its first
5
- * events. An id a server issued to an older client is kept as it is: the visitor continues.
5
+ * events. A uuidv7 a server issued to an older client is kept as it is: the visitor continues.
6
+ * Anything else stored there is replaced, because the server rejects every batch carrying it:
7
+ * clients before 11.0 kept the int64 id older servers issued, and healed it by recreating the
8
+ * visitor when the server refused it; without that round trip the id would never change.
6
9
  *
7
10
  * Needs a server that creates visitors from events (see the README, "Visitors"); one that still
8
11
  * only creates them on `POST /visitors` rejects the events of a new visitor.
@@ -1 +1 @@
1
- {"version":3,"file":"id.d.cts","names":[],"sources":["../../src/visitor/id.ts"],"mappings":";;;;;;;;;wBAagB;;wBASA"}
1
+ {"version":3,"file":"id.d.cts","names":[],"sources":["../../src/visitor/id.ts"],"mappings":";;;;;;;;;;;;wBAgBgB;;wBASA"}
@@ -2,7 +2,10 @@
2
2
  * This visitor's id: generated here on the first visit (uuidv7) and kept in `config.storage`, so
3
3
  * it exists the moment the page loads. The first events, and the beacon of a visit left within a
4
4
  * second, go out without waiting for a round trip; the server creates the visitor from its first
5
- * events. An id a server issued to an older client is kept as it is: the visitor continues.
5
+ * events. A uuidv7 a server issued to an older client is kept as it is: the visitor continues.
6
+ * Anything else stored there is replaced, because the server rejects every batch carrying it:
7
+ * clients before 11.0 kept the int64 id older servers issued, and healed it by recreating the
8
+ * visitor when the server refused it; without that round trip the id would never change.
6
9
  *
7
10
  * Needs a server that creates visitors from events (see the README, "Visitors"); one that still
8
11
  * only creates them on `POST /visitors` rejects the events of a new visitor.
@@ -1 +1 @@
1
- {"version":3,"file":"id.d.mts","names":[],"sources":["../../src/visitor/id.ts"],"mappings":";;;;;;;;;wBAagB;;wBASA"}
1
+ {"version":3,"file":"id.d.mts","names":[],"sources":["../../src/visitor/id.ts"],"mappings":";;;;;;;;;;;;wBAgBgB;;wBASA"}
@@ -1,19 +1,22 @@
1
1
  import { config } from "../setup/index.mjs";
2
2
  import { keys } from "../constants/storage.mjs";
3
- import { v7 } from "uuid";
3
+ import { v7, validate, version } from "uuid";
4
4
  // src/visitor/id.ts
5
5
  /**
6
6
  * This visitor's id: generated here on the first visit (uuidv7) and kept in `config.storage`, so
7
7
  * it exists the moment the page loads. The first events, and the beacon of a visit left within a
8
8
  * second, go out without waiting for a round trip; the server creates the visitor from its first
9
- * events. An id a server issued to an older client is kept as it is: the visitor continues.
9
+ * events. A uuidv7 a server issued to an older client is kept as it is: the visitor continues.
10
+ * Anything else stored there is replaced, because the server rejects every batch carrying it:
11
+ * clients before 11.0 kept the int64 id older servers issued, and healed it by recreating the
12
+ * visitor when the server refused it; without that round trip the id would never change.
10
13
  *
11
14
  * Needs a server that creates visitors from events (see the README, "Visitors"); one that still
12
15
  * only creates them on `POST /visitors` rejects the events of a new visitor.
13
16
  */
14
17
  function visitorId() {
15
18
  const stored = config.storage.getItem(keys.visitor_id);
16
- if (stored && stored !== "undefined") return stored;
19
+ if (stored && validate(stored) && version(stored) === 7) return stored;
17
20
  return newVisitorId();
18
21
  }
19
22
  /** Starts a new visitor on this device — `reset()` — and returns its id. */
@@ -1 +1 @@
1
- {"version":3,"file":"id.mjs","names":["uuidv7"],"sources":["../../src/visitor/id.ts"],"sourcesContent":["import { v7 as uuidv7 } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { config } from '../setup/index';\n\n/**\n * This visitor's id: generated here on the first visit (uuidv7) and kept in `config.storage`, so\n * it exists the moment the page loads. The first events, and the beacon of a visit left within a\n * second, go out without waiting for a round trip; the server creates the visitor from its first\n * events. An id a server issued to an older client is kept as it is: the visitor continues.\n *\n * Needs a server that creates visitors from events (see the README, \"Visitors\"); one that still\n * only creates them on `POST /visitors` rejects the events of a new visitor.\n */\nexport function visitorId(): string {\n const stored = config.storage.getItem(keys.visitor_id);\n // An old client stored the string 'undefined' as the id (it wrote an unset id): not an id, so it\n // is replaced below with a new one, which also clears the bad value from storage for good.\n if (stored && stored !== 'undefined') return stored;\n return newVisitorId();\n}\n\n/** Starts a new visitor on this device — `reset()` — and returns its id. */\nexport function newVisitorId(): string {\n const id = uuidv7();\n config.storage.setItem(keys.visitor_id, id);\n return id;\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,YAAoB;CAClC,MAAM,SAAS,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAGrD,IAAI,UAAU,WAAW,aAAa,OAAO;CAC7C,OAAO,aAAa;AACtB;;AAGA,SAAgB,eAAuB;CACrC,MAAM,KAAKA,GAAO;CAClB,OAAO,QAAQ,QAAQ,KAAK,YAAY,EAAE;CAC1C,OAAO;AACT"}
1
+ {"version":3,"file":"id.mjs","names":["uuidv7"],"sources":["../../src/visitor/id.ts"],"sourcesContent":["import { v7 as uuidv7, validate, version } from 'uuid';\nimport { keys } from '../constants/storage';\nimport { config } from '../setup/index';\n\n/**\n * This visitor's id: generated here on the first visit (uuidv7) and kept in `config.storage`, so\n * it exists the moment the page loads. The first events, and the beacon of a visit left within a\n * second, go out without waiting for a round trip; the server creates the visitor from its first\n * events. A uuidv7 a server issued to an older client is kept as it is: the visitor continues.\n * Anything else stored there is replaced, because the server rejects every batch carrying it:\n * clients before 11.0 kept the int64 id older servers issued, and healed it by recreating the\n * visitor when the server refused it; without that round trip the id would never change.\n *\n * Needs a server that creates visitors from events (see the README, \"Visitors\"); one that still\n * only creates them on `POST /visitors` rejects the events of a new visitor.\n */\nexport function visitorId(): string {\n const stored = config.storage.getItem(keys.visitor_id);\n // Also covers the string 'undefined' an old client stored for an unset id. Replacing it below\n // writes the new id back, which clears the bad value from storage for good.\n if (stored && validate(stored) && version(stored) === 7) return stored;\n return newVisitorId();\n}\n\n/** Starts a new visitor on this device — `reset()` — and returns its id. */\nexport function newVisitorId(): string {\n const id = uuidv7();\n config.storage.setItem(keys.visitor_id, id);\n return id;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,YAAoB;CAClC,MAAM,SAAS,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAGrD,IAAI,UAAU,SAAS,MAAM,KAAK,QAAQ,MAAM,MAAM,GAAG,OAAO;CAChE,OAAO,aAAa;AACtB;;AAGA,SAAgB,eAAuB;CACrC,MAAM,KAAKA,GAAO;CAClB,OAAO,QAAQ,QAAQ,KAAK,YAAY,EAAE;CAC1C,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shware/analytics",
3
- "version": "16.2.2",
3
+ "version": "16.2.3",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",