bitsnap-react 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -0
- package/dist/CartProvider-HXLGQ4EX.mjs +2 -0
- package/dist/CartProvider-OHHYOMSG.js +2 -0
- package/dist/CartProvider-OHHYOMSG.js.map +1 -0
- package/dist/analytics.d.mts +45 -0
- package/dist/analytics.d.ts +45 -0
- package/dist/analytics.js +2 -0
- package/dist/analytics.js.map +1 -0
- package/dist/analytics.mjs +2 -0
- package/dist/catalog.d.mts +14 -1
- package/dist/catalog.d.ts +14 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chunk-3Z6VNXBP.js +2 -0
- package/dist/chunk-3Z6VNXBP.js.map +1 -0
- package/dist/chunk-43IIYJ6J.mjs +2 -0
- package/dist/chunk-43IIYJ6J.mjs.map +1 -0
- package/dist/chunk-6D3OORMK.mjs +2 -0
- package/dist/chunk-6D3OORMK.mjs.map +1 -0
- package/dist/chunk-ADYVTMGH.mjs +2 -0
- package/dist/chunk-ADYVTMGH.mjs.map +1 -0
- package/dist/{chunk-WRCXZMKK.js → chunk-AJNULBC3.js} +2 -2
- package/dist/chunk-AJNULBC3.js.map +1 -0
- package/dist/chunk-B32ACCW2.js +2 -0
- package/dist/chunk-B32ACCW2.js.map +1 -0
- package/dist/chunk-DDY7IBMG.mjs +2 -0
- package/dist/chunk-DDY7IBMG.mjs.map +1 -0
- package/dist/chunk-DPKT6ITB.js +4 -0
- package/dist/chunk-DPKT6ITB.js.map +1 -0
- package/dist/{chunk-T2POA6RW.js → chunk-F46RJVWC.js} +2 -2
- package/dist/chunk-F46RJVWC.js.map +1 -0
- package/dist/chunk-F6GQLKA6.js +2 -0
- package/dist/chunk-F6GQLKA6.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-JXCHRSPW.mjs +4 -0
- package/dist/chunk-JXCHRSPW.mjs.map +1 -0
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/chunk-RLEC25JI.mjs +2 -0
- package/dist/chunk-RLEC25JI.mjs.map +1 -0
- package/dist/chunk-RVILRUW3.js +2 -0
- package/dist/chunk-RVILRUW3.js.map +1 -0
- package/dist/chunk-T2OUOO4X.mjs +2 -0
- package/dist/chunk-T2OUOO4X.mjs.map +1 -0
- package/dist/chunk-VIII45AC.js +2 -0
- package/dist/chunk-VIII45AC.js.map +1 -0
- package/dist/chunk-XIHGWNTS.js +2 -0
- package/dist/chunk-XIHGWNTS.js.map +1 -0
- package/dist/chunk-YXFJG4MF.mjs +2 -0
- package/dist/chunk-YXFJG4MF.mjs.map +1 -0
- package/dist/chunk-ZPTHK4OX.mjs +2 -0
- package/dist/{chunk-OJT3YO2R.mjs.map → chunk-ZPTHK4OX.mjs.map} +1 -1
- package/dist/consent.d.mts +165 -0
- package/dist/consent.d.ts +165 -0
- package/dist/consent.js +75 -0
- package/dist/consent.js.map +1 -0
- package/dist/consent.mjs +75 -0
- package/dist/consent.mjs.map +1 -0
- package/dist/course.d.mts +13 -3
- package/dist/course.d.ts +13 -3
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/course.mjs.map +1 -1
- package/dist/embed/analytics.js +1 -0
- package/dist/embed/consent.js +74 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +54 -7
- package/dist/index.d.ts +54 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/instrument-CmxK7S4T.d.mts +929 -0
- package/dist/instrument-CmxK7S4T.d.ts +929 -0
- package/dist/internal.js.map +1 -1
- package/dist/methods-A5KGZBAM.js +2 -0
- package/dist/methods-A5KGZBAM.js.map +1 -0
- package/dist/methods-AOHKV7IN.mjs +2 -0
- package/dist/methods-AOHKV7IN.mjs.map +1 -0
- package/dist/models.js.map +1 -1
- package/dist/returns.d.mts +9 -1
- package/dist/returns.d.ts +9 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/{types-PSBBDdQm.d.mts → types-BnVWLcoB.d.mts} +13 -0
- package/dist/{types-BTm_ZolC.d.ts → types-i-IuN4Im.d.ts} +13 -0
- package/package.json +46 -45
- package/dist/CartProvider-5KAG5QGA.mjs +0 -2
- package/dist/CartProvider-7GJXW2IP.js +0 -2
- package/dist/CartProvider-7GJXW2IP.js.map +0 -1
- package/dist/chunk-45AP7UZE.mjs +0 -2
- package/dist/chunk-45AP7UZE.mjs.map +0 -1
- package/dist/chunk-7XTDFTQU.js +0 -4
- package/dist/chunk-7XTDFTQU.js.map +0 -1
- package/dist/chunk-C6Z7LOHB.mjs +0 -2
- package/dist/chunk-C6Z7LOHB.mjs.map +0 -1
- package/dist/chunk-HB6KQT26.mjs +0 -4
- package/dist/chunk-HB6KQT26.mjs.map +0 -1
- package/dist/chunk-LWK4E5G5.js +0 -2
- package/dist/chunk-LWK4E5G5.js.map +0 -1
- package/dist/chunk-OJT3YO2R.mjs +0 -2
- package/dist/chunk-OUYRKNZJ.mjs +0 -2
- package/dist/chunk-OUYRKNZJ.mjs.map +0 -1
- package/dist/chunk-P2YB25KZ.js +0 -2
- package/dist/chunk-P2YB25KZ.js.map +0 -1
- package/dist/chunk-T2POA6RW.js.map +0 -1
- package/dist/chunk-VPKE2ZOR.mjs +0 -2
- package/dist/chunk-VPKE2ZOR.mjs.map +0 -1
- package/dist/chunk-WRCXZMKK.js.map +0 -1
- package/dist/chunk-WSM4OM72.mjs +0 -2
- package/dist/chunk-WSM4OM72.mjs.map +0 -1
- package/dist/chunk-XRNTUSBH.js +0 -2
- package/dist/chunk-XRNTUSBH.js.map +0 -1
- package/dist/chunk-Z2BKIX6F.js +0 -2
- package/dist/chunk-Z2BKIX6F.js.map +0 -1
- package/dist/methods-ITD6WFIY.mjs +0 -2
- package/dist/methods-JENIGNF7.js +0 -2
- package/dist/methods-JENIGNF7.js.map +0 -1
- /package/dist/{CartProvider-5KAG5QGA.mjs.map → CartProvider-HXLGQ4EX.mjs.map} +0 -0
- /package/dist/{methods-ITD6WFIY.mjs.map → analytics.mjs.map} +0 -0
|
@@ -0,0 +1,929 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Bitsnap merchant analytics: the wire contract.
|
|
6
|
+
*
|
|
7
|
+
* SOURCE OF TRUTH: instapay `apps/collector/src/contract.ts` (prose version:
|
|
8
|
+
* `docs/merchant-analytics-contract.md`). This file is a verbatim copy of it
|
|
9
|
+
* (everything below the next comment block). Do not edit it here: change
|
|
10
|
+
* instapay's file and copy it over. `computeVisitorId` and
|
|
11
|
+
* `computeConsentedVisitorId` are pure but need the server secret; they are
|
|
12
|
+
* server-only: the browser never calls them, so bundlers drop them.
|
|
13
|
+
*/
|
|
14
|
+
declare const SCHEMA_VERSION = 1;
|
|
15
|
+
declare const ENVS: readonly ["live", "test"];
|
|
16
|
+
type Env = (typeof ENVS)[number];
|
|
17
|
+
declare const SOURCES: readonly ["storefront", "sdk_react", "script", "server", "dashboard"];
|
|
18
|
+
type Source = (typeof SOURCES)[number];
|
|
19
|
+
declare const CHANNELS: readonly ["hosted", "custom_domain", "embed", "api", "panel"];
|
|
20
|
+
type Channel = (typeof CHANNELS)[number];
|
|
21
|
+
declare const PAGE_TYPES: readonly ["shop", "catalog", "product", "cart", "checkout", "payment", "panel", "course", "custom_page", "order", "returns", "app", "other"];
|
|
22
|
+
type PageType = (typeof PAGE_TYPES)[number];
|
|
23
|
+
/** Browser events from hosted pages (H), bitsnap-react (R) and the script (S). */
|
|
24
|
+
declare const STOREFRONT_EVENT_SPEC: {
|
|
25
|
+
readonly page_view: {
|
|
26
|
+
readonly landing: "boolean";
|
|
27
|
+
};
|
|
28
|
+
readonly product_list_viewed: {
|
|
29
|
+
readonly list_id: "string?";
|
|
30
|
+
readonly item_count: "number";
|
|
31
|
+
};
|
|
32
|
+
readonly product_impression: {
|
|
33
|
+
readonly list_id: "string?";
|
|
34
|
+
readonly product_ids: "string[]";
|
|
35
|
+
readonly positions: "number[]";
|
|
36
|
+
};
|
|
37
|
+
readonly product_clicked: {
|
|
38
|
+
readonly list_id: "string?";
|
|
39
|
+
readonly position: "number?";
|
|
40
|
+
};
|
|
41
|
+
readonly product_view: {
|
|
42
|
+
readonly price_minor: "number";
|
|
43
|
+
readonly currency: "string";
|
|
44
|
+
readonly availability: "enum:in_stock|out_of_stock|preorder";
|
|
45
|
+
};
|
|
46
|
+
readonly variant_selected: {};
|
|
47
|
+
readonly add_to_cart: {
|
|
48
|
+
readonly value_minor: "number";
|
|
49
|
+
readonly currency: "string";
|
|
50
|
+
readonly qty: "number";
|
|
51
|
+
};
|
|
52
|
+
readonly remove_from_cart: {
|
|
53
|
+
readonly value_minor: "number";
|
|
54
|
+
readonly currency: "string";
|
|
55
|
+
readonly qty: "number";
|
|
56
|
+
};
|
|
57
|
+
readonly cart_opened: {
|
|
58
|
+
readonly value_minor: "number";
|
|
59
|
+
readonly currency: "string";
|
|
60
|
+
readonly item_count: "number";
|
|
61
|
+
};
|
|
62
|
+
readonly checkout_started: {
|
|
63
|
+
readonly value_minor: "number";
|
|
64
|
+
readonly currency: "string";
|
|
65
|
+
readonly item_count: "number";
|
|
66
|
+
readonly checkout_type: "enum:single|cart|link";
|
|
67
|
+
};
|
|
68
|
+
readonly checkout_step_completed: {
|
|
69
|
+
readonly step: "enum:contact|delivery|invoice|consents";
|
|
70
|
+
};
|
|
71
|
+
readonly checkout_validation_error: {
|
|
72
|
+
readonly field: "string";
|
|
73
|
+
readonly rule: "string";
|
|
74
|
+
};
|
|
75
|
+
readonly coupon_applied: {
|
|
76
|
+
readonly coupon_id: "string";
|
|
77
|
+
};
|
|
78
|
+
readonly coupon_rejected: {
|
|
79
|
+
readonly coupon_id: "string?";
|
|
80
|
+
readonly reason: "string";
|
|
81
|
+
};
|
|
82
|
+
readonly delivery_method_selected: {
|
|
83
|
+
readonly method: "string";
|
|
84
|
+
};
|
|
85
|
+
readonly payment_method_selected: {
|
|
86
|
+
readonly gateway: "string";
|
|
87
|
+
readonly method: "string";
|
|
88
|
+
};
|
|
89
|
+
readonly payment_submitted: {
|
|
90
|
+
readonly gateway: "string";
|
|
91
|
+
readonly method: "string";
|
|
92
|
+
};
|
|
93
|
+
readonly apple_pay_clicked: {};
|
|
94
|
+
readonly apple_pay_result: {
|
|
95
|
+
readonly outcome: "enum:success|fail|cancel";
|
|
96
|
+
};
|
|
97
|
+
readonly payment_returned: {
|
|
98
|
+
readonly gateway: "string";
|
|
99
|
+
readonly method: "string?";
|
|
100
|
+
readonly outcome: "enum:success|fail|cancel|pending";
|
|
101
|
+
readonly error_code: "string?";
|
|
102
|
+
};
|
|
103
|
+
readonly availability_signup: {};
|
|
104
|
+
readonly panel_login: {};
|
|
105
|
+
readonly panel_order_viewed: {};
|
|
106
|
+
readonly panel_download: {};
|
|
107
|
+
readonly return_started: {};
|
|
108
|
+
readonly return_submitted: {
|
|
109
|
+
readonly reason_code: "string";
|
|
110
|
+
readonly item_count: "number";
|
|
111
|
+
};
|
|
112
|
+
readonly course_opened: {
|
|
113
|
+
readonly course_id: "string";
|
|
114
|
+
};
|
|
115
|
+
readonly lesson_started: {
|
|
116
|
+
readonly course_id: "string";
|
|
117
|
+
readonly lesson_id: "string";
|
|
118
|
+
readonly position: "number";
|
|
119
|
+
};
|
|
120
|
+
readonly lesson_completed: {
|
|
121
|
+
readonly course_id: "string";
|
|
122
|
+
readonly lesson_id: "string";
|
|
123
|
+
readonly position: "number";
|
|
124
|
+
};
|
|
125
|
+
readonly video_progress: {
|
|
126
|
+
readonly course_id: "string";
|
|
127
|
+
readonly lesson_id: "string";
|
|
128
|
+
/** 25, 50, 75 or 100. */
|
|
129
|
+
readonly milestone: "number";
|
|
130
|
+
};
|
|
131
|
+
readonly test_submitted: {
|
|
132
|
+
readonly course_id: "string";
|
|
133
|
+
readonly lesson_id: "string";
|
|
134
|
+
readonly score_bucket: "enum:0-24|25-49|50-74|75-99|100";
|
|
135
|
+
};
|
|
136
|
+
readonly lesson_rated: {
|
|
137
|
+
readonly course_id: "string";
|
|
138
|
+
readonly lesson_id: "string";
|
|
139
|
+
/** 1..5. */
|
|
140
|
+
readonly rating: "number";
|
|
141
|
+
};
|
|
142
|
+
/** Written by the collector's POST /consent, never sent to POST /e. */
|
|
143
|
+
readonly consent_updated: {
|
|
144
|
+
readonly consent_id: "string";
|
|
145
|
+
readonly action: "enum:accept_all|reject_all|custom|withdraw";
|
|
146
|
+
readonly analytics: "boolean";
|
|
147
|
+
readonly marketing: "boolean";
|
|
148
|
+
readonly preferences: "boolean";
|
|
149
|
+
readonly banner_version: "number";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
/** Merchant behaviour in /app, sent through the same tracker core. */
|
|
153
|
+
declare const APP_EVENT_SPEC: {
|
|
154
|
+
readonly app_page_view: {
|
|
155
|
+
readonly route: "string";
|
|
156
|
+
readonly previous_route: "string?";
|
|
157
|
+
};
|
|
158
|
+
readonly insight_shown: {
|
|
159
|
+
readonly insight_type: "string";
|
|
160
|
+
readonly rank: "number";
|
|
161
|
+
readonly category: "string";
|
|
162
|
+
};
|
|
163
|
+
readonly insight_clicked: {
|
|
164
|
+
readonly insight_type: "string";
|
|
165
|
+
readonly rank: "number";
|
|
166
|
+
readonly category: "string";
|
|
167
|
+
};
|
|
168
|
+
readonly insight_dismissed: {
|
|
169
|
+
readonly insight_type: "string";
|
|
170
|
+
readonly rank: "number";
|
|
171
|
+
readonly category: "string";
|
|
172
|
+
};
|
|
173
|
+
readonly checklist_step_viewed: {
|
|
174
|
+
readonly step: "string";
|
|
175
|
+
};
|
|
176
|
+
readonly checklist_step_completed: {
|
|
177
|
+
readonly step: "string";
|
|
178
|
+
};
|
|
179
|
+
readonly gateway_connect_started: {
|
|
180
|
+
readonly gateway: "string";
|
|
181
|
+
readonly step: "string?";
|
|
182
|
+
};
|
|
183
|
+
readonly gateway_connect_completed: {
|
|
184
|
+
readonly gateway: "string";
|
|
185
|
+
readonly step: "string?";
|
|
186
|
+
};
|
|
187
|
+
readonly gateway_connect_failed: {
|
|
188
|
+
readonly gateway: "string";
|
|
189
|
+
readonly step: "string?";
|
|
190
|
+
readonly error_code: "string?";
|
|
191
|
+
};
|
|
192
|
+
readonly domain_connect_started: {};
|
|
193
|
+
readonly domain_connect_verified: {};
|
|
194
|
+
readonly domain_connect_failed: {
|
|
195
|
+
readonly error_code: "string?";
|
|
196
|
+
};
|
|
197
|
+
readonly product_created: {
|
|
198
|
+
readonly product_type: "string?";
|
|
199
|
+
};
|
|
200
|
+
readonly product_published: {
|
|
201
|
+
readonly product_type: "string?";
|
|
202
|
+
};
|
|
203
|
+
readonly product_editor_section_opened: {
|
|
204
|
+
readonly section: "string";
|
|
205
|
+
};
|
|
206
|
+
readonly feature_enabled: {
|
|
207
|
+
readonly feature: "string";
|
|
208
|
+
};
|
|
209
|
+
readonly stats_viewed: {
|
|
210
|
+
readonly tab: "string";
|
|
211
|
+
};
|
|
212
|
+
readonly stats_filter_changed: {
|
|
213
|
+
readonly tab: "string";
|
|
214
|
+
readonly filter: "string";
|
|
215
|
+
};
|
|
216
|
+
readonly report_exported: {
|
|
217
|
+
readonly report: "string";
|
|
218
|
+
readonly format: "string?";
|
|
219
|
+
};
|
|
220
|
+
readonly search_performed: {
|
|
221
|
+
readonly result_count: "number";
|
|
222
|
+
};
|
|
223
|
+
readonly error_shown: {
|
|
224
|
+
readonly code: "string";
|
|
225
|
+
readonly route: "string";
|
|
226
|
+
};
|
|
227
|
+
readonly help_opened: {
|
|
228
|
+
readonly topic: "string?";
|
|
229
|
+
};
|
|
230
|
+
readonly ai_assistant_used: {
|
|
231
|
+
readonly topic: "string?";
|
|
232
|
+
};
|
|
233
|
+
readonly member_invited: {
|
|
234
|
+
readonly role: "string";
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Emitted by instapay only. The lower-cased `EventType` of
|
|
239
|
+
* server/event-system/event.list.ts maps 1:1 to the first group.
|
|
240
|
+
*/
|
|
241
|
+
declare const BUSINESS_EVENT_SPEC: {
|
|
242
|
+
readonly transaction_created: {
|
|
243
|
+
readonly gateway: "string?";
|
|
244
|
+
readonly method: "string?";
|
|
245
|
+
readonly value_minor: "number?";
|
|
246
|
+
readonly currency: "string?";
|
|
247
|
+
};
|
|
248
|
+
readonly transaction_success: {
|
|
249
|
+
readonly gateway: "string?";
|
|
250
|
+
readonly method: "string?";
|
|
251
|
+
readonly value_minor: "number?";
|
|
252
|
+
readonly currency: "string?";
|
|
253
|
+
};
|
|
254
|
+
readonly transaction_failure: {
|
|
255
|
+
readonly error_code: "string?";
|
|
256
|
+
readonly gateway: "string?";
|
|
257
|
+
readonly method: "string?";
|
|
258
|
+
readonly value_minor: "number?";
|
|
259
|
+
readonly currency: "string?";
|
|
260
|
+
};
|
|
261
|
+
readonly transaction_expired: {
|
|
262
|
+
readonly gateway: "string?";
|
|
263
|
+
readonly method: "string?";
|
|
264
|
+
readonly value_minor: "number?";
|
|
265
|
+
readonly currency: "string?";
|
|
266
|
+
};
|
|
267
|
+
readonly transaction_charge: {
|
|
268
|
+
readonly gateway: "string?";
|
|
269
|
+
readonly method: "string?";
|
|
270
|
+
readonly value_minor: "number?";
|
|
271
|
+
readonly currency: "string?";
|
|
272
|
+
};
|
|
273
|
+
readonly subscription_created: {
|
|
274
|
+
readonly subscription_id: "string?";
|
|
275
|
+
readonly value_minor: "number?";
|
|
276
|
+
readonly currency: "string?";
|
|
277
|
+
};
|
|
278
|
+
readonly subscription_paused: {
|
|
279
|
+
readonly subscription_id: "string?";
|
|
280
|
+
readonly value_minor: "number?";
|
|
281
|
+
readonly currency: "string?";
|
|
282
|
+
};
|
|
283
|
+
readonly subscription_resumed: {
|
|
284
|
+
readonly subscription_id: "string?";
|
|
285
|
+
readonly value_minor: "number?";
|
|
286
|
+
readonly currency: "string?";
|
|
287
|
+
};
|
|
288
|
+
readonly subscription_updated: {
|
|
289
|
+
readonly subscription_id: "string?";
|
|
290
|
+
readonly value_minor: "number?";
|
|
291
|
+
readonly currency: "string?";
|
|
292
|
+
};
|
|
293
|
+
readonly subscription_deleted: {
|
|
294
|
+
readonly subscription_id: "string?";
|
|
295
|
+
readonly value_minor: "number?";
|
|
296
|
+
readonly currency: "string?";
|
|
297
|
+
};
|
|
298
|
+
readonly subscription_charge_paid: {
|
|
299
|
+
readonly subscription_id: "string?";
|
|
300
|
+
readonly value_minor: "number?";
|
|
301
|
+
readonly currency: "string?";
|
|
302
|
+
};
|
|
303
|
+
readonly subscription_charge_failed: {
|
|
304
|
+
readonly error_code: "string?";
|
|
305
|
+
readonly subscription_id: "string?";
|
|
306
|
+
readonly value_minor: "number?";
|
|
307
|
+
readonly currency: "string?";
|
|
308
|
+
};
|
|
309
|
+
readonly subscription_past_due: {
|
|
310
|
+
readonly subscription_id: "string?";
|
|
311
|
+
readonly value_minor: "number?";
|
|
312
|
+
readonly currency: "string?";
|
|
313
|
+
};
|
|
314
|
+
readonly subscription_canceled: {
|
|
315
|
+
readonly subscription_id: "string?";
|
|
316
|
+
readonly value_minor: "number?";
|
|
317
|
+
readonly currency: "string?";
|
|
318
|
+
};
|
|
319
|
+
readonly access_expires_in_3_days: {};
|
|
320
|
+
readonly access_expired: {};
|
|
321
|
+
readonly cart_recovery: {
|
|
322
|
+
readonly value_minor: "number?";
|
|
323
|
+
readonly currency: "string?";
|
|
324
|
+
};
|
|
325
|
+
readonly testimonial_email_send: {};
|
|
326
|
+
readonly testimonial_fulfilled: {};
|
|
327
|
+
readonly partner_commission_earned: {
|
|
328
|
+
readonly partner_id: "string";
|
|
329
|
+
readonly commission_minor: "number";
|
|
330
|
+
readonly currency: "string";
|
|
331
|
+
};
|
|
332
|
+
readonly checkout_session_created: {
|
|
333
|
+
readonly value_minor: "number";
|
|
334
|
+
readonly currency: "string";
|
|
335
|
+
readonly item_count: "number";
|
|
336
|
+
readonly checkout_type: "enum:single|cart|link";
|
|
337
|
+
readonly gateway: "string?";
|
|
338
|
+
};
|
|
339
|
+
readonly order_paid: {
|
|
340
|
+
readonly value_minor: "number";
|
|
341
|
+
readonly currency: "string";
|
|
342
|
+
readonly gateway: "string";
|
|
343
|
+
readonly method: "string?";
|
|
344
|
+
readonly item_count: "number?";
|
|
345
|
+
/** UTC date (`YYYY-MM-DD`) the envelope `visitor_id` was computed for. */
|
|
346
|
+
readonly visitor_day: "string?";
|
|
347
|
+
/** Every line of the order (public hashed product ids), at most 50. */
|
|
348
|
+
readonly items: "line_items?";
|
|
349
|
+
};
|
|
350
|
+
readonly refund_issued: {
|
|
351
|
+
readonly value_minor: "number";
|
|
352
|
+
readonly currency: "string";
|
|
353
|
+
readonly gateway: "string?";
|
|
354
|
+
readonly reason: "string?";
|
|
355
|
+
};
|
|
356
|
+
readonly return_requested: {
|
|
357
|
+
readonly item_count: "number";
|
|
358
|
+
readonly reason_code: "string?";
|
|
359
|
+
};
|
|
360
|
+
readonly automation_run_completed: {
|
|
361
|
+
readonly automation_id: "string";
|
|
362
|
+
readonly status: "string";
|
|
363
|
+
readonly trigger: "string?";
|
|
364
|
+
};
|
|
365
|
+
readonly notification_sent: {
|
|
366
|
+
readonly medium: "string";
|
|
367
|
+
readonly template: "string?";
|
|
368
|
+
};
|
|
369
|
+
readonly notification_failed: {
|
|
370
|
+
readonly medium: "string";
|
|
371
|
+
readonly template: "string?";
|
|
372
|
+
readonly error_code: "string?";
|
|
373
|
+
};
|
|
374
|
+
readonly recovery_email_sent: {
|
|
375
|
+
readonly step: "number?";
|
|
376
|
+
};
|
|
377
|
+
readonly recovery_link_clicked: {};
|
|
378
|
+
readonly api_request: {
|
|
379
|
+
/** Route template without ids or query, e.g. `/api/rpc/public.v1.PublicApiService/ListProducts`. */
|
|
380
|
+
readonly endpoint: "string";
|
|
381
|
+
/** `X-Bitsnap-Client` value, absent when the caller sent none. */
|
|
382
|
+
readonly client: "string?";
|
|
383
|
+
readonly status: "number";
|
|
384
|
+
readonly latency_bucket: "enum:lt_50|lt_200|lt_1000|gte_1000";
|
|
385
|
+
/** 1 for errors, <1 for sampled successes; rollups divide counts by it. */
|
|
386
|
+
readonly sample_rate: "number";
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
declare const EVENT_SPEC: {
|
|
390
|
+
readonly transaction_created: {
|
|
391
|
+
readonly gateway: "string?";
|
|
392
|
+
readonly method: "string?";
|
|
393
|
+
readonly value_minor: "number?";
|
|
394
|
+
readonly currency: "string?";
|
|
395
|
+
};
|
|
396
|
+
readonly transaction_success: {
|
|
397
|
+
readonly gateway: "string?";
|
|
398
|
+
readonly method: "string?";
|
|
399
|
+
readonly value_minor: "number?";
|
|
400
|
+
readonly currency: "string?";
|
|
401
|
+
};
|
|
402
|
+
readonly transaction_failure: {
|
|
403
|
+
readonly error_code: "string?";
|
|
404
|
+
readonly gateway: "string?";
|
|
405
|
+
readonly method: "string?";
|
|
406
|
+
readonly value_minor: "number?";
|
|
407
|
+
readonly currency: "string?";
|
|
408
|
+
};
|
|
409
|
+
readonly transaction_expired: {
|
|
410
|
+
readonly gateway: "string?";
|
|
411
|
+
readonly method: "string?";
|
|
412
|
+
readonly value_minor: "number?";
|
|
413
|
+
readonly currency: "string?";
|
|
414
|
+
};
|
|
415
|
+
readonly transaction_charge: {
|
|
416
|
+
readonly gateway: "string?";
|
|
417
|
+
readonly method: "string?";
|
|
418
|
+
readonly value_minor: "number?";
|
|
419
|
+
readonly currency: "string?";
|
|
420
|
+
};
|
|
421
|
+
readonly subscription_created: {
|
|
422
|
+
readonly subscription_id: "string?";
|
|
423
|
+
readonly value_minor: "number?";
|
|
424
|
+
readonly currency: "string?";
|
|
425
|
+
};
|
|
426
|
+
readonly subscription_paused: {
|
|
427
|
+
readonly subscription_id: "string?";
|
|
428
|
+
readonly value_minor: "number?";
|
|
429
|
+
readonly currency: "string?";
|
|
430
|
+
};
|
|
431
|
+
readonly subscription_resumed: {
|
|
432
|
+
readonly subscription_id: "string?";
|
|
433
|
+
readonly value_minor: "number?";
|
|
434
|
+
readonly currency: "string?";
|
|
435
|
+
};
|
|
436
|
+
readonly subscription_updated: {
|
|
437
|
+
readonly subscription_id: "string?";
|
|
438
|
+
readonly value_minor: "number?";
|
|
439
|
+
readonly currency: "string?";
|
|
440
|
+
};
|
|
441
|
+
readonly subscription_deleted: {
|
|
442
|
+
readonly subscription_id: "string?";
|
|
443
|
+
readonly value_minor: "number?";
|
|
444
|
+
readonly currency: "string?";
|
|
445
|
+
};
|
|
446
|
+
readonly subscription_charge_paid: {
|
|
447
|
+
readonly subscription_id: "string?";
|
|
448
|
+
readonly value_minor: "number?";
|
|
449
|
+
readonly currency: "string?";
|
|
450
|
+
};
|
|
451
|
+
readonly subscription_charge_failed: {
|
|
452
|
+
readonly error_code: "string?";
|
|
453
|
+
readonly subscription_id: "string?";
|
|
454
|
+
readonly value_minor: "number?";
|
|
455
|
+
readonly currency: "string?";
|
|
456
|
+
};
|
|
457
|
+
readonly subscription_past_due: {
|
|
458
|
+
readonly subscription_id: "string?";
|
|
459
|
+
readonly value_minor: "number?";
|
|
460
|
+
readonly currency: "string?";
|
|
461
|
+
};
|
|
462
|
+
readonly subscription_canceled: {
|
|
463
|
+
readonly subscription_id: "string?";
|
|
464
|
+
readonly value_minor: "number?";
|
|
465
|
+
readonly currency: "string?";
|
|
466
|
+
};
|
|
467
|
+
readonly access_expires_in_3_days: {};
|
|
468
|
+
readonly access_expired: {};
|
|
469
|
+
readonly cart_recovery: {
|
|
470
|
+
readonly value_minor: "number?";
|
|
471
|
+
readonly currency: "string?";
|
|
472
|
+
};
|
|
473
|
+
readonly testimonial_email_send: {};
|
|
474
|
+
readonly testimonial_fulfilled: {};
|
|
475
|
+
readonly partner_commission_earned: {
|
|
476
|
+
readonly partner_id: "string";
|
|
477
|
+
readonly commission_minor: "number";
|
|
478
|
+
readonly currency: "string";
|
|
479
|
+
};
|
|
480
|
+
readonly checkout_session_created: {
|
|
481
|
+
readonly value_minor: "number";
|
|
482
|
+
readonly currency: "string";
|
|
483
|
+
readonly item_count: "number";
|
|
484
|
+
readonly checkout_type: "enum:single|cart|link";
|
|
485
|
+
readonly gateway: "string?";
|
|
486
|
+
};
|
|
487
|
+
readonly order_paid: {
|
|
488
|
+
readonly value_minor: "number";
|
|
489
|
+
readonly currency: "string";
|
|
490
|
+
readonly gateway: "string";
|
|
491
|
+
readonly method: "string?";
|
|
492
|
+
readonly item_count: "number?";
|
|
493
|
+
/** UTC date (`YYYY-MM-DD`) the envelope `visitor_id` was computed for. */
|
|
494
|
+
readonly visitor_day: "string?";
|
|
495
|
+
/** Every line of the order (public hashed product ids), at most 50. */
|
|
496
|
+
readonly items: "line_items?";
|
|
497
|
+
};
|
|
498
|
+
readonly refund_issued: {
|
|
499
|
+
readonly value_minor: "number";
|
|
500
|
+
readonly currency: "string";
|
|
501
|
+
readonly gateway: "string?";
|
|
502
|
+
readonly reason: "string?";
|
|
503
|
+
};
|
|
504
|
+
readonly return_requested: {
|
|
505
|
+
readonly item_count: "number";
|
|
506
|
+
readonly reason_code: "string?";
|
|
507
|
+
};
|
|
508
|
+
readonly automation_run_completed: {
|
|
509
|
+
readonly automation_id: "string";
|
|
510
|
+
readonly status: "string";
|
|
511
|
+
readonly trigger: "string?";
|
|
512
|
+
};
|
|
513
|
+
readonly notification_sent: {
|
|
514
|
+
readonly medium: "string";
|
|
515
|
+
readonly template: "string?";
|
|
516
|
+
};
|
|
517
|
+
readonly notification_failed: {
|
|
518
|
+
readonly medium: "string";
|
|
519
|
+
readonly template: "string?";
|
|
520
|
+
readonly error_code: "string?";
|
|
521
|
+
};
|
|
522
|
+
readonly recovery_email_sent: {
|
|
523
|
+
readonly step: "number?";
|
|
524
|
+
};
|
|
525
|
+
readonly recovery_link_clicked: {};
|
|
526
|
+
readonly api_request: {
|
|
527
|
+
/** Route template without ids or query, e.g. `/api/rpc/public.v1.PublicApiService/ListProducts`. */
|
|
528
|
+
readonly endpoint: "string";
|
|
529
|
+
/** `X-Bitsnap-Client` value, absent when the caller sent none. */
|
|
530
|
+
readonly client: "string?";
|
|
531
|
+
readonly status: "number";
|
|
532
|
+
readonly latency_bucket: "enum:lt_50|lt_200|lt_1000|gte_1000";
|
|
533
|
+
/** 1 for errors, <1 for sampled successes; rollups divide counts by it. */
|
|
534
|
+
readonly sample_rate: "number";
|
|
535
|
+
};
|
|
536
|
+
readonly app_page_view: {
|
|
537
|
+
readonly route: "string";
|
|
538
|
+
readonly previous_route: "string?";
|
|
539
|
+
};
|
|
540
|
+
readonly insight_shown: {
|
|
541
|
+
readonly insight_type: "string";
|
|
542
|
+
readonly rank: "number";
|
|
543
|
+
readonly category: "string";
|
|
544
|
+
};
|
|
545
|
+
readonly insight_clicked: {
|
|
546
|
+
readonly insight_type: "string";
|
|
547
|
+
readonly rank: "number";
|
|
548
|
+
readonly category: "string";
|
|
549
|
+
};
|
|
550
|
+
readonly insight_dismissed: {
|
|
551
|
+
readonly insight_type: "string";
|
|
552
|
+
readonly rank: "number";
|
|
553
|
+
readonly category: "string";
|
|
554
|
+
};
|
|
555
|
+
readonly checklist_step_viewed: {
|
|
556
|
+
readonly step: "string";
|
|
557
|
+
};
|
|
558
|
+
readonly checklist_step_completed: {
|
|
559
|
+
readonly step: "string";
|
|
560
|
+
};
|
|
561
|
+
readonly gateway_connect_started: {
|
|
562
|
+
readonly gateway: "string";
|
|
563
|
+
readonly step: "string?";
|
|
564
|
+
};
|
|
565
|
+
readonly gateway_connect_completed: {
|
|
566
|
+
readonly gateway: "string";
|
|
567
|
+
readonly step: "string?";
|
|
568
|
+
};
|
|
569
|
+
readonly gateway_connect_failed: {
|
|
570
|
+
readonly gateway: "string";
|
|
571
|
+
readonly step: "string?";
|
|
572
|
+
readonly error_code: "string?";
|
|
573
|
+
};
|
|
574
|
+
readonly domain_connect_started: {};
|
|
575
|
+
readonly domain_connect_verified: {};
|
|
576
|
+
readonly domain_connect_failed: {
|
|
577
|
+
readonly error_code: "string?";
|
|
578
|
+
};
|
|
579
|
+
readonly product_created: {
|
|
580
|
+
readonly product_type: "string?";
|
|
581
|
+
};
|
|
582
|
+
readonly product_published: {
|
|
583
|
+
readonly product_type: "string?";
|
|
584
|
+
};
|
|
585
|
+
readonly product_editor_section_opened: {
|
|
586
|
+
readonly section: "string";
|
|
587
|
+
};
|
|
588
|
+
readonly feature_enabled: {
|
|
589
|
+
readonly feature: "string";
|
|
590
|
+
};
|
|
591
|
+
readonly stats_viewed: {
|
|
592
|
+
readonly tab: "string";
|
|
593
|
+
};
|
|
594
|
+
readonly stats_filter_changed: {
|
|
595
|
+
readonly tab: "string";
|
|
596
|
+
readonly filter: "string";
|
|
597
|
+
};
|
|
598
|
+
readonly report_exported: {
|
|
599
|
+
readonly report: "string";
|
|
600
|
+
readonly format: "string?";
|
|
601
|
+
};
|
|
602
|
+
readonly search_performed: {
|
|
603
|
+
readonly result_count: "number";
|
|
604
|
+
};
|
|
605
|
+
readonly error_shown: {
|
|
606
|
+
readonly code: "string";
|
|
607
|
+
readonly route: "string";
|
|
608
|
+
};
|
|
609
|
+
readonly help_opened: {
|
|
610
|
+
readonly topic: "string?";
|
|
611
|
+
};
|
|
612
|
+
readonly ai_assistant_used: {
|
|
613
|
+
readonly topic: "string?";
|
|
614
|
+
};
|
|
615
|
+
readonly member_invited: {
|
|
616
|
+
readonly role: "string";
|
|
617
|
+
};
|
|
618
|
+
readonly page_view: {
|
|
619
|
+
readonly landing: "boolean";
|
|
620
|
+
};
|
|
621
|
+
readonly product_list_viewed: {
|
|
622
|
+
readonly list_id: "string?";
|
|
623
|
+
readonly item_count: "number";
|
|
624
|
+
};
|
|
625
|
+
readonly product_impression: {
|
|
626
|
+
readonly list_id: "string?";
|
|
627
|
+
readonly product_ids: "string[]";
|
|
628
|
+
readonly positions: "number[]";
|
|
629
|
+
};
|
|
630
|
+
readonly product_clicked: {
|
|
631
|
+
readonly list_id: "string?";
|
|
632
|
+
readonly position: "number?";
|
|
633
|
+
};
|
|
634
|
+
readonly product_view: {
|
|
635
|
+
readonly price_minor: "number";
|
|
636
|
+
readonly currency: "string";
|
|
637
|
+
readonly availability: "enum:in_stock|out_of_stock|preorder";
|
|
638
|
+
};
|
|
639
|
+
readonly variant_selected: {};
|
|
640
|
+
readonly add_to_cart: {
|
|
641
|
+
readonly value_minor: "number";
|
|
642
|
+
readonly currency: "string";
|
|
643
|
+
readonly qty: "number";
|
|
644
|
+
};
|
|
645
|
+
readonly remove_from_cart: {
|
|
646
|
+
readonly value_minor: "number";
|
|
647
|
+
readonly currency: "string";
|
|
648
|
+
readonly qty: "number";
|
|
649
|
+
};
|
|
650
|
+
readonly cart_opened: {
|
|
651
|
+
readonly value_minor: "number";
|
|
652
|
+
readonly currency: "string";
|
|
653
|
+
readonly item_count: "number";
|
|
654
|
+
};
|
|
655
|
+
readonly checkout_started: {
|
|
656
|
+
readonly value_minor: "number";
|
|
657
|
+
readonly currency: "string";
|
|
658
|
+
readonly item_count: "number";
|
|
659
|
+
readonly checkout_type: "enum:single|cart|link";
|
|
660
|
+
};
|
|
661
|
+
readonly checkout_step_completed: {
|
|
662
|
+
readonly step: "enum:contact|delivery|invoice|consents";
|
|
663
|
+
};
|
|
664
|
+
readonly checkout_validation_error: {
|
|
665
|
+
readonly field: "string";
|
|
666
|
+
readonly rule: "string";
|
|
667
|
+
};
|
|
668
|
+
readonly coupon_applied: {
|
|
669
|
+
readonly coupon_id: "string";
|
|
670
|
+
};
|
|
671
|
+
readonly coupon_rejected: {
|
|
672
|
+
readonly coupon_id: "string?";
|
|
673
|
+
readonly reason: "string";
|
|
674
|
+
};
|
|
675
|
+
readonly delivery_method_selected: {
|
|
676
|
+
readonly method: "string";
|
|
677
|
+
};
|
|
678
|
+
readonly payment_method_selected: {
|
|
679
|
+
readonly gateway: "string";
|
|
680
|
+
readonly method: "string";
|
|
681
|
+
};
|
|
682
|
+
readonly payment_submitted: {
|
|
683
|
+
readonly gateway: "string";
|
|
684
|
+
readonly method: "string";
|
|
685
|
+
};
|
|
686
|
+
readonly apple_pay_clicked: {};
|
|
687
|
+
readonly apple_pay_result: {
|
|
688
|
+
readonly outcome: "enum:success|fail|cancel";
|
|
689
|
+
};
|
|
690
|
+
readonly payment_returned: {
|
|
691
|
+
readonly gateway: "string";
|
|
692
|
+
readonly method: "string?";
|
|
693
|
+
readonly outcome: "enum:success|fail|cancel|pending";
|
|
694
|
+
readonly error_code: "string?";
|
|
695
|
+
};
|
|
696
|
+
readonly availability_signup: {};
|
|
697
|
+
readonly panel_login: {};
|
|
698
|
+
readonly panel_order_viewed: {};
|
|
699
|
+
readonly panel_download: {};
|
|
700
|
+
readonly return_started: {};
|
|
701
|
+
readonly return_submitted: {
|
|
702
|
+
readonly reason_code: "string";
|
|
703
|
+
readonly item_count: "number";
|
|
704
|
+
};
|
|
705
|
+
readonly course_opened: {
|
|
706
|
+
readonly course_id: "string";
|
|
707
|
+
};
|
|
708
|
+
readonly lesson_started: {
|
|
709
|
+
readonly course_id: "string";
|
|
710
|
+
readonly lesson_id: "string";
|
|
711
|
+
readonly position: "number";
|
|
712
|
+
};
|
|
713
|
+
readonly lesson_completed: {
|
|
714
|
+
readonly course_id: "string";
|
|
715
|
+
readonly lesson_id: "string";
|
|
716
|
+
readonly position: "number";
|
|
717
|
+
};
|
|
718
|
+
readonly video_progress: {
|
|
719
|
+
readonly course_id: "string";
|
|
720
|
+
readonly lesson_id: "string";
|
|
721
|
+
/** 25, 50, 75 or 100. */
|
|
722
|
+
readonly milestone: "number";
|
|
723
|
+
};
|
|
724
|
+
readonly test_submitted: {
|
|
725
|
+
readonly course_id: "string";
|
|
726
|
+
readonly lesson_id: "string";
|
|
727
|
+
readonly score_bucket: "enum:0-24|25-49|50-74|75-99|100";
|
|
728
|
+
};
|
|
729
|
+
readonly lesson_rated: {
|
|
730
|
+
readonly course_id: "string";
|
|
731
|
+
readonly lesson_id: "string";
|
|
732
|
+
/** 1..5. */
|
|
733
|
+
readonly rating: "number";
|
|
734
|
+
};
|
|
735
|
+
/** Written by the collector's POST /consent, never sent to POST /e. */
|
|
736
|
+
readonly consent_updated: {
|
|
737
|
+
readonly consent_id: "string";
|
|
738
|
+
readonly action: "enum:accept_all|reject_all|custom|withdraw";
|
|
739
|
+
readonly analytics: "boolean";
|
|
740
|
+
readonly marketing: "boolean";
|
|
741
|
+
readonly preferences: "boolean";
|
|
742
|
+
readonly banner_version: "number";
|
|
743
|
+
};
|
|
744
|
+
};
|
|
745
|
+
type StorefrontEventName = keyof typeof STOREFRONT_EVENT_SPEC;
|
|
746
|
+
type AppEventName = keyof typeof APP_EVENT_SPEC;
|
|
747
|
+
type BusinessEventName = keyof typeof BUSINESS_EVENT_SPEC;
|
|
748
|
+
type EventName = StorefrontEventName | AppEventName | BusinessEventName;
|
|
749
|
+
type PropPrimitives = {
|
|
750
|
+
string: string;
|
|
751
|
+
number: number;
|
|
752
|
+
boolean: boolean;
|
|
753
|
+
"string[]": string[];
|
|
754
|
+
"number[]": number[];
|
|
755
|
+
line_items: Array<{
|
|
756
|
+
product_id: string;
|
|
757
|
+
qty: number;
|
|
758
|
+
value_minor: number;
|
|
759
|
+
}>;
|
|
760
|
+
};
|
|
761
|
+
type SplitEnum<S extends string> = S extends `${infer H}|${infer R}` ? H | SplitEnum<R> : S;
|
|
762
|
+
type StripOpt<S extends string> = S extends `${infer B}?` ? B : S;
|
|
763
|
+
type ResolveProp<S extends string> = StripOpt<S> extends `enum:${infer E}` ? SplitEnum<E> : StripOpt<S> extends keyof PropPrimitives ? PropPrimitives[StripOpt<S>] : never;
|
|
764
|
+
type PropsFromSpec<S extends Record<string, string>> = {
|
|
765
|
+
[K in keyof S as S[K] extends `${string}?` ? never : K]: ResolveProp<S[K]>;
|
|
766
|
+
} & {
|
|
767
|
+
[K in keyof S as S[K] extends `${string}?` ? K : never]?: ResolveProp<S[K]>;
|
|
768
|
+
};
|
|
769
|
+
type EventProps<E extends EventName> = PropsFromSpec<(typeof EVENT_SPEC)[E]>;
|
|
770
|
+
/** Fields the emitter fills in. Everything else is derived by the collector. */
|
|
771
|
+
interface ClientEvent<E extends EventName = EventName> {
|
|
772
|
+
/** UUIDv7, generated by the emitter. Dedupe key. */
|
|
773
|
+
event_id: string;
|
|
774
|
+
event: E;
|
|
775
|
+
/** Client clock, unix ms. */
|
|
776
|
+
ts: number;
|
|
777
|
+
schema_version: typeof SCHEMA_VERSION;
|
|
778
|
+
env: Env;
|
|
779
|
+
source: Source;
|
|
780
|
+
channel: Channel;
|
|
781
|
+
/** `<package>@<version>`, e.g. `bitsnap-react@1.9.0`. */
|
|
782
|
+
sdk?: string | null;
|
|
783
|
+
/** Random per page load, in memory only. */
|
|
784
|
+
page_id?: string | null;
|
|
785
|
+
page_type?: PageType | null;
|
|
786
|
+
host?: string | null;
|
|
787
|
+
/** Path without query string and fragment, already run through `sanitizePath`. */
|
|
788
|
+
path?: string | null;
|
|
789
|
+
referrer_host?: string | null;
|
|
790
|
+
utm_source?: string | null;
|
|
791
|
+
utm_medium?: string | null;
|
|
792
|
+
utm_campaign?: string | null;
|
|
793
|
+
utm_content?: string | null;
|
|
794
|
+
utm_term?: string | null;
|
|
795
|
+
ref_code?: string | null;
|
|
796
|
+
product_id?: string | null;
|
|
797
|
+
variant_id?: string | null;
|
|
798
|
+
order_ref?: string | null;
|
|
799
|
+
/** Object on the wire; the collector stores `JSON.stringify(props)`. */
|
|
800
|
+
props: EventProps<E>;
|
|
801
|
+
/**
|
|
802
|
+
* Only honoured for `source: "dashboard"`: the hashed Clerk user id computed
|
|
803
|
+
* by instapay and handed to the dashboard tracker. Ignored for every other
|
|
804
|
+
* source (the collector computes `visitor_id` itself).
|
|
805
|
+
*/
|
|
806
|
+
visitor_id?: string | null;
|
|
807
|
+
/**
|
|
808
|
+
* The value of the first-party `bs_vid_<projectKey>` cookie (`CLIENT_ID_RE`), sent only
|
|
809
|
+
* while analytics consent is granted. The collector turns it into a stable
|
|
810
|
+
* `consentedVisitorId` and never stores it.
|
|
811
|
+
*/
|
|
812
|
+
client_id?: string | null;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/** Events a browser may send. `consent_updated` is written by the consent log only. */
|
|
816
|
+
type BrowserEventName = Exclude<StorefrontEventName, "consent_updated"> | AppEventName;
|
|
817
|
+
type TrackerOptions = {
|
|
818
|
+
/** Public project key (the hashed project id). `pk_` prefix is accepted. */
|
|
819
|
+
projectKey: string;
|
|
820
|
+
/** Defaults to `live`, or `test` when the page URL has the `?test=` test-mode parameter. */
|
|
821
|
+
env?: Env;
|
|
822
|
+
/** Collector origin. Default `https://collect.bitsnap.pl`. */
|
|
823
|
+
endpoint?: string;
|
|
824
|
+
/** `false` turns tracking off. Default `true`. */
|
|
825
|
+
enabled?: boolean;
|
|
826
|
+
/** Default `embed`. */
|
|
827
|
+
channel?: Channel;
|
|
828
|
+
/** Default `sdk_react`. */
|
|
829
|
+
source?: Source;
|
|
830
|
+
/** Only honoured by the collector for `source: "dashboard"` (hashed user id). */
|
|
831
|
+
visitorId?: string;
|
|
832
|
+
/** Receives every valid envelope before it is queued, e.g. to forward it to the merchant's own tools. */
|
|
833
|
+
onEvent?: (event: ClientEvent) => void;
|
|
834
|
+
/** `console.warn` dropped events. */
|
|
835
|
+
debug?: boolean;
|
|
836
|
+
};
|
|
837
|
+
/** Envelope fields a call site may set per event. */
|
|
838
|
+
type TrackExtra = {
|
|
839
|
+
page_type?: PageType | null;
|
|
840
|
+
product_id?: string | null;
|
|
841
|
+
variant_id?: string | null;
|
|
842
|
+
order_ref?: string | null;
|
|
843
|
+
/** Route template for pages whose URL path is not the path to report (the dashboard). */
|
|
844
|
+
path?: string;
|
|
845
|
+
/**
|
|
846
|
+
* Deterministic UUIDv7 for events another system reports too (e.g. hosted
|
|
847
|
+
* `payment_returned`), so the collector dedupes them. An invalid value is
|
|
848
|
+
* ignored and a fresh id is used.
|
|
849
|
+
*/
|
|
850
|
+
event_id?: string;
|
|
851
|
+
};
|
|
852
|
+
interface Tracker {
|
|
853
|
+
track<E extends BrowserEventName>(event: E, props: EventProps<E>, extra?: TrackExtra): void;
|
|
854
|
+
/**
|
|
855
|
+
* Sends `page_view` and makes `pageType` the page type of the following events
|
|
856
|
+
* (`null` clears it, `undefined` keeps the current one).
|
|
857
|
+
*/
|
|
858
|
+
page(pageType?: PageType | null, extra?: TrackExtra): void;
|
|
859
|
+
/**
|
|
860
|
+
* The visitor's `bs_vid_<projectKey>` client id, only while this tracker is on
|
|
861
|
+
* (enabled, no Global Privacy Control, not automated, analytics not denied) and
|
|
862
|
+
* Bitsnap Consent grants analytics. `projectKey` must match the tracker's, if given.
|
|
863
|
+
*/
|
|
864
|
+
clientId(projectKey?: string): string | null;
|
|
865
|
+
/** Sends the queue now. */
|
|
866
|
+
flush(): void;
|
|
867
|
+
setEnabled(enabled: boolean): void;
|
|
868
|
+
/** Returns an unsubscribe function. */
|
|
869
|
+
onEvent(fn: (event: ClientEvent) => void): () => void;
|
|
870
|
+
/** Updates `env` and `endpoint` of a running tracker. Other options are fixed at creation. */
|
|
871
|
+
configure(patch: {
|
|
872
|
+
env?: Env;
|
|
873
|
+
endpoint?: string;
|
|
874
|
+
}): void;
|
|
875
|
+
/** Removes the page listeners and drops the queue. */
|
|
876
|
+
destroy(): void;
|
|
877
|
+
}
|
|
878
|
+
declare const DEFAULT_ENDPOINT = "https://collect.bitsnap.pl";
|
|
879
|
+
/**
|
|
880
|
+
* In-memory event tracker. It never throws into the host page and touches no
|
|
881
|
+
* cookie or Web Storage, except the `bs_vid_<projectKey>` client id cookie, which it keeps
|
|
882
|
+
* only while Bitsnap Consent grants analytics. On the server it returns a no-op.
|
|
883
|
+
*/
|
|
884
|
+
declare function createTracker(options: TrackerOptions): Tracker;
|
|
885
|
+
/**
|
|
886
|
+
* Creates the page's tracker on the first call and returns that same tracker
|
|
887
|
+
* afterwards. A later call with another `projectKey` is ignored (warns in
|
|
888
|
+
* debug mode); a later call with `env`, `endpoint` or `enabled` updates the
|
|
889
|
+
* running tracker. A malformed key is not remembered, so a later valid call still works.
|
|
890
|
+
*/
|
|
891
|
+
declare function initTracker(options: TrackerOptions): Tracker;
|
|
892
|
+
/** The tracker made by `initTracker`, if any. */
|
|
893
|
+
declare function getTracker(): Tracker | undefined;
|
|
894
|
+
/** Destroys the singleton so that `initTracker` can build a fresh one (tests, hot reload). */
|
|
895
|
+
declare function resetTracker(): void;
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* The `analytics` prop of every instrumented bitsnap-react component.
|
|
899
|
+
* `true` (the default) tracks, `false` opts out, an object tracks and can
|
|
900
|
+
* forward each event to the merchant's own tools.
|
|
901
|
+
*/
|
|
902
|
+
type AnalyticsOption = boolean | {
|
|
903
|
+
/** Called with every event this component emits, after Bitsnap Consent allows analytics. */
|
|
904
|
+
onEvent?: (event: ClientEvent) => void;
|
|
905
|
+
/** `test` events are stored but never reach the merchant's stats. */
|
|
906
|
+
env?: Env;
|
|
907
|
+
};
|
|
908
|
+
/** What the components call. It never throws and does nothing on the server. */
|
|
909
|
+
interface Instrument {
|
|
910
|
+
track<E extends BrowserEventName>(event: E, props: EventProps<E>, extra?: TrackExtra): void;
|
|
911
|
+
}
|
|
912
|
+
declare const noopInstrument: Instrument;
|
|
913
|
+
/** Hands the instrument of a top-level component to the parts below it. */
|
|
914
|
+
declare function InstrumentProvider({ value, children }: {
|
|
915
|
+
value: Instrument;
|
|
916
|
+
children?: ReactNode;
|
|
917
|
+
}): react.FunctionComponentElement<react.ProviderProps<Instrument | null>>;
|
|
918
|
+
/** The instrument of the closest instrumented ancestor, or a no-op. */
|
|
919
|
+
declare function useInstrumentContext(): Instrument;
|
|
920
|
+
/**
|
|
921
|
+
* The instrument of a top-level component. `projectKey` is the public
|
|
922
|
+
* project id the component already has. When `analytics` is not given and an
|
|
923
|
+
* ancestor is instrumented, the ancestor's instrument is reused.
|
|
924
|
+
*/
|
|
925
|
+
declare function useInstrument(projectKey: string | null | undefined, analytics?: AnalyticsOption, pageType?: PageType): Instrument;
|
|
926
|
+
/** Score (0..100) → the contract's bucket. */
|
|
927
|
+
declare function scoreBucket(percent: number): "0-24" | "25-49" | "50-74" | "75-99" | "100";
|
|
928
|
+
|
|
929
|
+
export { type AnalyticsOption as A, type BrowserEventName as B, type ClientEvent as C, DEFAULT_ENDPOINT as D, type Env as E, InstrumentProvider as I, type PageType as P, type Source as S, type Tracker as T, type TrackerOptions as a, type TrackExtra as b, createTracker as c, type AppEventName as d, type Channel as e, type EventName as f, getTracker as g, type EventProps as h, initTracker as i, type StorefrontEventName as j, useInstrumentContext as k, type Instrument as l, noopInstrument as n, resetTracker as r, scoreBucket as s, useInstrument as u };
|