@tell-rs/nextjs 0.1.1 → 0.2.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.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -49,6 +49,9 @@ function Tell({
|
|
|
49
49
|
const initialized = (0, import_react.useRef)(false);
|
|
50
50
|
const pathname = (0, import_navigation.usePathname)();
|
|
51
51
|
const searchParams = (0, import_navigation.useSearchParams)();
|
|
52
|
+
const search = searchParams?.toString() ?? "";
|
|
53
|
+
const pageViewPropsRef = (0, import_react.useRef)(pageViewProperties);
|
|
54
|
+
pageViewPropsRef.current = pageViewProperties;
|
|
52
55
|
(0, import_react.useEffect)(() => {
|
|
53
56
|
if (!initialized.current) {
|
|
54
57
|
import_browser.default.configure(apiKey, options);
|
|
@@ -60,13 +63,13 @@ function Tell({
|
|
|
60
63
|
}, []);
|
|
61
64
|
(0, import_react.useEffect)(() => {
|
|
62
65
|
if (!trackPageViews || !initialized.current) return;
|
|
63
|
-
const url =
|
|
66
|
+
const url = search ? `${pathname}?${search}` : pathname;
|
|
64
67
|
import_browser.default.track("Page Viewed", {
|
|
65
68
|
url,
|
|
66
69
|
path: pathname,
|
|
67
|
-
...
|
|
70
|
+
...pageViewPropsRef.current
|
|
68
71
|
});
|
|
69
|
-
}, [pathname,
|
|
72
|
+
}, [pathname, search, trackPageViews]);
|
|
70
73
|
return children ?? null;
|
|
71
74
|
}
|
|
72
75
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport { usePathname, useSearchParams } from \"next/navigation\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport interface TellProps {\n apiKey: string;\n options?: TellBrowserConfig;\n /** Track page views automatically on route change. Default: true */\n trackPageViews?: boolean;\n /** Extra properties to include with every page view event. */\n pageViewProperties?: Properties;\n children?: ReactNode;\n}\n\n/**\n * Drop-in Next.js analytics component.\n * Place in your root layout to auto-configure Tell and track page views.\n *\n * ```tsx\n * // app/layout.tsx\n * import { Tell } from \"@tell-rs/nextjs\";\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <Tell apiKey=\"...\" />\n * {children}\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function Tell({\n apiKey,\n options,\n trackPageViews = true,\n pageViewProperties,\n children,\n}: TellProps) {\n const initialized = useRef(false);\n const pathname = usePathname();\n const searchParams = useSearchParams();\n\n // Initialize once\n useEffect(() => {\n if (!initialized.current) {\n tell.configure(apiKey, options);\n initialized.current = true;\n }\n return () => {\n tell.close();\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Track page views on route changes\n useEffect(() => {\n if (!trackPageViews || !initialized.current) return;\n\n const url =
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport { usePathname, useSearchParams } from \"next/navigation\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport interface TellProps {\n apiKey: string;\n options?: TellBrowserConfig;\n /** Track page views automatically on route change. Default: true */\n trackPageViews?: boolean;\n /** Extra properties to include with every page view event. */\n pageViewProperties?: Properties;\n children?: ReactNode;\n}\n\n/**\n * Drop-in Next.js analytics component.\n * Place in your root layout to auto-configure Tell and track page views.\n *\n * ```tsx\n * // app/layout.tsx\n * import { Tell } from \"@tell-rs/nextjs\";\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <Tell apiKey=\"...\" />\n * {children}\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function Tell({\n apiKey,\n options,\n trackPageViews = true,\n pageViewProperties,\n children,\n}: TellProps) {\n const initialized = useRef(false);\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const search = searchParams?.toString() ?? \"\";\n const pageViewPropsRef = useRef(pageViewProperties);\n pageViewPropsRef.current = pageViewProperties;\n\n // Initialize once\n useEffect(() => {\n if (!initialized.current) {\n tell.configure(apiKey, options);\n initialized.current = true;\n }\n return () => {\n tell.close();\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Track page views on route changes\n useEffect(() => {\n if (!trackPageViews || !initialized.current) return;\n\n const url = search ? `${pathname}?${search}` : pathname;\n\n tell.track(\"Page Viewed\", {\n url,\n path: pathname,\n ...pageViewPropsRef.current,\n });\n }, [pathname, search, trackPageViews]);\n\n return children ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAkD;AAClD,wBAA6C;AAC7C,qBAAiB;AAGjB,IAAAA,kBAAqB;AAiCd,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AACF,GAAc;AACZ,QAAM,kBAAc,qBAAO,KAAK;AAChC,QAAM,eAAW,+BAAY;AAC7B,QAAM,mBAAe,mCAAgB;AACrC,QAAM,SAAS,cAAc,SAAS,KAAK;AAC3C,QAAM,uBAAmB,qBAAO,kBAAkB;AAClD,mBAAiB,UAAU;AAG3B,8BAAU,MAAM;AACd,QAAI,CAAC,YAAY,SAAS;AACxB,qBAAAC,QAAK,UAAU,QAAQ,OAAO;AAC9B,kBAAY,UAAU;AAAA,IACxB;AACA,WAAO,MAAM;AACX,qBAAAA,QAAK,MAAM;AAAA,IACb;AAAA,EACF,GAAG,CAAC,CAAC;AAGL,8BAAU,MAAM;AACd,QAAI,CAAC,kBAAkB,CAAC,YAAY,QAAS;AAE7C,UAAM,MAAM,SAAS,GAAG,QAAQ,IAAI,MAAM,KAAK;AAE/C,mBAAAA,QAAK,MAAM,eAAe;AAAA,MACxB;AAAA,MACA,MAAM;AAAA,MACN,GAAG,iBAAiB;AAAA,IACtB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,QAAQ,cAAc,CAAC;AAErC,SAAO,YAAY;AACrB;","names":["import_browser","tell"]}
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,9 @@ function Tell({
|
|
|
15
15
|
const initialized = useRef(false);
|
|
16
16
|
const pathname = usePathname();
|
|
17
17
|
const searchParams = useSearchParams();
|
|
18
|
+
const search = searchParams?.toString() ?? "";
|
|
19
|
+
const pageViewPropsRef = useRef(pageViewProperties);
|
|
20
|
+
pageViewPropsRef.current = pageViewProperties;
|
|
18
21
|
useEffect(() => {
|
|
19
22
|
if (!initialized.current) {
|
|
20
23
|
tell.configure(apiKey, options);
|
|
@@ -26,13 +29,13 @@ function Tell({
|
|
|
26
29
|
}, []);
|
|
27
30
|
useEffect(() => {
|
|
28
31
|
if (!trackPageViews || !initialized.current) return;
|
|
29
|
-
const url =
|
|
32
|
+
const url = search ? `${pathname}?${search}` : pathname;
|
|
30
33
|
tell.track("Page Viewed", {
|
|
31
34
|
url,
|
|
32
35
|
path: pathname,
|
|
33
|
-
...
|
|
36
|
+
...pageViewPropsRef.current
|
|
34
37
|
});
|
|
35
|
-
}, [pathname,
|
|
38
|
+
}, [pathname, search, trackPageViews]);
|
|
36
39
|
return children ?? null;
|
|
37
40
|
}
|
|
38
41
|
export {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport { usePathname, useSearchParams } from \"next/navigation\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport interface TellProps {\n apiKey: string;\n options?: TellBrowserConfig;\n /** Track page views automatically on route change. Default: true */\n trackPageViews?: boolean;\n /** Extra properties to include with every page view event. */\n pageViewProperties?: Properties;\n children?: ReactNode;\n}\n\n/**\n * Drop-in Next.js analytics component.\n * Place in your root layout to auto-configure Tell and track page views.\n *\n * ```tsx\n * // app/layout.tsx\n * import { Tell } from \"@tell-rs/nextjs\";\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <Tell apiKey=\"...\" />\n * {children}\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function Tell({\n apiKey,\n options,\n trackPageViews = true,\n pageViewProperties,\n children,\n}: TellProps) {\n const initialized = useRef(false);\n const pathname = usePathname();\n const searchParams = useSearchParams();\n\n // Initialize once\n useEffect(() => {\n if (!initialized.current) {\n tell.configure(apiKey, options);\n initialized.current = true;\n }\n return () => {\n tell.close();\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Track page views on route changes\n useEffect(() => {\n if (!trackPageViews || !initialized.current) return;\n\n const url =
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport { usePathname, useSearchParams } from \"next/navigation\";\nimport tell from \"@tell-rs/browser\";\nimport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport { tell } from \"@tell-rs/browser\";\nexport type { TellBrowserConfig, Properties } from \"@tell-rs/browser\";\n\nexport interface TellProps {\n apiKey: string;\n options?: TellBrowserConfig;\n /** Track page views automatically on route change. Default: true */\n trackPageViews?: boolean;\n /** Extra properties to include with every page view event. */\n pageViewProperties?: Properties;\n children?: ReactNode;\n}\n\n/**\n * Drop-in Next.js analytics component.\n * Place in your root layout to auto-configure Tell and track page views.\n *\n * ```tsx\n * // app/layout.tsx\n * import { Tell } from \"@tell-rs/nextjs\";\n *\n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <Tell apiKey=\"...\" />\n * {children}\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function Tell({\n apiKey,\n options,\n trackPageViews = true,\n pageViewProperties,\n children,\n}: TellProps) {\n const initialized = useRef(false);\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const search = searchParams?.toString() ?? \"\";\n const pageViewPropsRef = useRef(pageViewProperties);\n pageViewPropsRef.current = pageViewProperties;\n\n // Initialize once\n useEffect(() => {\n if (!initialized.current) {\n tell.configure(apiKey, options);\n initialized.current = true;\n }\n return () => {\n tell.close();\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n // Track page views on route changes\n useEffect(() => {\n if (!trackPageViews || !initialized.current) return;\n\n const url = search ? `${pathname}?${search}` : pathname;\n\n tell.track(\"Page Viewed\", {\n url,\n path: pathname,\n ...pageViewPropsRef.current,\n });\n }, [pathname, search, trackPageViews]);\n\n return children ?? null;\n}\n"],"mappings":";;;AAEA,SAAS,WAAW,cAA8B;AAClD,SAAS,aAAa,uBAAuB;AAC7C,OAAO,UAAU;AAGjB,SAAS,QAAAA,aAAY;AAiCd,SAAS,KAAK;AAAA,EACnB;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AACF,GAAc;AACZ,QAAM,cAAc,OAAO,KAAK;AAChC,QAAM,WAAW,YAAY;AAC7B,QAAM,eAAe,gBAAgB;AACrC,QAAM,SAAS,cAAc,SAAS,KAAK;AAC3C,QAAM,mBAAmB,OAAO,kBAAkB;AAClD,mBAAiB,UAAU;AAG3B,YAAU,MAAM;AACd,QAAI,CAAC,YAAY,SAAS;AACxB,WAAK,UAAU,QAAQ,OAAO;AAC9B,kBAAY,UAAU;AAAA,IACxB;AACA,WAAO,MAAM;AACX,WAAK,MAAM;AAAA,IACb;AAAA,EACF,GAAG,CAAC,CAAC;AAGL,YAAU,MAAM;AACd,QAAI,CAAC,kBAAkB,CAAC,YAAY,QAAS;AAE7C,UAAM,MAAM,SAAS,GAAG,QAAQ,IAAI,MAAM,KAAK;AAE/C,SAAK,MAAM,eAAe;AAAA,MACxB;AAAA,MACA,MAAM;AAAA,MACN,GAAG,iBAAiB;AAAA,IACtB,CAAC;AAAA,EACH,GAAG,CAAC,UAAU,QAAQ,cAAc,CAAC;AAErC,SAAO,YAAY;AACrB;","names":["tell"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tell-rs/nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Tell SDK Next.js integration — automatic page tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsup",
|
|
21
|
-
"test": "
|
|
21
|
+
"test": "node --import tsx --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"./test/loader.mjs\", pathToFileURL(\"./\"));' --test test/*.test.tsx",
|
|
22
22
|
"typecheck": "tsc --noEmit",
|
|
23
23
|
"clean": "rm -rf dist"
|
|
24
24
|
},
|
|
@@ -29,10 +29,13 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.0.0",
|
|
32
|
+
"@types/react-dom": "^19.0.0",
|
|
32
33
|
"next": "^15.0.0",
|
|
33
34
|
"react": "^19.0.0",
|
|
35
|
+
"react-dom": "^19.0.0",
|
|
34
36
|
"@tell-rs/browser": "*",
|
|
35
37
|
"tsup": "^8.0.0",
|
|
38
|
+
"tsx": "^4.0.0",
|
|
36
39
|
"typescript": "^5.5.0"
|
|
37
40
|
},
|
|
38
41
|
"repository": {
|