-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsnowplow.js
47 lines (42 loc) · 1.24 KB
/
snowplow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
import { newTracker, trackPageView } from "@snowplow/browser-tracker";
const isProduction = process.env.NODE_ENV === "production";
const trackerConfig = {
appId: "klaw-docs",
platform: "web",
forceSecureTracker: true,
discoverRootDomain: true,
cookieSameSite: "Lax",
anonymousTracking: { withServerAnonymisation: true },
postPath: "/aiven/dc2",
crossDomainLinker: function (linkElement) {
return linkElement.id === "crossDomainLink";
},
stateStorageStrategy: "none",
eventMethod: "post",
contexts: {
webPage: true,
},
};
function setupBrowserTracker() {
newTracker("at", "dc.aiven.io", trackerConfig);
}
if (isProduction && ExecutionEnvironment.canUseDOM) {
// only set tracker on prod
setupBrowserTracker();
}
const module = {
onRouteDidUpdate({ location, previousLocation }) {
// only set tracker on prod
if (isProduction) {
// only call trackPageView when page route changed
if (location.pathname !== previousLocation?.pathname) {
// see https://github.com/facebook/docusaurus/pull/7424 regarding setTimeout
setTimeout(() => {
trackPageView();
});
}
}
},
};
export default module;