@nexly/react-web 0.2.0 → 0.3.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
@@ -18,7 +18,6 @@ import { NexlyProvider, useNexlyClient } from '@nexly/react-web'
18
18
  function Root() {
19
19
  return (
20
20
  <NexlyProvider
21
- collectUrl={collectUrl}
22
21
  appId={appId}
23
22
  ingestKey={apiToken}
24
23
  autoPageView
@@ -42,14 +41,18 @@ function App() {
42
41
 
43
42
  ### `NexlyProvider` props
44
43
 
45
- - **`collectUrl`**, **`appId`**, **`ingestKey`** — required strings (`ingestKey` is the ingest API token; not named `key` because that is reserved in React).
46
- - **`autoPageView`** (default `false`) — when a client exists, send one pageview on mount / when the credential tuple changes (deduped for React Strict Mode).
44
+ - **`appId`**, **`ingestKey`** — required strings (`ingestKey` is the ingest API token; not named `key` because that is reserved in React).
45
+ - **`autoPageView`** (default `false`) — when a client exists, send one pageview on mount.
47
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.
48
47
 
49
48
  ### `useNexlyClient()`
50
49
 
51
50
  Returns `Nexly | null` inside a provider (`null` if any credential trims to empty).
52
51
 
52
+ ## Next.js
53
+
54
+ For Next.js App Router (route-aware `autoPageView` on every navigation), use **[@nexly/next](https://www.npmjs.com/package/@nexly/next)** instead.
55
+
53
56
  ## License
54
57
 
55
58
  MIT — see [LICENSE](./LICENSE).
@@ -5,10 +5,7 @@ export type NexlyProviderProps = {
5
5
  appId: string;
6
6
  /** Ingest API token (maps to `key` on {@link Nexly}). Not named `key` — reserved in React. */
7
7
  ingestKey: string;
8
- /**
9
- * When a client exists, send one pageview after mount and whenever this credential tuple changes.
10
- * Deduped so React Strict Mode does not double-send for the same tuple.
11
- */
8
+ /** When a client exists, send one pageview on mount. */
12
9
  autoPageView?: boolean;
13
10
  /** When true and a client exists, attach engagement listeners (scroll, click, visibility, …). Cleaned up on change/unmount. */
14
11
  autoEngagement?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"nexly-provider.d.ts","sourceRoot":"","sources":["../src/nexly-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAyD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAI7F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,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,2CAiCpB;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,aAAa,CAAA;AACnC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,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,2CAyBpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Nexly } from '@nexly/core';
3
- import { createContext, useContext, useEffect, useMemo, useRef } from 'react';
3
+ import { createContext, useContext, useEffect, useMemo } from 'react';
4
4
  const NexlyClientContext = createContext(null);
5
5
  export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = false, autoEngagement = false, children, }) {
6
6
  const client = useMemo(() => {
@@ -12,18 +12,11 @@ export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = fal
12
12
  }
13
13
  return new Nexly({ collectUrl: u, appId: id, key: k });
14
14
  }, [collectUrl, appId, ingestKey]);
15
- const lastAutoPageViewKeyRef = useRef('');
16
15
  useEffect(() => {
17
- if (!autoPageView || !client) {
18
- return;
19
- }
20
- const tupleKey = `${collectUrl.trim()}|${appId.trim()}|${ingestKey.trim()}`;
21
- if (lastAutoPageViewKeyRef.current === tupleKey) {
22
- return;
16
+ if (autoPageView && client) {
17
+ client.pageview();
23
18
  }
24
- lastAutoPageViewKeyRef.current = tupleKey;
25
- client.pageview();
26
- }, [autoPageView, client, collectUrl, appId, ingestKey]);
19
+ }, [autoPageView, client]);
27
20
  useEffect(() => {
28
21
  if (!autoEngagement || !client) {
29
22
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/react-web",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "React bindings for Nexly (@nexly/core): provider, client hook, engagement, optional auto pageview",
5
5
  "license": "MIT",
6
6
  "keywords": [