@nekm/svelte-core 1.0.14 → 1.0.16

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.
@@ -10,12 +10,23 @@
10
10
  readonly id: string;
11
11
 
12
12
  /**
13
- * Base domain to the site.
13
+ * Base domain to the production site. If the current domain does not match
14
+ * this, then Google Analytics will send debug data only.
14
15
  */
15
- readonly baseDomain: string;
16
+ readonly productionDomain?: string | URL;
16
17
  }
17
18
 
18
- const { id, baseDomain }: GoogleAnalyticsProps = $props();
19
+ const { id, productionDomain }: GoogleAnalyticsProps = $props();
20
+
21
+ const productionDomainStr = productionDomain instanceof URL ? productionDomain.hostname : productionDomain;
22
+
23
+ function createConfig() {
24
+ if (!productionDomainStr) {
25
+ return {};
26
+ }
27
+
28
+ return page.url.hostname !== productionDomainStr ? { debug_mode: true } : {};
29
+ }
19
30
 
20
31
  onMount(() => {
21
32
  window.dataLayer = window.dataLayer || [];
@@ -23,8 +34,7 @@
23
34
  window.dataLayer.push(arguments);
24
35
  }
25
36
  window.gtag("js", new Date());
26
- const config = page.url.hostname !== baseDomain ? { debug_mode: true } : {};
27
- window.gtag("config", id, config);
37
+ window.gtag("config", id, createConfig());
28
38
 
29
39
  return browserImportScript(`https://www.googletagmanager.com/gtag/js?id=${id}`);
30
40
  });
@@ -4,9 +4,10 @@ export interface GoogleAnalyticsProps {
4
4
  */
5
5
  readonly id: string;
6
6
  /**
7
- * Base domain to the site.
7
+ * Base domain to the production site. If the current domain does not match
8
+ * this, then Google Analytics will send debug data only.
8
9
  */
9
- readonly baseDomain: string;
10
+ readonly productionDomain?: string | URL;
10
11
  }
11
12
  declare const GoogleAnalytics: import("svelte").Component<GoogleAnalyticsProps, {}, "">;
12
13
  type GoogleAnalytics = ReturnType<typeof GoogleAnalytics>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nekm/svelte-core",
3
3
  "description": "Code I find myself re-writing over-and-over, Svelte edition.",
4
- "version": "1.0.14",
4
+ "version": "1.0.16",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run prepack",