@xingwangzhe/stalux 1.22.0 → 1.22.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
|
@@ -6,33 +6,29 @@ const headConfig = getHeadData(configEntries);
|
|
|
6
6
|
const gaID = headConfig?.googleAnalyticsId;
|
|
7
7
|
---
|
|
8
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
|
-
</script>
|
|
36
|
-
</>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
9
|
+
<script is:inline define:vars={{ gaID }}>
|
|
10
|
+
(() => {
|
|
11
|
+
const load = () => {
|
|
12
|
+
if (window.__staluxAnalyticsLoaded) return;
|
|
13
|
+
window.__staluxAnalyticsLoaded = true;
|
|
14
|
+
const script = document.createElement("script");
|
|
15
|
+
script.async = true;
|
|
16
|
+
script.src = `https://www.googletagmanager.com/gtag/js?id=${gaID}`;
|
|
17
|
+
document.head.appendChild(script);
|
|
18
|
+
window.dataLayer = window.dataLayer || [];
|
|
19
|
+
window.gtag = window.gtag || function () {
|
|
20
|
+
window.dataLayer.push(arguments);
|
|
21
|
+
};
|
|
22
|
+
window.gtag("js", new Date());
|
|
23
|
+
window.gtag("config", gaID);
|
|
24
|
+
if (!window.__gtagListenerAdded) {
|
|
25
|
+
document.addEventListener("astro:page-load", () => {
|
|
26
|
+
window.gtag("event", "page_view", { page_path: window.location.pathname });
|
|
27
|
+
});
|
|
28
|
+
window.__gtagListenerAdded = true;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if ("requestIdleCallback" in window) requestIdleCallback(load, { timeout: 3000 });
|
|
32
|
+
else window.addEventListener("load", () => setTimeout(load, 0), { once: true });
|
|
33
|
+
})();
|
|
34
|
+
</script>
|