@nexly/react-web 0.2.0 → 0.4.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 +6 -3
- package/dist/nexly-provider.d.ts +1 -4
- package/dist/nexly-provider.d.ts.map +1 -1
- package/dist/nexly-provider.js +4 -11
- package/package.json +2 -2
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
|
-
- **`
|
|
46
|
-
- **`autoPageView`** (default `false`) — when a client exists, send one pageview on mount
|
|
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).
|
package/dist/nexly-provider.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/nexly-provider.js
CHANGED
|
@@ -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
|
|
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 (
|
|
18
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React bindings for Nexly (@nexly/core): 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/core": "0.
|
|
42
|
+
"@nexly/core": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/react": "^19.2.14",
|