@getpimms/analytics 1.1.4 → 1.3.0

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/README.md CHANGED
@@ -43,44 +43,148 @@ export default function RootLayout({ children }: { children: React.ReactNode })
43
43
 
44
44
  Alternatively, for other frameworks, use the `inject()` method.
45
45
 
46
+ ## CDN Scripts
47
+
48
+ All scripts are available via CDN at `https://cdn.pimms.io/analytics/`.
49
+
50
+ ### Available Bundles
51
+
52
+ | Script | Includes | Use case |
53
+ |--------|----------|----------|
54
+ | `script.js` | Base tracking | Minimal click tracking only |
55
+ | `script.site-visit.js` | Base + site visit | Track anonymous site visits |
56
+ | `script.outbound-domains.js` | Base + outbound domains | Cross-domain `pimms_id` on outbound links |
57
+ | `script.site-visit.outbound-domains.js` | Base + site visit + outbound domains | Both visit tracking and outbound links |
58
+ | `script.detection.js` | Base + outbound domains + detect IDs + embed support + thank-you page | Detection and conversion tracking bundle |
59
+ | `script.expose.js` | Expose IDs only | Sets `window.pimms_id` from cookie/URL (standalone, no base) |
60
+ | `script.inject-form.js` | Form injection only | Injects hidden `pimms_id` into all forms (standalone, no base) |
61
+
62
+ ### Recommended: Detection Bundle
63
+
64
+ For most use cases, the detection bundle gives you everything in a single script tag:
65
+
66
+ ```html
67
+ <script
68
+ defer
69
+ src="https://cdn.pimms.io/analytics/script.detection.js"
70
+ data-domains='{
71
+ "refer": "your-short.domain",
72
+ "site": "your-site.domain",
73
+ "outbound": "tally.so,cal.com"
74
+ }'>
75
+ </script>
76
+ ```
77
+
46
78
  ## Available Props
47
79
 
48
- Customize the analytics script by passing props to the `Analytics` component:
80
+ Customize the analytics script by passing props to the `Analytics` component or as `data-*` attributes on the script tag.
49
81
 
50
82
  ### `apiHost`
51
83
 
52
84
  Defines a custom API host for tracking requests. Useful when using reverse proxies to bypass ad-blockers.
53
85
 
54
86
  - **Default:** `https://api.pimms.io`
87
+ - **Script attribute:** `data-api-host`
55
88
 
56
89
  ### `domainsConfig`
57
90
 
58
- Configure domains for accurate tracking:
91
+ Configure domains and features via a single JSON object. Passed as `data-domains` on the script tag.
59
92
 
60
93
  ```tsx
61
94
  <PimmsAnalytics
62
95
  domainsConfig={{
63
- site: "pim.ms",
64
- outbound: ["yourdomain.com", "anotherdomain.com"],
96
+ refer: "pim.ms",
97
+ site: "site.pimms.io",
98
+ outbound: "tally.so,cal.com",
65
99
  }}
66
100
  />
67
101
  ```
68
102
 
