@nexly/react-web 0.13.0 → 0.15.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/README.md CHANGED
@@ -43,7 +43,17 @@ function App() {
43
43
 
44
44
  - **`appId`**, **`ingestKey`** — required strings (`ingestKey` is the ingest API token; not named `key` because that is reserved in React).
45
45
  - **`autoPageView`** (default `false`) — when a client exists, send one pageview on mount.
46
- - **`autoEngagement`** (default `false`) — when **`true`** and a client exists (all three strings non-empty after trim), attach engagement listeners; otherwise no-op. Cleanup on unmount or when the client or flag changes.
46
+ - **`autoEngagement`** (default `false`) — when **`true`** and a client exists (all three strings non-empty after trim), attach engagement listeners; otherwise no-op. Cleanup on unmount or when the client or flag changes. The underlying `startEngagement()` is idempotent, so double-mounts (StrictMode, HMR) don't produce duplicate listeners.
47
+
48
+ ### Opting elements out of auto-capture
49
+
50
+ Mark any element with `data-nexly-ignore` to skip auto-`click` and auto-`input_focus` events for it (and its descendants). Use it on elements where you already emit your own `event(...)` to avoid semantic duplicates:
51
+
52
+ ```tsx
53
+ <button data-nexly-ignore onClick={() => client?.event({ name: 'signup_clicked', type: 'custom' })}>
54
+ Sign up
55
+ </button>
56
+ ```
47
57
 
48
58
  ### `useNexlyClient()`
49
59
 
@@ -19,9 +19,16 @@ export type NexlyProviderProps = {
19
19
  autoPageView?: boolean;
20
20
  /** When true and a client exists, attach engagement listeners (scroll, click, visibility, …). Cleaned up on change/unmount. */
21
21
  autoEngagement?: boolean;
22
+ /**
23
+ * When true and a client exists, auto-track clicks on `<a>` elements that
24
+ * navigate away: external `http(s)` links, file downloads (by `download`
25
+ * attr or known extension), `mailto:` and `tel:` links. Cleaned up on
26
+ * change/unmount.
27
+ */
28
+ autoOutboundLinks?: boolean;
22
29
  children: ReactNode;
23
30
  };
24
- export declare function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView, autoEngagement, children, }: NexlyProviderProps): import("react/jsx-runtime").JSX.Element;
31
+ export declare function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView, autoEngagement, autoOutboundLinks, children, }: NexlyProviderProps): import("react/jsx-runtime").JSX.Element;
25
32
  /** Returns the configured {@link Nexly} client, or `null` if credentials are incomplete. Must be used under {@link NexlyProvider}. */
26
33
  export declare function useNexlyClient(): Nexly | null;
27
34
  //# 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,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF;;;;;;GAMG;AAEH,eAAO,MAAM,2BAA2B,sCAAgD,CAAA;AAExF,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,2CA2BpB;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,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF;;;;;;GAMG;AAEH,eAAO,MAAM,2BAA2B,sCAAgD,CAAA;AAExF,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;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAoB,EACpB,cAAsB,EACtB,iBAAyB,EACzB,QAAQ,GACT,EAAE,kBAAkB,2CAkCpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
@@ -12,7 +12,7 @@ const NexlyClientContext = createContext(null);
12
12
  */
13
13
  // eslint-disable-next-line @typescript-eslint/naming-convention
14
14
  export const _NexlyClientIdentityContext = createContext(NexlyClient.React);
15
- export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = false, autoEngagement = false, children, }) {
15
+ export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = false, autoEngagement = false, autoOutboundLinks = false, children, }) {
16
16
  const clientId = useContext(_NexlyClientIdentityContext);
17
17
  const nexly = useMemo(() => {
18
18
  const id = (appId ?? '').trim();
@@ -37,6 +37,12 @@ export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = fal
37
37
  }
38
38
  return nexly.startEngagement();
39
39
  }, [autoEngagement, nexly]);
40
+ useEffect(() => {
41
+ if (!autoOutboundLinks || !nexly) {
42
+ return;
43
+ }
44
+ return nexly.startOutboundLinks();
45
+ }, [autoOutboundLinks, nexly]);
40
46
  return _jsx(NexlyClientContext.Provider, { value: nexly, children: children });
41
47
  }
42
48
  /** Returns the configured {@link Nexly} client, or `null` if credentials are incomplete. Must be used under {@link NexlyProvider}. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/react-web",
3
- "version": "0.13.0",
3
+ "version": "0.15.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.13.0"
42
+ "@nexly/web": "0.15.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/react": "^19.2.14",