@m13v/seo-components 0.16.1 → 0.16.2
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/package.json
CHANGED
|
@@ -75,41 +75,44 @@ export function FullSiteAnalytics({
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
let cancelled = false;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const id = ric(
|
|
91
|
-
() => {
|
|
92
|
-
import("posthog-js").then((mod) => {
|
|
93
|
-
if (cancelled) return;
|
|
94
|
-
const lib = mod.default;
|
|
95
|
-
lib.init(posthogKey, {
|
|
96
|
-
api_host: posthogHost,
|
|
97
|
-
person_profiles: personProfiles,
|
|
98
|
-
capture_pageview: capturePageview,
|
|
99
|
-
capture_pageleave: capturePageleave,
|
|
100
|
-
});
|
|
101
|
-
// Legacy: some helpers still read window.posthog. Setting this
|
|
102
|
-
// is what 3 of 4 consumer sites forgot, which silently broke
|
|
103
|
-
// newsletter_subscribed and schedule_click events.
|
|
104
|
-
(window as unknown as { posthog: typeof lib }).posthog = lib;
|
|
105
|
-
setPosthog(lib as unknown as PostHogLike);
|
|
78
|
+
let idleId: number | undefined;
|
|
79
|
+
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
80
|
+
|
|
81
|
+
const run = () => {
|
|
82
|
+
import("posthog-js").then((mod) => {
|
|
83
|
+
if (cancelled) return;
|
|
84
|
+
const lib = mod.default;
|
|
85
|
+
lib.init(posthogKey, {
|
|
86
|
+
api_host: posthogHost,
|
|
87
|
+
person_profiles: personProfiles,
|
|
88
|
+
capture_pageview: capturePageview,
|
|
89
|
+
capture_pageleave: capturePageleave,
|
|
106
90
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
// Legacy: some helpers still read window.posthog. Setting this
|
|
92
|
+
// is what 3 of 4 consumer sites forgot, which silently broke
|
|
93
|
+
// newsletter_subscribed and schedule_click events.
|
|
94
|
+
(window as unknown as { posthog: typeof lib }).posthog = lib;
|
|
95
|
+
setPosthog(lib as unknown as PostHogLike);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Defer init to idle to keep it off the critical path.
|
|
100
|
+
if (typeof window !== "undefined" && window.requestIdleCallback) {
|
|
101
|
+
idleId = window.requestIdleCallback(run, { timeout: 3000 });
|
|
102
|
+
} else {
|
|
103
|
+
timeoutId = setTimeout(run, 1);
|
|
104
|
+
}
|
|
105
|
+
|
|
110
106
|
return () => {
|
|
111
107
|
cancelled = true;
|
|
112
|
-
|
|
108
|
+
if (
|
|
109
|
+
idleId !== undefined &&
|
|
110
|
+
typeof window !== "undefined" &&
|
|
111
|
+
window.cancelIdleCallback
|
|
112
|
+
) {
|
|
113
|
+
window.cancelIdleCallback(idleId);
|
|
114
|
+
}
|
|
115
|
+
if (timeoutId !== undefined) clearTimeout(timeoutId);
|
|
113
116
|
};
|
|
114
117
|
}, [
|
|
115
118
|
posthogKey,
|