@sprig-technologies/sprig-browser 2.22.4 → 2.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +11 -10
- package/dist/index.d.ts +187 -3
- package/dist/index.js +4068 -2417
- 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
|
};
|
|
@@ -682,6 +855,7 @@ interface Config {
|
|
|
682
855
|
interactiveEvents: InteractiveEvent[];
|
|
683
856
|
interactiveEventsHandler?: (e: MouseEvent) => void;
|
|
684
857
|
isPreview?: boolean;
|
|
858
|
+
launchDarklyEnabled?: boolean;
|
|
685
859
|
locale: string;
|
|
686
860
|
marketingUrl?: string;
|
|
687
861
|
maxAttrNameLength: number;
|
|
@@ -692,7 +866,7 @@ interface Config {
|
|
|
692
866
|
mobileSDKVersion: undefined;
|
|
693
867
|
mode?: string;
|
|
694
868
|
mute?: boolean;
|
|
695
|
-
optimizelyEnabled
|
|
869
|
+
optimizelyEnabled?: boolean;
|
|
696
870
|
overlayStyle: "light";
|
|
697
871
|
overlayStyleMobile: "none";
|
|
698
872
|
pageUrlEvents: PageUrlEvent[];
|
|
@@ -728,6 +902,11 @@ declare enum SurveyState {
|
|
|
728
902
|
NoSurvey = "no survey"
|
|
729
903
|
}
|
|
730
904
|
|
|
905
|
+
interface Experiment {
|
|
906
|
+
id: string;
|
|
907
|
+
variation?: string;
|
|
908
|
+
}
|
|
909
|
+
|
|
731
910
|
declare type QueueItem = [string, ...unknown[]] | (() => void);
|
|
732
911
|
declare class SprigQueue {
|
|
733
912
|
paused: boolean;
|
|
@@ -855,7 +1034,12 @@ declare namespace sprigConfig {
|
|
|
855
1034
|
userId?: string;
|
|
856
1035
|
}) => IdentifyResult;
|
|
857
1036
|
identifyAndTrack: (payload: TrackPayload) => IdentifyResult;
|
|
858
|
-
|
|
1037
|
+
importLaunchDarklyData: (data: Record<string, number>) => void;
|
|
1038
|
+
integrateOptimizely: (
|
|
1039
|
+
strData: string | { experiments: Experiment[] },
|
|
1040
|
+
isOverride?: boolean
|
|
1041
|
+
) => void;
|
|
1042
|
+
integrateOptimizelyClient: (client: Client) => void;
|
|
859
1043
|
logoutUser: () => void;
|
|
860
1044
|
mute: () => void;
|
|
861
1045
|
previewSurvey: (surveyTemplateId: UUID) => void;
|
|
@@ -926,7 +1110,7 @@ declare namespace sprigConfig {
|
|
|
926
1110
|
nonce?: string;
|
|
927
1111
|
partnerAnonymousId: string | null;
|
|
928
1112
|
replayNonce?: string;
|
|
929
|
-
reportError: (name: string, err: Error) => void;
|
|
1113
|
+
reportError: (name: string, err: Error, extraInfo?: object) => void;
|
|
930
1114
|
sampleRate?: unknown; // TODO: determine type
|
|
931
1115
|
token: string | null;
|
|
932
1116
|
UPDATES: typeof EVENTS;
|