@analyticscli/sdk 0.1.0-preview.5 → 0.1.0-preview.7
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 +75 -80
- package/dist/browser.cjs +92 -103
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +5 -15
- package/dist/{chunk-HL2VOD3Z.js → chunk-O4FIH647.js} +90 -96
- package/dist/index.cjs +92 -103
- package/dist/index.d.cts +57 -53
- package/dist/index.d.ts +57 -53
- package/dist/index.js +5 -15
- package/dist/react-native.cjs +92 -103
- package/dist/react-native.d.cts +1 -1
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js +5 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,101 +38,96 @@ Before integrating, collect required values in [dash.analyticscli.com](https://d
|
|
|
38
38
|
## Usage (Low Boilerplate)
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
const analytics =
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
import { createAnalyticsContext } from '@analyticscli/sdk';
|
|
42
|
+
|
|
43
|
+
const analytics = createAnalyticsContext({
|
|
44
|
+
client: {
|
|
45
|
+
apiKey: '<YOUR_APP_KEY>',
|
|
46
|
+
identityTrackingMode: 'consent_gated', // explicit host-app default
|
|
47
|
+
},
|
|
48
|
+
onboarding: {
|
|
49
|
+
onboardingFlowId: 'onboarding_v1',
|
|
50
|
+
onboardingFlowVersion: '1.0.0',
|
|
51
|
+
isNewUser: true,
|
|
52
|
+
},
|
|
46
53
|
});
|
|
47
54
|
|
|
48
|
-
analytics.
|
|
49
|
-
|
|
50
|
-
});
|
|
55
|
+
analytics.onboarding.start();
|
|
56
|
+
analytics.onboarding.step('welcome', 0).view();
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
`
|
|
54
|
-
|
|
55
|
-
- `
|
|
56
|
-
- `
|
|
59
|
+
`createAnalyticsContext(...)` gives you:
|
|
60
|
+
- `analytics.client` (raw `AnalyticsClient`)
|
|
61
|
+
- `analytics.onboarding` (pre-wired tracker instance)
|
|
62
|
+
- `analytics.paywall` (optional tracker instance)
|
|
63
|
+
- `analytics.consent.*` (collection + full-tracking controls)
|
|
64
|
+
- `analytics.user.*` (`set`, `clear`, `identify`)
|
|
57
65
|
|
|
58
|
-
For host-app integration, prefer
|
|
66
|
+
For host-app integration, prefer explicit client config with
|
|
59
67
|
`identityTrackingMode: 'consent_gated'` unless you intentionally need another mode.
|
|
60
68
|
|
|
61
69
|
Optional runtime collection pause/resume:
|
|
62
70
|
|
|
63
71
|
```ts
|
|
64
|
-
import {
|
|
72
|
+
import { createAnalyticsContext } from '@analyticscli/sdk';
|
|
65
73
|
|
|
66
|
-
const analytics =
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
const analytics = createAnalyticsContext({
|
|
75
|
+
client: {
|
|
76
|
+
apiKey: '<YOUR_APP_KEY>',
|
|
77
|
+
identityTrackingMode: 'consent_gated',
|
|
78
|
+
},
|
|
69
79
|
});
|
|
70
|
-
analytics.optOut(); // stop sending until optIn()
|
|
80
|
+
analytics.consent.optOut(); // stop sending until optIn()
|
|
71
81
|
// ...
|
|
72
|
-
analytics.optIn();
|
|
82
|
+
analytics.consent.optIn();
|
|
73
83
|
```
|
|
74
84
|
|
|
75
85
|
Optional full-tracking consent gate (recommended default):
|
|
76
86
|
|
|
77
87
|
```ts
|
|
78
|
-
import {
|
|
88
|
+
import { createAnalyticsContext } from '@analyticscli/sdk';
|
|
79
89
|
|
|
80
|
-
const analytics =
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
const analytics = createAnalyticsContext({
|
|
91
|
+
client: {
|
|
92
|
+
apiKey: '<YOUR_APP_KEY>',
|
|
93
|
+
identityTrackingMode: 'consent_gated',
|
|
94
|
+
},
|
|
83
95
|
});
|
|
84
96
|
|
|
85
97
|
// user accepts full tracking in your consent UI
|
|
86
|
-
analytics.
|
|
98
|
+
analytics.consent.setFullTracking(true);
|
|
87
99
|
|
|
88
100
|
// user rejects full tracking but you still keep strict anonymous analytics
|
|
89
|
-
analytics.
|
|
101
|
+
analytics.consent.setFullTracking(false);
|
|
90
102
|
```
|
|
91
103
|
|
|
92
|
-
`
|
|
93
|
-
|
|
94
|
-
- `ANALYTICSCLI_PUBLISHABLE_API_KEY`
|
|
95
|
-
- `NEXT_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY`
|
|
96
|
-
- `EXPO_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY`
|
|
97
|
-
- `VITE_ANALYTICSCLI_PUBLISHABLE_API_KEY`
|
|
98
|
-
|
|
99
|
-
Runtime-specific env helpers are also available:
|
|
100
|
-
|
|
101
|
-
- `@analyticscli/sdk` -> `initBrowserFromEnv(...)`
|
|
102
|
-
- adds `PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY` lookup for Astro/browser-first setups
|
|
103
|
-
- `@analyticscli/sdk` -> `initReactNativeFromEnv(...)`
|
|
104
|
-
- defaults to native-friendly env key lookup
|
|
105
|
-
- optional compatibility subpaths:
|
|
106
|
-
- `@analyticscli/sdk/browser`
|
|
107
|
-
- `@analyticscli/sdk/react-native`
|
|
108
|
-
|
|
109
|
-
If config is missing, the client is a safe no-op (default behavior).
|
|
110
|
-
When `apiKey` is missing, the SDK logs a console error and remains no-op.
|
|
111
|
-
Use strict mode if you want hard failure:
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
const analytics = initFromEnv({
|
|
115
|
-
missingConfigMode: 'throw',
|
|
116
|
-
});
|
|
117
|
-
```
|
|
104
|
+
If `apiKey` is missing, the SDK logs a console error and remains a safe no-op client.
|
|
118
105
|
|
|
119
106
|
## Optional Configuration
|
|
120
107
|
|
|
121
108
|
```ts
|
|
122
109
|
import * as Application from 'expo-application';
|
|
123
110
|
import { Platform } from 'react-native';
|
|
124
|
-
import {
|
|
125
|
-
|
|
126
|
-
const analytics =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
import { createAnalyticsContext } from '@analyticscli/sdk';
|
|
112
|
+
|
|
113
|
+
const analytics = createAnalyticsContext({
|
|
114
|
+
client: {
|
|
115
|
+
apiKey: process.env.EXPO_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY,
|
|
116
|
+
debug: __DEV__,
|
|
117
|
+
platform: Platform.OS,
|
|
118
|
+
projectSurface: 'app',
|
|
119
|
+
appVersion: Application.nativeApplicationVersion,
|
|
120
|
+
initialConsentGranted: true,
|
|
121
|
+
identityTrackingMode: 'consent_gated',
|
|
122
|
+
initialFullTrackingConsentGranted: false,
|
|
123
|
+
dedupeOnboardingStepViewsPerSession: true,
|
|
124
|
+
},
|
|
125
|
+
onboarding: {
|
|
126
|
+
onboardingFlowId: 'onboarding_main',
|
|
127
|
+
onboardingFlowVersion: '1',
|
|
128
|
+
isNewUser: true,
|
|
129
|
+
stepCount: 7,
|
|
130
|
+
},
|
|
136
131
|
});
|
|
137
132
|
```
|
|
138
133
|
|
|
@@ -151,7 +146,7 @@ For paywall funnels with stable `source` + `paywallId`, create one tracker per
|
|
|
151
146
|
flow context and reuse it:
|
|
152
147
|
|
|
153
148
|
```ts
|
|
154
|
-
const paywall = analytics.
|
|
149
|
+
const paywall = analytics.createPaywall({
|
|
155
150
|
source: 'onboarding',
|
|
156
151
|
paywallId: 'default_paywall',
|
|
157
152
|
offering: 'rc_main', // RevenueCat example
|
|
@@ -161,7 +156,7 @@ paywall.shown({ fromScreen: 'onboarding_offer' });
|
|
|
161
156
|
paywall.purchaseSuccess({ packageId: 'annual' });
|
|
162
157
|
```
|
|
163
158
|
|
|
164
|
-
Do not create a new `
|
|
159
|
+
Do not create a new `createPaywall(...)` instance for every paywall callback/event.
|
|
165
160
|
If your paywall provider exposes it, pass `offering` in tracker defaults
|
|
166
161
|
(RevenueCat offering id, Adapty paywall/placement id, Superwall placement/paywall id).
|
|
167
162
|
|
|
@@ -169,7 +164,7 @@ For onboarding surveys, avoid repeating unchanged flow metadata at every callsit
|
|
|
169
164
|
Create one onboarding tracker with defaults and emit minimal survey payloads:
|
|
170
165
|
|
|
171
166
|
```ts
|
|
172
|
-
const onboarding = analytics.
|
|
167
|
+
const onboarding = analytics.createOnboarding({
|
|
173
168
|
onboardingFlowId: 'onboarding_main',
|
|
174
169
|
onboardingFlowVersion: '1',
|
|
175
170
|
stepCount: 7,
|
|
@@ -187,15 +182,15 @@ onboarding.step('budget-survey', 6).surveyResponse({
|
|
|
187
182
|
For RevenueCat correlation, keep identity and paywall purchase metadata aligned:
|
|
188
183
|
|
|
189
184
|
```ts
|
|
190
|
-
analytics.
|
|
185
|
+
analytics.user.set(appUserId); // same id passed to Purchases.logIn(appUserId)
|
|
191
186
|
// in purchase callbacks, prefer provider-native ids
|
|
192
187
|
paywall.purchaseStarted({ packageId: packageBeingPurchased.identifier });
|
|
193
188
|
// on sign-out
|
|
194
|
-
analytics.
|
|
189
|
+
analytics.user.clear();
|
|
195
190
|
```
|
|
196
191
|
|
|
197
192
|
Identity tracking modes:
|
|
198
|
-
- `consent_gated` (default): starts strict (no persistent identity), enables persistence/linkage only after
|
|
193
|
+
- `consent_gated` (default): starts strict (no persistent identity), enables persistence/linkage only after full-tracking consent is granted
|
|
199
194
|
- `always_on`: enables persistence/linkage immediately (`enableFullTrackingWithoutConsent: true` is a boolean shortcut)
|
|
200
195
|
- `strict`: keeps strict anonymous behavior permanently
|
|
201
196
|
|
|
@@ -205,28 +200,28 @@ Recommendation for global tenant apps:
|
|
|
205
200
|
In strict phase (and in `strict` mode):
|
|
206
201
|
- no persistent SDK identity across app/browser restarts
|
|
207
202
|
- no cookie-domain identity continuity
|
|
208
|
-
- `identify()` / `
|
|
203
|
+
- `analytics.user.identify(...)` / `analytics.user.set(...)` are ignored
|
|
209
204
|
|
|
210
205
|
`initialConsentGranted` is optional:
|
|
211
206
|
- default: `true` when `apiKey` is present
|
|
212
207
|
- you can still pause/resume collection at runtime with consent APIs when your app needs that
|
|
213
208
|
|
|
214
209
|
Runtime collection control APIs:
|
|
215
|
-
- `analytics.
|
|
216
|
-
- `analytics.
|
|
217
|
-
- `analytics.optIn()` / `analytics.optOut()`
|
|
218
|
-
- `analytics.
|
|
210
|
+
- `analytics.consent.get()` -> current in-memory consent
|
|
211
|
+
- `analytics.consent.getState()` -> `'granted' | 'denied' | 'unknown'`
|
|
212
|
+
- `analytics.consent.optIn()` / `analytics.consent.optOut()`
|
|
213
|
+
- `analytics.consent.set(true|false)`
|
|
219
214
|
|
|
220
215
|
Full-tracking control APIs:
|
|
221
|
-
- `analytics.
|
|
222
|
-
- `analytics.optInFullTracking()` / `analytics.optOutFullTracking()`
|
|
223
|
-
- `analytics.isFullTrackingEnabled()`
|
|
216
|
+
- `analytics.consent.setFullTracking(true|false)`
|
|
217
|
+
- `analytics.consent.optInFullTracking()` / `analytics.consent.optOutFullTracking()`
|
|
218
|
+
- `analytics.consent.isFullTrackingEnabled()`
|
|
224
219
|
|
|
225
|
-
`analytics.ready()`
|
|
226
|
-
starts on `
|
|
220
|
+
`analytics.ready()` / `analytics.client.ready()` do not "start" tracking. With default settings, tracking
|
|
221
|
+
starts on `createAnalyticsContext(...)`.
|
|
227
222
|
|
|
228
223
|
Use your project-specific publishable API key from the AnalyticsCLI dashboard in your workspace.
|
|
229
|
-
Only the publishable API key (`apiKey`) is needed for SDK
|
|
224
|
+
Only the publishable API key (`apiKey`) is needed for SDK setup calls.
|
|
230
225
|
The SDK uses the default collector endpoint internally.
|
|
231
226
|
In host apps, do not pass `endpoint` and do not add `ANALYTICSCLI_ENDPOINT` env vars.
|
|
232
227
|
|
package/dist/browser.cjs
CHANGED
|
@@ -21,8 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var browser_exports = {};
|
|
22
22
|
__export(browser_exports, {
|
|
23
23
|
AnalyticsClient: () => AnalyticsClient,
|
|
24
|
-
BROWSER_API_KEY_ENV_KEYS: () => BROWSER_API_KEY_ENV_KEYS,
|
|
25
|
-
DEFAULT_API_KEY_ENV_KEYS: () => DEFAULT_API_KEY_ENV_KEYS,
|
|
26
24
|
ONBOARDING_EVENTS: () => ONBOARDING_EVENTS,
|
|
27
25
|
ONBOARDING_PROGRESS_EVENT_ORDER: () => ONBOARDING_PROGRESS_EVENT_ORDER,
|
|
28
26
|
ONBOARDING_SCREEN_EVENT_PREFIXES: () => ONBOARDING_SCREEN_EVENT_PREFIXES,
|
|
@@ -33,14 +31,11 @@ __export(browser_exports, {
|
|
|
33
31
|
PAYWALL_SKIP_EVENT_CANDIDATES: () => PAYWALL_SKIP_EVENT_CANDIDATES,
|
|
34
32
|
PURCHASE_EVENTS: () => PURCHASE_EVENTS,
|
|
35
33
|
PURCHASE_SUCCESS_EVENT_CANDIDATES: () => PURCHASE_SUCCESS_EVENT_CANDIDATES,
|
|
36
|
-
|
|
34
|
+
createAnalyticsContext: () => createAnalyticsContext,
|
|
37
35
|
init: () => init,
|
|
38
36
|
initAsync: () => initAsync,
|
|
39
|
-
initBrowserFromEnv: () => initBrowserFromEnv,
|
|
40
37
|
initConsentFirst: () => initConsentFirst,
|
|
41
|
-
initConsentFirstAsync: () => initConsentFirstAsync
|
|
42
|
-
initFromEnv: () => initFromEnv,
|
|
43
|
-
initReactNativeFromEnv: () => initReactNativeFromEnv
|
|
38
|
+
initConsentFirstAsync: () => initConsentFirstAsync
|
|
44
39
|
});
|
|
45
40
|
module.exports = __toCommonJS(browser_exports);
|
|
46
41
|
|
|
@@ -242,7 +237,28 @@ var randomId = () => {
|
|
|
242
237
|
if (globalThis.crypto?.randomUUID) {
|
|
243
238
|
return globalThis.crypto.randomUUID();
|
|
244
239
|
}
|
|
245
|
-
|
|
240
|
+
const bytes = new Uint8Array(16);
|
|
241
|
+
if (globalThis.crypto?.getRandomValues) {
|
|
242
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
243
|
+
} else {
|
|
244
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
245
|
+
bytes[index] = Math.floor(Math.random() * 256);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const byte6 = bytes[6] ?? 0;
|
|
249
|
+
const byte8 = bytes[8] ?? 0;
|
|
250
|
+
bytes[6] = byte6 & 15 | 64;
|
|
251
|
+
bytes[8] = byte8 & 63 | 128;
|
|
252
|
+
let output = "";
|
|
253
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
254
|
+
const byte = bytes[index] ?? 0;
|
|
255
|
+
const hex = byte.toString(16).padStart(2, "0");
|
|
256
|
+
output += hex;
|
|
257
|
+
if (index === 3 || index === 5 || index === 7 || index === 9) {
|
|
258
|
+
output += "-";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return output;
|
|
246
262
|
};
|
|
247
263
|
var readStorageSync = (storage, key) => {
|
|
248
264
|
if (!storage) {
|
|
@@ -1603,75 +1619,78 @@ var AnalyticsClient = class {
|
|
|
1603
1619
|
}
|
|
1604
1620
|
};
|
|
1605
1621
|
|
|
1606
|
-
// src/
|
|
1607
|
-
var
|
|
1608
|
-
"
|
|
1609
|
-
|
|
1610
|
-
"EXPO_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1611
|
-
"VITE_ANALYTICSCLI_PUBLISHABLE_API_KEY"
|
|
1612
|
-
];
|
|
1613
|
-
var readTrimmedString2 = (value) => {
|
|
1614
|
-
if (typeof value === "string") {
|
|
1615
|
-
return value.trim();
|
|
1616
|
-
}
|
|
1617
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
1618
|
-
return String(value).trim();
|
|
1619
|
-
}
|
|
1620
|
-
return "";
|
|
1621
|
-
};
|
|
1622
|
-
var resolveDefaultEnv = () => {
|
|
1623
|
-
const withProcess = globalThis;
|
|
1624
|
-
if (typeof withProcess.process?.env === "object" && withProcess.process.env !== null) {
|
|
1625
|
-
return withProcess.process.env;
|
|
1622
|
+
// src/context.ts
|
|
1623
|
+
var normalizeInitInput = (input) => {
|
|
1624
|
+
if (typeof input === "string") {
|
|
1625
|
+
return { apiKey: input };
|
|
1626
1626
|
}
|
|
1627
|
-
|
|
1628
|
-
};
|
|
1629
|
-
var resolveValueFromEnv = (env, keys) => {
|
|
1630
|
-
for (const key of keys) {
|
|
1631
|
-
const value = readTrimmedString2(env[key]);
|
|
1632
|
-
if (value.length > 0) {
|
|
1633
|
-
return value;
|
|
1634
|
-
}
|
|
1627
|
+
if (input === null || input === void 0) {
|
|
1628
|
+
return {};
|
|
1635
1629
|
}
|
|
1636
|
-
return
|
|
1630
|
+
return input;
|
|
1637
1631
|
};
|
|
1638
|
-
var
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
parts.push(`apiKey (searched: ${details.searchedApiKeyEnvKeys.join(", ") || "none"})`);
|
|
1632
|
+
var resolveClient = (input) => {
|
|
1633
|
+
if (input instanceof AnalyticsClient) {
|
|
1634
|
+
return input;
|
|
1642
1635
|
}
|
|
1643
|
-
return
|
|
1636
|
+
return new AnalyticsClient(normalizeInitInput(input ?? {}));
|
|
1644
1637
|
};
|
|
1645
|
-
var
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1638
|
+
var createAnalyticsContext = (options = {}) => {
|
|
1639
|
+
const client = resolveClient(options.client);
|
|
1640
|
+
let onboardingTracker = client.createOnboardingTracker(options.onboarding ?? {});
|
|
1641
|
+
let paywallTracker = options.paywall ? client.createPaywallTracker(options.paywall) : null;
|
|
1642
|
+
const consent = {
|
|
1643
|
+
get: () => client.getConsent(),
|
|
1644
|
+
getState: () => client.getConsentState(),
|
|
1645
|
+
set: (granted, setOptions) => client.setConsent(granted, setOptions),
|
|
1646
|
+
optIn: (setOptions) => client.optIn(setOptions),
|
|
1647
|
+
optOut: (setOptions) => client.optOut(setOptions),
|
|
1648
|
+
setFullTracking: (granted, setOptions) => client.setFullTrackingConsent(granted, setOptions),
|
|
1649
|
+
optInFullTracking: (setOptions) => client.optInFullTracking(setOptions),
|
|
1650
|
+
optOutFullTracking: (setOptions) => client.optOutFullTracking(setOptions),
|
|
1651
|
+
isFullTrackingEnabled: () => client.isFullTrackingEnabled()
|
|
1652
|
+
};
|
|
1653
|
+
const user = {
|
|
1654
|
+
identify: (userId, traits) => client.identify(userId, traits),
|
|
1655
|
+
set: (userId, traits) => client.setUser(userId, traits),
|
|
1656
|
+
clear: () => client.clearUser()
|
|
1657
|
+
};
|
|
1658
|
+
return {
|
|
1659
|
+
client,
|
|
1660
|
+
get onboarding() {
|
|
1661
|
+
return onboardingTracker;
|
|
1662
|
+
},
|
|
1663
|
+
get paywall() {
|
|
1664
|
+
return paywallTracker;
|
|
1665
|
+
},
|
|
1666
|
+
consent,
|
|
1667
|
+
user,
|
|
1668
|
+
track: (eventName, properties) => client.track(eventName, properties),
|
|
1669
|
+
trackOnboardingEvent: (eventName, properties) => client.trackOnboardingEvent(eventName, properties),
|
|
1670
|
+
trackOnboardingSurveyResponse: (input, eventName) => client.trackOnboardingSurveyResponse(input, eventName),
|
|
1671
|
+
trackPaywallEvent: (eventName, properties) => client.trackPaywallEvent(eventName, properties),
|
|
1672
|
+
screen: (name, properties) => client.screen(name, properties),
|
|
1673
|
+
page: (name, properties) => client.page(name, properties),
|
|
1674
|
+
feedback: (message, rating, properties) => client.feedback(message, rating, properties),
|
|
1675
|
+
setContext: (context) => client.setContext(context),
|
|
1676
|
+
createOnboarding: (defaults) => client.createOnboardingTracker(defaults),
|
|
1677
|
+
createPaywall: (defaults) => client.createPaywallTracker(defaults),
|
|
1678
|
+
configureOnboarding: (defaults) => {
|
|
1679
|
+
onboardingTracker = client.createOnboardingTracker(defaults);
|
|
1680
|
+
return onboardingTracker;
|
|
1681
|
+
},
|
|
1682
|
+
configurePaywall: (defaults) => {
|
|
1683
|
+
paywallTracker = client.createPaywallTracker(defaults);
|
|
1684
|
+
return paywallTracker;
|
|
1685
|
+
},
|
|
1686
|
+
ready: () => client.ready(),
|
|
1687
|
+
flush: () => client.flush(),
|
|
1688
|
+
shutdown: () => client.shutdown()
|
|
1660
1689
|
};
|
|
1661
|
-
if (missingConfig.missingApiKey) {
|
|
1662
|
-
onMissingConfig?.(missingConfig);
|
|
1663
|
-
if (missingConfigMode === "throw") {
|
|
1664
|
-
throw new Error(toMissingMessage(missingConfig));
|
|
1665
|
-
}
|
|
1666
|
-
}
|
|
1667
|
-
return new AnalyticsClient({
|
|
1668
|
-
...clientOptions,
|
|
1669
|
-
apiKey: resolvedApiKey
|
|
1670
|
-
});
|
|
1671
1690
|
};
|
|
1672
1691
|
|
|
1673
1692
|
// src/index.ts
|
|
1674
|
-
var
|
|
1693
|
+
var normalizeInitInput2 = (input) => {
|
|
1675
1694
|
if (typeof input === "string") {
|
|
1676
1695
|
return { apiKey: input };
|
|
1677
1696
|
}
|
|
@@ -1681,17 +1700,17 @@ var normalizeInitInput = (input) => {
|
|
|
1681
1700
|
return input;
|
|
1682
1701
|
};
|
|
1683
1702
|
var init = (input = {}) => {
|
|
1684
|
-
return new AnalyticsClient(
|
|
1703
|
+
return new AnalyticsClient(normalizeInitInput2(input));
|
|
1685
1704
|
};
|
|
1686
1705
|
var initConsentFirst = (input = {}) => {
|
|
1687
|
-
const normalized =
|
|
1706
|
+
const normalized = normalizeInitInput2(input);
|
|
1688
1707
|
return new AnalyticsClient({
|
|
1689
1708
|
...normalized,
|
|
1690
1709
|
initialConsentGranted: false
|
|
1691
1710
|
});
|
|
1692
1711
|
};
|
|
1693
1712
|
var initAsync = async (input = {}) => {
|
|
1694
|
-
const client = new AnalyticsClient(
|
|
1713
|
+
const client = new AnalyticsClient(normalizeInitInput2(input));
|
|
1695
1714
|
await client.ready();
|
|
1696
1715
|
return client;
|
|
1697
1716
|
};
|
|
@@ -1700,36 +1719,9 @@ var initConsentFirstAsync = async (input = {}) => {
|
|
|
1700
1719
|
await client.ready();
|
|
1701
1720
|
return client;
|
|
1702
1721
|
};
|
|
1703
|
-
var BROWSER_API_KEY_ENV_KEYS = [
|
|
1704
|
-
"ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1705
|
-
"NEXT_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1706
|
-
"PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1707
|
-
"VITE_ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1708
|
-
"EXPO_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY"
|
|
1709
|
-
];
|
|
1710
|
-
var REACT_NATIVE_API_KEY_ENV_KEYS = [
|
|
1711
|
-
"ANALYTICSCLI_PUBLISHABLE_API_KEY",
|
|
1712
|
-
"EXPO_PUBLIC_ANALYTICSCLI_PUBLISHABLE_API_KEY"
|
|
1713
|
-
];
|
|
1714
|
-
var initBrowserFromEnv = (options = {}) => {
|
|
1715
|
-
const { apiKeyEnvKeys, ...rest } = options;
|
|
1716
|
-
return initFromEnv({
|
|
1717
|
-
...rest,
|
|
1718
|
-
apiKeyEnvKeys: [...apiKeyEnvKeys ?? BROWSER_API_KEY_ENV_KEYS]
|
|
1719
|
-
});
|
|
1720
|
-
};
|
|
1721
|
-
var initReactNativeFromEnv = (options = {}) => {
|
|
1722
|
-
const { apiKeyEnvKeys, ...rest } = options;
|
|
1723
|
-
return initFromEnv({
|
|
1724
|
-
...rest,
|
|
1725
|
-
apiKeyEnvKeys: [...apiKeyEnvKeys ?? REACT_NATIVE_API_KEY_ENV_KEYS]
|
|
1726
|
-
});
|
|
1727
|
-
};
|
|
1728
1722
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1729
1723
|
0 && (module.exports = {
|
|
1730
1724
|
AnalyticsClient,
|
|
1731
|
-
BROWSER_API_KEY_ENV_KEYS,
|
|
1732
|
-
DEFAULT_API_KEY_ENV_KEYS,
|
|
1733
1725
|
ONBOARDING_EVENTS,
|
|
1734
1726
|
ONBOARDING_PROGRESS_EVENT_ORDER,
|
|
1735
1727
|
ONBOARDING_SCREEN_EVENT_PREFIXES,
|
|
@@ -1740,12 +1732,9 @@ var initReactNativeFromEnv = (options = {}) => {
|
|
|
1740
1732
|
PAYWALL_SKIP_EVENT_CANDIDATES,
|
|
1741
1733
|
PURCHASE_EVENTS,
|
|
1742
1734
|
PURCHASE_SUCCESS_EVENT_CANDIDATES,
|
|
1743
|
-
|
|
1735
|
+
createAnalyticsContext,
|
|
1744
1736
|
init,
|
|
1745
1737
|
initAsync,
|
|
1746
|
-
initBrowserFromEnv,
|
|
1747
1738
|
initConsentFirst,
|
|
1748
|
-
initConsentFirstAsync
|
|
1749
|
-
initFromEnv,
|
|
1750
|
-
initReactNativeFromEnv
|
|
1739
|
+
initConsentFirstAsync
|
|
1751
1740
|
});
|
package/dist/browser.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AnalyticsClient, AnalyticsClientOptions, AnalyticsConsentState,
|
|
1
|
+
export { AnalyticsClient, AnalyticsClientOptions, AnalyticsConsentState, AnalyticsContext, AnalyticsContextConsentControls, AnalyticsContextUserControls, AnalyticsStorageAdapter, CreateAnalyticsContextOptions, EventContext, EventProperties, IdentityTrackingMode, InitInput, InitOptions, ONBOARDING_EVENTS, ONBOARDING_PROGRESS_EVENT_ORDER, ONBOARDING_SCREEN_EVENT_PREFIXES, ONBOARDING_SURVEY_EVENTS, OnboardingEventName, OnboardingEventProperties, OnboardingStepTracker, OnboardingSurveyAnswerType, OnboardingSurveyEventName, OnboardingSurveyResponseInput, OnboardingTracker, OnboardingTrackerDefaults, OnboardingTrackerSurveyInput, PAYWALL_ANCHOR_EVENT_CANDIDATES, PAYWALL_EVENTS, PAYWALL_JOURNEY_EVENT_ORDER, PAYWALL_SKIP_EVENT_CANDIDATES, PURCHASE_EVENTS, PURCHASE_SUCCESS_EVENT_CANDIDATES, PaywallEventName, PaywallEventProperties, PaywallJourneyEventName, PaywallTracker, PaywallTrackerDefaults, PaywallTrackerProperties, PurchaseEventName, SetConsentOptions, createAnalyticsContext, init, initAsync, initConsentFirst, initConsentFirstAsync } from './index.cjs';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { AnalyticsClient, AnalyticsClientOptions, AnalyticsConsentState,
|
|
1
|
+
export { AnalyticsClient, AnalyticsClientOptions, AnalyticsConsentState, AnalyticsContext, AnalyticsContextConsentControls, AnalyticsContextUserControls, AnalyticsStorageAdapter, CreateAnalyticsContextOptions, EventContext, EventProperties, IdentityTrackingMode, InitInput, InitOptions, ONBOARDING_EVENTS, ONBOARDING_PROGRESS_EVENT_ORDER, ONBOARDING_SCREEN_EVENT_PREFIXES, ONBOARDING_SURVEY_EVENTS, OnboardingEventName, OnboardingEventProperties, OnboardingStepTracker, OnboardingSurveyAnswerType, OnboardingSurveyEventName, OnboardingSurveyResponseInput, OnboardingTracker, OnboardingTrackerDefaults, OnboardingTrackerSurveyInput, PAYWALL_ANCHOR_EVENT_CANDIDATES, PAYWALL_EVENTS, PAYWALL_JOURNEY_EVENT_ORDER, PAYWALL_SKIP_EVENT_CANDIDATES, PURCHASE_EVENTS, PURCHASE_SUCCESS_EVENT_CANDIDATES, PaywallEventName, PaywallEventProperties, PaywallJourneyEventName, PaywallTracker, PaywallTrackerDefaults, PaywallTrackerProperties, PurchaseEventName, SetConsentOptions, createAnalyticsContext, init, initAsync, initConsentFirst, initConsentFirstAsync } from './index.js';
|
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AnalyticsClient,
|
|
3
|
-
BROWSER_API_KEY_ENV_KEYS,
|
|
4
|
-
DEFAULT_API_KEY_ENV_KEYS,
|
|
5
3
|
ONBOARDING_EVENTS,
|
|
6
4
|
ONBOARDING_PROGRESS_EVENT_ORDER,
|
|
7
5
|
ONBOARDING_SCREEN_EVENT_PREFIXES,
|
|
@@ -12,19 +10,14 @@ import {
|
|
|
12
10
|
PAYWALL_SKIP_EVENT_CANDIDATES,
|
|
13
11
|
PURCHASE_EVENTS,
|
|
14
12
|
PURCHASE_SUCCESS_EVENT_CANDIDATES,
|
|
15
|
-
|
|
13
|
+
createAnalyticsContext,
|
|
16
14
|
init,
|
|
17
15
|
initAsync,
|
|
18
|
-
initBrowserFromEnv,
|
|
19
16
|
initConsentFirst,
|
|
20
|
-
initConsentFirstAsync
|
|
21
|
-
|
|
22
|
-
initReactNativeFromEnv
|
|
23
|
-
} from "./chunk-HL2VOD3Z.js";
|
|
17
|
+
initConsentFirstAsync
|
|
18
|
+
} from "./chunk-O4FIH647.js";
|
|
24
19
|
export {
|
|
25
20
|
AnalyticsClient,
|
|
26
|
-
BROWSER_API_KEY_ENV_KEYS,
|
|
27
|
-
DEFAULT_API_KEY_ENV_KEYS,
|
|
28
21
|
ONBOARDING_EVENTS,
|
|
29
22
|
ONBOARDING_PROGRESS_EVENT_ORDER,
|
|
30
23
|
ONBOARDING_SCREEN_EVENT_PREFIXES,
|
|
@@ -35,12 +28,9 @@ export {
|
|
|
35
28
|
PAYWALL_SKIP_EVENT_CANDIDATES,
|
|
36
29
|
PURCHASE_EVENTS,
|
|
37
30
|
PURCHASE_SUCCESS_EVENT_CANDIDATES,
|
|
38
|
-
|
|
31
|
+
createAnalyticsContext,
|
|
39
32
|
init,
|
|
40
33
|
initAsync,
|
|
41
|
-
initBrowserFromEnv,
|
|
42
34
|
initConsentFirst,
|
|
43
|
-
initConsentFirstAsync
|
|
44
|
-
initFromEnv,
|
|
45
|
-
initReactNativeFromEnv
|
|
35
|
+
initConsentFirstAsync
|
|
46
36
|
};
|