69
- - `site`: Short domain provided by PIMMS.
70
- - `outbound`: Array of domains enabling cross-domain tracking.
103
+ **Available keys:**
104
+
105
+ | Key | Type | Description |
106
+ |-----|------|-------------|
107
+ | `refer` | `string` | PIMMS short domain for referral click tracking |
108
+ | `site` | `string` | PIMMS short domain for anonymous site visit tracking |
109
+ | `outbound` | `string` | Comma-separated list of domains. `pimms_id` is auto-appended to all outbound `<a>` links matching these domains |
110
+ | `embed` | `object` | Embed support configuration (see below) |
111
+ | `thank-you` | `string` | PIMMS short link to fetch on `/thanks/` pages (see below) |
112
+
113
+ ### Outbound Domains
114
+
115
+ When `outbound` is configured, all `<a>` links whose `href` matches one of the listed domains will automatically get `?pimms_id=...` appended. This enables cross-domain tracking without manual URL changes.
116
+
117
+ ```html
118
+ <script
119
+ defer
120
+ src="https://cdn.pimms.io/analytics/script.detection.js"
121
+ data-domains='{"outbound": "tally.so,cal.com"}'>
122
+ </script>
123
+ ```
124
+
125
+ ### Embed Support
126
+
127
+ The embed extension auto-appends `pimms_id` to embed widget attributes (e.g. `data-tally-src`, `data-cal-link`) and inside `srcdoc` HTML content, for any URL matching an `outbound` domain.
128
+
129
+ **Defaults:** targets `data-cal-link` and `data-tally-src` attributes. Customize via `embed.attributes`:
130
+
131
+ ```html
132
+ <script
133
+ defer
134
+ src="https://cdn.pimms.io/analytics/script.detection.js"
135
+ data-domains='{
136
+ "outbound": "tally.so,cal.com",
137
+ "embed": {
138
+ "attributes": ["data-tally-src", "data-cal-link", "data-custom-src"]
139
+ }
140
+ }'>
141
+ </script>
142
+ ```
143
+
144
+ For `<iframe srcdoc="...">` content, any URL matching an outbound domain is automatically updated. No extra config needed.
145
+
146
+ ### Thank-You Page
147
+
148
+ When enabled, the script fires a one-time `GET` fetch to a PIMMS short link (per session, per path) on pages under `/thanks/`. This triggers a conversion event server-side.
149
+
150
+ Enable by setting `thank-you` to a PIMMS short link:
151
+
152
+ ```html
153
+ <script
154
+ defer
155
+ src="https://cdn.pimms.io/analytics/script.detection.js"
156
+ data-domains='{
157
+ "outbound": "tally.so",
158
+ "thank-you": "https://pim.ms/your-thank-you-link"
159
+ }'>
160
+ </script>
161
+ ```
162
+
163
+ The fetch uses `mode: "no-cors"`, `credentials: "include"`, and `keepalive: true`. It fires once per `/thanks/*` path per browser session (deduplicated via `sessionStorage`).
164
+
165
+ ### Detect IDs
166
+
167
+ Automatically replaces placeholder values in links to official integrations:
168
+
169
+ - **Cal.com** (`*.cal.com`): adds `pimms_id`
170
+ - **Stripe Checkout** (`buy.stripe.com`): adds `client_reference_id`
171
+ - **iClosed** (`*.iclosed.io`): adds `utm_term`
172
+
173
+ Also replaces `pimms_id=1` placeholders in any link with the real `pimms_id` value.
174
+
175
+ When `data-forward-all="true"` is set, `pimms_id` is appended to all same-domain links as well.
71
176
 
72
177
  ### `attributionModel`
73
178
 
74
179
  Defines which touchpoint receives conversion credit:
75
180
 
76
181
  - **Default:** `last-click`
182
+ - **Script attribute:** `data-attribution-model`
77
183
 
78
184
  Available options:
79
185
  - `first-click`: Credits the initial user interaction.
80
186
  - `last-click`: Credits the final user interaction.
81
187
 
82
- Example:
83
-
84
188
  ```tsx
85
189
  <PimmsAnalytics attributionModel="first-click" />
86
190
  ```
@@ -89,14 +193,14 @@ Example:
89
193
 
90
194
  Customize the cookie behavior for tracking:
91
195
 
92
- | Key | Default | Description | Example |
93
- |-----------------|---------------------|--------------------------------------------------------------|---------------------------|
94
- | `domain` | `null` | Domain scope of the cookie | `example.com` |
95
- | `expires` | 90 days from now | Explicit expiry date | `new Date('2024-12-31')` |
96
- | `expiresInDays` | `90` | Number of days before the cookie expires | `60` |
97
- | `path` | `/` | URL path the cookie applies to | `/` |
196
+ | Key | Default | Description | Example |
197
+ |-----|---------|-------------|---------|
198
+ | `domain` | `null` | Domain scope of the cookie | `example.com` |
199
+ | `expires` | 90 days from now | Explicit expiry date | `new Date('2024-12-31')` |
200
+ | `expiresInDays` | `90` | Number of days before the cookie expires | `60` |
201
+ | `path` | `/` | URL path the cookie applies to | `/` |
98
202
 
99
- Example (set a 60-day cookie lifespan):
203
+ - **Script attribute:** `data-cookie-options` (JSON string)
100
204
 
