@nexly/react-web 0.9.0 → 0.10.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.
@@ -6,13 +6,18 @@ export type NexlyProviderProps = {
6
6
  appId: string;
7
7
  /** Ingest API token (maps to `key` on {@link Nexly}). Not named `key` — reserved in React. */
8
8
  ingestKey: string;
9
+ /**
10
+ * SDK identity sent as top-level `client` on the wire. Defaults to `'react'`
11
+ * for this package; framework wrappers (e.g. `@nexly/next`) override it.
12
+ */
13
+ client?: string;
9
14
  /** When a client exists, send one pageview on mount. */
10
15
  autoPageView?: boolean;
11
16
  /** When true and a client exists, attach engagement listeners (scroll, click, visibility, …). Cleaned up on change/unmount. */
12
17
  autoEngagement?: boolean;
13
18
  children: ReactNode;
14
19
  };
15
- export declare function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView, autoEngagement, children, }: NexlyProviderProps): import("react/jsx-runtime").JSX.Element;
20
+ export declare function NexlyProvider({ collectUrl, appId, ingestKey, client: clientOverride, autoPageView, autoEngagement, children, }: NexlyProviderProps): import("react/jsx-runtime").JSX.Element;
16
21
  /** Returns the configured {@link Nexly} client, or `null` if credentials are incomplete. Must be used under {@link NexlyProvider}. */
17
22
  export declare function useNexlyClient(): Nexly | null;
18
23
  //# sourceMappingURL=nexly-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nexly-provider.d.ts","sourceRoot":"","sources":["../src/nexly-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;IACjB,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+HAA+H;IAC/H,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAoB,EACpB,cAAsB,EACtB,QAAQ,GACT,EAAE,kBAAkB,2CA0BpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
1
+ {"version":3,"file":"nexly-provider.d.ts","sourceRoot":"","sources":["../src/nexly-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+HAA+H;IAC/H,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,KAAK,EACL,SAAS,EACT,MAAM,EAAE,cAAc,EACtB,YAAoB,EACpB,cAAsB,EACtB,QAAQ,GACT,EAAE,kBAAkB,2CA2BpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
@@ -2,8 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Nexly } from '@nexly/web';
3
3
  import { createContext, useContext, useEffect, useMemo } from 'react';
4
4
  const NexlyClientContext = createContext(null);
5
- export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = false, autoEngagement = false, children, }) {
6
- const client = useMemo(() => {
5
+ export function NexlyProvider({ collectUrl, appId, ingestKey, client: clientOverride, autoPageView = false, autoEngagement = false, children, }) {
6
+ const clientId = clientOverride ?? 'react';
7
+ const nexly = useMemo(() => {
7
8
  const id = (appId ?? '').trim();
8
9
  const k = (ingestKey ?? '').trim();
9
10
  if (!id || !k) {
@@ -13,20 +14,20 @@ export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = fal
13
14
  console.warn('[Nexly] Missing ingestKey — tracking is disabled.');
14
15
  return null;
15
16
  }
16
- return Nexly.init({ collectUrl, appId: id, key: k });
17
- }, [collectUrl, appId, ingestKey]);
17
+ return Nexly.init({ collectUrl, appId: id, key: k, client: clientId });
18
+ }, [collectUrl, appId, ingestKey, clientId]);
18
19
  useEffect(() => {
19
- if (autoPageView && client) {
20
- client.pageview();
20
+ if (autoPageView && nexly) {
21
+ nexly.pageview();
21
22
  }
22
- }, [autoPageView, client]);
23
+ }, [autoPageView, nexly]);
23
24
  useEffect(() => {
24
- if (!autoEngagement || !client) {
25
+ if (!autoEngagement || !nexly) {
25
26
  return;
26
27
  }
27
- return client.startEngagement();
28
- }, [autoEngagement, client]);
29
- return _jsx(NexlyClientContext.Provider, { value: client, children: children });
28
+ return nexly.startEngagement();
29
+ }, [autoEngagement, nexly]);
30
+ return _jsx(NexlyClientContext.Provider, { value: nexly, children: children });
30
31
  }
31
32
  /** Returns the configured {@link Nexly} client, or `null` if credentials are incomplete. Must be used under {@link NexlyProvider}. */
32
33
  export function useNexlyClient() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/react-web",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "React bindings for Nexly (@nexly/web): provider, client hook, engagement, optional auto pageview",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "react": "^18.0.0 || ^19.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@nexly/web": "0.9.0"
42
+ "@nexly/web": "0.10.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/react": "^19.2.14",