@nexly/core 0.9.0 → 0.12.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Which SDK is reporting an event. Each runtime/framework package ships its own
3
+ * constant; framework wrappers override (e.g. `@nexly/next` sends `Next` on top
4
+ * of `@nexly/react-web`). Wire values are kebab-case; the backend rejects any
5
+ * other value.
6
+ */
7
+ export declare const NexlyClient: {
8
+ readonly Web: "web";
9
+ readonly React: "react";
10
+ readonly Next: "next";
11
+ readonly RNIos: "rn-ios";
12
+ readonly RNAndroid: "rn-android";
13
+ readonly RNWeb: "rn-web";
14
+ };
15
+ /** Type union of all known client identifiers (string-literal type). */
16
+ export type NexlyClient = (typeof NexlyClient)[keyof typeof NexlyClient];
17
+ //# sourceMappingURL=clients.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Which SDK is reporting an event. Each runtime/framework package ships its own
3
+ * constant; framework wrappers override (e.g. `@nexly/next` sends `Next` on top
4
+ * of `@nexly/react-web`). Wire values are kebab-case; the backend rejects any
5
+ * other value.
6
+ */
7
+ export const NexlyClient = {
8
+ Web: 'web',
9
+ React: 'react',
10
+ Next: 'next',
11
+ RNIos: 'rn-ios',
12
+ RNAndroid: 'rn-android',
13
+ RNWeb: 'rn-web',
14
+ };
package/dist/collect.d.ts CHANGED
@@ -4,6 +4,7 @@
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
+ import type { NexlyClient } from './clients.js';
7
8
  /** Auth fields for ingest (no transport URL). */
8
9
  export type IngestCredentials = {
9
10
  appId: string;
@@ -12,6 +13,8 @@ export type IngestCredentials = {
12
13
  /** Flat credentials + URL for small apps and event helpers. */
13
14
  export type CollectCredentials = {
14
15
  collectUrl: string;
16
+ /** Which SDK identity to report (see {@link TrackEventInput.client}). Optional. */
17
+ client?: NexlyClient;
15
18
  } & IngestCredentials;
16
19
  /**
17
20
  * Event envelope:
@@ -23,6 +26,12 @@ export type TrackEventInput = {
23
26
  credentials: IngestCredentials;
24
27
  eventName: string;
25
28
  eventType: string;
29
+ /**
30
+ * Which SDK is sending the event. See {@link NexlyClient}.
31
+ * Emitted as top-level `client` on the wire when non-empty. The backend
32
+ * rejects any value outside the enum.
33
+ */
34
+ client?: NexlyClient;
26
35
  context?: Record<string, unknown>;
27
36
  data?: Record<string, unknown>;
28
37
  sessionContext?: Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,iBAAiB,CAAA;AAErB;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,iBAAiB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBnF"}
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;AAE/C,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB,GAAG,iBAAiB,CAAA;AAErB;;;;;GAKG;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,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwBnF"}
package/dist/collect.js CHANGED
@@ -24,6 +24,10 @@ export function buildCollectPayload(input) {
24
24
  context,
25
25
  data,
26
26
  };
27
+ const client = typeof input.client === 'string' ? input.client.trim() : '';
28
+ if (client) {
29
+ body.client = client;
30
+ }
27
31
  if (pathFromContext) {
28
32
  body.path = pathFromContext;
29
33
  }
package/dist/index.d.ts CHANGED
@@ -7,4 +7,5 @@
7
7
  */
8
8
  export { buildCollectPayload, type CollectCredentials, type IngestCredentials, type TrackEventInput, } from './collect.js';
9
9
  export { NexlyBase, DEFAULT_COLLECT_URL, type NexlyEventInput, type NexlyEventType, type NexlyInit, } from './nexly-base.js';
10
+ export { NexlyClient } from './clients.js';
10
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,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,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
@@ -7,3 +7,4 @@
7
7
  */
8
8
  export { buildCollectPayload, } from './collect.js';
9
9
  export { NexlyBase, DEFAULT_COLLECT_URL, } from './nexly-base.js';
10
+ export { NexlyClient } from './clients.js';
@@ -1,3 +1,4 @@
1
+ import type { NexlyClient } from './clients.js';
1
2
  import { type IngestCredentials } from './collect.js';
2
3
  export declare const DEFAULT_COLLECT_URL = "https://gate.nexly.to/v1/collect";
3
4
  /** Options for {@link NexlyBase}. `key` is the ingest API token (sent as `api_token` on the wire). */
@@ -6,6 +7,15 @@ export type NexlyInit = {
6
7
  collectUrl?: string;
7
8
  appId: string;
8
9
  key: string;
10
+ /**
11
+ * @internal
12
+ *
13
+ * SDK identifier sent on the wire as `client`. Runtime packages (e.g.
14
+ * `@nexly/web`, `@nexly/react-native`) set a default here; framework
15
+ * adapters (e.g. `@nexly/next`) override via the React context exported
16
+ * from `@nexly/react-web`. Application code should not set this directly.
17
+ */
18
+ client?: NexlyClient;
9
19
  };
10
20
  /** Allowed event types. The backend rejects any other value. */
11
21
  export type NexlyEventType = 'pageview' | 'engagement' | 'custom';
@@ -34,6 +44,7 @@ export declare abstract class NexlyBase {
34
44
  readonly collectUrl: string;
35
45
  readonly appId: string;
36
46
  readonly key: string;
47
+ readonly client: NexlyClient | undefined;
37
48
  protected constructor(init: NexlyInit);
38
49
  protected get disabled(): boolean;
39
50
  protected get credentials(): IngestCredentials;
@@ -1 +1 @@
1
- {"version":3,"file":"nexly-base.d.ts","sourceRoot":"","sources":["../src/nexly-base.ts"],"names":[],"mappings":"AAAA,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;CACZ,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;IAC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AS,KAAK,WAAW,IAAI,iBAAiB,CAE7C;IAED,kFAAkF;IAClF,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;IAEvE,yDAAyD;IACzD,SAAS,CAAC,QAAQ,CAAC,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAEjE,yDAAyD;IACzD,SAAS,CAAC,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;IAYhC;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO;IAatC,OAAO,CAAC,QAAQ;CAkBjB"}
@@ -22,10 +22,12 @@ export class NexlyBase {
22
22
  collectUrl;
23
23
  appId;
24
24
  key;
25
+ client;
25
26
  constructor(init) {
26
27
  this.collectUrl = (init.collectUrl ?? DEFAULT_COLLECT_URL).trim();
27
28
  this.appId = (init.appId ?? '').trim();
28
29
  this.key = (init.key ?? '').trim();
30
+ this.client = init.client;
29
31
  if (!this.appId)
30
32
  console.warn('[Nexly] Missing appId — tracking will be disabled.');
31
33
  if (!this.key)
@@ -73,6 +75,7 @@ export class NexlyBase {
73
75
  credentials: this.credentials,
74
76
  eventName: args.eventName,
75
77
  eventType: args.eventType,
78
+ client: this.client,
76
79
  context: args.context,
77
80
  data: args.data,
78
81
  sessionContext: args.sessionContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/core",
3
- "version": "0.9.0",
3
+ "version": "0.12.0",
4
4
  "description": "Nexly ingest core (platform-agnostic): types, payload builder, abstract NexlyBase client",
5
5
  "license": "MIT",
6
6
  "keywords": [