@leapio/web 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +305 -2
- package/dist/index.d.mts +267 -0
- package/dist/index.d.ts +267 -0
- package/dist/index.js +3628 -0
- package/dist/index.mjs +3622 -0
- package/package.json +46 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
//#region src/sdk-config.d.ts
|
|
2
|
+
type EventPayload = {
|
|
3
|
+
name: string;
|
|
4
|
+
channel?: string | null;
|
|
5
|
+
message?: string | null;
|
|
6
|
+
notify?: boolean | null;
|
|
7
|
+
user_id?: string | null;
|
|
8
|
+
anonymous_id?: string | null;
|
|
9
|
+
metadata?: any | null;
|
|
10
|
+
hostname?: string | null;
|
|
11
|
+
url?: string | null;
|
|
12
|
+
referrer?: string | null;
|
|
13
|
+
language?: string | null;
|
|
14
|
+
screen?: string | null;
|
|
15
|
+
value?: number | null;
|
|
16
|
+
currency?: string | null;
|
|
17
|
+
privacy_categories?: string;
|
|
18
|
+
privacy_signals?: string;
|
|
19
|
+
consent_source?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Mirrors the org-level `consentBehavior` setting. `notRequired` (default)
|
|
23
|
+
* preserves the SDK's existing send-immediately behavior byte-for-byte.
|
|
24
|
+
* `implied` sends until analytics is explicitly denied. `express` queues
|
|
25
|
+
* events until analytics is explicitly granted (denial drops the queue).
|
|
26
|
+
*/
|
|
27
|
+
type ConsentBehavior = "notRequired" | "implied" | "express";
|
|
28
|
+
/**
|
|
29
|
+
* Per-type autocapture toggles. Each capture type can be enabled/disabled
|
|
30
|
+
* independently. Unset keys fall back to {@link AUTOCAPTURE_DEFAULTS}.
|
|
31
|
+
*
|
|
32
|
+
* - `outboundLinks` — clicks on `<a>` whose host differs from `location.host`
|
|
33
|
+
* - `fileDownloads` — clicks on `<a>` whose href ends in a download extension
|
|
34
|
+
* (or that carry a `download` attribute); metadata only, no PII
|
|
35
|
+
* - `formSubmissions` — `submit` events (metadata only, never field values)
|
|
36
|
+
* - `clicks` — clicks on interactive elements (noisy; off by default)
|
|
37
|
+
* - `inputChanges` — `change` events on inputs (metadata only; off by default)
|
|
38
|
+
* - `mediaPlayback` — native `<video>`/`<audio>` engagement (play/pause/progress/
|
|
39
|
+
* complete); metadata only, never a recording. Audience-dependent; off by
|
|
40
|
+
* default.
|
|
41
|
+
*/
|
|
42
|
+
type AutocaptureConfig = {
|
|
43
|
+
outboundLinks?: boolean;
|
|
44
|
+
fileDownloads?: boolean;
|
|
45
|
+
formSubmissions?: boolean;
|
|
46
|
+
clicks?: boolean;
|
|
47
|
+
inputChanges?: boolean;
|
|
48
|
+
mediaPlayback?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Snippet-shaped autocapture config used by the CDN wrapper (`leapio-js`). It
|
|
52
|
+
* separates the **master** enablement (the `data-autocapture` attribute) from
|
|
53
|
+
* per-**type** overrides (`data-autocapture-<type>`), so a bare per-type
|
|
54
|
+
* attribute can override that type *without* force-enabling autocapture.
|
|
55
|
+
*
|
|
56
|
+
* - `master` — `true`/`false` when `data-autocapture` is explicitly set;
|
|
57
|
+
* `undefined` when only per-type attributes are present (enablement then
|
|
58
|
+
* defers to the server / dashboard).
|
|
59
|
+
* - `types` — the per-type overrides parsed from `data-autocapture-<type>`.
|
|
60
|
+
*
|
|
61
|
+
* The plain {@link AutocaptureConfig} object form (used by direct `init()`
|
|
62
|
+
* callers) keeps its historical meaning: passing an object enables autocapture.
|
|
63
|
+
* Only this `{ master, types }` shape decouples the two.
|
|
64
|
+
*/
|
|
65
|
+
type AutocaptureSnippetConfig = {
|
|
66
|
+
master?: boolean;
|
|
67
|
+
types?: AutocaptureConfig;
|
|
68
|
+
};
|
|
69
|
+
interface SdkConfig {
|
|
70
|
+
publicKey: string;
|
|
71
|
+
pageviewsChannel?: string;
|
|
72
|
+
cookiesDisabled?: boolean;
|
|
73
|
+
enableAutoPageviews?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Escape hatch: fall back to the legacy MutationObserver-based SPA route
|
|
76
|
+
* detection instead of the default History-API method (patching
|
|
77
|
+
* `pushState`/`replaceState` + `popstate`/`hashchange`). Default `false`.
|
|
78
|
+
* Only relevant when `enableAutoPageviews` is true. The History-API method is
|
|
79
|
+
* more accurate (it does not fire spurious pageviews on unrelated DOM churn
|
|
80
|
+
* and dedupes URL-normalizing `replaceState` calls), so this exists purely as
|
|
81
|
+
* a safety valve for sites that depend on the old heuristic.
|
|
82
|
+
*/
|
|
83
|
+
legacySpaDetection?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Legacy single-toggle "capture every click" flag. Retained for back-compat:
|
|
86
|
+
* it maps to `autocapture: { clicks: true }`. Prefer `autocapture`.
|
|
87
|
+
*/
|
|
88
|
+
enableAutoClicks?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Delegated autocapture.
|
|
91
|
+
*
|
|
92
|
+
* - `true` / `false` — master toggle.
|
|
93
|
+
* - {@link AutocaptureConfig} object — enables autocapture and applies the
|
|
94
|
+
* per-type overrides (direct-`init()` convenience; an object means enable).
|
|
95
|
+
* - {@link AutocaptureSnippetConfig} `{ master, types }` — the snippet form,
|
|
96
|
+
* which separates master enablement from per-type overrides so a bare
|
|
97
|
+
* per-type attribute does NOT by itself enable autocapture.
|
|
98
|
+
*
|
|
99
|
+
* Per-type resolution uses {@link AUTOCAPTURE_DEFAULTS}. When unset (and
|
|
100
|
+
* `enableAutoClicks` is false), no autocapture listeners are attached and
|
|
101
|
+
* default behavior is byte-identical.
|
|
102
|
+
*/
|
|
103
|
+
autocapture?: boolean | AutocaptureConfig | AutocaptureSnippetConfig;
|
|
104
|
+
externalApiUrl?: string;
|
|
105
|
+
identifyApiUrl?: string;
|
|
106
|
+
/** Override for the `POST /consent` endpoint (pattern of `identifyApiUrl`). */
|
|
107
|
+
consentApiUrl?: string;
|
|
108
|
+
/** Override for the `POST /group` endpoint (pattern of `identifyApiUrl`). */
|
|
109
|
+
groupApiUrl?: string;
|
|
110
|
+
/** Gating behavior for consent. Default `notRequired` (no behavior change). */
|
|
111
|
+
consentBehavior?: ConsentBehavior;
|
|
112
|
+
/**
|
|
113
|
+
* Names of consent sources to register (e.g. `['onetrust', 'gcm']`).
|
|
114
|
+
* Plumbed through from the CDN wrapper's `data-consent-source` attribute; the
|
|
115
|
+
* plugin registry (consent-sources/) consumes these ids.
|
|
116
|
+
*/
|
|
117
|
+
consentSources?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Defense-in-depth URL privacy. When `true`, the SDK removes query params not
|
|
120
|
+
* in {@link queryParamAllowlist} (and always the hash) from BOTH the event url
|
|
121
|
+
* and the referrer before sending, so PII/secrets in the query string never
|
|
122
|
+
* leave the browser. The referrer matters most for SPAs, where it becomes the
|
|
123
|
+
* previous in-app URL on each route change. The server applies the
|
|
124
|
+
* authoritative per-project rule regardless; this only keeps the wire clean.
|
|
125
|
+
* Default `false` (url + referrer sent unchanged). UTM attribution is
|
|
126
|
+
* unaffected (captured from `window.location`, not the payload url).
|
|
127
|
+
*/
|
|
128
|
+
stripQueryParams?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Query-param names kept on the url when {@link stripQueryParams} is on
|
|
131
|
+
* (case-insensitive). Defaults to UTM params + common ad click-ids + `ref`.
|
|
132
|
+
*/
|
|
133
|
+
queryParamAllowlist?: string[];
|
|
134
|
+
stickyCampaigns?: boolean;
|
|
135
|
+
stickyCampaignsExpirationInSeconds?: number;
|
|
136
|
+
cookieDomain?: string;
|
|
137
|
+
cookieExpirationInSeconds?: number;
|
|
138
|
+
enableBrowserDNT?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Add the anonymous id as `client_reference_id` to Stripe Payment Link
|
|
141
|
+
* (`buy.stripe.com`) hrefs when they are pressed, so the payment is
|
|
142
|
+
* attributed without hand-built URLs. An existing `client_reference_id` is
|
|
143
|
+
* never overwritten, and nothing is tagged while consent withholds sending.
|
|
144
|
+
* Default `true`.
|
|
145
|
+
*/
|
|
146
|
+
tagPaymentLinks?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Engaged-time tracking: `"leave"` sends a "Page Leave" event when a page is
|
|
149
|
+
* hidden or left; `"heartbeat"` also sends a "Page Heartbeat" each visible
|
|
150
|
+
* minute. Both carry `engaged_seconds` and count as events. Overrides the
|
|
151
|
+
* dashboard setting; default is the dashboard's, which defaults to `"off"`.
|
|
152
|
+
*/
|
|
153
|
+
engagement?: "off" | "leave" | "heartbeat";
|
|
154
|
+
/**
|
|
155
|
+
* Track browsers driven by WebDriver (`navigator.webdriver`), e.g. to test
|
|
156
|
+
* the integration end to end with Playwright or Selenium. Default `false`.
|
|
157
|
+
*/
|
|
158
|
+
trackAutomatedBrowsers?: boolean;
|
|
159
|
+
onLoad?: () => void | Promise<void>;
|
|
160
|
+
eventMapper?: (payload: EventPayload) => EventPayload | Promise<EventPayload>;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/super-properties.d.ts
|
|
164
|
+
type Property = string | number | boolean;
|
|
165
|
+
type Properties = Record<string, Property>;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/consent.d.ts
|
|
168
|
+
type ConsentCategory = "analytics" | "functional" | "marketing";
|
|
169
|
+
type PrivacySignals = {
|
|
170
|
+
doNotSellShare?: boolean;
|
|
171
|
+
gpc?: boolean;
|
|
172
|
+
gppDetected?: boolean;
|
|
173
|
+
/** Raw GPP string when present; detection + raw value only in V1. */
|
|
174
|
+
gppString?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* A persisted consent snapshot. `categories` is a partial map: an absent key
|
|
178
|
+
* means "this source never spoke about that category" (falls through to the
|
|
179
|
+
* org's consentBehavior server-side), distinct from an explicit `false` (denied).
|
|
180
|
+
*/
|
|
181
|
+
type ConsentSnapshot = {
|
|
182
|
+
categories: Partial<Record<ConsentCategory, boolean>>;
|
|
183
|
+
signals: PrivacySignals;
|
|
184
|
+
source: string;
|
|
185
|
+
updatedAt: string;
|
|
186
|
+
/** Optional vendor payload / consent version / region for `/consent`. */
|
|
187
|
+
sourceMetadata?: Record<string, unknown>;
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/api.d.ts
|
|
191
|
+
type IdentifyOptions = {
|
|
192
|
+
identityVerification?: {
|
|
193
|
+
token: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
type IdentifyResult = {
|
|
197
|
+
ok: boolean;
|
|
198
|
+
status?: number;
|
|
199
|
+
reason?: string;
|
|
200
|
+
};
|
|
201
|
+
type ConsentResult = {
|
|
202
|
+
ok: boolean;
|
|
203
|
+
status?: number;
|
|
204
|
+
reason?: string;
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/url-privacy.d.ts
|
|
208
|
+
export declare const DEFAULT_QUERY_PARAM_ALLOWLIST: string[];
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/index.d.ts
|
|
211
|
+
/** Public argument shape for `setConsent()` — all fields optional (partial). */
|
|
212
|
+
export type SetConsentInput = {
|
|
213
|
+
analytics?: boolean;
|
|
214
|
+
functional?: boolean;
|
|
215
|
+
marketing?: boolean;
|
|
216
|
+
doNotSellShare?: boolean;
|
|
217
|
+
};
|
|
218
|
+
/** Options for `revenue()`. `currency` is ISO-4217; the rest become metadata. */
|
|
219
|
+
export type RevenueOptions = {
|
|
220
|
+
currency?: string;
|
|
221
|
+
/** Override the reserved revenue event name (defaults to "Payment"). */
|
|
222
|
+
event?: string;
|
|
223
|
+
channel?: string | null;
|
|
224
|
+
userId?: string;
|
|
225
|
+
[key: string]: any;
|
|
226
|
+
};
|
|
227
|
+
export declare const leapio: {
|
|
228
|
+
init: (config: SdkConfig) => Promise<void>;
|
|
229
|
+
track: (data: {
|
|
230
|
+
event: string;
|
|
231
|
+
channel?: string | null;
|
|
232
|
+
userId?: string;
|
|
233
|
+
message?: string;
|
|
234
|
+
notify?: boolean;
|
|
235
|
+
metadata?: Record<string, any>;
|
|
236
|
+
value?: number;
|
|
237
|
+
currency?: string;
|
|
238
|
+
/** Associate this event with a group/account (Segment `$groups` style).
|
|
239
|
+
* With groupType "company" (the default when groupId is set) the platform
|
|
240
|
+
* resolves and stamps the company on the event. */
|
|
241
|
+
groupId?: string;
|
|
242
|
+
groupType?: string;
|
|
243
|
+
}) => Promise<void>;
|
|
244
|
+
revenue: (amount: number, options?: RevenueOptions) => Promise<void>;
|
|
245
|
+
pageview: (data?: {
|
|
246
|
+
userId?: string;
|
|
247
|
+
metadata?: Record<string, any>;
|
|
248
|
+
}) => Promise<void>;
|
|
249
|
+
register: (properties: Properties) => void | true;
|
|
250
|
+
unregister: (property: string) => void;
|
|
251
|
+
reset: () => void;
|
|
252
|
+
identify: (newUserId: string, traits?: Record<string, any>, opts?: IdentifyOptions) => Promise<IdentifyResult>;
|
|
253
|
+
group: (groupId: string, traits?: Record<string, any>, opts?: IdentifyOptions & {
|
|
254
|
+
type?: string;
|
|
255
|
+
}) => Promise<IdentifyResult>;
|
|
256
|
+
setConsent: (input: SetConsentInput, opts?: {
|
|
257
|
+
identityVerification?: {
|
|
258
|
+
token: string;
|
|
259
|
+
};
|
|
260
|
+
}) => Promise<ConsentResult>;
|
|
261
|
+
getConsent: () => ConsentSnapshot | null;
|
|
262
|
+
applyConsentSnapshot: (snapshot: ConsentSnapshot) => Promise<boolean>;
|
|
263
|
+
getProperties: () => Record<string, Property>;
|
|
264
|
+
getAnonymousId: () => string | null;
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
export { type AutocaptureConfig, type AutocaptureSnippetConfig, type ConsentBehavior, type EventPayload, type SdkConfig, leapio as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
//#region src/sdk-config.d.ts
|
|
2
|
+
type EventPayload = {
|
|
3
|
+
name: string;
|
|
4
|
+
channel?: string | null;
|
|
5
|
+
message?: string | null;
|
|
6
|
+
notify?: boolean | null;
|
|
7
|
+
user_id?: string | null;
|
|
8
|
+
anonymous_id?: string | null;
|
|
9
|
+
metadata?: any | null;
|
|
10
|
+
hostname?: string | null;
|
|
11
|
+
url?: string | null;
|
|
12
|
+
referrer?: string | null;
|
|
13
|
+
language?: string | null;
|
|
14
|
+
screen?: string | null;
|
|
15
|
+
value?: number | null;
|
|
16
|
+
currency?: string | null;
|
|
17
|
+
privacy_categories?: string;
|
|
18
|
+
privacy_signals?: string;
|
|
19
|
+
consent_source?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Mirrors the org-level `consentBehavior` setting. `notRequired` (default)
|
|
23
|
+
* preserves the SDK's existing send-immediately behavior byte-for-byte.
|
|
24
|
+
* `implied` sends until analytics is explicitly denied. `express` queues
|
|
25
|
+
* events until analytics is explicitly granted (denial drops the queue).
|
|
26
|
+
*/
|
|
27
|
+
type ConsentBehavior = "notRequired" | "implied" | "express";
|
|
28
|
+
/**
|
|
29
|
+
* Per-type autocapture toggles. Each capture type can be enabled/disabled
|
|
30
|
+
* independently. Unset keys fall back to {@link AUTOCAPTURE_DEFAULTS}.
|
|
31
|
+
*
|
|
32
|
+
* - `outboundLinks` — clicks on `<a>` whose host differs from `location.host`
|
|
33
|
+
* - `fileDownloads` — clicks on `<a>` whose href ends in a download extension
|
|
34
|
+
* (or that carry a `download` attribute); metadata only, no PII
|
|
35
|
+
* - `formSubmissions` — `submit` events (metadata only, never field values)
|
|
36
|
+
* - `clicks` — clicks on interactive elements (noisy; off by default)
|
|
37
|
+
* - `inputChanges` — `change` events on inputs (metadata only; off by default)
|
|
38
|
+
* - `mediaPlayback` — native `<video>`/`<audio>` engagement (play/pause/progress/
|
|
39
|
+
* complete); metadata only, never a recording. Audience-dependent; off by
|
|
40
|
+
* default.
|
|
41
|
+
*/
|
|
42
|
+
type AutocaptureConfig = {
|
|
43
|
+
outboundLinks?: boolean;
|
|
44
|
+
fileDownloads?: boolean;
|
|
45
|
+
formSubmissions?: boolean;
|
|
46
|
+
clicks?: boolean;
|
|
47
|
+
inputChanges?: boolean;
|
|
48
|
+
mediaPlayback?: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Snippet-shaped autocapture config used by the CDN wrapper (`leapio-js`). It
|
|
52
|
+
* separates the **master** enablement (the `data-autocapture` attribute) from
|
|
53
|
+
* per-**type** overrides (`data-autocapture-<type>`), so a bare per-type
|
|
54
|
+
* attribute can override that type *without* force-enabling autocapture.
|
|
55
|
+
*
|
|
56
|
+
* - `master` — `true`/`false` when `data-autocapture` is explicitly set;
|
|
57
|
+
* `undefined` when only per-type attributes are present (enablement then
|
|
58
|
+
* defers to the server / dashboard).
|
|
59
|
+
* - `types` — the per-type overrides parsed from `data-autocapture-<type>`.
|
|
60
|
+
*
|
|
61
|
+
* The plain {@link AutocaptureConfig} object form (used by direct `init()`
|
|
62
|
+
* callers) keeps its historical meaning: passing an object enables autocapture.
|
|
63
|
+
* Only this `{ master, types }` shape decouples the two.
|
|
64
|
+
*/
|
|
65
|
+
type AutocaptureSnippetConfig = {
|
|
66
|
+
master?: boolean;
|
|
67
|
+
types?: AutocaptureConfig;
|
|
68
|
+
};
|
|
69
|
+
interface SdkConfig {
|
|
70
|
+
publicKey: string;
|
|
71
|
+
pageviewsChannel?: string;
|
|
72
|
+
cookiesDisabled?: boolean;
|
|
73
|
+
enableAutoPageviews?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Escape hatch: fall back to the legacy MutationObserver-based SPA route
|
|
76
|
+
* detection instead of the default History-API method (patching
|
|
77
|
+
* `pushState`/`replaceState` + `popstate`/`hashchange`). Default `false`.
|
|
78
|
+
* Only relevant when `enableAutoPageviews` is true. The History-API method is
|
|
79
|
+
* more accurate (it does not fire spurious pageviews on unrelated DOM churn
|
|
80
|
+
* and dedupes URL-normalizing `replaceState` calls), so this exists purely as
|
|
81
|
+
* a safety valve for sites that depend on the old heuristic.
|
|
82
|
+
*/
|
|
83
|
+
legacySpaDetection?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Legacy single-toggle "capture every click" flag. Retained for back-compat:
|
|
86
|
+
* it maps to `autocapture: { clicks: true }`. Prefer `autocapture`.
|
|
87
|
+
*/
|
|
88
|
+
enableAutoClicks?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Delegated autocapture.
|
|
91
|
+
*
|
|
92
|
+
* - `true` / `false` — master toggle.
|
|
93
|
+
* - {@link AutocaptureConfig} object — enables autocapture and applies the
|
|
94
|
+
* per-type overrides (direct-`init()` convenience; an object means enable).
|
|
95
|
+
* - {@link AutocaptureSnippetConfig} `{ master, types }` — the snippet form,
|
|
96
|
+
* which separates master enablement from per-type overrides so a bare
|
|
97
|
+
* per-type attribute does NOT by itself enable autocapture.
|
|
98
|
+
*
|
|
99
|
+
* Per-type resolution uses {@link AUTOCAPTURE_DEFAULTS}. When unset (and
|
|
100
|
+
* `enableAutoClicks` is false), no autocapture listeners are attached and
|
|
101
|
+
* default behavior is byte-identical.
|
|
102
|
+
*/
|
|
103
|
+
autocapture?: boolean | AutocaptureConfig | AutocaptureSnippetConfig;
|
|
104
|
+
externalApiUrl?: string;
|
|
105
|
+
identifyApiUrl?: string;
|
|
106
|
+
/** Override for the `POST /consent` endpoint (pattern of `identifyApiUrl`). */
|
|
107
|
+
consentApiUrl?: string;
|
|
108
|
+
/** Override for the `POST /group` endpoint (pattern of `identifyApiUrl`). */
|
|
109
|
+
groupApiUrl?: string;
|
|
110
|
+
/** Gating behavior for consent. Default `notRequired` (no behavior change). */
|
|
111
|
+
consentBehavior?: ConsentBehavior;
|
|
112
|
+
/**
|
|
113
|
+
* Names of consent sources to register (e.g. `['onetrust', 'gcm']`).
|
|
114
|
+
* Plumbed through from the CDN wrapper's `data-consent-source` attribute; the
|
|
115
|
+
* plugin registry (consent-sources/) consumes these ids.
|
|
116
|
+
*/
|
|
117
|
+
consentSources?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Defense-in-depth URL privacy. When `true`, the SDK removes query params not
|
|
120
|
+
* in {@link queryParamAllowlist} (and always the hash) from BOTH the event url
|
|
121
|
+
* and the referrer before sending, so PII/secrets in the query string never
|
|
122
|
+
* leave the browser. The referrer matters most for SPAs, where it becomes the
|
|
123
|
+
* previous in-app URL on each route change. The server applies the
|
|
124
|
+
* authoritative per-project rule regardless; this only keeps the wire clean.
|
|
125
|
+
* Default `false` (url + referrer sent unchanged). UTM attribution is
|
|
126
|
+
* unaffected (captured from `window.location`, not the payload url).
|
|
127
|
+
*/
|
|
128
|
+
stripQueryParams?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Query-param names kept on the url when {@link stripQueryParams} is on
|
|
131
|
+
* (case-insensitive). Defaults to UTM params + common ad click-ids + `ref`.
|
|
132
|
+
*/
|
|
133
|
+
queryParamAllowlist?: string[];
|
|
134
|
+
stickyCampaigns?: boolean;
|
|
135
|
+
stickyCampaignsExpirationInSeconds?: number;
|
|
136
|
+
cookieDomain?: string;
|
|
137
|
+
cookieExpirationInSeconds?: number;
|
|
138
|
+
enableBrowserDNT?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Add the anonymous id as `client_reference_id` to Stripe Payment Link
|
|
141
|
+
* (`buy.stripe.com`) hrefs when they are pressed, so the payment is
|
|
142
|
+
* attributed without hand-built URLs. An existing `client_reference_id` is
|
|
143
|
+
* never overwritten, and nothing is tagged while consent withholds sending.
|
|
144
|
+
* Default `true`.
|
|
145
|
+
*/
|
|
146
|
+
tagPaymentLinks?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Engaged-time tracking: `"leave"` sends a "Page Leave" event when a page is
|
|
149
|
+
* hidden or left; `"heartbeat"` also sends a "Page Heartbeat" each visible
|
|
150
|
+
* minute. Both carry `engaged_seconds` and count as events. Overrides the
|
|
151
|
+
* dashboard setting; default is the dashboard's, which defaults to `"off"`.
|
|
152
|
+
*/
|
|
153
|
+
engagement?: "off" | "leave" | "heartbeat";
|
|
154
|
+
/**
|
|
155
|
+
* Track browsers driven by WebDriver (`navigator.webdriver`), e.g. to test
|
|
156
|
+
* the integration end to end with Playwright or Selenium. Default `false`.
|
|
157
|
+
*/
|
|
158
|
+
trackAutomatedBrowsers?: boolean;
|
|
159
|
+
onLoad?: () => void | Promise<void>;
|
|
160
|
+
eventMapper?: (payload: EventPayload) => EventPayload | Promise<EventPayload>;
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/super-properties.d.ts
|
|
164
|
+
type Property = string | number | boolean;
|
|
165
|
+
type Properties = Record<string, Property>;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/consent.d.ts
|
|
168
|
+
type ConsentCategory = "analytics" | "functional" | "marketing";
|
|
169
|
+
type PrivacySignals = {
|
|
170
|
+
doNotSellShare?: boolean;
|
|
171
|
+
gpc?: boolean;
|
|
172
|
+
gppDetected?: boolean;
|
|
173
|
+
/** Raw GPP string when present; detection + raw value only in V1. */
|
|
174
|
+
gppString?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* A persisted consent snapshot. `categories` is a partial map: an absent key
|
|
178
|
+
* means "this source never spoke about that category" (falls through to the
|
|
179
|
+
* org's consentBehavior server-side), distinct from an explicit `false` (denied).
|
|
180
|
+
*/
|
|
181
|
+
type ConsentSnapshot = {
|
|
182
|
+
categories: Partial<Record<ConsentCategory, boolean>>;
|
|
183
|
+
signals: PrivacySignals;
|
|
184
|
+
source: string;
|
|
185
|
+
updatedAt: string;
|
|
186
|
+
/** Optional vendor payload / consent version / region for `/consent`. */
|
|
187
|
+
sourceMetadata?: Record<string, unknown>;
|
|
188
|
+
};
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/api.d.ts
|
|
191
|
+
type IdentifyOptions = {
|
|
192
|
+
identityVerification?: {
|
|
193
|
+
token: string;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
type IdentifyResult = {
|
|
197
|
+
ok: boolean;
|
|
198
|
+
status?: number;
|
|
199
|
+
reason?: string;
|
|
200
|
+
};
|
|
201
|
+
type ConsentResult = {
|
|
202
|
+
ok: boolean;
|
|
203
|
+
status?: number;
|
|
204
|
+
reason?: string;
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/url-privacy.d.ts
|
|
208
|
+
export declare const DEFAULT_QUERY_PARAM_ALLOWLIST: string[];
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/index.d.ts
|
|
211
|
+
/** Public argument shape for `setConsent()` — all fields optional (partial). */
|
|
212
|
+
export type SetConsentInput = {
|
|
213
|
+
analytics?: boolean;
|
|
214
|
+
functional?: boolean;
|
|
215
|
+
marketing?: boolean;
|
|
216
|
+
doNotSellShare?: boolean;
|
|
217
|
+
};
|
|
218
|
+
/** Options for `revenue()`. `currency` is ISO-4217; the rest become metadata. */
|
|
219
|
+
export type RevenueOptions = {
|
|
220
|
+
currency?: string;
|
|
221
|
+
/** Override the reserved revenue event name (defaults to "Payment"). */
|
|
222
|
+
event?: string;
|
|
223
|
+
channel?: string | null;
|
|
224
|
+
userId?: string;
|
|
225
|
+
[key: string]: any;
|
|
226
|
+
};
|
|
227
|
+
export declare const leapio: {
|
|
228
|
+
init: (config: SdkConfig) => Promise<void>;
|
|
229
|
+
track: (data: {
|
|
230
|
+
event: string;
|
|
231
|
+
channel?: string | null;
|
|
232
|
+
userId?: string;
|
|
233
|
+
message?: string;
|
|
234
|
+
notify?: boolean;
|
|
235
|
+
metadata?: Record<string, any>;
|
|
236
|
+
value?: number;
|
|
237
|
+
currency?: string;
|
|
238
|
+
/** Associate this event with a group/account (Segment `$groups` style).
|
|
239
|
+
* With groupType "company" (the default when groupId is set) the platform
|
|
240
|
+
* resolves and stamps the company on the event. */
|
|
241
|
+
groupId?: string;
|
|
242
|
+
groupType?: string;
|
|
243
|
+
}) => Promise<void>;
|
|
244
|
+
revenue: (amount: number, options?: RevenueOptions) => Promise<void>;
|
|
245
|
+
pageview: (data?: {
|
|
246
|
+
userId?: string;
|
|
247
|
+
metadata?: Record<string, any>;
|
|
248
|
+
}) => Promise<void>;
|
|
249
|
+
register: (properties: Properties) => void | true;
|
|
250
|
+
unregister: (property: string) => void;
|
|
251
|
+
reset: () => void;
|
|
252
|
+
identify: (newUserId: string, traits?: Record<string, any>, opts?: IdentifyOptions) => Promise<IdentifyResult>;
|
|
253
|
+
group: (groupId: string, traits?: Record<string, any>, opts?: IdentifyOptions & {
|
|
254
|
+
type?: string;
|
|
255
|
+
}) => Promise<IdentifyResult>;
|
|
256
|
+
setConsent: (input: SetConsentInput, opts?: {
|
|
257
|
+
identityVerification?: {
|
|
258
|
+
token: string;
|
|
259
|
+
};
|
|
260
|
+
}) => Promise<ConsentResult>;
|
|
261
|
+
getConsent: () => ConsentSnapshot | null;
|
|
262
|
+
applyConsentSnapshot: (snapshot: ConsentSnapshot) => Promise<boolean>;
|
|
263
|
+
getProperties: () => Record<string, Property>;
|
|
264
|
+
getAnonymousId: () => string | null;
|
|
265
|
+
};
|
|
266
|
+
//#endregion
|
|
267
|
+
export { type AutocaptureConfig, type AutocaptureSnippetConfig, type ConsentBehavior, type EventPayload, type SdkConfig, leapio as default };
|