@nexly/core 0.16.0 → 0.16.1

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.
package/dist/collect.d.ts CHANGED
@@ -55,6 +55,29 @@ export type StandardContextOverride = {
55
55
  mc_cid?: string;
56
56
  ref?: string;
57
57
  };
58
+ /**
59
+ * Runtime mirror of the keys in {@link StandardContextOverride}.
60
+ * Mirrors `internal/apps/ingest_context.go::StandardAttributionKeys`
61
+ * on the server — when adding a new marketing parameter, update both
62
+ * sides plus the type above.
63
+ *
64
+ * Useful when application code needs to split a free-form payload
65
+ * into the {@link CData} slot (product-data) and the third `context`
66
+ * parameter of {@link NexlyBase.customEvent} (attribution
67
+ * overrides). Note that `ref` is included because it is a
68
+ * standard affiliate / referral parameter; apps that use `ref` as
69
+ * a product-internal code (e.g. Vaiz) should treat it as cdata
70
+ * rather than attribution — partition it out manually.
71
+ */
72
+ export declare const STANDARD_ATTRIBUTION_KEYS: readonly ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", "gclid", "gad_source", "gad_campaignid", "fbclid", "msclkid", "ttclid", "li_fat_id", "yclid", "mc_cid", "ref"];
73
+ /** Union of {@link STANDARD_ATTRIBUTION_KEYS} entries. */
74
+ export type StandardAttributionKey = (typeof STANDARD_ATTRIBUTION_KEYS)[number];
75
+ /**
76
+ * Returns `true` when `key` is a member of {@link STANDARD_ATTRIBUTION_KEYS}.
77
+ * Use this as a predicate when splitting a flat payload into the
78
+ * {@link CData} slot and the attribution-overrides slot.
79
+ */
80
+ export declare function isStandardAttributionKey(key: string): key is StandardAttributionKey;
58
81
  /**
59
82
  * Event envelope:
60
83
  * - `context` — per-event volatile metadata (path, screen, viewport, visitor_id, session_id, …)
@@ -1 +1 @@
1
- {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;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A;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,iMAgB5B,CAAA;AAEV,0DAA0D;AAC1D,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAA;AAI/E;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,sBAAsB,CAEnF;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,iBAAiB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4BnF"}
package/dist/collect.js CHANGED
@@ -4,6 +4,46 @@
4
4
  * This module is safe to import from any runtime (browser, React Native, Node).
5
5
  * Transport (beacon / fetch / native) lives in platform-specific packages.
6
6
  */
7
+ /**
8
+ * Runtime mirror of the keys in {@link StandardContextOverride}.
9
+ * Mirrors `internal/apps/ingest_context.go::StandardAttributionKeys`
10
+ * on the server — when adding a new marketing parameter, update both
11
+ * sides plus the type above.
12
+ *
13
+ * Useful when application code needs to split a free-form payload
14
+ * into the {@link CData} slot (product-data) and the third `context`
15
+ * parameter of {@link NexlyBase.customEvent} (attribution
16
+ * overrides). Note that `ref` is included because it is a
17
+ * standard affiliate / referral parameter; apps that use `ref` as
18
+ * a product-internal code (e.g. Vaiz) should treat it as cdata
19
+ * rather than attribution — partition it out manually.
20
+ */
21
+ export const STANDARD_ATTRIBUTION_KEYS = [
22
+ 'utm_source',
23
+ 'utm_medium',
24
+ 'utm_campaign',
25
+ 'utm_content',
26
+ 'utm_term',
27
+ 'gclid',
28
+ 'gad_source',
29
+ 'gad_campaignid',
30
+ 'fbclid',
31
+ 'msclkid',
32
+ 'ttclid',
33
+ 'li_fat_id',
34
+ 'yclid',
35
+ 'mc_cid',
36
+ 'ref',
37
+ ];
38
+ const STANDARD_ATTRIBUTION_KEY_SET = new Set(STANDARD_ATTRIBUTION_KEYS);
39
+ /**
40
+ * Returns `true` when `key` is a member of {@link STANDARD_ATTRIBUTION_KEYS}.
41
+ * Use this as a predicate when splitting a flat payload into the
42
+ * {@link CData} slot and the attribution-overrides slot.
43
+ */
44
+ export function isStandardAttributionKey(key) {
45
+ return STANDARD_ATTRIBUTION_KEY_SET.has(key);
46
+ }
7
47
  function isPlainObject(v) {
8
48
  return v !== null && typeof v === 'object' && !Array.isArray(v);
9
49
  }
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * - `@nexly/web` — browser (sendBeacon, DOM meta, engagement listeners).
6
6
  * - `@nexly/react-native` — React Native (fetch, AsyncStorage, AppState).
7
7
  */
8
- export { buildCollectPayload, type CData, type CollectCredentials, type IngestCredentials, type StandardContextOverride, type TrackEventInput, } from './collect.js';
8
+ export { buildCollectPayload, isStandardAttributionKey, STANDARD_ATTRIBUTION_KEYS, type CData, type CollectCredentials, type IngestCredentials, type StandardAttributionKey, type StandardContextOverride, type TrackEventInput, } from './collect.js';
9
9
  export { NexlyBase, DEFAULT_COLLECT_URL, type NexlyEventInput, type NexlyEventType, type NexlyInit, } from './nexly-base.js';
10
10
  export { NexlyClient } from './clients.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -5,6 +5,6 @@
5
5
  * - `@nexly/web` — browser (sendBeacon, DOM meta, engagement listeners).
6
6
  * - `@nexly/react-native` — React Native (fetch, AsyncStorage, AppState).
7
7
  */
8
- export { buildCollectPayload, } from './collect.js';
8
+ export { buildCollectPayload, isStandardAttributionKey, STANDARD_ATTRIBUTION_KEYS, } from './collect.js';
9
9
  export { NexlyBase, DEFAULT_COLLECT_URL, } from './nexly-base.js';
10
10
  export { NexlyClient } from './clients.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/core",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Nexly ingest core (platform-agnostic): types, payload builder, abstract NexlyBase client",
5
5
  "license": "MIT",
6
6
  "keywords": [