@getpimms/analytics 0.0.28 → 1.1.3
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 +101 -50
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +7 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +7 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/src/generic.ts +8 -0
package/README.md
CHANGED
|
@@ -1,86 +1,137 @@
|
|
|
1
|
+
# @getpimms/analytics
|
|
2
|
+
|
|
3
|
+
Easily track and optimize your lead and sales conversions using PIMMS across multiple channels and applications.
|
|
4
|
+
|
|
1
5
|
## Overview
|
|
2
6
|
|
|
3
|
-
`@getpimms/analytics`
|
|
7
|
+
`@getpimms/analytics` provides a streamlined way to implement conversion tracking on your site or application, helping you identify exactly what generates your leads and conversions.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
Follow these steps to quickly integrate PIMMS analytics:
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
2. Install the `@getpimms/analytics` package to your project
|
|
13
|
+
### 1. Enable Conversion Tracking
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
npm install @getpimms/analytics
|
|
12
|
-
```
|
|
15
|
+
Activate conversion tracking for your PIMMS links via the [PIMMS dashboard](https://app.pimms.io).
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
### 2. Install the Analytics Package
|
|
18
|
+
|
|
19
|
+
Add the `@getpimms/analytics` package to your project:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @getpimms/analytics
|
|
23
|
+
```
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
### 3. Inject the Analytics Script
|
|
26
|
+
|
|
27
|
+
Integrate the tracking script into your application:
|
|
28
|
+
|
|
29
|
+
**React Example:**
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Analytics as PimmsAnalytics } from '@getpimms/analytics/react';
|
|
33
|
+
|
|
34
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
35
|
+
return (
|
|
36
|
+
<html lang="en">
|
|
37
|
+
<body>{children}</body>
|
|
38
|
+
<PimmsAnalytics />
|
|
39
|
+
</html>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
18
43
|
|
|
19
|
-
|
|
20
|
-
children,
|
|
21
|
-
}: Readonly<{
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
}>) {
|
|
24
|
-
return (
|
|
25
|
-
<html lang="en">
|
|
26
|
-
<body>{children}</body>
|
|
27
|
-
<PimmsAnalytics />
|
|
28
|
-
</html>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
You can all use the `inject()` function to add the tracking script to other frameworks.
|
|
44
|
+
Alternatively, for other frameworks, use the `inject()` method.
|
|
34
45
|
|
|
35
46
|
## Available Props
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
Customize the analytics script by passing props to the `Analytics` component:
|
|
38
49
|
|
|
39
50
|
### `apiHost`
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
Defines a custom API host for tracking requests. Useful when using reverse proxies to bypass ad-blockers.
|
|
53
|
+
|
|
54
|
+
- **Default:** `https://api.pimms.io`
|
|
42
55
|
|
|
43
56
|
### `domainsConfig`
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
Configure domains for accurate tracking:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<PimmsAnalytics
|
|
62
|
+
domainsConfig={{
|
|
63
|
+
site: "pim.ms",
|
|
64
|
+
outbound: ["yourdomain.com", "anotherdomain.com"],
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
46
68
|
|
|
47
|
-
- `site`:
|
|
48
|
-
- `outbound`:
|
|
69
|
+
- `site`: Short domain provided by PIMMS.
|
|
70
|
+
- `outbound`: Array of domains enabling cross-domain tracking.
|
|
49
71
|
|
|
50
72
|
### `attributionModel`
|
|
51
73
|
|
|
52
|
-
|
|
74
|
+
Defines which touchpoint receives conversion credit:
|
|
75
|
+
|
|
76
|
+
- **Default:** `last-click`
|
|
77
|
+
|
|
78
|
+
Available options:
|
|
79
|
+
- `first-click`: Credits the initial user interaction.
|
|
80
|
+
- `last-click`: Credits the final user interaction.
|
|
53
81
|
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
Example:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<PimmsAnalytics attributionModel="first-click" />
|
|
86
|
+
```
|
|
56
87
|
|
|
57
88
|
### `cookieOptions`
|
|
58
89
|
|
|
59
|
-
|
|
90
|
+
Customize the cookie behavior for tracking:
|
|
60
91
|
|
|
61
|
-
| Key
|
|
62
|
-
|
|
63
|
-
| `domain`
|
|
64
|
-
| `expires`
|
|
65
|
-
| `expiresInDays` | `90`
|
|
66
|
-
| `path`
|
|
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 | `/` |
|
|
67
98
|
|
|
68
|
-
|
|
99
|
+
Example (set a 60-day cookie lifespan):
|
|
69
100
|
|
|
70
101
|
```tsx
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<PimmsAnalytics
|
|
74
|
-
cookieOptions={{
|
|
75
|
-
expiresInDays: 60,
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
102
|
+
<PimmsAnalytics cookieOptions={{ expiresInDays: 60 }} />
|
|
78
103
|
```
|
|
79
104
|
|
|
80
105
|
### `queryParam`
|
|
81
106
|
|
|
82
|
-
|
|
107
|
+
Specifies the URL parameter to use for tracking (e.g., referral codes):
|
|
108
|
+
|
|
109
|
+
- **Default:** `via`
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
?ref=john_doe
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
To use `ref` instead of the default:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<PimmsAnalytics queryParam="ref" />
|
|
121
|
+
```
|
|
83
122
|
|
|
84
123
|
### `scriptProps`
|
|
85
124
|
|
|
86
|
-
Custom
|
|
125
|
+
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
|
+
|
|
127
|
+
Example:
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<PimmsAnalytics scriptProps={{ defer: true }} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Next Steps
|
|
134
|
+
|
|
135
|
+
[Sign up for PIMMS today →](https://app.pimms.io/register)
|
|
136
|
+
|
|
137
|
+
[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 = "
|
|
30
|
+
var version = "1.1.3";
|
|
31
31
|
|
|
32
32
|
// src/utils.tsx
|
|
33
33
|
function isBrowser() {
|
|
@@ -39,6 +39,12 @@ function inject(props) {
|
|
|
39
39
|
var _a, _b, _c, _d;
|
|
40
40
|
if (!isBrowser())
|
|
41
41
|
return;
|
|
42
|
+
if (!document.head.querySelector('meta[name="pimms-sdk"]')) {
|
|
43
|
+
const meta = document.createElement("meta");
|
|
44
|
+
meta.name = "pimms-sdk";
|
|
45
|
+
meta.content = "true";
|
|
46
|
+
document.head.appendChild(meta);
|
|
47
|
+
}
|
|
42
48
|
const baseUrl = "https://cdn.pimms.io/analytics/script";
|
|
43
49
|
const features = [];
|
|
44
50
|
if ((_a = props.domainsConfig) == null ? void 0 : _a.site)
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 // 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
|
+
{"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.3\",\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,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":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@getpimms/analytics";
|
|
3
|
-
var version = "
|
|
3
|
+
var version = "1.1.3";
|
|
4
4
|
|
|
5
5
|
// src/utils.tsx
|
|
6
6
|
function isBrowser() {
|
|
@@ -12,6 +12,12 @@ function inject(props) {
|
|
|
12
12
|
var _a, _b, _c, _d;
|
|
13
13
|
if (!isBrowser())
|
|
14
14
|
return;
|
|
15
|
+
if (!document.head.querySelector('meta[name="pimms-sdk"]')) {
|
|
16
|
+
const meta = document.createElement("meta");
|
|
17
|
+
meta.name = "pimms-sdk";
|
|
18
|
+
meta.content = "true";
|
|
19
|
+
document.head.appendChild(meta);
|
|
20
|
+
}
|
|
15
21
|
const baseUrl = "https://cdn.pimms.io/analytics/script";
|
|
16
22
|
const features = [];
|
|
17
23
|
if ((_a = props.domainsConfig) == null ? void 0 : _a.site)
|
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
|
+
{"version":3,"sources":["../package.json","../src/utils.tsx","../src/generic.ts"],"sourcesContent":["{\n \"name\": \"@getpimms/analytics\",\n \"version\": \"1.1.3\",\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":[]}
|
package/dist/react/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@ var import_react = require("react");
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var name = "@getpimms/analytics";
|
|
31
|
-
var version = "
|
|
31
|
+
var version = "1.1.3";
|
|
32
32
|
|
|
33
33
|
// src/utils.tsx
|
|
34
34
|
function isBrowser() {
|
|
@@ -40,6 +40,12 @@ function inject(props) {
|
|
|
40
40
|
var _a, _b, _c, _d;
|
|
41
41
|
if (!isBrowser())
|
|
42
42
|
return;
|
|
43
|
+
if (!document.head.querySelector('meta[name="pimms-sdk"]')) {
|
|
44
|
+
const meta = document.createElement("meta");
|
|
45
|
+
meta.name = "pimms-sdk";
|
|
46
|
+
meta.content = "true";
|
|
47
|
+
document.head.appendChild(meta);
|
|
48
|
+
}
|
|
43
49
|
const baseUrl = "https://cdn.pimms.io/analytics/script";
|
|
44
50
|
const features = [];
|
|
45
51
|
if ((_a = props.domainsConfig) == null ? void 0 : _a.site)
|
package/dist/react/index.cjs.map
CHANGED
|
@@ -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
|
+
{"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.3\",\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,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":[]}
|
package/dist/react/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useEffect } from "react";
|
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
7
|
var name = "@getpimms/analytics";
|
|
8
|
-
var version = "
|
|
8
|
+
var version = "1.1.3";
|
|
9
9
|
|
|
10
10
|
// src/utils.tsx
|
|
11
11
|
function isBrowser() {
|
|
@@ -17,6 +17,12 @@ function inject(props) {
|
|
|
17
17
|
var _a, _b, _c, _d;
|
|
18
18
|
if (!isBrowser())
|
|
19
19
|
return;
|
|
20
|
+
if (!document.head.querySelector('meta[name="pimms-sdk"]')) {
|
|
21
|
+
const meta = document.createElement("meta");
|
|
22
|
+
meta.name = "pimms-sdk";
|
|
23
|
+
meta.content = "true";
|
|
24
|
+
document.head.appendChild(meta);
|
|
25
|
+
}
|
|
20
26
|
const baseUrl = "https://cdn.pimms.io/analytics/script";
|
|
21
27
|
const features = [];
|
|
22
28
|
if ((_a = props.domainsConfig) == null ? void 0 : _a.site)
|
package/dist/react/index.js.map
CHANGED
|
@@ -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
|
+
{"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.3\",\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":[]}
|
package/package.json
CHANGED
package/src/generic.ts
CHANGED
|
@@ -8,6 +8,14 @@ import { isBrowser } from './utils';
|
|
|
8
8
|
function inject(props: AnalyticsProps): void {
|
|
9
9
|
if (!isBrowser()) return;
|
|
10
10
|
|
|
11
|
+
// Inject meta tag for SDK detection
|
|
12
|
+
if (!document.head.querySelector('meta[name="pimms-sdk"]')) {
|
|
13
|
+
const meta = document.createElement('meta');
|
|
14
|
+
meta.name = 'pimms-sdk';
|
|
15
|
+
meta.content = 'true';
|
|
16
|
+
document.head.appendChild(meta);
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
// Determine script source based on enabled features
|
|
12
20
|
const baseUrl = 'https://cdn.pimms.io/analytics/script';
|
|
13
21
|
const features = [];
|