@coframe/sdk 1.1.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.
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var sdk = require('@coframe/sdk');
5
+ var React = require('react');
6
+
7
+ const CoframeContext = React.createContext({ treatments: null });
8
+ function CoframeProvider({ projectConfig, projectData, onTreatmentApplied: onTreatmentAppliedProp, onTreatmentAppliedBulk: onTreatmentAppliedBulkProp, onTreatmentAppliedBulkV2, onLog: onLogProp, children, }) {
9
+ const [treatments, setTreatments] = React.useState(null);
10
+ React.useEffect(() => {
11
+ var _a, _b;
12
+ sdk.onTreatmentApplied({
13
+ callback: onTreatmentAppliedProp,
14
+ bulkCallback: (data) => {
15
+ setTreatments(data);
16
+ onTreatmentAppliedBulkProp === null || onTreatmentAppliedBulkProp === void 0 ? void 0 : onTreatmentAppliedBulkProp(data);
17
+ },
18
+ bulkCallbackV2: onTreatmentAppliedBulkV2,
19
+ });
20
+ if (onLogProp) {
21
+ sdk.onLog(onLogProp);
22
+ }
23
+ sdk.init({
24
+ config: {
25
+ ...projectConfig,
26
+ startTime: (_a = projectConfig.startTime) !== null && _a !== void 0 ? _a : Date.now(),
27
+ currentUrl: (_b = projectConfig.currentUrl) !== null && _b !== void 0 ? _b : window.location.href,
28
+ },
29
+ ...(projectData ? { projectData } : {}),
30
+ })
31
+ .catch((e) => {
32
+ console.error('[Coframe] Error initializing SDK', e);
33
+ })
34
+ .finally(() => {
35
+ var _a;
36
+ const cached = typeof window !== 'undefined' ? (_a = window.Coframe) === null || _a === void 0 ? void 0 : _a.treatmentsData : null;
37
+ setTreatments((curr) => { var _a; return (_a = curr !== null && curr !== void 0 ? curr : cached) !== null && _a !== void 0 ? _a : []; });
38
+ });
39
+ }, []);
40
+ return React.createElement(CoframeContext.Provider, { value: { treatments } }, children);
41
+ }
42
+ function useCoframeTreatments() {
43
+ return React.useContext(CoframeContext).treatments;
44
+ }
45
+ function useCoframeTreatment(experimentId) {
46
+ const treatments = useCoframeTreatments();
47
+ return treatments === null || treatments === void 0 ? void 0 : treatments.find((t) => t.experimentId === experimentId);
48
+ }
49
+ function useCoframeVariant(experimentId) {
50
+ var _a;
51
+ return (_a = useCoframeTreatment(experimentId)) === null || _a === void 0 ? void 0 : _a.variantId;
52
+ }
53
+
54
+ Object.defineProperty(exports, "init", {
55
+ enumerable: true,
56
+ get: function () { return sdk.init; }
57
+ });
58
+ Object.defineProperty(exports, "onLog", {
59
+ enumerable: true,
60
+ get: function () { return sdk.onLog; }
61
+ });
62
+ Object.defineProperty(exports, "onTreatmentApplied", {
63
+ enumerable: true,
64
+ get: function () { return sdk.onTreatmentApplied; }
65
+ });
66
+ Object.defineProperty(exports, "setConsent", {
67
+ enumerable: true,
68
+ get: function () { return sdk.setConsent; }
69
+ });
70
+ Object.defineProperty(exports, "setFeatureFlag", {
71
+ enumerable: true,
72
+ get: function () { return sdk.setFeatureFlag; }
73
+ });
74
+ Object.defineProperty(exports, "setPageHydrated", {
75
+ enumerable: true,
76
+ get: function () { return sdk.setPageHydrated; }
77
+ });
78
+ Object.defineProperty(exports, "setUserToken", {
79
+ enumerable: true,
80
+ get: function () { return sdk.setUserToken; }
81
+ });
82
+ Object.defineProperty(exports, "trackConversion", {
83
+ enumerable: true,
84
+ get: function () { return sdk.trackConversion; }
85
+ });
86
+ exports.CoframeProvider = CoframeProvider;
87
+ exports.useCoframeTreatment = useCoframeTreatment;
88
+ exports.useCoframeTreatments = useCoframeTreatments;
89
+ exports.useCoframeVariant = useCoframeVariant;
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ import { onTreatmentApplied, onLog, init } from '@coframe/sdk';
3
+ export { init, onLog, onTreatmentApplied, setConsent, setFeatureFlag, setPageHydrated, setUserToken, trackConversion } from '@coframe/sdk';
4
+ import React, { createContext, useState, useEffect, useContext } from 'react';
5
+
6
+ const CoframeContext = createContext({ treatments: null });
7
+ function CoframeProvider({ projectConfig, projectData, onTreatmentApplied: onTreatmentAppliedProp, onTreatmentAppliedBulk: onTreatmentAppliedBulkProp, onTreatmentAppliedBulkV2, onLog: onLogProp, children, }) {
8
+ const [treatments, setTreatments] = useState(null);
9
+ useEffect(() => {
10
+ var _a, _b;
11
+ onTreatmentApplied({
12
+ callback: onTreatmentAppliedProp,
13
+ bulkCallback: (data) => {
14
+ setTreatments(data);
15
+ onTreatmentAppliedBulkProp === null || onTreatmentAppliedBulkProp === void 0 ? void 0 : onTreatmentAppliedBulkProp(data);
16
+ },
17
+ bulkCallbackV2: onTreatmentAppliedBulkV2,
18
+ });
19
+ if (onLogProp) {
20
+ onLog(onLogProp);
21
+ }
22
+ init({
23
+ config: {
24
+ ...projectConfig,
25
+ startTime: (_a = projectConfig.startTime) !== null && _a !== void 0 ? _a : Date.now(),
26
+ currentUrl: (_b = projectConfig.currentUrl) !== null && _b !== void 0 ? _b : window.location.href,
27
+ },
28
+ ...(projectData ? { projectData } : {}),
29
+ })
30
+ .catch((e) => {
31
+ console.error('[Coframe] Error initializing SDK', e);
32
+ })
33
+ .finally(() => {
34
+ var _a;
35
+ const cached = typeof window !== 'undefined' ? (_a = window.Coframe) === null || _a === void 0 ? void 0 : _a.treatmentsData : null;
36
+ setTreatments((curr) => { var _a; return (_a = curr !== null && curr !== void 0 ? curr : cached) !== null && _a !== void 0 ? _a : []; });
37
+ });
38
+ }, []);
39
+ return React.createElement(CoframeContext.Provider, { value: { treatments } }, children);
40
+ }
41
+ function useCoframeTreatments() {
42
+ return useContext(CoframeContext).treatments;
43
+ }
44
+ function useCoframeTreatment(experimentId) {
45
+ const treatments = useCoframeTreatments();
46
+ return treatments === null || treatments === void 0 ? void 0 : treatments.find((t) => t.experimentId === experimentId);
47
+ }
48
+ function useCoframeVariant(experimentId) {
49
+ var _a;
50
+ return (_a = useCoframeTreatment(experimentId)) === null || _a === void 0 ? void 0 : _a.variantId;
51
+ }
52
+
53
+ export { CoframeProvider, useCoframeTreatment, useCoframeTreatments, useCoframeVariant };
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ const MAX_USER_CONTEXT_JSON_BYTES = 4096;
4
+ function userContextJsonByteLength(userContext) {
5
+ try {
6
+ return new TextEncoder().encode(JSON.stringify(userContext !== null && userContext !== void 0 ? userContext : null)).length;
7
+ }
8
+ catch (_a) {
9
+ return Number.POSITIVE_INFINITY;
10
+ }
11
+ }
12
+ function sanitizeUserContext(userContext) {
13
+ if (userContext === undefined ||
14
+ userContext === null ||
15
+ typeof userContext !== 'object' ||
16
+ Array.isArray(userContext)) {
17
+ return undefined;
18
+ }
19
+ if (userContextJsonByteLength(userContext) > MAX_USER_CONTEXT_JSON_BYTES) {
20
+ return undefined;
21
+ }
22
+ return userContext;
23
+ }
24
+
25
+ async function fetchProjectFromEdge(projectId, currentUrl, signal, userContext, headers) {
26
+ const payload = { projectId, currentUrl };
27
+ const safe = sanitizeUserContext(userContext);
28
+ if (safe) {
29
+ payload.userContext = safe;
30
+ }
31
+ const config = encodeURIComponent(JSON.stringify(payload));
32
+ const edgeUrl = new URL(`${"https://edge.cofra.me"}/api/v1/frames`);
33
+ edgeUrl.searchParams.set('config', config);
34
+ try {
35
+ const response = await fetch(edgeUrl, { headers, signal });
36
+ if (!response.ok)
37
+ return null;
38
+ return await response.json();
39
+ }
40
+ catch (error) {
41
+ if (error instanceof DOMException && error.name === 'AbortError') {
42
+ return null;
43
+ }
44
+ return null;
45
+ }
46
+ }
47
+
48
+ async function fetchAntiflickerFromEdge(projectId, currentUrl, userContext, headers) {
49
+ try {
50
+ const payload = { projectId, currentUrl };
51
+ if (userContext) {
52
+ payload.userContext = userContext;
53
+ }
54
+ const config = encodeURIComponent(JSON.stringify(payload));
55
+ const edgeUrl = new URL(`${"https://edge.cofra.me"}/cf.css`);
56
+ edgeUrl.searchParams.set('config', config);
57
+ const response = await fetch(edgeUrl, {
58
+ headers,
59
+ });
60
+ if (!response.ok)
61
+ return null;
62
+ return await response.text();
63
+ }
64
+ catch (_a) {
65
+ return null;
66
+ }
67
+ }
68
+ async function getProjectData(options) {
69
+ const includeProject = options.includeProject !== false;
70
+ const includeCSS = options.includeCSS !== false;
71
+ const [projectResult, antiflickerCSS] = await Promise.all([
72
+ includeProject
73
+ ? fetchProjectFromEdge(options.projectId, options.currentUrl, undefined, options.userContext, options.headers)
74
+ : Promise.resolve(null),
75
+ includeCSS
76
+ ? fetchAntiflickerFromEdge(options.projectId, options.currentUrl, options.userContext, options.headers)
77
+ : Promise.resolve(null),
78
+ ]);
79
+ const config = {};
80
+ if (projectResult) {
81
+ config.project = projectResult.project;
82
+ config.personalizationHeaders = projectResult.personalizationHeaders;
83
+ }
84
+ if (antiflickerCSS !== null) {
85
+ config.antiflickerCSS = antiflickerCSS;
86
+ }
87
+ if (Object.keys(config).length > 0) {
88
+ return config;
89
+ }
90
+ if (!includeProject && !includeCSS) {
91
+ return config;
92
+ }
93
+ return null;
94
+ }
95
+
96
+ exports.getProjectData = getProjectData;
@@ -0,0 +1,94 @@
1
+ const MAX_USER_CONTEXT_JSON_BYTES = 4096;
2
+ function userContextJsonByteLength(userContext) {
3
+ try {
4
+ return new TextEncoder().encode(JSON.stringify(userContext !== null && userContext !== void 0 ? userContext : null)).length;
5
+ }
6
+ catch (_a) {
7
+ return Number.POSITIVE_INFINITY;
8
+ }
9
+ }
10
+ function sanitizeUserContext(userContext) {
11
+ if (userContext === undefined ||
12
+ userContext === null ||
13
+ typeof userContext !== 'object' ||
14
+ Array.isArray(userContext)) {
15
+ return undefined;
16
+ }
17
+ if (userContextJsonByteLength(userContext) > MAX_USER_CONTEXT_JSON_BYTES) {
18
+ return undefined;
19
+ }
20
+ return userContext;
21
+ }
22
+
23
+ async function fetchProjectFromEdge(projectId, currentUrl, signal, userContext, headers) {
24
+ const payload = { projectId, currentUrl };
25
+ const safe = sanitizeUserContext(userContext);
26
+ if (safe) {
27
+ payload.userContext = safe;
28
+ }
29
+ const config = encodeURIComponent(JSON.stringify(payload));
30
+ const edgeUrl = new URL(`${"https://edge.cofra.me"}/api/v1/frames`);
31
+ edgeUrl.searchParams.set('config', config);
32
+ try {
33
+ const response = await fetch(edgeUrl, { headers, signal });
34
+ if (!response.ok)
35
+ return null;
36
+ return await response.json();
37
+ }
38
+ catch (error) {
39
+ if (error instanceof DOMException && error.name === 'AbortError') {
40
+ return null;
41
+ }
42
+ return null;
43
+ }
44
+ }
45
+
46
+ async function fetchAntiflickerFromEdge(projectId, currentUrl, userContext, headers) {
47
+ try {
48
+ const payload = { projectId, currentUrl };
49
+ if (userContext) {
50
+ payload.userContext = userContext;
51
+ }
52
+ const config = encodeURIComponent(JSON.stringify(payload));
53
+ const edgeUrl = new URL(`${"https://edge.cofra.me"}/cf.css`);
54
+ edgeUrl.searchParams.set('config', config);
55
+ const response = await fetch(edgeUrl, {
56
+ headers,
57
+ });
58
+ if (!response.ok)
59
+ return null;
60
+ return await response.text();
61
+ }
62
+ catch (_a) {
63
+ return null;
64
+ }
65
+ }
66
+ async function getProjectData(options) {
67
+ const includeProject = options.includeProject !== false;
68
+ const includeCSS = options.includeCSS !== false;
69
+ const [projectResult, antiflickerCSS] = await Promise.all([
70
+ includeProject
71
+ ? fetchProjectFromEdge(options.projectId, options.currentUrl, undefined, options.userContext, options.headers)
72
+ : Promise.resolve(null),
73
+ includeCSS
74
+ ? fetchAntiflickerFromEdge(options.projectId, options.currentUrl, options.userContext, options.headers)
75
+ : Promise.resolve(null),
76
+ ]);
77
+ const config = {};
78
+ if (projectResult) {
79
+ config.project = projectResult.project;
80
+ config.personalizationHeaders = projectResult.personalizationHeaders;
81
+ }
82
+ if (antiflickerCSS !== null) {
83
+ config.antiflickerCSS = antiflickerCSS;
84
+ }
85
+ if (Object.keys(config).length > 0) {
86
+ return config;
87
+ }
88
+ if (!includeProject && !includeCSS) {
89
+ return config;
90
+ }
91
+ return null;
92
+ }
93
+
94
+ export { getProjectData };
@@ -0,0 +1,308 @@
1
+ interface UniversalSelector {
2
+ t: string;
3
+ fingerprint?: string;
4
+ id?: string;
5
+ dataTestId?: string;
6
+ n?: {
7
+ i: number;
8
+ t: number;
9
+ };
10
+ text?: string;
11
+ href?: string;
12
+ ariaLabel?: string;
13
+ p?: UniversalSelector;
14
+ descendants?: {
15
+ depth: number;
16
+ sel: UniversalSelector;
17
+ }[];
18
+ isShadowRoot?: boolean;
19
+ }
20
+
21
+ type ElementStyles = Record<string, string | undefined>;
22
+ type ElementAttributes = {
23
+ src?: string;
24
+ innerHTML?: string;
25
+ styles?: ElementStyles;
26
+ onClick?: string;
27
+ textContent?: string;
28
+ role?: string;
29
+ disabled?: boolean;
30
+ };
31
+ type ProjectTag = {
32
+ js: string | null;
33
+ };
34
+
35
+ type Modification = ModificationUpdate | ModificationInsertInto | ModificationInsertBy | ModificationDelete | ModificationAddBanner | ModificationAddModal | ModificationExecuteJs;
36
+ type Modifications = {
37
+ [elementId: string]: Array<Modification>;
38
+ };
39
+ type NewElementAttributes = ElementAttributes & {
40
+ tagName?: 'h1' | 'p' | 'div' | 'span' | 'button' | 'input' | 'img' | 'div';
41
+ };
42
+ type ModificationUpdate = {
43
+ type: 'update';
44
+ attributes: ElementAttributes;
45
+ };
46
+ type ModificationInsertInto = {
47
+ type: 'insert_into';
48
+ child_position: 'first' | 'last';
49
+ new_element: NewElementAttributes;
50
+ };
51
+ type ModificationInsertBy = {
52
+ type: 'insert_by';
53
+ position: 'before' | 'after';
54
+ new_element: NewElementAttributes;
55
+ };
56
+ type ModificationDelete = {
57
+ type: 'delete';
58
+ };
59
+ type ModificationAddModal = {
60
+ type: 'add_modal';
61
+ modal_content: NewElementAttributes;
62
+ trigger: ModalTrigger;
63
+ };
64
+ type ModificationAddBanner = {
65
+ type: 'add_banner';
66
+ banner_content: NewElementAttributes;
67
+ };
68
+ type ModificationExecuteJs = {
69
+ type: 'execute_js';
70
+ js: string;
71
+ };
72
+ type ModalTrigger = 'exit' | 'scroll' | 'enter' | 'timer';
73
+
74
+ interface AnalyticsCallback {
75
+ callback: string;
76
+ }
77
+ interface TreatmentData {
78
+ impressionId: string;
79
+ userToken: string;
80
+ experimentId: string;
81
+ variantId: string;
82
+ inGlobalHoldout: boolean;
83
+ isBaseline: boolean;
84
+ holdoutExperimentId?: string;
85
+ }
86
+ interface TreatmentDataV2 {
87
+ coframe_experiment_id: string;
88
+ coframe_experiment_slug: string;
89
+ coframe_variant_id: string;
90
+ coframe_variant_slug: string;
91
+ coframe_user_token: string;
92
+ coframe_impression_id: string;
93
+ coframe_in_global_holdout: boolean;
94
+ coframe_in_exp_baseline: boolean;
95
+ }
96
+ declare const GLOBAL_HOLDOUT: "global_holdout";
97
+ declare const EXPERIMENT_HOLDOUT: "experiment_holdout";
98
+ declare const EXPERIMENT: "experiment";
99
+ type ExperimentLevel = typeof GLOBAL_HOLDOUT | typeof EXPERIMENT_HOLDOUT | typeof EXPERIMENT;
100
+ interface ExperimentInfo {
101
+ variant_id: string;
102
+ variant_slug: string;
103
+ experiment_id: string;
104
+ experiment_slug: string;
105
+ iteration_id: string;
106
+ level: ExperimentLevel;
107
+ final_state: boolean;
108
+ holdout_experiment_id?: string;
109
+ holdout_experiment_slug?: string;
110
+ }
111
+ interface Audience {
112
+ selector: ActivationCondition;
113
+ }
114
+ interface LaneMember {
115
+ experiment_id: string;
116
+ iteration_id: string;
117
+ }
118
+ interface LaneStatus {
119
+ seed: number;
120
+ members: LaneMember[];
121
+ }
122
+ interface HoldoutInfo {
123
+ holdout_experiment_id: string;
124
+ holdout_experiment_slug: string;
125
+ holdout_variant_id: string;
126
+ holdout_variant_slug: string;
127
+ treatment_variant_id: string;
128
+ treatment_variant_slug: string;
129
+ seed: number;
130
+ variant_bins: Allocation;
131
+ }
132
+ interface Metric {
133
+ id: string;
134
+ selector: SelectorCondition;
135
+ js_binder?: string;
136
+ }
137
+ interface ProjectSettings {
138
+ mutation_observer_active: boolean;
139
+ track_only_activated_frames?: boolean;
140
+ blocklist_ips?: string[];
141
+ bot_cloaking_enabled?: boolean;
142
+ bot_score_threshold?: number;
143
+ analytics_callback?: AnalyticsCallback;
144
+ }
145
+ interface Project {
146
+ org_id: string;
147
+ holdout_info: HoldoutInfo;
148
+ audiences: Record<string, Audience>;
149
+ frames: Frame[];
150
+ metrics?: Metric[];
151
+ settings: ProjectSettings;
152
+ tags?: ProjectTag[];
153
+ lanes?: Record<string, LaneStatus>;
154
+ }
155
+ interface Frame {
156
+ activation_condition: ActivationCondition;
157
+ experiments: Experiment[];
158
+ elements: CoframeElements;
159
+ }
160
+ interface Experiment {
161
+ metadata: ExperimentMetadata;
162
+ variants: Variant[];
163
+ }
164
+ interface ExperimentMetadata {
165
+ experiment_id: string;
166
+ slug: string;
167
+ iteration_id: string;
168
+ seed: number;
169
+ holdout_info: HoldoutInfo;
170
+ allocation: Allocation;
171
+ activation_condition: {
172
+ audience_ids?: string[];
173
+ };
174
+ lane_ids?: string[];
175
+ }
176
+ interface Allocation {
177
+ [variantId: string]: number[][];
178
+ }
179
+ interface Variant {
180
+ id: string;
181
+ slug: string;
182
+ experiment_id: string;
183
+ modifications: Modifications;
184
+ }
185
+ interface CoframeElements {
186
+ [elementId: string]: SelectorCondition[];
187
+ }
188
+ type SelectorCondition = {
189
+ and?: SelectorCondition[];
190
+ or?: SelectorCondition[];
191
+ name?: string;
192
+ url?: string;
193
+ url_starts_with?: string;
194
+ navigate_to_url_starts_with?: string;
195
+ css?: string;
196
+ universal?: UniversalSelector;
197
+ js?: string;
198
+ };
199
+ type Operator = 'equals' | 'contains' | 'not_contains';
200
+ type SegmentCondition = {
201
+ operator: Operator;
202
+ operand: string;
203
+ key?: string;
204
+ };
205
+ type ActivationConditionAllocation = {
206
+ seed: number;
207
+ allocation_bins: number[][];
208
+ allocation_scale: number;
209
+ };
210
+ type ActivationCondition = {
211
+ and?: ActivationCondition[];
212
+ or?: ActivationCondition[];
213
+ device?: string[];
214
+ platform?: string[];
215
+ language?: string[];
216
+ country?: string[];
217
+ region?: string[];
218
+ city?: string[];
219
+ search?: SegmentCondition[];
220
+ user_context?: SegmentCondition[];
221
+ first_time_vs_returning?: string[];
222
+ url?: string;
223
+ base_url_matches?: string;
224
+ url_regex?: string;
225
+ contains?: string;
226
+ time?: {
227
+ before?: Date;
228
+ after?: Date;
229
+ };
230
+ allocation?: ActivationConditionAllocation;
231
+ js_function?: string;
232
+ };
233
+ type CoframeConfig = {
234
+ projectId: string;
235
+ trackingOnly?: boolean;
236
+ enableAntiFlickering?: boolean;
237
+ waitForHydration?: boolean;
238
+ waitForCookiesEnabled?: boolean;
239
+ waitForFeatureFlag?: boolean;
240
+ waitForUserToken?: boolean;
241
+ batchSize?: number;
242
+ startTime?: number;
243
+ timeoutMs?: number;
244
+ timeoutBehavior?: 'exclude';
245
+ currentUrl?: string;
246
+ userContext?: Record<string, unknown>;
247
+ nonce?: string;
248
+ };
249
+ type ConversionEventPayload = {
250
+ metricId?: string;
251
+ metricName?: string;
252
+ metadata?: Record<string, string>;
253
+ value?: number;
254
+ };
255
+ type BotReason = 'none' | 'cf_bot_score' | 'cf_verified_bot' | 'force_bot_param';
256
+ type PersonalizationHeaders = {
257
+ 'x-device-type': string;
258
+ 'x-is-mobile-viewer': string;
259
+ 'x-viewer-city': string;
260
+ 'x-viewer-country': string;
261
+ 'x-viewer-region': string;
262
+ 'x-is-bot': string;
263
+ 'x-is-blocklist-ip': string;
264
+ 'x-cf-bot-score': string;
265
+ 'x-cf-verified-bot-category': string;
266
+ 'x-bot-reason': BotReason;
267
+ };
268
+
269
+ interface ProjectData {
270
+ project: Project;
271
+ personalizationHeaders?: Partial<PersonalizationHeaders>;
272
+ }
273
+ interface CoframeInitOptions {
274
+ config?: CoframeConfig;
275
+ projectData?: ProjectData;
276
+ }
277
+ type LogPayload = {
278
+ kind: 'warn' | 'error' | 'exception';
279
+ org_id: string;
280
+ project_id: string;
281
+ event_id: string;
282
+ variant_id: string;
283
+ experiment_id: string;
284
+ session_id: string;
285
+ url: string;
286
+ monitoring_type: string;
287
+ local_time: string;
288
+ metadata: Record<string, unknown>;
289
+ variant_ids?: string[];
290
+ };
291
+
292
+ interface TreatmentAppliedHandlers {
293
+ callback?: (data: TreatmentData) => void;
294
+ bulkCallback?: (data: TreatmentData[]) => void;
295
+ bulkCallbackV2?: (data: TreatmentDataV2[], rawIds: ExperimentInfo[]) => void;
296
+ }
297
+ declare function setConsent(enabled: boolean): void;
298
+ declare function setUserToken(token: string): void;
299
+ declare function setFeatureFlag(enabled: boolean): void;
300
+ declare function setPageHydrated(): void;
301
+ declare function trackConversion(payload: ConversionEventPayload): void;
302
+ declare function onTreatmentApplied(handlers: TreatmentAppliedHandlers): void;
303
+ declare function onLog(cb: (payload: LogPayload) => void): void;
304
+
305
+ declare function init(options?: CoframeInitOptions): Promise<void>;
306
+
307
+ export { init, onLog, onTreatmentApplied, setConsent, setFeatureFlag, setPageHydrated, setUserToken, trackConversion };
308
+ export type { CoframeConfig, CoframeInitOptions, ConversionEventPayload, ExperimentInfo, LogPayload, PersonalizationHeaders, Project, ProjectData, TreatmentAppliedHandlers, TreatmentData, TreatmentDataV2 };