@sprig-technologies/sprig-browser 2.23.0 → 2.23.2
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/index.cjs +28 -10
- package/dist/index.d.ts +184 -1
- package/dist/index.js +8426 -3434
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,176 @@
|
|
|
1
|
+
declare enum NOTIFICATION_TYPES {
|
|
2
|
+
ACTIVATE = "ACTIVATE:experiment, user_id,attributes, variation, event",
|
|
3
|
+
DECISION = "DECISION:type, userId, attributes, decisionInfo",
|
|
4
|
+
LOG_EVENT = "LOG_EVENT:logEvent",
|
|
5
|
+
OPTIMIZELY_CONFIG_UPDATE = "OPTIMIZELY_CONFIG_UPDATE",
|
|
6
|
+
TRACK = "TRACK:event_key, user_id, attributes, event_tags, event"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare type UserAttributes = {
|
|
10
|
+
[name: string]: any;
|
|
11
|
+
};
|
|
12
|
+
declare type EventTags = {
|
|
13
|
+
[key: string]: string | number | null;
|
|
14
|
+
};
|
|
15
|
+
interface ListenerPayload {
|
|
16
|
+
userId: string;
|
|
17
|
+
attributes?: UserAttributes;
|
|
18
|
+
}
|
|
19
|
+
declare type NotificationListener<T extends ListenerPayload> = (notificationData: T) => void;
|
|
20
|
+
interface NotificationCenter {
|
|
21
|
+
addNotificationListener<T extends ListenerPayload>(notificationType: string, callback: NotificationListener<T>): number;
|
|
22
|
+
removeNotificationListener(listenerId: number): boolean;
|
|
23
|
+
clearAllNotificationListeners(): void;
|
|
24
|
+
clearNotificationListeners(notificationType: NOTIFICATION_TYPES): void;
|
|
25
|
+
}
|
|
26
|
+
declare enum OptimizelyDecideOption {
|
|
27
|
+
DISABLE_DECISION_EVENT = "DISABLE_DECISION_EVENT",
|
|
28
|
+
ENABLED_FLAGS_ONLY = "ENABLED_FLAGS_ONLY",
|
|
29
|
+
IGNORE_USER_PROFILE_SERVICE = "IGNORE_USER_PROFILE_SERVICE",
|
|
30
|
+
INCLUDE_REASONS = "INCLUDE_REASONS",
|
|
31
|
+
EXCLUDE_VARIABLES = "EXCLUDE_VARIABLES"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Optimizely Config Entities
|
|
35
|
+
*/
|
|
36
|
+
interface OptimizelyExperiment {
|
|
37
|
+
id: string;
|
|
38
|
+
key: string;
|
|
39
|
+
audiences: string;
|
|
40
|
+
variationsMap: {
|
|
41
|
+
[variationKey: string]: OptimizelyVariation;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface OptimizelyVariable {
|
|
45
|
+
id: string;
|
|
46
|
+
key: string;
|
|
47
|
+
type: string;
|
|
48
|
+
value: string;
|
|
49
|
+
}
|
|
50
|
+
interface Client {
|
|
51
|
+
notificationCenter: NotificationCenter;
|
|
52
|
+
createUserContext(userId: string, attributes?: UserAttributes): OptimizelyUserContext | null;
|
|
53
|
+
activate(experimentKey: string, userId: string, attributes?: UserAttributes): string | null;
|
|
54
|
+
track(eventKey: string, userId: string, attributes?: UserAttributes, eventTags?: EventTags): void;
|
|
55
|
+
getVariation(experimentKey: string, userId: string, attributes?: UserAttributes): string | null;
|
|
56
|
+
setForcedVariation(experimentKey: string, userId: string, variationKey: string | null): boolean;
|
|
57
|
+
getForcedVariation(experimentKey: string, userId: string): string | null;
|
|
58
|
+
isFeatureEnabled(featureKey: string, userId: string, attributes?: UserAttributes): boolean;
|
|
59
|
+
getEnabledFeatures(userId: string, attributes?: UserAttributes): string[];
|
|
60
|
+
getFeatureVariable(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): unknown;
|
|
61
|
+
getFeatureVariableBoolean(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): boolean | null;
|
|
62
|
+
getFeatureVariableDouble(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): number | null;
|
|
63
|
+
getFeatureVariableInteger(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): number | null;
|
|
64
|
+
getFeatureVariableString(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): string | null;
|
|
65
|
+
getFeatureVariableJSON(featureKey: string, variableKey: string, userId: string, attributes?: UserAttributes): unknown;
|
|
66
|
+
getAllFeatureVariables(featureKey: string, userId: string, attributes?: UserAttributes): {
|
|
67
|
+
[variableKey: string]: unknown;
|
|
68
|
+
} | null;
|
|
69
|
+
getOptimizelyConfig(): OptimizelyConfig | null;
|
|
70
|
+
onReady(options?: {
|
|
71
|
+
timeout?: number;
|
|
72
|
+
}): Promise<{
|
|
73
|
+
success: boolean;
|
|
74
|
+
reason?: string;
|
|
75
|
+
}>;
|
|
76
|
+
close(): Promise<{
|
|
77
|
+
success: boolean;
|
|
78
|
+
reason?: string;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
declare type OptimizelyExperimentsMap = {
|
|
82
|
+
[experimentKey: string]: OptimizelyExperiment;
|
|
83
|
+
};
|
|
84
|
+
declare type OptimizelyVariablesMap = {
|
|
85
|
+
[variableKey: string]: OptimizelyVariable;
|
|
86
|
+
};
|
|
87
|
+
declare type OptimizelyFeaturesMap = {
|
|
88
|
+
[featureKey: string]: OptimizelyFeature;
|
|
89
|
+
};
|
|
90
|
+
declare type OptimizelyAttribute = {
|
|
91
|
+
id: string;
|
|
92
|
+
key: string;
|
|
93
|
+
};
|
|
94
|
+
declare type OptimizelyAudience = {
|
|
95
|
+
id: string;
|
|
96
|
+
name: string;
|
|
97
|
+
conditions: string;
|
|
98
|
+
};
|
|
99
|
+
declare type OptimizelyEvent = {
|
|
100
|
+
id: string;
|
|
101
|
+
key: string;
|
|
102
|
+
experimentsIds: string[];
|
|
103
|
+
};
|
|
104
|
+
interface OptimizelyFeature {
|
|
105
|
+
id: string;
|
|
106
|
+
key: string;
|
|
107
|
+
experimentRules: OptimizelyExperiment[];
|
|
108
|
+
deliveryRules: OptimizelyExperiment[];
|
|
109
|
+
variablesMap: OptimizelyVariablesMap;
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Use experimentRules and deliveryRules
|
|
112
|
+
*/
|
|
113
|
+
experimentsMap: OptimizelyExperimentsMap;
|
|
114
|
+
}
|
|
115
|
+
interface OptimizelyVariation {
|
|
116
|
+
id: string;
|
|
117
|
+
key: string;
|
|
118
|
+
featureEnabled?: boolean;
|
|
119
|
+
variablesMap: OptimizelyVariablesMap;
|
|
120
|
+
}
|
|
121
|
+
interface OptimizelyConfig {
|
|
122
|
+
environmentKey: string;
|
|
123
|
+
sdkKey: string;
|
|
124
|
+
revision: string;
|
|
125
|
+
/**
|
|
126
|
+
* This experimentsMap is for experiments of legacy projects only.
|
|
127
|
+
* For flag projects, experiment keys are not guaranteed to be unique
|
|
128
|
+
* across multiple flags, so this map may not include all experiments
|
|
129
|
+
* when keys conflict.
|
|
130
|
+
*/
|
|
131
|
+
experimentsMap: OptimizelyExperimentsMap;
|
|
132
|
+
featuresMap: OptimizelyFeaturesMap;
|
|
133
|
+
attributes: OptimizelyAttribute[];
|
|
134
|
+
audiences: OptimizelyAudience[];
|
|
135
|
+
events: OptimizelyEvent[];
|
|
136
|
+
getDatafile(): string;
|
|
137
|
+
}
|
|
138
|
+
interface OptimizelyUserContext {
|
|
139
|
+
getUserId(): string;
|
|
140
|
+
getAttributes(): UserAttributes;
|
|
141
|
+
setAttribute(key: string, value: unknown): void;
|
|
142
|
+
decide(key: string, options?: OptimizelyDecideOption[]): OptimizelyDecision;
|
|
143
|
+
decideForKeys(keys: string[], options?: OptimizelyDecideOption[]): {
|
|
144
|
+
[key: string]: OptimizelyDecision;
|
|
145
|
+
};
|
|
146
|
+
decideAll(options?: OptimizelyDecideOption[]): {
|
|
147
|
+
[key: string]: OptimizelyDecision;
|
|
148
|
+
};
|
|
149
|
+
trackEvent(eventName: string, eventTags?: EventTags): void;
|
|
150
|
+
setForcedDecision(context: OptimizelyDecisionContext, decision: OptimizelyForcedDecision): boolean;
|
|
151
|
+
getForcedDecision(context: OptimizelyDecisionContext): OptimizelyForcedDecision | null;
|
|
152
|
+
removeForcedDecision(context: OptimizelyDecisionContext): boolean;
|
|
153
|
+
removeAllForcedDecisions(): boolean;
|
|
154
|
+
}
|
|
155
|
+
interface OptimizelyDecision {
|
|
156
|
+
variationKey: string | null;
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
variables: {
|
|
159
|
+
[variableKey: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
ruleKey: string | null;
|
|
162
|
+
flagKey: string;
|
|
163
|
+
userContext: OptimizelyUserContext;
|
|
164
|
+
reasons: string[];
|
|
165
|
+
}
|
|
166
|
+
interface OptimizelyDecisionContext {
|
|
167
|
+
flagKey: string;
|
|
168
|
+
ruleKey?: string;
|
|
169
|
+
}
|
|
170
|
+
interface OptimizelyForcedDecision {
|
|
171
|
+
variationKey: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
1
174
|
declare type EventMap = {
|
|
2
175
|
[eventName: string]: Array<unknown>;
|
|
3
176
|
};
|
|
@@ -699,6 +872,7 @@ interface Config {
|
|
|
699
872
|
pageUrlEvents: PageUrlEvent[];
|
|
700
873
|
path?: string;
|
|
701
874
|
platform?: Platform;
|
|
875
|
+
previewKey?: string | null;
|
|
702
876
|
replayNonce?: string;
|
|
703
877
|
replaySettings?: object;
|
|
704
878
|
requireUserIdForTracking: boolean;
|
|
@@ -729,6 +903,11 @@ declare enum SurveyState {
|
|
|
729
903
|
NoSurvey = "no survey"
|
|
730
904
|
}
|
|
731
905
|
|
|
906
|
+
interface Experiment {
|
|
907
|
+
id: string;
|
|
908
|
+
variation?: string;
|
|
909
|
+
}
|
|
910
|
+
|
|
732
911
|
declare type QueueItem = [string, ...unknown[]] | (() => void);
|
|
733
912
|
declare class SprigQueue {
|
|
734
913
|
paused: boolean;
|
|
@@ -857,7 +1036,11 @@ declare namespace sprigConfig {
|
|
|
857
1036
|
}) => IdentifyResult;
|
|
858
1037
|
identifyAndTrack: (payload: TrackPayload) => IdentifyResult;
|
|
859
1038
|
importLaunchDarklyData: (data: Record<string, number>) => void;
|
|
860
|
-
integrateOptimizely: (
|
|
1039
|
+
integrateOptimizely: (
|
|
1040
|
+
strData: string | { experiments: Experiment[] },
|
|
1041
|
+
isOverride?: boolean
|
|
1042
|
+
) => void;
|
|
1043
|
+
integrateOptimizelyClient: (client: Client) => void;
|
|
861
1044
|
logoutUser: () => void;
|
|
862
1045
|
mute: () => void;
|
|
863
1046
|
previewSurvey: (surveyTemplateId: UUID) => void;
|