@decocms/blocks 7.84.1 → 7.85.1
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 +1 -1
- package/src/hooks/Stats.tsx +8 -8
package/package.json
CHANGED
package/src/hooks/Stats.tsx
CHANGED
|
@@ -91,16 +91,16 @@ export const DEFAULT_ORIGIN = "https://analytics.decocdn.com";
|
|
|
91
91
|
/**
|
|
92
92
|
* On unless "false", and independent of `ONEDOLLAR_ENABLED` so both can run at once.
|
|
93
93
|
*/
|
|
94
|
-
const DECO_ANALYTICS_ENABLED = process.env.DECO_ANALYTICS_ENABLED !== "false";
|
|
95
|
-
const DECO_ANALYTICS_FIRST_PARTY = process.env.DECO_ANALYTICS_FIRST_PARTY === "true";
|
|
96
|
-
const DECO_ANALYTICS_ORIGIN = process.env.DECO_ANALYTICS_ORIGIN;
|
|
97
|
-
const DECO_ANALYTICS_SITE_KEY = process.env.DECO_ANALYTICS_SITE_KEY;
|
|
98
|
-
|
|
99
94
|
function Stats({ origin, siteKey, defer, dev, debug }: Props) {
|
|
100
|
-
|
|
95
|
+
// Read at render, not at import: the `@decocms/blocks/hooks` barrel reaches client bundles, and
|
|
96
|
+
// `process` does not exist in a browser unless the bundler provides it.
|
|
97
|
+
if (process.env.DECO_ANALYTICS_ENABLED === "false") return null;
|
|
101
98
|
|
|
102
|
-
const base =
|
|
103
|
-
|
|
99
|
+
const base =
|
|
100
|
+
origin ??
|
|
101
|
+
process.env.DECO_ANALYTICS_ORIGIN ??
|
|
102
|
+
(process.env.DECO_ANALYTICS_FIRST_PARTY === "true" ? "" : DEFAULT_ORIGIN);
|
|
103
|
+
const key = siteKey ?? process.env.DECO_ANALYTICS_SITE_KEY;
|
|
104
104
|
if (base === DEFAULT_ORIGIN && !key) return null;
|
|
105
105
|
|
|
106
106
|
return (
|