@productbet/tracker-next 0.1.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/dist/index.d.ts +6 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +42 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider.d.ts +5 -0
- package/dist/script.d.ts +28 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ProductBetProvider } from "./provider";
|
|
2
|
+
export type { NextProductBetProviderProps } from "./provider";
|
|
3
|
+
export { ProductBetScript } from "./script";
|
|
4
|
+
export type { ProductBetScriptProps } from "./script";
|
|
5
|
+
export { useTracker, useIdentify, useTrackEvent, usePageView, } from "@productbet/tracker-react";
|
|
6
|
+
export type { TrackerOptions, AutoTrackingOptions, RedactionOptions, } from "@productbet/tracker-core";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var trackerReact = require('@productbet/tracker-react');
|
|
7
|
+
|
|
8
|
+
function RouteTracker() {
|
|
9
|
+
const pathname = navigation.usePathname();
|
|
10
|
+
trackerReact.usePageView(pathname);
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function ProductBetProvider({ children, trackRouteChanges = true, ...props }) {
|
|
14
|
+
return (jsxRuntime.jsxs(trackerReact.ProductBetProvider, { ...props, children: [trackRouteChanges && jsxRuntime.jsx(RouteTracker, {}), children] }));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Drop-in component for Next.js App Router layout.tsx files.
|
|
19
|
+
*
|
|
20
|
+
* Usage in app/layout.tsx:
|
|
21
|
+
*
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { ProductBetScript } from "@productbet/tracker-next"
|
|
24
|
+
*
|
|
25
|
+
* export default function RootLayout({ children }) {
|
|
26
|
+
* return (
|
|
27
|
+
* <html>
|
|
28
|
+
* <body>
|
|
29
|
+
* <ProductBetScript apiKey="pb_live_xxxx">
|
|
30
|
+
* {children}
|
|
31
|
+
* </ProductBetScript>
|
|
32
|
+
* </body>
|
|
33
|
+
* </html>
|
|
34
|
+
* )
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function ProductBetScript({ apiKey, children, ...options }) {
|
|
39
|
+
return (jsxRuntime.jsx(ProductBetProvider, { apiKey: apiKey, ...options, children: children }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Object.defineProperty(exports, "useIdentify", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () { return trackerReact.useIdentify; }
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "usePageView", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () { return trackerReact.usePageView; }
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "useTrackEvent", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () { return trackerReact.useTrackEvent; }
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "useTracker", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return trackerReact.useTracker; }
|
|
57
|
+
});
|
|
58
|
+
exports.ProductBetProvider = ProductBetProvider;
|
|
59
|
+
exports.ProductBetScript = ProductBetScript;
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/provider.tsx","../src/script.tsx"],"sourcesContent":["\"use client\"\n\nimport { useEffect } from \"react\"\nimport { usePathname } from \"next/navigation\"\nimport {\n ProductBetProvider as BaseProvider,\n useTracker,\n usePageView,\n type ProductBetProviderProps,\n} from \"@productbet/tracker-react\"\nimport type { ReactNode } from \"react\"\n\nfunction RouteTracker() {\n const pathname = usePathname()\n usePageView(pathname)\n return null\n}\n\nexport interface NextProductBetProviderProps extends ProductBetProviderProps {\n trackRouteChanges?: boolean\n}\n\nexport function ProductBetProvider({\n children,\n trackRouteChanges = true,\n ...props\n}: NextProductBetProviderProps) {\n return (\n <BaseProvider {...props}>\n {trackRouteChanges && <RouteTracker />}\n {children}\n </BaseProvider>\n )\n}\n","\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport { ProductBetProvider } from \"./provider\"\nimport type { TrackerOptions } from \"@productbet/tracker-core\"\n\nexport interface ProductBetScriptProps extends TrackerOptions {\n apiKey: string\n children: ReactNode\n}\n\n/**\n * Drop-in component for Next.js App Router layout.tsx files.\n *\n * Usage in app/layout.tsx:\n *\n * ```tsx\n * import { ProductBetScript } from \"@productbet/tracker-next\"\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <ProductBetScript apiKey=\"pb_live_xxxx\">\n * {children}\n * </ProductBetScript>\n * </body>\n * </html>\n * )\n * }\n * ```\n */\nexport function ProductBetScript({\n apiKey,\n children,\n ...options\n}: ProductBetScriptProps) {\n return (\n <ProductBetProvider apiKey={apiKey} {...options}>\n {children}\n </ProductBetProvider>\n )\n}\n"],"names":["usePathname","usePageView","_jsxs","BaseProvider","_jsx"],"mappings":";;;;;;;AAYA,SAAS,YAAY,GAAA;AACjB,IAAA,MAAM,QAAQ,GAAGA,sBAAW,EAAE;IAC9BC,wBAAW,CAAC,QAAQ,CAAC;AACrB,IAAA,OAAO,IAAI;AACf;AAMM,SAAU,kBAAkB,CAAC,EAC/B,QAAQ,EACR,iBAAiB,GAAG,IAAI,EACxB,GAAG,KAAK,EACkB,EAAA;AAC1B,IAAA,QACIC,eAAA,CAACC,+BAAY,EAAA,EAAA,GAAK,KAAK,EAAA,QAAA,EAAA,CAClB,iBAAiB,IAAIC,cAAA,CAAC,YAAY,EAAA,EAAA,CAAG,EACrC,QAAQ,CAAA,EAAA,CACE;AAEvB;;ACtBA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,gBAAgB,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,GAAG,OAAO,EACU,EAAA;AACpB,IAAA,QACIA,cAAA,CAAC,kBAAkB,EAAA,EAAC,MAAM,EAAE,MAAM,EAAA,GAAM,OAAO,EAAA,QAAA,EAC1C,QAAQ,EAAA,CACQ;AAE7B;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { usePathname } from 'next/navigation';
|
|
4
|
+
import { ProductBetProvider as ProductBetProvider$1, usePageView } from '@productbet/tracker-react';
|
|
5
|
+
export { useIdentify, usePageView, useTrackEvent, useTracker } from '@productbet/tracker-react';
|
|
6
|
+
|
|
7
|
+
function RouteTracker() {
|
|
8
|
+
const pathname = usePathname();
|
|
9
|
+
usePageView(pathname);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function ProductBetProvider({ children, trackRouteChanges = true, ...props }) {
|
|
13
|
+
return (jsxs(ProductBetProvider$1, { ...props, children: [trackRouteChanges && jsx(RouteTracker, {}), children] }));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Drop-in component for Next.js App Router layout.tsx files.
|
|
18
|
+
*
|
|
19
|
+
* Usage in app/layout.tsx:
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { ProductBetScript } from "@productbet/tracker-next"
|
|
23
|
+
*
|
|
24
|
+
* export default function RootLayout({ children }) {
|
|
25
|
+
* return (
|
|
26
|
+
* <html>
|
|
27
|
+
* <body>
|
|
28
|
+
* <ProductBetScript apiKey="pb_live_xxxx">
|
|
29
|
+
* {children}
|
|
30
|
+
* </ProductBetScript>
|
|
31
|
+
* </body>
|
|
32
|
+
* </html>
|
|
33
|
+
* )
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function ProductBetScript({ apiKey, children, ...options }) {
|
|
38
|
+
return (jsx(ProductBetProvider, { apiKey: apiKey, ...options, children: children }));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { ProductBetProvider, ProductBetScript };
|
|
42
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/provider.tsx","../src/script.tsx"],"sourcesContent":["\"use client\"\n\nimport { useEffect } from \"react\"\nimport { usePathname } from \"next/navigation\"\nimport {\n ProductBetProvider as BaseProvider,\n useTracker,\n usePageView,\n type ProductBetProviderProps,\n} from \"@productbet/tracker-react\"\nimport type { ReactNode } from \"react\"\n\nfunction RouteTracker() {\n const pathname = usePathname()\n usePageView(pathname)\n return null\n}\n\nexport interface NextProductBetProviderProps extends ProductBetProviderProps {\n trackRouteChanges?: boolean\n}\n\nexport function ProductBetProvider({\n children,\n trackRouteChanges = true,\n ...props\n}: NextProductBetProviderProps) {\n return (\n <BaseProvider {...props}>\n {trackRouteChanges && <RouteTracker />}\n {children}\n </BaseProvider>\n )\n}\n","\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport { ProductBetProvider } from \"./provider\"\nimport type { TrackerOptions } from \"@productbet/tracker-core\"\n\nexport interface ProductBetScriptProps extends TrackerOptions {\n apiKey: string\n children: ReactNode\n}\n\n/**\n * Drop-in component for Next.js App Router layout.tsx files.\n *\n * Usage in app/layout.tsx:\n *\n * ```tsx\n * import { ProductBetScript } from \"@productbet/tracker-next\"\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <ProductBetScript apiKey=\"pb_live_xxxx\">\n * {children}\n * </ProductBetScript>\n * </body>\n * </html>\n * )\n * }\n * ```\n */\nexport function ProductBetScript({\n apiKey,\n children,\n ...options\n}: ProductBetScriptProps) {\n return (\n <ProductBetProvider apiKey={apiKey} {...options}>\n {children}\n </ProductBetProvider>\n )\n}\n"],"names":["_jsxs","BaseProvider","_jsx"],"mappings":";;;;;;AAYA,SAAS,YAAY,GAAA;AACjB,IAAA,MAAM,QAAQ,GAAG,WAAW,EAAE;IAC9B,WAAW,CAAC,QAAQ,CAAC;AACrB,IAAA,OAAO,IAAI;AACf;AAMM,SAAU,kBAAkB,CAAC,EAC/B,QAAQ,EACR,iBAAiB,GAAG,IAAI,EACxB,GAAG,KAAK,EACkB,EAAA;AAC1B,IAAA,QACIA,IAAA,CAACC,oBAAY,EAAA,EAAA,GAAK,KAAK,EAAA,QAAA,EAAA,CAClB,iBAAiB,IAAIC,GAAA,CAAC,YAAY,EAAA,EAAA,CAAG,EACrC,QAAQ,CAAA,EAAA,CACE;AAEvB;;ACtBA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,gBAAgB,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,GAAG,OAAO,EACU,EAAA;AACpB,IAAA,QACIA,GAAA,CAAC,kBAAkB,EAAA,EAAC,MAAM,EAAE,MAAM,EAAA,GAAM,OAAO,EAAA,QAAA,EAC1C,QAAQ,EAAA,CACQ;AAE7B;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ProductBetProviderProps } from "@productbet/tracker-react";
|
|
2
|
+
export interface NextProductBetProviderProps extends ProductBetProviderProps {
|
|
3
|
+
trackRouteChanges?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function ProductBetProvider({ children, trackRouteChanges, ...props }: NextProductBetProviderProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/script.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { TrackerOptions } from "@productbet/tracker-core";
|
|
3
|
+
export interface ProductBetScriptProps extends TrackerOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in component for Next.js App Router layout.tsx files.
|
|
9
|
+
*
|
|
10
|
+
* Usage in app/layout.tsx:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { ProductBetScript } from "@productbet/tracker-next"
|
|
14
|
+
*
|
|
15
|
+
* export default function RootLayout({ children }) {
|
|
16
|
+
* return (
|
|
17
|
+
* <html>
|
|
18
|
+
* <body>
|
|
19
|
+
* <ProductBetScript apiKey="pb_live_xxxx">
|
|
20
|
+
* {children}
|
|
21
|
+
* </ProductBetScript>
|
|
22
|
+
* </body>
|
|
23
|
+
* </html>
|
|
24
|
+
* )
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function ProductBetScript({ apiKey, children, ...options }: ProductBetScriptProps): import("react/jsx-runtime").JSX.Element;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@productbet/tracker-next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js App Router integration for ProductBet behavioral analytics SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@productbet/tracker-core": "0.1.0",
|
|
20
|
+
"@productbet/tracker-react": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"next": ">=13.0.0",
|
|
24
|
+
"react": ">=18.0.0",
|
|
25
|
+
"react-dom": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
30
|
+
"@rollup/plugin-typescript": "^12.0.0",
|
|
31
|
+
"@types/react": "^19.0.0",
|
|
32
|
+
"rimraf": "^6.0.0",
|
|
33
|
+
"rollup": "^4.0.0",
|
|
34
|
+
"tslib": "^2.8.0",
|
|
35
|
+
"typescript": "^5.8.0"
|
|
36
|
+
},
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/productbet/productbet",
|
|
42
|
+
"directory": "packages/tracker-next"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"analytics",
|
|
46
|
+
"nextjs",
|
|
47
|
+
"session-recording",
|
|
48
|
+
"productbet"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "rollup -c rollup.config.mjs",
|
|
52
|
+
"dev": "rollup -c rollup.config.mjs --watch",
|
|
53
|
+
"clean": "rimraf dist"
|
|
54
|
+
}
|
|
55
|
+
}
|