@nexly/core 0.12.0 → 0.13.0

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/clients.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const NexlyClient: {
11
11
  readonly RNIos: "rn-ios";
12
12
  readonly RNAndroid: "rn-android";
13
13
  readonly RNWeb: "rn-web";
14
+ readonly Node: "node";
14
15
  };
15
16
  /** Type union of all known client identifiers (string-literal type). */
16
17
  export type NexlyClient = (typeof NexlyClient)[keyof typeof NexlyClient];
@@ -1 +1 @@
1
- {"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;CAOd,CAAA;AAEV,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA"}
1
+ {"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;CAQd,CAAA;AAEV,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAA"}
package/dist/clients.js CHANGED
@@ -11,4 +11,5 @@ export const NexlyClient = {
11
11
  RNIos: 'rn-ios',
12
12
  RNAndroid: 'rn-android',
13
13
  RNWeb: 'rn-web',
14
+ Node: 'node',
14
15
  };
@@ -45,6 +45,14 @@ export declare abstract class NexlyBase {
45
45
  readonly appId: string;
46
46
  readonly key: string;
47
47
  readonly client: NexlyClient | undefined;
48
+ /**
49
+ * Tracks whether `session_context` has already been emitted for the current
50
+ * `session_id`. `session_context` is session-stable (UA, screen, locale) —
51
+ * the collector upserts it once per session, so resending on every event is
52
+ * wasted bandwidth. Reset automatically when the observed `session_id`
53
+ * changes (e.g. 30-minute idle rollover).
54
+ */
55
+ private sentSessionContextFor;
48
56
  protected constructor(init: NexlyInit);
49
57
  protected get disabled(): boolean;
50
58
  protected get credentials(): IngestCredentials;
@@ -1 +1 @@
1
- {"version":3,"file":"nexly-base.d.ts","sourceRoot":"","sources":["../src/nexly-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAI1E,eAAO,MAAM,mBAAmB,qCAAqC,CAAA;AAErE,sGAAsG;AACtG,MAAM,MAAM,SAAS,GAAG;IACtB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,gEAAgE;AAChE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAA;AAEjE,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,cAAc,GAAG,MAAM,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC,CAAA;AAED;;;;;;;;;GASG;AACH,8BAAsB,SAAS;IAC7B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAyB;IAEjD,iFAAiF;IACjF,MAAM,CAAC,WAAW,IAAI,SAAS,GAAG,IAAI;IAItC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAI9D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MA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C,QAAQ,CAAC,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnE,kDAAkD;IAClD,QAAQ,CAAC,cAAc,IAAI,MAAM;IAEjC,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,IAAI,MAAM,IAAI;IAEtC;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO;IAWhC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO;IAYtC,OAAO,CAAC,QAAQ;CA4BjB"}
@@ -23,6 +23,14 @@ export class NexlyBase {
23
23
  appId;
24
24
  key;
25
25
  client;
26
+ /**
27
+ * Tracks whether `session_context` has already been emitted for the current
28
+ * `session_id`. `session_context` is session-stable (UA, screen, locale) —
29
+ * the collector upserts it once per session, so resending on every event is
30
+ * wasted bandwidth. Reset automatically when the observed `session_id`
31
+ * changes (e.g. 30-minute idle rollover).
32
+ */
33
+ sentSessionContextFor = null;
26
34
  constructor(init) {
27
35
  this.collectUrl = (init.collectUrl ?? DEFAULT_COLLECT_URL).trim();
28
36
  this.appId = (init.appId ?? '').trim();
@@ -51,7 +59,6 @@ export class NexlyBase {
51
59
  eventType: 'pageview',
52
60
  context: { ...this.collectEventContext(), path: resolvedPath },
53
61
  data: {},
54
- sessionContext: this.collectSessionContext(),
55
62
  });
56
63
  }
57
64
  /**
@@ -67,10 +74,18 @@ export class NexlyBase {
67
74
  eventType: input.type,
68
75
  context,
69
76
  data: input.data ?? {},
70
- sessionContext: this.collectSessionContext(),
71
77
  });
72
78
  }
73
79
  dispatch(args) {
80
+ const sessionId = typeof args.context.session_id === 'string' ? args.context.session_id : '';
81
+ let sessionContext;
82
+ if (sessionId && sessionId !== this.sentSessionContextFor) {
83
+ const collected = this.collectSessionContext();
84
+ if (collected && Object.keys(collected).length > 0) {
85
+ sessionContext = collected;
86
+ this.sentSessionContextFor = sessionId;
87
+ }
88
+ }
74
89
  const payload = buildCollectPayload({
75
90
  credentials: this.credentials,
76
91
  eventName: args.eventName,
@@ -78,7 +93,7 @@ export class NexlyBase {
78
93
  client: this.client,
79
94
  context: args.context,
80
95
  data: args.data,
81
- sessionContext: args.sessionContext,
96
+ sessionContext,
82
97
  });
83
98
  return this.transport(payload);
84
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/core",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Nexly ingest core (platform-agnostic): types, payload builder, abstract NexlyBase client",
5
5
  "license": "MIT",
6
6
  "keywords": [