101
205
  ```tsx
102
206
  <PimmsAnalytics cookieOptions={{ expiresInDays: 60 }} />
@@ -107,14 +211,7 @@ Example (set a 60-day cookie lifespan):
107
211
  Specifies the URL parameter to use for tracking (e.g., referral codes):
108
212
 
109
213
  - **Default:** `via`
110
-
111
- Example:
112
-
113
- ```
114
- ?ref=john_doe
115
- ```
116
-
117
- To use `ref` instead of the default:
214
+ - **Script attribute:** `data-query-param`
118
215
 
119
216
  ```tsx
120
217
  <PimmsAnalytics queryParam="ref" />
@@ -124,14 +221,54 @@ To use `ref` instead of the default:
124
221
 
125
222
  Custom attributes for the injected `<script>` tag. See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement) for all available options.
126
223
 
127
- Example:
128
-
129
224
  ```tsx
130
225
  <PimmsAnalytics scriptProps={{ defer: true }} />
131
226
  ```
132
227
 
228
+ ## Standalone Scripts
229
+
230
+ These scripts work independently (no base tracking required):
231
+
232
+ ### `script.expose.js`
233
+
234
+ Reads `pimms_id` from cookies or URL and exposes it as `window.pimms_id`.
235
+
236
+ ```html
237
+ <script src="https://cdn.pimms.io/analytics/script.expose.js"></script>
238
+ <script>
239
+ console.log(window.pimms_id); // the pimms_id value or null
240
+ </script>
241
+ ```
242
+
243
+ ### `script.inject-form.js`
244
+
245
+ Injects a hidden `<input name="pimms_id">` into all `<form>` elements on the page. Watches for dynamically added forms via MutationObserver.
246
+
247
+ ```html
248
+ <script src="https://cdn.pimms.io/analytics/script.inject-form.js"></script>
249
+ ```
250
+
251
+ ## Full Example (Detection Bundle)
252
+
253
+ ```html
254
+ <script
255
+ defer
256
+ src="https://cdn.pimms.io/analytics/script.detection.js"
257
+ data-domains='{
258
+ "refer": "go.example.com",
259
+ "site": "site.example.com",
260
+ "outbound": "tally.so,cal.com",
261
+ "thank-you": "https://api.example.com/convert"
262
+ }'
263
+ data-attribution-model="last-click"
264
+ data-query-param="via">
265
+ </script>
266
+ ```
267
+
268
+ This single script tag enables: click tracking, outbound link tracking, embed support for Tally/Cal, link detection for Stripe/Cal/iClosed, and thank-you page conversion callbacks.
269
+
133
270
  ## Next Steps
134
271
 
