@runbandit/sdk 3.1.3 → 3.4.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/dist/chunk-BG5L4PBC.js +319 -0
- package/dist/chunk-BG5L4PBC.js.map +1 -0
- package/dist/decision-cookie-CNIp56yQ.d.ts +503 -0
- package/dist/index.d.ts +85 -468
- package/dist/index.js +414 -250
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +48 -0
- package/dist/server.js +195 -0
- package/dist/server.js.map +1 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,470 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare const PLACEMENTS_BY_KIND: {
|
|
4
|
-
readonly text: readonly ["hero_headline", "hero_subhead", "cta_primary", "banner_text", "badge_text"];
|
|
5
|
-
readonly image: readonly ["hero_image", "banner_image", "feature_image"];
|
|
6
|
-
readonly ordering: readonly ["product_list_primary", "product_list_secondary"];
|
|
7
|
-
readonly offer: readonly ["offer_banner"];
|
|
8
|
-
};
|
|
9
|
-
type Placement = (typeof PLACEMENTS_BY_KIND)[StorefrontKind][number];
|
|
10
|
-
declare const PLACEMENTS: readonly Placement[];
|
|
11
|
-
declare function isPlacement(value: unknown): value is Placement;
|
|
12
|
-
declare function kindOfPlacement(placement: Placement): StorefrontKind;
|
|
13
|
-
declare const CONTENT_TYPE_BY_KIND: {
|
|
14
|
-
readonly text: {
|
|
15
|
-
readonly contentType: "TEXT";
|
|
16
|
-
readonly contentSubtype: "plain_text";
|
|
17
|
-
};
|
|
18
|
-
readonly image: {
|
|
19
|
-
readonly contentType: "FILE";
|
|
20
|
-
readonly contentSubtype: "image";
|
|
21
|
-
};
|
|
22
|
-
readonly ordering: {
|
|
23
|
-
readonly contentType: "CODE";
|
|
24
|
-
readonly contentSubtype: "json";
|
|
25
|
-
};
|
|
26
|
-
readonly offer: {
|
|
27
|
-
readonly contentType: "CODE";
|
|
28
|
-
readonly contentSubtype: "json";
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
declare const MIN_ORDERING_ITEMS = 2;
|
|
32
|
-
declare const MAX_ORDERING_ITEMS = 12;
|
|
33
|
-
interface ImageContent {
|
|
34
|
-
url: string;
|
|
35
|
-
alt: string;
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
sourceId: string;
|
|
39
|
-
}
|
|
40
|
-
interface OfferContent {
|
|
41
|
-
discountId: string;
|
|
42
|
-
code: string;
|
|
43
|
-
headline: string;
|
|
44
|
-
subtext: string;
|
|
45
|
-
}
|
|
46
|
-
type TreatmentContent = {
|
|
47
|
-
kind: 'text';
|
|
48
|
-
text: string;
|
|
49
|
-
} | {
|
|
50
|
-
kind: 'image';
|
|
51
|
-
image: ImageContent;
|
|
52
|
-
} | {
|
|
53
|
-
kind: 'ordering';
|
|
54
|
-
productIds: string[];
|
|
55
|
-
} | {
|
|
56
|
-
kind: 'offer';
|
|
57
|
-
offer: OfferContent | null;
|
|
58
|
-
};
|
|
59
|
-
declare function isShopifyCdnUrl(value: string): boolean;
|
|
60
|
-
declare function parseTreatmentContent(kind: StorefrontKind, config: unknown): TreatmentContent | null;
|
|
61
|
-
declare function serializeTreatmentConfig(content: TreatmentContent): {
|
|
62
|
-
content: unknown;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
declare const SITE_TARGET_KINDS: readonly ["text", "image"];
|
|
66
|
-
type SiteTargetKind = (typeof SITE_TARGET_KINDS)[number];
|
|
67
|
-
interface SiteTarget {
|
|
68
|
-
page: string;
|
|
69
|
-
selector: string;
|
|
70
|
-
tag: string;
|
|
71
|
-
kind: SiteTargetKind;
|
|
72
|
-
original: string;
|
|
73
|
-
}
|
|
74
|
-
type FunnelGoal = {
|
|
75
|
-
kind: 'page';
|
|
76
|
-
page: string;
|
|
77
|
-
} | {
|
|
78
|
-
kind: 'click';
|
|
79
|
-
page: string;
|
|
80
|
-
selector: string;
|
|
81
|
-
tag: string;
|
|
82
|
-
label: string;
|
|
83
|
-
};
|
|
84
|
-
declare function parseSiteContent(config: unknown): string | null;
|
|
85
|
-
declare function normalizeSiteTarget(target: SiteTarget): SiteTarget;
|
|
86
|
-
declare function normalizeFunnelGoal(goal: FunnelGoal): FunnelGoal;
|
|
87
|
-
declare function targetMatchesPage(target: Pick<SiteTarget, 'page'>, pathname: string): boolean;
|
|
88
|
-
declare function goalMatchesPage(goal: Pick<FunnelGoal, 'page'>, pathname: string): boolean;
|
|
89
|
-
declare const MAX_ALTERNATIVES = 5;
|
|
90
|
-
declare const MAX_TEXT_ALTERNATIVE_LENGTH = 300;
|
|
91
|
-
declare const MAX_IMAGE_URL_LENGTH = 2048;
|
|
92
|
-
interface PickDraft {
|
|
93
|
-
target?: SiteTarget;
|
|
94
|
-
alternatives: string[];
|
|
95
|
-
goal?: FunnelGoal;
|
|
96
|
-
}
|
|
97
|
-
interface PickState {
|
|
98
|
-
funnelId: string;
|
|
99
|
-
siteHost: string;
|
|
100
|
-
expiresAt: number;
|
|
101
|
-
draft: PickDraft;
|
|
102
|
-
funnelGoal: FunnelGoal | null;
|
|
103
|
-
experimentId: string | null;
|
|
104
|
-
runningExperiments: number;
|
|
105
|
-
}
|
|
106
|
-
declare const SUGGESTED_SITE_EXPERIMENTS = 3;
|
|
107
|
-
declare function moreExperimentsSentence(running: number, suggested: number): string;
|
|
108
|
-
type PickStep = 'pick' | 'alternatives' | 'goal' | 'ready' | 'live';
|
|
109
|
-
declare function pickStep(state: Pick<PickState, 'draft' | 'funnelGoal' | 'experimentId'>): PickStep;
|
|
110
|
-
declare function parseAlternative(kind: SiteTargetKind, raw: string): string;
|
|
111
|
-
declare const PICK_CHANNEL = "bandit-pick";
|
|
112
|
-
declare const PICK_PROTOCOL_VERSION = 1;
|
|
113
|
-
declare const PICK_MODES: readonly ["idle", "target", "goal-click"];
|
|
114
|
-
type PickMode = (typeof PICK_MODES)[number];
|
|
115
|
-
declare const PICK_REJECTIONS: readonly ["not-text-or-image", "has-markup", "not-clickable", "no-selector"];
|
|
116
|
-
type PickRejection = (typeof PICK_REJECTIONS)[number];
|
|
117
|
-
type ClickFunnelGoal = Extract<FunnelGoal, {
|
|
118
|
-
kind: 'click';
|
|
119
|
-
}>;
|
|
120
|
-
type PickerToPanel = {
|
|
121
|
-
type: 'navigated';
|
|
122
|
-
page: string;
|
|
123
|
-
} | {
|
|
124
|
-
type: 'target-picked';
|
|
125
|
-
target: SiteTarget;
|
|
126
|
-
} | {
|
|
127
|
-
type: 'goal-picked';
|
|
128
|
-
goal: ClickFunnelGoal;
|
|
129
|
-
} | {
|
|
130
|
-
type: 'rejected';
|
|
131
|
-
reason: PickRejection;
|
|
132
|
-
} | {
|
|
133
|
-
type: 'cancelled';
|
|
134
|
-
};
|
|
135
|
-
type PanelToPicker = {
|
|
136
|
-
type: 'hello';
|
|
137
|
-
} | {
|
|
138
|
-
type: 'mode';
|
|
139
|
-
mode: PickMode;
|
|
140
|
-
} | {
|
|
141
|
-
type: 'preview';
|
|
142
|
-
target: SiteTarget;
|
|
143
|
-
content: string;
|
|
144
|
-
} | {
|
|
145
|
-
type: 'clear-preview';
|
|
146
|
-
} | {
|
|
147
|
-
type: 'finish';
|
|
148
|
-
} | {
|
|
149
|
-
type: 'renew';
|
|
150
|
-
token: string;
|
|
151
|
-
};
|
|
152
|
-
declare const PICK_TOKEN_PREFIX = "bpick_";
|
|
153
|
-
interface PickEnvelope<M> {
|
|
154
|
-
channel: typeof PICK_CHANNEL;
|
|
155
|
-
v: typeof PICK_PROTOCOL_VERSION;
|
|
156
|
-
msg: M;
|
|
157
|
-
}
|
|
158
|
-
declare function pickEnvelope<M extends PickerToPanel | PanelToPicker>(msg: M): PickEnvelope<M>;
|
|
159
|
-
declare function parsePickerMessage(data: unknown): PickerToPanel | null;
|
|
160
|
-
declare function parsePanelMessage(data: unknown): PanelToPicker | null;
|
|
161
|
-
|
|
162
|
-
interface Company {
|
|
163
|
-
id: string;
|
|
164
|
-
name: string;
|
|
165
|
-
subdomain?: string;
|
|
166
|
-
domain?: string;
|
|
167
|
-
plan: string;
|
|
168
|
-
apiKey: string;
|
|
169
|
-
status: string;
|
|
170
|
-
createdAt: Date;
|
|
171
|
-
updatedAt: Date;
|
|
172
|
-
}
|
|
173
|
-
interface User {
|
|
174
|
-
id: string;
|
|
175
|
-
email: string;
|
|
176
|
-
name: string;
|
|
177
|
-
image?: string;
|
|
178
|
-
role: string;
|
|
179
|
-
companyId: string | null;
|
|
180
|
-
emailVerified?: boolean;
|
|
181
|
-
createdAt: Date;
|
|
182
|
-
updatedAt: Date;
|
|
183
|
-
}
|
|
184
|
-
interface Session {
|
|
185
|
-
id: string;
|
|
186
|
-
userId: string;
|
|
187
|
-
token: string;
|
|
188
|
-
expiresAt: Date;
|
|
189
|
-
ipAddress?: string | null;
|
|
190
|
-
userAgent?: string | null;
|
|
191
|
-
createdAt: Date;
|
|
192
|
-
updatedAt: Date;
|
|
193
|
-
}
|
|
194
|
-
interface Account {
|
|
195
|
-
id: string;
|
|
196
|
-
userId: string;
|
|
197
|
-
provider: string;
|
|
198
|
-
providerAccountId: string;
|
|
199
|
-
accessToken?: string;
|
|
200
|
-
refreshToken?: string;
|
|
201
|
-
accessTokenExpiresAt?: Date;
|
|
202
|
-
refreshTokenExpiresAt?: Date;
|
|
203
|
-
scope?: string;
|
|
204
|
-
idToken?: string;
|
|
205
|
-
sessionState?: string;
|
|
206
|
-
createdAt: Date;
|
|
207
|
-
updatedAt: Date;
|
|
208
|
-
}
|
|
209
|
-
interface Experiment {
|
|
210
|
-
id: string;
|
|
211
|
-
name: string;
|
|
212
|
-
description?: string;
|
|
213
|
-
algorithm: BanditAlgorithm;
|
|
214
|
-
forgetting?: ForgettingConfig;
|
|
215
|
-
status: ExperimentStatus;
|
|
216
|
-
contentType: ContentType;
|
|
217
|
-
treatments: Treatment[];
|
|
218
|
-
context?: Record<string, any>;
|
|
219
|
-
bundleId?: string;
|
|
220
|
-
image?: string;
|
|
221
|
-
emoji?: string;
|
|
222
|
-
assignmentTtl: number;
|
|
223
|
-
companyId: string;
|
|
224
|
-
createdAt: Date;
|
|
225
|
-
updatedAt: Date;
|
|
226
|
-
endAt?: Date;
|
|
227
|
-
placement?: Placement;
|
|
228
|
-
}
|
|
229
|
-
interface Treatment {
|
|
230
|
-
id: string;
|
|
231
|
-
experimentId: string;
|
|
232
|
-
name: string;
|
|
233
|
-
description?: string;
|
|
234
|
-
config: VariantConfig;
|
|
235
|
-
weight?: number;
|
|
236
|
-
companyId: string;
|
|
237
|
-
createdAt: Date;
|
|
238
|
-
}
|
|
239
|
-
interface AlgorithmResult {
|
|
240
|
-
treatmentId: string;
|
|
241
|
-
confidence: number;
|
|
242
|
-
probabilityBest?: number;
|
|
243
|
-
}
|
|
244
|
-
interface BanditResult {
|
|
245
|
-
assignmentId: string;
|
|
246
|
-
treatmentId: string;
|
|
247
|
-
confidence: number;
|
|
248
|
-
probabilityBest?: number;
|
|
249
|
-
metadata?: Record<string, any>;
|
|
250
|
-
}
|
|
251
|
-
interface ContextualFeatures {
|
|
252
|
-
[key: string]: string | number | boolean;
|
|
253
|
-
}
|
|
254
|
-
declare enum ExperimentStatus {
|
|
255
|
-
DRAFT = "draft",
|
|
256
|
-
ACTIVE = "active",
|
|
257
|
-
PAUSED = "paused",
|
|
258
|
-
COMPLETED = "completed",
|
|
259
|
-
ARCHIVED = "archived"
|
|
260
|
-
}
|
|
261
|
-
interface TreatmentMetadata {
|
|
262
|
-
strategy?: string;
|
|
263
|
-
tone?: string;
|
|
264
|
-
ctaStyle?: string;
|
|
265
|
-
emotionalHook?: string;
|
|
266
|
-
reasoning?: string;
|
|
267
|
-
tags?: string[];
|
|
268
|
-
generated?: boolean;
|
|
269
|
-
generatedAt?: string;
|
|
270
|
-
}
|
|
271
|
-
interface VariantConfig {
|
|
272
|
-
content: string;
|
|
273
|
-
metadata?: TreatmentMetadata & Record<string, any>;
|
|
274
|
-
}
|
|
275
|
-
declare enum BanditAlgorithm {
|
|
276
|
-
THOMPSON_SAMPLING = "thompson_sampling",
|
|
277
|
-
CONTEXTUAL_LINEAR = "contextual_linear"
|
|
278
|
-
}
|
|
279
|
-
declare enum Posterior {
|
|
280
|
-
BETA = "beta",
|
|
281
|
-
NORMAL_GAMMA = "normal_gamma"
|
|
282
|
-
}
|
|
283
|
-
declare function normalizePosterior(posterior: string | null | undefined): Posterior;
|
|
284
|
-
declare enum ForgettingMode {
|
|
285
|
-
NONE = "none",
|
|
286
|
-
DISCOUNTED = "discounted",
|
|
287
|
-
SLIDING_WINDOW = "sliding_window"
|
|
288
|
-
}
|
|
289
|
-
interface ForgettingConfig {
|
|
290
|
-
mode: ForgettingMode;
|
|
291
|
-
halfLifeMs?: number;
|
|
292
|
-
windowMs?: number;
|
|
293
|
-
}
|
|
294
|
-
declare const DEFAULT_HALF_LIFE_MS: number;
|
|
295
|
-
declare const DEFAULT_WINDOW_MS: number;
|
|
296
|
-
declare const STATIONARY: ForgettingConfig;
|
|
297
|
-
declare function resolveForgetting(config?: Partial<ForgettingConfig> | null): ForgettingConfig;
|
|
298
|
-
declare function normalizeAlgorithm(algorithm: string | null | undefined): BanditAlgorithm;
|
|
299
|
-
declare enum ContentType {
|
|
300
|
-
PLAIN_TEXT = "plain_text",
|
|
301
|
-
MARKDOWN = "markdown",
|
|
302
|
-
HTML = "html",
|
|
303
|
-
CSS = "css",
|
|
304
|
-
JAVASCRIPT = "javascript",
|
|
305
|
-
JSON = "json",
|
|
306
|
-
IMAGE = "image",
|
|
307
|
-
VIDEO = "video",
|
|
308
|
-
AUDIO = "audio",
|
|
309
|
-
DOCUMENT = "document"
|
|
310
|
-
}
|
|
311
|
-
declare function getContentTypeCategory(contentType: ContentType): 'text' | 'code' | 'file';
|
|
312
|
-
interface BanditConfig {
|
|
313
|
-
algorithm: BanditAlgorithm;
|
|
314
|
-
parameters: Record<string, any>;
|
|
315
|
-
}
|
|
316
|
-
interface ExperimentStats {
|
|
317
|
-
totalAssignments: number;
|
|
318
|
-
totalConversions: number;
|
|
319
|
-
conversionRate: number;
|
|
320
|
-
treatmentStats: Record<string, TreatmentStats>;
|
|
321
|
-
}
|
|
322
|
-
interface TreatmentStats {
|
|
323
|
-
assignments: number;
|
|
324
|
-
conversions: number;
|
|
325
|
-
conversionRate: number;
|
|
326
|
-
confidence: number;
|
|
327
|
-
lift?: number;
|
|
328
|
-
}
|
|
329
|
-
interface APIResponse<T = any> {
|
|
330
|
-
success: boolean;
|
|
331
|
-
data?: T;
|
|
332
|
-
error?: string;
|
|
333
|
-
timestamp: Date;
|
|
334
|
-
}
|
|
335
|
-
interface CreateExperimentRequest {
|
|
336
|
-
name: string;
|
|
337
|
-
description?: string;
|
|
338
|
-
algorithm: BanditAlgorithm;
|
|
339
|
-
contentType: ContentType;
|
|
340
|
-
algorithmConfig?: Record<string, any>;
|
|
341
|
-
treatments?: Omit<Treatment, 'id' | 'experimentId' | 'createdAt'>[];
|
|
342
|
-
}
|
|
343
|
-
interface AssignmentRequest {
|
|
344
|
-
experimentId: string;
|
|
345
|
-
userId: string;
|
|
346
|
-
context?: ContextualFeatures;
|
|
347
|
-
sessionId?: string;
|
|
348
|
-
pageUrl?: string;
|
|
349
|
-
}
|
|
350
|
-
interface TrackNamedEventRequest {
|
|
351
|
-
name: string;
|
|
352
|
-
category?: string;
|
|
353
|
-
value?: number;
|
|
354
|
-
metadata?: Record<string, any>;
|
|
355
|
-
sessionId: string;
|
|
356
|
-
userId?: string;
|
|
357
|
-
assignmentId?: string;
|
|
358
|
-
}
|
|
359
|
-
declare enum FunnelStatus {
|
|
360
|
-
DRAFT = "draft",
|
|
361
|
-
ACTIVE = "active",
|
|
362
|
-
PAUSED = "paused",
|
|
363
|
-
COMPLETED = "completed"
|
|
364
|
-
}
|
|
365
|
-
interface Funnel {
|
|
366
|
-
id: string;
|
|
367
|
-
name: string;
|
|
368
|
-
description?: string;
|
|
369
|
-
status: FunnelStatus;
|
|
370
|
-
inactivityTimeoutMs?: number;
|
|
371
|
-
revisionWindowMs?: number;
|
|
372
|
-
companyId: string;
|
|
373
|
-
createdAt: Date;
|
|
374
|
-
updatedAt: Date;
|
|
375
|
-
}
|
|
376
|
-
interface FunnelRewardRequest {
|
|
377
|
-
funnelId: string;
|
|
378
|
-
userId: string;
|
|
379
|
-
value: number;
|
|
380
|
-
}
|
|
381
|
-
interface ApiKey {
|
|
382
|
-
id: string;
|
|
383
|
-
name: string;
|
|
384
|
-
keyPrefix: string;
|
|
385
|
-
status: 'active' | 'revoked';
|
|
386
|
-
createdBy: string;
|
|
387
|
-
createdAt: Date;
|
|
388
|
-
lastUsedAt?: Date;
|
|
389
|
-
revokedAt?: Date;
|
|
390
|
-
revokedBy?: string;
|
|
391
|
-
}
|
|
392
|
-
interface CreateApiKeyRequest {
|
|
393
|
-
name: string;
|
|
394
|
-
}
|
|
395
|
-
interface CreateApiKeyResponse {
|
|
396
|
-
id: string;
|
|
397
|
-
key: string;
|
|
398
|
-
name: string;
|
|
399
|
-
}
|
|
400
|
-
type IdentifyMergeReason = 'user_signup' | 'email_verification' | 'social_login' | 'account_recovery' | 'manual';
|
|
401
|
-
interface IdentifyUserRequest {
|
|
402
|
-
anonymousId: string;
|
|
403
|
-
identifiedUserId: string;
|
|
404
|
-
mergeReason?: IdentifyMergeReason;
|
|
405
|
-
}
|
|
406
|
-
interface IdentifyUserResponse {
|
|
407
|
-
anonymousId: string;
|
|
408
|
-
identifiedUserId: string;
|
|
409
|
-
alreadyMapped: boolean;
|
|
410
|
-
}
|
|
411
|
-
interface ResolvedIdentity {
|
|
412
|
-
canonicalId: string;
|
|
413
|
-
anonymousIds: string[];
|
|
414
|
-
isIdentified: boolean;
|
|
415
|
-
}
|
|
416
|
-
type BundleMode = 'factored' | 'joint';
|
|
417
|
-
interface Bundle {
|
|
418
|
-
id: string;
|
|
419
|
-
name: string;
|
|
420
|
-
description?: string;
|
|
421
|
-
status: ExperimentStatus;
|
|
422
|
-
mode: BundleMode;
|
|
423
|
-
funnelId?: string;
|
|
424
|
-
assignmentTtl: number;
|
|
425
|
-
conversionWindowMs: number;
|
|
426
|
-
inactivityTimeoutMs?: number;
|
|
427
|
-
revisionWindowMs?: number;
|
|
428
|
-
companyId: string;
|
|
429
|
-
createdAt: Date;
|
|
430
|
-
updatedAt: Date;
|
|
431
|
-
}
|
|
432
|
-
interface BundleAssignmentRequest {
|
|
433
|
-
bundleId: string;
|
|
434
|
-
userId: string;
|
|
435
|
-
context?: ContextualFeatures;
|
|
436
|
-
sessionId?: string;
|
|
437
|
-
pageUrl?: string;
|
|
438
|
-
}
|
|
439
|
-
interface BundleSlotAssignment {
|
|
440
|
-
assignmentId: string;
|
|
441
|
-
experimentId: string;
|
|
442
|
-
treatmentId: string;
|
|
443
|
-
config: VariantConfig | Record<string, unknown>;
|
|
444
|
-
}
|
|
445
|
-
interface BundleAssignmentResponse {
|
|
446
|
-
bundleAssignmentId: string;
|
|
447
|
-
slots: Record<string, BundleSlotAssignment>;
|
|
448
|
-
}
|
|
449
|
-
interface SnapshotTreatment {
|
|
450
|
-
id: string;
|
|
451
|
-
name?: string;
|
|
452
|
-
config: unknown;
|
|
453
|
-
pct: number;
|
|
454
|
-
}
|
|
455
|
-
interface SnapshotExperiment {
|
|
456
|
-
mode: 'snapshot' | 'network';
|
|
457
|
-
assignmentTtl: number;
|
|
458
|
-
treatments: SnapshotTreatment[];
|
|
459
|
-
target?: SiteTarget;
|
|
460
|
-
funnelId?: string;
|
|
461
|
-
}
|
|
462
|
-
interface CompanySnapshot {
|
|
463
|
-
ttl: number;
|
|
464
|
-
generatedAt: number;
|
|
465
|
-
experiments: Record<string, SnapshotExperiment>;
|
|
466
|
-
goals?: Record<string, FunnelGoal>;
|
|
467
|
-
}
|
|
1
|
+
import { T as Treatment, C as ContextualFeatures, O as OrderLineItem, B as BundleAssignmentResponse, a as CompanySnapshot, S as SnapshotTreatment } from './decision-cookie-CNIp56yQ.js';
|
|
2
|
+
export { H as APIResponse, A as Account, g as AlgorithmResult, Q as ApiKey, J as AssignmentRequest, l as BanditAlgorithm, y as BanditConfig, h as BanditResult, a0 as Bundle, a1 as BundleAssignmentRequest, $ as BundleMode, a2 as BundleSlotAssignment, aa as CONTENT_TYPE_BY_KIND, aI as ClickFunnelGoal, e as Company, w as ContentType, c as CookieDecision, d as CookieDecisions, R as CreateApiKeyRequest, W as CreateApiKeyResponse, I as CreateExperimentRequest, D as DECISIONS_COOKIE, o as DEFAULT_HALF_LIFE_MS, q as DEFAULT_WINDOW_MS, E as Experiment, z as ExperimentStats, i as ExperimentStatus, m as ForgettingConfig, F as ForgettingMode, M as Funnel, am as FunnelGoal, N as FunnelRewardRequest, L as FunnelStatus, X as IdentifyMergeReason, Y as IdentifyUserRequest, Z as IdentifyUserResponse, ad as ImageContent, as as MAX_ALTERNATIVES, au as MAX_IMAGE_URL_LENGTH, ac as MAX_ORDERING_ITEMS, at as MAX_TEXT_ALTERNATIVE_LENGTH, ab as MIN_ORDERING_ITEMS, ae as OfferContent, aQ as OrderAmounts, aC as PICK_CHANNEL, aE as PICK_MODES, aD as PICK_PROTOCOL_VERSION, aG as PICK_REJECTIONS, aL as PICK_TOKEN_PREFIX, a7 as PLACEMENTS, a5 as PLACEMENTS_BY_KIND, aK as PanelToPicker, av as PickDraft, aM as PickEnvelope, aF as PickMode, aH as PickRejection, aw as PickState, az as PickStep, aJ as PickerToPanel, a6 as Placement, P as Posterior, _ as ResolvedIdentity, aj as SITE_TARGET_KINDS, t as STATIONARY, a3 as STOREFRONT_KINDS, ax as SUGGESTED_SITE_EXPERIMENTS, f as Session, al as SiteTarget, ak as SiteTargetKind, b as SnapshotExperiment, a4 as StorefrontKind, K as TrackNamedEventRequest, af as TreatmentContent, j as TreatmentMetadata, G as TreatmentStats, U as User, V as VISITOR_COOKIE, k as VariantConfig, x as getContentTypeCategory, ar as goalMatchesPage, a8 as isPlacement, ag as isShopifyCdnUrl, a9 as kindOfPlacement, ay as moreExperimentsSentence, v as normalizeAlgorithm, ap as normalizeFunnelGoal, n as normalizePosterior, ao as normalizeSiteTarget, aB as parseAlternative, p as parseDecisions, aP as parsePanelMessage, aO as parsePickerMessage, an as parseSiteContent, ah as parseTreatmentContent, aN as pickEnvelope, aA as pickStep, r as readCookie, u as resolveForgetting, s as serializeDecisions, ai as serializeTreatmentConfig, aq as targetMatchesPage } from './decision-cookie-CNIp56yQ.js';
|
|
468
3
|
|
|
469
4
|
declare function validateTreatmentWeights(treatments: Treatment[]): boolean;
|
|
470
5
|
declare function normalizeTreatmentWeights(treatments: Treatment[]): Treatment[];
|
|
@@ -682,6 +217,83 @@ type ScriptPlatform = SitePlatform & {
|
|
|
682
217
|
declare const SCRIPT_PLATFORMS: readonly ScriptPlatform[];
|
|
683
218
|
declare function platformById(id: string | undefined): SitePlatform | undefined;
|
|
684
219
|
|
|
220
|
+
declare const ARRIVAL_CHANNELS: readonly ["ad", "email", "social", "search", "referral", "direct"];
|
|
221
|
+
type ArrivalChannel = (typeof ARRIVAL_CHANNELS)[number];
|
|
222
|
+
declare const ARRIVAL_TTL_MS: number;
|
|
223
|
+
declare const MAX_ARRIVAL_VALUE_LENGTH = 40;
|
|
224
|
+
declare const MAX_REFERRER_HOST_LENGTH = 100;
|
|
225
|
+
declare const MAX_RAW_TOUCH_VALUE_LENGTH = 200;
|
|
226
|
+
type ArrivalTouch = {
|
|
227
|
+
utmSource?: string;
|
|
228
|
+
utmMedium?: string;
|
|
229
|
+
utmCampaign?: string;
|
|
230
|
+
utmContent?: string;
|
|
231
|
+
trackingParam?: string;
|
|
232
|
+
referrerHost?: string;
|
|
233
|
+
};
|
|
234
|
+
type Arrival = {
|
|
235
|
+
source?: string;
|
|
236
|
+
medium?: string;
|
|
237
|
+
campaign?: string;
|
|
238
|
+
content?: string;
|
|
239
|
+
referrerHost?: string;
|
|
240
|
+
channel?: ArrivalChannel;
|
|
241
|
+
};
|
|
242
|
+
declare const UTM_PARAMS: readonly [readonly ["utmSource", "utm_source"], readonly ["utmMedium", "utm_medium"], readonly ["utmCampaign", "utm_campaign"], readonly ["utmContent", "utm_content"]];
|
|
243
|
+
declare const TRACKING_PARAM_SOURCES: Readonly<Record<string, string>>;
|
|
244
|
+
type ArrivalSignals = Omit<Arrival, 'channel'> & {
|
|
245
|
+
trackingParam?: string;
|
|
246
|
+
};
|
|
247
|
+
type ChannelRule = {
|
|
248
|
+
channel: ArrivalChannel;
|
|
249
|
+
field: 'medium' | 'trackingParam' | 'source' | 'referrerHost';
|
|
250
|
+
values: readonly string[];
|
|
251
|
+
};
|
|
252
|
+
declare const CHANNEL_RULES: readonly ChannelRule[];
|
|
253
|
+
declare function normalizeArrivalValue(raw: string | undefined): string | undefined;
|
|
254
|
+
declare function normalizeHost(raw: string | undefined): string | undefined;
|
|
255
|
+
declare const PASS_THROUGH_HOSTS: readonly string[];
|
|
256
|
+
declare function isPassThroughHost(host: string): boolean;
|
|
257
|
+
declare function channelOf(signals: ArrivalSignals): ArrivalChannel | undefined;
|
|
258
|
+
declare function arrivalFromTouch(touch: ArrivalTouch): Arrival;
|
|
259
|
+
declare function isDirectTouch(touch: ArrivalTouch): boolean;
|
|
260
|
+
declare function touchFromPage(page: {
|
|
261
|
+
href: string;
|
|
262
|
+
referrer: string;
|
|
263
|
+
}): ArrivalTouch;
|
|
264
|
+
type StoredArrival = {
|
|
265
|
+
signature: string;
|
|
266
|
+
sessionId: string;
|
|
267
|
+
at: number;
|
|
268
|
+
};
|
|
269
|
+
declare function touchSignature(touch: ArrivalTouch): string;
|
|
270
|
+
declare function shouldReportTouch(touch: ArrivalTouch, stored: StoredArrival | null, sessionId: string, now: number): boolean;
|
|
271
|
+
declare function isArrivalActive(startedAt: number, at: number): boolean;
|
|
272
|
+
declare const CHANNEL_LABELS: Readonly<Record<ArrivalChannel, string>>;
|
|
273
|
+
declare const UNKNOWN_SOURCE_KEY = "unknown";
|
|
274
|
+
type ArrivalSource = {
|
|
275
|
+
key: string;
|
|
276
|
+
label: string;
|
|
277
|
+
channel?: ArrivalChannel;
|
|
278
|
+
};
|
|
279
|
+
declare function sourceOf(arrival: Arrival | undefined): ArrivalSource;
|
|
280
|
+
|
|
281
|
+
type PayoutUnit = 'count' | 'revenue' | 'margin';
|
|
282
|
+
declare const PAYOUT_UNITS: readonly PayoutUnit[];
|
|
283
|
+
declare const NEW_PAYOUT_UNIT: PayoutUnit;
|
|
284
|
+
declare function isPayoutUnit(value: unknown): value is PayoutUnit;
|
|
285
|
+
declare function isCurrencyUnit(unit: PayoutUnit): boolean;
|
|
286
|
+
declare function rewardValue(unit: PayoutUnit, supplied: number | undefined): number;
|
|
287
|
+
declare function payoutUnitOfRewardBasis(rewardBasis: string | undefined): PayoutUnit;
|
|
288
|
+
declare const PAYOUT_UNIT_COPY: Record<PayoutUnit, {
|
|
289
|
+
label: string;
|
|
290
|
+
hint: string;
|
|
291
|
+
total: string;
|
|
292
|
+
perVisitor: string;
|
|
293
|
+
influence: string;
|
|
294
|
+
}>;
|
|
295
|
+
declare function formatPayout(unit: PayoutUnit, value: number): string;
|
|
296
|
+
|
|
685
297
|
interface BanditsClientConfig {
|
|
686
298
|
apiUrl: string;
|
|
687
299
|
apiKey: string;
|
|
@@ -689,6 +301,8 @@ interface BanditsClientConfig {
|
|
|
689
301
|
batchSize?: number;
|
|
690
302
|
flushInterval?: number;
|
|
691
303
|
sessionTtl?: number;
|
|
304
|
+
visitorId?: string;
|
|
305
|
+
captureArrival?: boolean;
|
|
692
306
|
}
|
|
693
307
|
declare class BanditsRequestError extends Error {
|
|
694
308
|
readonly status: number | undefined;
|
|
@@ -709,11 +323,14 @@ declare class BanditsClient {
|
|
|
709
323
|
readonly visitorId: string;
|
|
710
324
|
private flushTimer?;
|
|
711
325
|
constructor(config: BanditsClientConfig);
|
|
326
|
+
reportArrival(): Promise<boolean>;
|
|
712
327
|
getAssignment(experimentId: string, userId?: string, context?: ContextualFeatures): Promise<Assignment>;
|
|
713
328
|
trackNamedEvent(event: {
|
|
714
329
|
name: string;
|
|
715
330
|
category?: string;
|
|
716
331
|
value?: number;
|
|
332
|
+
cost?: number;
|
|
333
|
+
lineItems?: OrderLineItem[];
|
|
717
334
|
metadata?: Record<string, any>;
|
|
718
335
|
}, opts?: {
|
|
719
336
|
immediate?: boolean;
|
|
@@ -831,4 +448,4 @@ declare function reportPlanImpressions(plan: EmailPlan, recipientIds: string[],
|
|
|
831
448
|
alreadyRecorded: boolean;
|
|
832
449
|
}>;
|
|
833
450
|
|
|
834
|
-
export {
|
|
451
|
+
export { ARRIVAL_CHANNELS, ARRIVAL_TTL_MS, type Arrival, type ArrivalChannel, type ArrivalSource, type ArrivalTouch, type Assignment, BanditsClient as BanditClient, BanditsClient, type BanditsClientConfig, BanditsRequestError, type Bound, BundleAssignmentResponse, type ButtonBlock, CHANNEL_LABELS, CHANNEL_RULES, CompanySnapshot, ContextualFeatures, DEFAULT_SESSION_TTL_MS, type DividerBlock, EMAIL_TOKEN_PARAM, type EmailBlock, type EmailDocument, type EmailPlan, type EmailTokenPayload, type HeadingBlock, type ImageBlock, MAX_ARRIVAL_VALUE_LENGTH, MAX_RAW_TOUCH_VALUE_LENGTH, MAX_REFERRER_HOST_LENGTH, NEW_PAYOUT_UNIT, OrderLineItem, PASS_THROUGH_HOSTS, PAYOUT_UNITS, PAYOUT_UNIT_COPY, type PayoutUnit, type PlanArm, type PlanRenderResult, type PlanSlot, type RenderEmailOptions, type RenderedDocument, type RenderedEmail, type RewriteOptions, type RewriteResult, SCRIPT_PLATFORMS, SESSION_CREATED_AT_KEY, SESSION_ID_KEY, SITE_PLATFORMS, SITE_PLATFORM_IDS, type ScriptPlatform, type SessionOptions, type SigningKey, type SitePlatform, type SitePlatformId, type SitePlatformPath, type SlotBinding, SnapshotClient, type SnapshotClientConfig, SnapshotTreatment, type SpacerBlock, type StoredArrival, type SyncAssignment, TRACKING_PARAM_SOURCES, type TextBlock, Treatment, UNKNOWN_SOURCE_KEY, UTM_PARAMS, VISITOR_ID_KEY, type VerifiedToken, appendEmailToken, arrivalFromTouch, buildSubdomainUrl, calculateConfidenceInterval, channelOf, extractDocumentSlots, extractEmailLinks, extractSlotNames, extractSubdomain, formatPayout, generateId, generateSubdomain, getOrCreateSessionId, getOrCreateVisitorId, hashRecipient, impressionManifest, isArrivalActive, isCurrencyUnit, isDirectTouch, isPassThroughHost, isPayoutUnit, isSlotBinding, isValidEmail, isValidSubdomain, matchesConversionPath, mintEmailToken, normalizeArrivalValue, normalizeConversionPath, normalizeHost, normalizeTreatmentWeights, payoutUnitOfRewardBasis, pickArm, pickTreatment, platformById, renderEmail, renderEmailDocument, renderFromPlan, reportPlanImpressions, rewardValue, rewriteEmailLinks, sampleCombination, sanitizeMetadata, shouldRefreshPlan, shouldReportTouch, sourceOf, touchFromPage, touchSignature, uniformFor, validateTreatmentWeights, verifyEmailToken };
|