@posthog/next 0.4.49 → 0.4.50
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/client/PostHogPageView.d.ts.map +1 -1
- package/dist/client/PostHogPageView.js +5 -7
- package/dist/client/PostHogPageView.js.map +1 -1
- package/dist/pages/PostHogPageView.d.ts.map +1 -1
- package/dist/pages/PostHogPageView.js +4 -2
- package/dist/pages/PostHogPageView.js.map +1 -1
- package/dist/shared/browser.d.ts +2 -0
- package/dist/shared/browser.d.ts.map +1 -0
- package/dist/shared/browser.js +7 -0
- package/dist/shared/browser.js.map +1 -0
- package/package.json +3 -3
- package/src/client/PostHogPageView.tsx +5 -8
- package/src/pages/PostHogPageView.tsx +4 -2
- package/src/shared/browser.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogPageView.d.ts","sourceRoot":"","sources":["../../src/client/PostHogPageView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PostHogPageView.d.ts","sourceRoot":"","sources":["../../src/client/PostHogPageView.tsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,4CAM9B"}
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Suspense, useEffect } from 'react';
|
|
4
4
|
import { usePathname, useSearchParams } from 'next/navigation.js';
|
|
5
5
|
import { usePostHog } from '@posthog/react';
|
|
6
|
+
import { getCurrentUrl } from '../shared/browser.js';
|
|
6
7
|
/**
|
|
7
8
|
* Tracks pageviews on route change in Next.js App Router.
|
|
8
9
|
*
|
|
@@ -39,15 +40,12 @@ function PageViewTracker() {
|
|
|
39
40
|
const searchParams = useSearchParams();
|
|
40
41
|
const posthog = usePostHog();
|
|
41
42
|
useEffect(() => {
|
|
42
|
-
if (!posthog) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
let url = pathname;
|
|
46
43
|
const search = searchParams.toString();
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const currentUrl = getCurrentUrl(search ? `${pathname}?${search}` : pathname);
|
|
45
|
+
if (!posthog || !currentUrl) {
|
|
46
|
+
return;
|
|
49
47
|
}
|
|
50
|
-
posthog.capture('$pageview', { $current_url:
|
|
48
|
+
posthog.capture('$pageview', { $current_url: currentUrl });
|
|
51
49
|
}, [pathname, searchParams, posthog]);
|
|
52
50
|
return null;
|
|
53
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogPageView.js","sourceRoot":"","sources":["../../src/client/PostHogPageView.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"PostHogPageView.js","sourceRoot":"","sources":["../../src/client/PostHogPageView.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,eAAe,GAAG;IAC9B,OAAO,CACH,KAAC,QAAQ,IAAC,QAAQ,EAAE,IAAI,YACpB,KAAC,eAAe,KAAG,GACZ,CACd,CAAA;AAAA,CACJ;AAED,SAAS,eAAe,GAAG;IACvB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAA;IACtC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAA;QACtC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC7E,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;YAC1B,OAAM;QACV,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAA;IAAA,CAC7D,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAErC,OAAO,IAAI,CAAA;AAAA,CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogPageView.d.ts","sourceRoot":"","sources":["../../src/pages/PostHogPageView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PostHogPageView.d.ts","sourceRoot":"","sources":["../../src/pages/PostHogPageView.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,SAc9B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { useRouter } from 'next/router.js';
|
|
3
3
|
import { usePostHog } from '@posthog/react';
|
|
4
|
+
import { getCurrentUrl } from '../shared/browser.js';
|
|
4
5
|
/**
|
|
5
6
|
* Tracks pageviews on route change in Next.js Pages Router.
|
|
6
7
|
*
|
|
@@ -28,10 +29,11 @@ export function PostHogPageView() {
|
|
|
28
29
|
const router = useRouter();
|
|
29
30
|
const posthog = usePostHog();
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
+
const currentUrl = getCurrentUrl(router.asPath);
|
|
33
|
+
if (!posthog || !router.isReady || !currentUrl) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
|
-
posthog.capture('$pageview', { $current_url:
|
|
36
|
+
posthog.capture('$pageview', { $current_url: currentUrl });
|
|
35
37
|
}, [router.asPath, router.isReady, posthog]);
|
|
36
38
|
return null;
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostHogPageView.js","sourceRoot":"","sources":["../../src/pages/PostHogPageView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"PostHogPageView.js","sourceRoot":"","sources":["../../src/pages/PostHogPageView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,GAAG;IAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE,CAAC;QACZ,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC/C,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;YAC7C,OAAM;QACV,CAAC;QAED,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAA;IAAA,CAC7D,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAE5C,OAAO,IAAI,CAAA;AAAA,CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/shared/browser.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/shared/browser.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,IAAY,EAAsB;IAC5D,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,SAAS,CAAA;IACpB,CAAC;IAED,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,EAAE,CAAA;AAAA,CAC5C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/next",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"description": "PostHog integration for Next.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"server-only": "^0.0.1",
|
|
53
53
|
"@posthog/core": "1.29.1",
|
|
54
54
|
"@posthog/react": "1.9.0",
|
|
55
|
-
"posthog-
|
|
56
|
-
"posthog-
|
|
55
|
+
"posthog-js": "1.373.4",
|
|
56
|
+
"posthog-node": "5.34.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Suspense, useEffect } from 'react'
|
|
4
4
|
import { usePathname, useSearchParams } from 'next/navigation.js'
|
|
5
5
|
import { usePostHog } from '@posthog/react'
|
|
6
|
+
import { getCurrentUrl } from '../shared/browser.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Tracks pageviews on route change in Next.js App Router.
|
|
@@ -46,17 +47,13 @@ function PageViewTracker() {
|
|
|
46
47
|
const posthog = usePostHog()
|
|
47
48
|
|
|
48
49
|
useEffect(() => {
|
|
49
|
-
if (!posthog) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let url = pathname
|
|
54
50
|
const search = searchParams.toString()
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const currentUrl = getCurrentUrl(search ? `${pathname}?${search}` : pathname)
|
|
52
|
+
if (!posthog || !currentUrl) {
|
|
53
|
+
return
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
posthog.capture('$pageview', { $current_url:
|
|
56
|
+
posthog.capture('$pageview', { $current_url: currentUrl })
|
|
60
57
|
}, [pathname, searchParams, posthog])
|
|
61
58
|
|
|
62
59
|
return null
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useEffect } from 'react'
|
|
2
2
|
import { useRouter } from 'next/router.js'
|
|
3
3
|
import { usePostHog } from '@posthog/react'
|
|
4
|
+
import { getCurrentUrl } from '../shared/browser.js'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Tracks pageviews on route change in Next.js Pages Router.
|
|
@@ -30,11 +31,12 @@ export function PostHogPageView() {
|
|
|
30
31
|
const posthog = usePostHog()
|
|
31
32
|
|
|
32
33
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
+
const currentUrl = getCurrentUrl(router.asPath)
|
|
35
|
+
if (!posthog || !router.isReady || !currentUrl) {
|
|
34
36
|
return
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
posthog.capture('$pageview', { $current_url:
|
|
39
|
+
posthog.capture('$pageview', { $current_url: currentUrl })
|
|
38
40
|
}, [router.asPath, router.isReady, posthog])
|
|
39
41
|
|
|
40
42
|
return null
|