135
- [Sign up for PIMMS today](https://app.pimms.io/register)
272
+ [Sign up for PIMMS today](https://app.pimms.io/register)
136
273
 
137
- [Introduction to conversion tracking | blog](https://pimms.io/blog/introducing-conversion-tracking)
274
+ [Introduction to conversion tracking | blog](https://pimms.io/blog/introducing-conversion-tracking)
package/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(generic_exports);
27
27
 
28
28
  // package.json
29
29
  var name = "@getpimms/analytics";
30
- var version = "1.1.4";
30
+ var version = "1.3.0";
31
31
 
32
32
  // src/utils.tsx
33
33
  function isBrowser() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/generic.ts","../package.json","../src/utils.tsx"],"sourcesContent":["import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.1.4\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCE,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;AFKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAChC;AAGA,QAAM,UAAU;AAChB,QAAM,WAAW,CAAC;AAElB,OAAI,WAAM,kBAAN,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O,kBAAQ;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/generic.ts","../package.json","../src/utils.tsx"],"sourcesContent":["import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.3.0\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n"],"mappings":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O,KAAK,MAAM,aAAa,EAAE,SAAS,GAAG;AACtE,WAAO;AAAA,MACL;AAAA,MACA,KAAK,UAAU,MAAM,aAAa;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,MAAM,YAAY;AACpB,WAAO,aAAa,oBAAoB,MAAM,UAAU;AAAA,EAC1D;AAEA,MAAI,MAAM,aAAa;AACrB,UAAM,EAAE,KAAK,GAAG,GAAG,UAAU,IAAI,MAAM;AACvC,WAAO,OAAO,QAAQ,SAAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;AAMA,IAAO,kBAAQ;AAAA,EACb;AACF;","names":[]}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@getpimms/analytics";
3
- var version = "1.1.4";
3
+ var version = "1.3.0";
4
4
 
5
5
  // src/utils.tsx
6
6
  function isBrowser() {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/utils.tsx","../src/generic.ts"],"sourcesContent":["{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.1.4\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAChC;AAGA,QAAM,UAAU;AAChB,QAAM,WAAW,CAAC;AAElB,OAAI,WAAM,kBAAN,mBAAqB;AAAM,aAAS,KAAK,YAAY;AACzD,OAAI,WAAM,kBAAN,mBAAqB;AAAU,aAAS,KAAK,kBAAkB;AAEnE,QAAM,QACJ,WAAM,gBAAN,mBAAmB,SAClB,SAAS,SAAS,IACf,GAAG,OAAO,IAAI,SAAS,KAAK,GAAG,CAAC,QAChC,GAAG,OAAO;AAEhB,MAAI,SAAS,KAAK,cAAc,gBAAgB,GAAG,IAAI;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,UAAQ,WAAM,gBAAN,mBAAmB,UAAS;AAC3C,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,MAAM,SAAS;AACjB,WAAO,aAAa,iBAAiB,MAAM,OAAO;AAAA,EACpD;AAEA,MAAI,MAAM,eAAe;AACvB,WAAO,aAAa,gBAAgB,KAAK,UAAU,MAAM,aAAa,CAAC;AAAA,EACzE;AAEA,MAAI,MAAM,aAAa;AACrB,WAAO,aAAa,qBAAqB,MAAM,WAAW;AAAA,EAC5D;AAEA,MAAI,MAAM,kBAAkB;AAC1B,WAAO,aAAa,0BAA0B,MAAM,gBAAgB;AAAA,EACtE;AAEA,MAAI,MAAM,iBAAiB,OAAO,KAAK,MAAM,aAAa,EAAE,SAAS,GAAG;AACtE,WAAO;AAAA,MACL;AAAA,MACA,KAAK,UAAU,MAAM,aAAa;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,MAAM,YAAY;AACpB,WAAO,aAAa,oBAAoB,MAAM,UAAU;AAAA,EAC1D;AAEA,MAAI,MAAM,aAAa;AACrB,UAAM,EAAE,KAAK,GAAG,GAAG,UAAU,IAAI,MAAM;AACvC,WAAO,OAAO,QAAQ,SAAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;AAMA,IAAO,kBAAQ;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../package.json","../src/utils.tsx","../src/generic.ts"],"sourcesContent":["{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.3.0\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";AACE,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C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AAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;AAMA,IAAO,kBAAQ;AAAA,EACb;AACF;","names":[]}
@@ -28,7 +28,7 @@ var import_react = require("react");
28
28
 
29
29
  // package.json
30
30
  var name = "@getpimms/analytics";
31
- var version = "1.1.4";
31
+ var version = "1.3.0";
32
32
 
33
33
  // src/utils.tsx
34
34
  function isBrowser() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react.tsx","../../package.json","../../src/utils.tsx","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n * @param props - Analytics options.\n * ```js\n * import { Analytics as PimmsAnalytics } from '@getpimms/analytics/react';\n *\n * export default function App() {\n * return (\n * <div>\n * <PimmsAnalytics />\n * <h1>My App</h1>\n * </div>\n * );\n * }\n * ```\n */\nfunction Analytics(props: AnalyticsProps): null {\n useEffect(() => {\n inject(props);\n }, [props]);\n\n return null;\n}\n\nexport { Analytics };\nexport type { AnalyticsProps };\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.1.4\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;;;ACCxB,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAChC;AAGA,QAAM,UAAU;AAChB,QAAM,WAAW,CAAC;AAElB,OAAI,WAAM,kBAAN,mBAAqB;AAAM,aAAS,KAAK,YAAY;AACzD,OAAI,WAAM,kBAAN,mBAAqB;AAAU,aAAS,KAAK,kBAAkB;AAEnE,QAAM,QACJ,WAAM,g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+ {"version":3,"sources":["../../src/react.tsx","../../package.json","../../src/utils.tsx","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n * @param props - Analytics options.\n * ```js\n * import { Analytics as PimmsAnalytics } from '@getpimms/analytics/react';\n *\n * export default function App() {\n * return (\n * <div>\n * <PimmsAnalytics />\n * <h1>My App</h1>\n * </div>\n * );\n * }\n * ```\n */\nfunction Analytics(props: AnalyticsProps): null {\n useEffect(() => {\n inject(props);\n }, [props]);\n\n return null;\n}\n\nexport { Analytics };\nexport type { AnalyticsProps };\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.3.0\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;;;ACCxB,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAChC;AAGA,QAAM,UAAU;AAChB,QAAM,WAAW,CAAC;AAElB,OAAI,WAAM,kBAAN,mBAAqB;AAAM,aAAS,KAAK,YAAY;AACzD,OAAI,WAAM,kBAAN,mBAAqB;AAAU,aAAS,KAAK,kBAAkB;AAEnE,QAAM,QACJ,WAAM,gBAAN,mBAAmB,SAClB,SAAS,SAAS,IACf,GAAG,OAAO,IAAI,SAAS,KAAK,GAAG,CAAC,QAChC,GAAG,OAAO;AAEhB,MAAI,SAAS,KAAK,cAAc,gBAAgB,GAAG,IAAI;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,UAAQ,WAAM,gBAAN,mBAAmB,UAAS;AAC3C,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,MAAM,SAAS;AACjB,WAAO,aAAa,iBAAiB,MAAM,OAAO;AAAA,EACpD;AAEA,MAAI,MAAM,eAAe;AACvB,WAAO,aAAa,gBAAgB,KAAK,UAAU,MAAM,aAAa,CAAC;AAAA,EACzE;AAEA,MAAI,MAAM,aAAa;AACrB,WAAO,aAAa,qBAAqB,MAAM,WAAW;AAAA,EAC5D;AAEA,MAAI,MAAM,kBAAkB;AAC1B,WAAO,aAAa,0BAA0B,MAAM,gBAAgB;AAAA,EACtE;AAEA,MAAI,MAAM,iBAAiB,OAAO,KAAK,MAAM,aAAa,EAAE,SAAS,GAAG;AACtE,WAAO;AAAA,MACL;AAAA,MACA,KAAK,UAAU,MAAM,aAAa;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,MAAM,YAAY;AACpB,WAAO,aAAa,oBAAoB,MAAM,UAAU;AAAA,EAC1D;AAEA,MAAI,MAAM,aAAa;AACrB,UAAM,EAAE,KAAK,GAAG,GAAG,UAAU,IAAI,MAAM;AACvC,WAAO,OAAO,QAAQ,SAAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHzDA,SAAS,UAAU,OAA6B;AAC9C,8BAAU,MAAM;AACd,WAAO,KAAK;AAAA,EACd,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AACT;","names":[]}
@@ -5,7 +5,7 @@ import { useEffect } from "react";
5
5
 
6
6
  // package.json
7
7
  var name = "@getpimms/analytics";
8
- var version = "1.1.4";
8
+ var version = "1.3.0";
9
9
 
10
10
  // src/utils.tsx
11
11
  function isBrowser() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react.tsx","../../package.json","../../src/utils.tsx","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n * @param props - Analytics options.\n * ```js\n * import { Analytics as PimmsAnalytics } from '@getpimms/analytics/react';\n *\n * export default function App() {\n * return (\n * <div>\n * <PimmsAnalytics />\n * <h1>My App</h1>\n * </div>\n * );\n * }\n * ```\n */\nfunction Analytics(props: AnalyticsProps): null {\n useEffect(() => {\n inject(props);\n }, [props]);\n\n return null;\n}\n\nexport { Analytics };\nexport type { AnalyticsProps };\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.1.4\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";;;AAAA,SAAS,iBAAiB;;;ACCxB,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,aAAS,KAAK,YAAY,IAAI;AAAA,EAChC;AAGA,QAAM,UAAU;AAChB,QAAM,WAAW,CAAC;AAElB,OAAI,WAAM,kBAAN,mBAAqB;AAAM,aAAS,KAAK,YAAY;AACzD,OAAI,WAAM,kBAAN,mBAAqB;AAAU,aAAS,KAAK,kBAAkB;AAEnE,QAAM,QACJ,WAAM,gBAAN,mBAAmB,SAClB,SAAS,SAAS,IACf,GAAG,OAAO,IAAI,SAAS,KAAK,GAAG,CAAC,QAChC,GAAG,OAAO;AAEhB,MAAI,SAAS,KAAK,cAAc,gBAAgB,GAAG,IAAI;AAAG;AAE1D,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,UAAQ,WAAM,gBAAN,mBAAmB,UAAS;AAC3C,SAAO,aAAa,aAAa,IAAI;AACrC,SAAO,aAAa,aAAa,OAAO;AAExC,MAAI,MAAM,SAAS;AACjB,WAAO,aAAa,iBAAiB,MAAM,OAAO;AAAA,EACpD;AAEA,MAAI,MAAM,eAAe;AACvB,WAAO,aAAa,gBAAgB,KAAK,UAAU,MAAM,aAAa,CAAC;AAAA,EACzE;AAEA,MAAI,MAAM,aAAa;AACrB,WAAO,aAAa,qBAAqB,MAAM,WAAW;AAAA,EAC5D;AAEA,MAAI,MAAM,kBAAkB;AAC1B,WAAO,aAAa,0BAA0B,MAAM,gBAAgB;AAAA,EACtE;AAEA,MAAI,MAAM,iBAAiB,OAAO,KAAK,MAAM,aAAa,EAAE,SAAS,GAAG;AACtE,WAAO;AAAA,MACL;AAAA,MACA,KAAK,UAAU,MAAM,aAAa;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,MAAM,YAAY;AACpB,WAAO,aAAa,oBAAoB,MAAM,UAAU;AAAA,EAC1D;AAEA,MAAI,MAAM,aAAa;AACrB,UAAM,EAAE,KAAK,GAAG,GAAG,UAAU,IAAI,MAAM;AACvC,WAAO,OAAO,QAAQ,SAAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHzDA,SAAS,UAAU,OAA6B;AAC9C,YAAU,MAAM;AACd,WAAO,KAAK;AAAA,EACd,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/react.tsx","../../package.json","../../src/utils.tsx","../../src/generic.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { inject } from './generic';\nimport type { AnalyticsProps } from './types';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n * @param props - Analytics options.\n * ```js\n * import { Analytics as PimmsAnalytics } from '@getpimms/analytics/react';\n *\n * export default function App() {\n * return (\n * <div>\n * <PimmsAnalytics />\n * <h1>My App</h1>\n * </div>\n * );\n * }\n * ```\n */\nfunction Analytics(props: AnalyticsProps): null {\n useEffect(() => {\n inject(props);\n }, [props]);\n\n return null;\n}\n\nexport { Analytics };\nexport type { AnalyticsProps };\n","{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.3.0\",\n \"description\": \"\",\n \"keywords\": [\n \"analytics\",\n \"pimms\"\n ],\n \"repository\": {\n \"url\": \"github:getpimms/analytics\",\n \"directory\": \"packages/web\"\n },\n \"license\": \"MPL-2.0\",\n \"type\": \"module\",\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"browser\": \"./dist/index.js\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n },\n \"./react\": {\n \"browser\": \"./dist/react/index.js\",\n \"import\": \"./dist/react/index.js\",\n \"require\": \"./dist/react/index.cjs\"\n }\n },\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"*\": [\n \"dist/index.d.ts\"\n ],\n \"react\": [\n \"dist/react/index.d.ts\"\n ]\n }\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"changeset\": \"pnpm version patch --no-script\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint .\",\n \"lint-fix\": \"eslint . --fix\",\n \"type-check\": \"tsc --noEmit\"\n },\n \"eslintConfig\": {\n \"extends\": [\n \"@dub/eslint-config\"\n ],\n \"rules\": {\n \"tsdoc/syntax\": \"off\"\n }\n },\n \"dependencies\": {\n \"server-only\": \"^0.0.1\"\n },\n \"devDependencies\": {\n \"@dub/eslint-config\": \"workspace:0.0.0\",\n \"@swc/core\": \"^1.3.66\",\n \"@types/node\": \"^20.3.1\",\n \"@types/react\": \"^18.2.14\",\n \"react\": \"^18.2.0\",\n \"react-dom\": \"^18.2.0\",\n \"tsup\": \"7.1.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","export function isBrowser() {\n return typeof window !== 'undefined';\n}\n","import { name, version } from '../package.json';\nimport type { AnalyticsProps } from './types';\nimport { isBrowser } from './utils';\n\n/**\n * Injects the PIMMS Web Analytics script into the page head.\n */\nfunction inject(props: AnalyticsProps): void {\n if (!isBrowser()) return;\n\n // Inject meta tag for SDK detection\n if (!document.head.querySelector('meta[name=\"pimms-sdk\"]')) {\n const meta = document.createElement('meta');\n meta.name = 'pimms-sdk';\n meta.content = 'true';\n document.head.appendChild(meta);\n }\n\n // Determine script source based on enabled features\n const baseUrl = 'https://cdn.pimms.io/analytics/script';\n const features = [];\n\n if (props.domainsConfig?.site) features.push('site-visit');\n if (props.domainsConfig?.outbound) features.push('outbound-domains');\n\n const src =\n props.scriptProps?.src ||\n (features.length > 0\n ? `${baseUrl}.${features.join('.')}.js`\n : `${baseUrl}.js`);\n\n if (document.head.querySelector(`script[src*=\"${src}\"]`)) return;\n\n const script = document.createElement('script');\n script.src = src;\n script.defer = props.scriptProps?.defer ?? true;\n script.setAttribute('data-sdkn', name);\n script.setAttribute('data-sdkv', version);\n\n if (props.apiHost) {\n script.setAttribute('data-api-host', props.apiHost);\n }\n\n if (props.domainsConfig) {\n script.setAttribute('data-domains', JSON.stringify(props.domainsConfig));\n }\n\n if (props.shortDomain) {\n script.setAttribute('data-short-domain', props.shortDomain);\n }\n\n if (props.attributionModel) {\n script.setAttribute('data-attribution-model', props.attributionModel);\n }\n\n if (props.cookieOptions && Object.keys(props.cookieOptions).length > 0) {\n script.setAttribute(\n 'data-cookie-options',\n JSON.stringify(props.cookieOptions),\n );\n }\n\n if (props.queryParam) {\n script.setAttribute('data-query-param', props.queryParam);\n }\n\n if (props.scriptProps) {\n const { src: _, ...restProps } = props.scriptProps; // we already set the src above\n Object.assign(script, restProps);\n }\n\n script.onerror = (): void => {\n // eslint-disable-next-line no-console -- Logging to console is intentional\n console.log(`[PIMMS Web Analytics] failed to load script from ${src}.`);\n };\n\n document.head.appendChild(script);\n}\n\nexport { inject };\nexport type { AnalyticsProps };\n\n// eslint-disable-next-line import/no-default-export -- Default export is intentional\nexport default {\n inject,\n};\n"],"mappings":";;;AAAA,SAAS,iBAAiB;;;ACCxB,WAAQ;AACR,cAAW;;;ACFN,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW;AAC3B;;;ACKA,SAAS,OAAO,OAA6B;AAP7C;AAQE,MAAI,CAAC,UAAU;AAAG;AAGlB,MAAI,CAAC,SAAS,KAAK,cAAc,wBAAwB,GAAG;AAC1D,UAAM,OA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;AACvC,WAAO,OAAO,QAAQ,SAAS;AAAA,EACjC;AAEA,SAAO,UAAU,MAAY;AAE3B,YAAQ,IAAI,oDAAoD,GAAG,GAAG;AAAA,EACxE;AAEA,WAAS,KAAK,YAAY,MAAM;AAClC;;;AHzDA,SAAS,UAAU,OAA6B;AAC9C,YAAU,MAAM;AACd,WAAO,KAAK;AAAA,EACd,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpimms/analytics",
3
- "version": "1.1.4",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "analytics",