Skip to content

Commit aad7687

Browse files
Fix: Check previous location on pageview capture (#22)
Co-authored-by: Rafa Audibert <[email protected]>
1 parent 6e796f8 commit aad7687

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/posthog.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ export default (function () {
66
}
77

88
return {
9-
onRouteUpdate() {
10-
window.posthog.capture('$pageview');
9+
onRouteUpdate({ location, previousLocation }) {
10+
if (location.pathname != previousLocation?.pathname) {
11+
window.posthog.capture('$pageview');
12+
}
1113
},
1214
};
1315
})();

0 commit comments

Comments
 (0)