@hackler/react-sdk 11.43.0 → 11.44.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/lib/client.d.ts +20 -16
- package/lib/client.d.ts.map +1 -1
- package/lib/index.es.js +118 -16
- package/lib/index.js +118 -16
- package/lib/index.umd.js +1 -1
- package/package.json +2 -2
package/lib/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Decision, FeatureFlagDecision, HackleEvent, HackleRemoteConfig, HackleUserExplorerBase, PageView, User, PropertyOperations, HackleInAppMessageListener } from "@hackler/javascript-sdk";
|
|
1
|
+
import { Decision, FeatureFlagDecision, HackleClient, HackleEvent, HackleRemoteConfig, HackleUserExplorerBase, PageView, User, PropertyOperations, HackleInAppMessageListener, Properties, HackleExperiment } from "@hackler/javascript-sdk";
|
|
2
2
|
import { Emitter } from "./emitter";
|
|
3
3
|
interface Config {
|
|
4
4
|
user?: User;
|
|
@@ -17,23 +17,25 @@ interface Config {
|
|
|
17
17
|
interface HackleReactSDKClientEventMap {
|
|
18
18
|
"user-updated": User | null;
|
|
19
19
|
}
|
|
20
|
-
export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEventMap> {
|
|
20
|
+
export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEventMap> implements HackleClient {
|
|
21
21
|
private client;
|
|
22
22
|
private _currentUser;
|
|
23
23
|
constructor(sdkKey: string, config?: Config);
|
|
24
|
+
getSessionId(): string;
|
|
24
25
|
getUser(): User;
|
|
25
|
-
setUser(user: User): void
|
|
26
|
-
setUserId(userId: string | undefined): void
|
|
27
|
-
setDeviceId(deviceId: string): void
|
|
28
|
-
setUserProperty(key: string, value: any): void
|
|
26
|
+
setUser(user: User): Promise<void>;
|
|
27
|
+
setUserId(userId: string | undefined): Promise<void>;
|
|
28
|
+
setDeviceId(deviceId: string): Promise<void>;
|
|
29
|
+
setUserProperty(key: string, value: any): Promise<void>;
|
|
30
|
+
setUserProperties(properties: Properties<string>): Promise<void>;
|
|
29
31
|
/**
|
|
30
32
|
* Updates the user's properties.
|
|
31
33
|
*
|
|
32
34
|
* @param operations Property operations to update user properties.
|
|
33
35
|
*
|
|
34
36
|
*/
|
|
35
|
-
updateUserProperties(operations: PropertyOperations): void
|
|
36
|
-
resetUser(): void
|
|
37
|
+
updateUserProperties(operations: PropertyOperations): Promise<void>;
|
|
38
|
+
resetUser(): Promise<void>;
|
|
37
39
|
/**
|
|
38
40
|
* Determine the variation to expose to the user for experiment.
|
|
39
41
|
*
|
|
@@ -49,7 +51,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
49
51
|
*
|
|
50
52
|
* @return string the decided variation for the user, or the default variation.
|
|
51
53
|
*/
|
|
52
|
-
variation(experimentKey: number, user?: User | null, defaultVariation?: string): string;
|
|
54
|
+
variation(experimentKey: number, user?: User | string | null, defaultVariation?: string): string;
|
|
53
55
|
/**
|
|
54
56
|
* Determine the variation to expose to the user for experiment, and returns an object that
|
|
55
57
|
* describes the way the variation was determined.
|
|
@@ -60,7 +62,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
60
62
|
*
|
|
61
63
|
* @return {Decision} object
|
|
62
64
|
*/
|
|
63
|
-
variationDetail(experimentKey: number, user?: User | null, defaultVariation?: string): Decision;
|
|
65
|
+
variationDetail(experimentKey: number, user?: User | string | null, defaultVariation?: string): Decision;
|
|
64
66
|
/**
|
|
65
67
|
* Determine whether the feature is turned on to the user.
|
|
66
68
|
*
|
|
@@ -71,7 +73,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
71
73
|
*
|
|
72
74
|
* @since 2.0.0
|
|
73
75
|
*/
|
|
74
|
-
isFeatureOn(featureKey: number, user?: User | null): boolean;
|
|
76
|
+
isFeatureOn(featureKey: number, user?: User | string | null): boolean;
|
|
75
77
|
/**
|
|
76
78
|
* Determine whether the feature is turned on to the user, and returns an object that
|
|
77
79
|
* describes the way the value was determined.
|
|
@@ -83,22 +85,23 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
83
85
|
*
|
|
84
86
|
* @since 2.0.0
|
|
85
87
|
*/
|
|
86
|
-
featureFlagDetail(featureKey: number, user?: User | null): FeatureFlagDecision;
|
|
88
|
+
featureFlagDetail(featureKey: number, user?: User | string | null): FeatureFlagDecision;
|
|
87
89
|
/**
|
|
88
90
|
* Records the event performed by the user.
|
|
89
91
|
*
|
|
90
92
|
* @param event the unique key of the event. MUST NOT be null.
|
|
91
93
|
* @param user the identifier of user that performed the event. id MUST NOT be null. (e.g. { id: "userId"} )
|
|
92
94
|
*/
|
|
93
|
-
track(event: string | HackleEvent, user?: User | null): void;
|
|
95
|
+
track(event: string | HackleEvent, user?: User | string | null): void;
|
|
94
96
|
trackPageView(option?: PageView): void;
|
|
95
97
|
/**
|
|
96
98
|
* Return a instance of Hackle Remote Config.
|
|
97
99
|
*
|
|
98
100
|
* @param user the identifier of user.
|
|
99
101
|
*/
|
|
100
|
-
remoteConfig(user?: User | null): HackleRemoteConfig;
|
|
102
|
+
remoteConfig(user?: User | string | null): HackleRemoteConfig;
|
|
101
103
|
onReady(cb: any, timeout?: number): void;
|
|
104
|
+
getExperiment(experimentKey: number): HackleExperiment | undefined;
|
|
102
105
|
onInitialized(config?: {
|
|
103
106
|
timeout: number;
|
|
104
107
|
}): Promise<{
|
|
@@ -109,16 +112,17 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
109
112
|
hideUserExplorer(): void;
|
|
110
113
|
fetch(): Promise<void>;
|
|
111
114
|
setInAppMessageListener(listener: HackleInAppMessageListener | null): void;
|
|
115
|
+
close(): void;
|
|
112
116
|
/**
|
|
113
117
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
114
118
|
*
|
|
115
119
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
116
120
|
*/
|
|
117
|
-
setPhoneNumber(phoneNumber: string): void
|
|
121
|
+
setPhoneNumber(phoneNumber: string): Promise<void>;
|
|
118
122
|
/**
|
|
119
123
|
* Reset user's phone number to be an empty value.
|
|
120
124
|
*/
|
|
121
|
-
unsetPhoneNumber(): void
|
|
125
|
+
unsetPhoneNumber(): Promise<void>;
|
|
122
126
|
}
|
|
123
127
|
export declare function createInstance(sdkKey: string, config?: Config): HackleReactSDKClient;
|
|
124
128
|
export {};
|
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,0BAA0B,EAC1B,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,UAAU,MAAM;IACd,IAAI,CAAC,EAAE,IAAI,CAAA;IAEX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,gCAAgC,CAAC,EAAE,MAAM,CAAA;IACzC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;QAAC,KAAK,IAAI,IAAI,CAAA;KAAE,CAAA;IACrF,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED,UAAU,4BAA4B;IAC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
|
return __assign.apply(this, arguments);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
50
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
51
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
52
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
53
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
54
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
55
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function __generator(thisArg, body) {
|
|
60
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
61
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
62
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
63
|
+
function step(op) {
|
|
64
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
65
|
+
while (_) try {
|
|
66
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
68
|
+
switch (op[0]) {
|
|
69
|
+
case 0: case 1: t = op; break;
|
|
70
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
71
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
72
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
73
|
+
default:
|
|
74
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
75
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
76
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
77
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
78
|
+
if (t[2]) _.ops.pop();
|
|
79
|
+
_.trys.pop(); continue;
|
|
80
|
+
}
|
|
81
|
+
op = body.call(thisArg, _);
|
|
82
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
83
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
49
87
|
function __read(o, n) {
|
|
50
88
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
89
|
if (!m) return o;
|
|
@@ -64,7 +102,7 @@ function __read(o, n) {
|
|
|
64
102
|
}
|
|
65
103
|
|
|
66
104
|
var SDK_NAME_HEADER = "react-sdk";
|
|
67
|
-
var SDK_VERSION_HEADER = "11.
|
|
105
|
+
var SDK_VERSION_HEADER = "11.44.0" ;
|
|
68
106
|
|
|
69
107
|
var Emitter = /** @class */ (function () {
|
|
70
108
|
function Emitter() {
|
|
@@ -128,11 +166,13 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
128
166
|
_this._currentUser = null;
|
|
129
167
|
_this.client = Hackle.createInstance(sdkKey, __assign(__assign({}, config), { SDK_NAME_HEADER: SDK_NAME_HEADER, SDK_VERSION_HEADER: SDK_VERSION_HEADER }));
|
|
130
168
|
// This is to prevent the "This Binding" problem.
|
|
169
|
+
_this.getSessionId = _this.getSessionId.bind(_this);
|
|
131
170
|
_this.getUser = _this.getUser.bind(_this);
|
|
132
171
|
_this.setUser = _this.setUser.bind(_this);
|
|
133
172
|
_this.setUserId = _this.setUserId.bind(_this);
|
|
134
173
|
_this.setDeviceId = _this.setDeviceId.bind(_this);
|
|
135
174
|
_this.setUserProperty = _this.setUserProperty.bind(_this);
|
|
175
|
+
_this.setUserProperties = _this.setUserProperties.bind(_this);
|
|
136
176
|
_this.updateUserProperties = _this.updateUserProperties.bind(_this);
|
|
137
177
|
_this.resetUser = _this.resetUser.bind(_this);
|
|
138
178
|
_this.variation = _this.variation.bind(_this);
|
|
@@ -144,34 +184,70 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
144
184
|
_this.remoteConfig = _this.remoteConfig.bind(_this);
|
|
145
185
|
_this.onReady = _this.onReady.bind(_this);
|
|
146
186
|
_this.onInitialized = _this.onInitialized.bind(_this);
|
|
147
|
-
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
148
187
|
_this.showUserExplorer = _this.showUserExplorer.bind(_this);
|
|
149
188
|
_this.hideUserExplorer = _this.hideUserExplorer.bind(_this);
|
|
150
189
|
_this.fetch = _this.fetch.bind(_this);
|
|
190
|
+
_this.close = _this.close.bind(_this);
|
|
151
191
|
_this.setInAppMessageListener = _this.setInAppMessageListener.bind(_this);
|
|
192
|
+
_this.getExperiment = _this.getExperiment.bind(_this);
|
|
193
|
+
_this.setPhoneNumber = _this.setPhoneNumber.bind(_this);
|
|
194
|
+
_this.unsetPhoneNumber = _this.unsetPhoneNumber.bind(_this);
|
|
195
|
+
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
152
196
|
if ((config === null || config === void 0 ? void 0 : config.devTool) && (config === null || config === void 0 ? void 0 : config.autoOpenDevTool) && typeof window !== "undefined") {
|
|
153
197
|
_this.showUserExplorer();
|
|
154
198
|
}
|
|
155
199
|
return _this;
|
|
156
200
|
}
|
|
201
|
+
HackleReactSDKClient.prototype.getSessionId = function () {
|
|
202
|
+
return this.client.getSessionId();
|
|
203
|
+
};
|
|
157
204
|
HackleReactSDKClient.prototype.getUser = function () {
|
|
158
205
|
return this.client.getUser();
|
|
159
206
|
};
|
|
160
207
|
HackleReactSDKClient.prototype.setUser = function (user) {
|
|
161
|
-
this
|
|
162
|
-
|
|
208
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
this.client.setUser(user);
|
|
211
|
+
this.emitUpdatedUser(this.getUser());
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
});
|
|
214
|
+
});
|
|
163
215
|
};
|
|
164
216
|
HackleReactSDKClient.prototype.setUserId = function (userId) {
|
|
165
|
-
this
|
|
166
|
-
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
this.client.setUserId(userId);
|
|
220
|
+
this.emitUpdatedUser(this.getUser());
|
|
221
|
+
return [2 /*return*/];
|
|
222
|
+
});
|
|
223
|
+
});
|
|
167
224
|
};
|
|
168
225
|
HackleReactSDKClient.prototype.setDeviceId = function (deviceId) {
|
|
169
|
-
this
|
|
170
|
-
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
this.client.setDeviceId(deviceId);
|
|
229
|
+
this.emitUpdatedUser(this.getUser());
|
|
230
|
+
return [2 /*return*/];
|
|
231
|
+
});
|
|
232
|
+
});
|
|
171
233
|
};
|
|
172
234
|
HackleReactSDKClient.prototype.setUserProperty = function (key, value) {
|
|
173
|
-
this
|
|
174
|
-
|
|
235
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
236
|
+
return __generator(this, function (_a) {
|
|
237
|
+
this.client.setUserProperty(key, value);
|
|
238
|
+
this.emitUpdatedUser(this.getUser());
|
|
239
|
+
return [2 /*return*/];
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
HackleReactSDKClient.prototype.setUserProperties = function (properties) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
245
|
+
return __generator(this, function (_a) {
|
|
246
|
+
this.client.setUserProperties(properties);
|
|
247
|
+
this.emitUpdatedUser(this.getUser());
|
|
248
|
+
return [2 /*return*/];
|
|
249
|
+
});
|
|
250
|
+
});
|
|
175
251
|
};
|
|
176
252
|
/**
|
|
177
253
|
* Updates the user's properties.
|
|
@@ -180,12 +256,22 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
180
256
|
*
|
|
181
257
|
*/
|
|
182
258
|
HackleReactSDKClient.prototype.updateUserProperties = function (operations) {
|
|
183
|
-
this
|
|
184
|
-
|
|
259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
this.client.updateUserProperties(operations);
|
|
262
|
+
this.emitUpdatedUser(this.getUser());
|
|
263
|
+
return [2 /*return*/];
|
|
264
|
+
});
|
|
265
|
+
});
|
|
185
266
|
};
|
|
186
267
|
HackleReactSDKClient.prototype.resetUser = function () {
|
|
187
|
-
this
|
|
188
|
-
|
|
268
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
+
return __generator(this, function (_a) {
|
|
270
|
+
this.client.resetUser();
|
|
271
|
+
this.emitUpdatedUser(this.getUser());
|
|
272
|
+
return [2 /*return*/];
|
|
273
|
+
});
|
|
274
|
+
});
|
|
189
275
|
};
|
|
190
276
|
/**
|
|
191
277
|
* Determine the variation to expose to the user for experiment.
|
|
@@ -268,6 +354,9 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
268
354
|
HackleReactSDKClient.prototype.onReady = function (cb, timeout) {
|
|
269
355
|
this.client.onReady(cb, timeout);
|
|
270
356
|
};
|
|
357
|
+
HackleReactSDKClient.prototype.getExperiment = function (experimentKey) {
|
|
358
|
+
return this.client.getExperiment(experimentKey);
|
|
359
|
+
};
|
|
271
360
|
HackleReactSDKClient.prototype.onInitialized = function (config) {
|
|
272
361
|
return this.client.onInitialized(config);
|
|
273
362
|
};
|
|
@@ -289,19 +378,32 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
289
378
|
HackleReactSDKClient.prototype.setInAppMessageListener = function (listener) {
|
|
290
379
|
this.client.setInAppMessageListener(listener);
|
|
291
380
|
};
|
|
381
|
+
HackleReactSDKClient.prototype.close = function () {
|
|
382
|
+
this.client.close();
|
|
383
|
+
};
|
|
292
384
|
/**
|
|
293
385
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
294
386
|
*
|
|
295
387
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
296
388
|
*/
|
|
297
389
|
HackleReactSDKClient.prototype.setPhoneNumber = function (phoneNumber) {
|
|
298
|
-
this
|
|
390
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
391
|
+
return __generator(this, function (_a) {
|
|
392
|
+
this.client.setPhoneNumber(phoneNumber);
|
|
393
|
+
return [2 /*return*/];
|
|
394
|
+
});
|
|
395
|
+
});
|
|
299
396
|
};
|
|
300
397
|
/**
|
|
301
398
|
* Reset user's phone number to be an empty value.
|
|
302
399
|
*/
|
|
303
400
|
HackleReactSDKClient.prototype.unsetPhoneNumber = function () {
|
|
304
|
-
this
|
|
401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
402
|
+
return __generator(this, function (_a) {
|
|
403
|
+
this.client.unsetPhoneNumber();
|
|
404
|
+
return [2 /*return*/];
|
|
405
|
+
});
|
|
406
|
+
});
|
|
305
407
|
};
|
|
306
408
|
return HackleReactSDKClient;
|
|
307
409
|
}(Emitter));
|
package/lib/index.js
CHANGED
|
@@ -71,6 +71,44 @@ var __assign = function() {
|
|
|
71
71
|
return __assign.apply(this, arguments);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
75
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
76
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
77
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
78
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
79
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
80
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function __generator(thisArg, body) {
|
|
85
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
86
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
87
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
88
|
+
function step(op) {
|
|
89
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
90
|
+
while (_) try {
|
|
91
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
92
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
93
|
+
switch (op[0]) {
|
|
94
|
+
case 0: case 1: t = op; break;
|
|
95
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
96
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
97
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
98
|
+
default:
|
|
99
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
100
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
101
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
102
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
103
|
+
if (t[2]) _.ops.pop();
|
|
104
|
+
_.trys.pop(); continue;
|
|
105
|
+
}
|
|
106
|
+
op = body.call(thisArg, _);
|
|
107
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
108
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
74
112
|
function __read(o, n) {
|
|
75
113
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
76
114
|
if (!m) return o;
|
|
@@ -89,7 +127,7 @@ function __read(o, n) {
|
|
|
89
127
|
}
|
|
90
128
|
|
|
91
129
|
var SDK_NAME_HEADER = "react-sdk";
|
|
92
|
-
var SDK_VERSION_HEADER = "11.
|
|
130
|
+
var SDK_VERSION_HEADER = "11.44.0" ;
|
|
93
131
|
|
|
94
132
|
var Emitter = /** @class */ (function () {
|
|
95
133
|
function Emitter() {
|
|
@@ -153,11 +191,13 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
153
191
|
_this._currentUser = null;
|
|
154
192
|
_this.client = Hackle__namespace.createInstance(sdkKey, __assign(__assign({}, config), { SDK_NAME_HEADER: SDK_NAME_HEADER, SDK_VERSION_HEADER: SDK_VERSION_HEADER }));
|
|
155
193
|
// This is to prevent the "This Binding" problem.
|
|
194
|
+
_this.getSessionId = _this.getSessionId.bind(_this);
|
|
156
195
|
_this.getUser = _this.getUser.bind(_this);
|
|
157
196
|
_this.setUser = _this.setUser.bind(_this);
|
|
158
197
|
_this.setUserId = _this.setUserId.bind(_this);
|
|
159
198
|
_this.setDeviceId = _this.setDeviceId.bind(_this);
|
|
160
199
|
_this.setUserProperty = _this.setUserProperty.bind(_this);
|
|
200
|
+
_this.setUserProperties = _this.setUserProperties.bind(_this);
|
|
161
201
|
_this.updateUserProperties = _this.updateUserProperties.bind(_this);
|
|
162
202
|
_this.resetUser = _this.resetUser.bind(_this);
|
|
163
203
|
_this.variation = _this.variation.bind(_this);
|
|
@@ -169,34 +209,70 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
169
209
|
_this.remoteConfig = _this.remoteConfig.bind(_this);
|
|
170
210
|
_this.onReady = _this.onReady.bind(_this);
|
|
171
211
|
_this.onInitialized = _this.onInitialized.bind(_this);
|
|
172
|
-
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
173
212
|
_this.showUserExplorer = _this.showUserExplorer.bind(_this);
|
|
174
213
|
_this.hideUserExplorer = _this.hideUserExplorer.bind(_this);
|
|
175
214
|
_this.fetch = _this.fetch.bind(_this);
|
|
215
|
+
_this.close = _this.close.bind(_this);
|
|
176
216
|
_this.setInAppMessageListener = _this.setInAppMessageListener.bind(_this);
|
|
217
|
+
_this.getExperiment = _this.getExperiment.bind(_this);
|
|
218
|
+
_this.setPhoneNumber = _this.setPhoneNumber.bind(_this);
|
|
219
|
+
_this.unsetPhoneNumber = _this.unsetPhoneNumber.bind(_this);
|
|
220
|
+
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
177
221
|
if ((config === null || config === void 0 ? void 0 : config.devTool) && (config === null || config === void 0 ? void 0 : config.autoOpenDevTool) && typeof window !== "undefined") {
|
|
178
222
|
_this.showUserExplorer();
|
|
179
223
|
}
|
|
180
224
|
return _this;
|
|
181
225
|
}
|
|
226
|
+
HackleReactSDKClient.prototype.getSessionId = function () {
|
|
227
|
+
return this.client.getSessionId();
|
|
228
|
+
};
|
|
182
229
|
HackleReactSDKClient.prototype.getUser = function () {
|
|
183
230
|
return this.client.getUser();
|
|
184
231
|
};
|
|
185
232
|
HackleReactSDKClient.prototype.setUser = function (user) {
|
|
186
|
-
this
|
|
187
|
-
|
|
233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
this.client.setUser(user);
|
|
236
|
+
this.emitUpdatedUser(this.getUser());
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
});
|
|
239
|
+
});
|
|
188
240
|
};
|
|
189
241
|
HackleReactSDKClient.prototype.setUserId = function (userId) {
|
|
190
|
-
this
|
|
191
|
-
|
|
242
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
this.client.setUserId(userId);
|
|
245
|
+
this.emitUpdatedUser(this.getUser());
|
|
246
|
+
return [2 /*return*/];
|
|
247
|
+
});
|
|
248
|
+
});
|
|
192
249
|
};
|
|
193
250
|
HackleReactSDKClient.prototype.setDeviceId = function (deviceId) {
|
|
194
|
-
this
|
|
195
|
-
|
|
251
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
+
return __generator(this, function (_a) {
|
|
253
|
+
this.client.setDeviceId(deviceId);
|
|
254
|
+
this.emitUpdatedUser(this.getUser());
|
|
255
|
+
return [2 /*return*/];
|
|
256
|
+
});
|
|
257
|
+
});
|
|
196
258
|
};
|
|
197
259
|
HackleReactSDKClient.prototype.setUserProperty = function (key, value) {
|
|
198
|
-
this
|
|
199
|
-
|
|
260
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
+
return __generator(this, function (_a) {
|
|
262
|
+
this.client.setUserProperty(key, value);
|
|
263
|
+
this.emitUpdatedUser(this.getUser());
|
|
264
|
+
return [2 /*return*/];
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
HackleReactSDKClient.prototype.setUserProperties = function (properties) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
270
|
+
return __generator(this, function (_a) {
|
|
271
|
+
this.client.setUserProperties(properties);
|
|
272
|
+
this.emitUpdatedUser(this.getUser());
|
|
273
|
+
return [2 /*return*/];
|
|
274
|
+
});
|
|
275
|
+
});
|
|
200
276
|
};
|
|
201
277
|
/**
|
|
202
278
|
* Updates the user's properties.
|
|
@@ -205,12 +281,22 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
205
281
|
*
|
|
206
282
|
*/
|
|
207
283
|
HackleReactSDKClient.prototype.updateUserProperties = function (operations) {
|
|
208
|
-
this
|
|
209
|
-
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
return __generator(this, function (_a) {
|
|
286
|
+
this.client.updateUserProperties(operations);
|
|
287
|
+
this.emitUpdatedUser(this.getUser());
|
|
288
|
+
return [2 /*return*/];
|
|
289
|
+
});
|
|
290
|
+
});
|
|
210
291
|
};
|
|
211
292
|
HackleReactSDKClient.prototype.resetUser = function () {
|
|
212
|
-
this
|
|
213
|
-
|
|
293
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
+
return __generator(this, function (_a) {
|
|
295
|
+
this.client.resetUser();
|
|
296
|
+
this.emitUpdatedUser(this.getUser());
|
|
297
|
+
return [2 /*return*/];
|
|
298
|
+
});
|
|
299
|
+
});
|
|
214
300
|
};
|
|
215
301
|
/**
|
|
216
302
|
* Determine the variation to expose to the user for experiment.
|
|
@@ -293,6 +379,9 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
293
379
|
HackleReactSDKClient.prototype.onReady = function (cb, timeout) {
|
|
294
380
|
this.client.onReady(cb, timeout);
|
|
295
381
|
};
|
|
382
|
+
HackleReactSDKClient.prototype.getExperiment = function (experimentKey) {
|
|
383
|
+
return this.client.getExperiment(experimentKey);
|
|
384
|
+
};
|
|
296
385
|
HackleReactSDKClient.prototype.onInitialized = function (config) {
|
|
297
386
|
return this.client.onInitialized(config);
|
|
298
387
|
};
|
|
@@ -314,19 +403,32 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
314
403
|
HackleReactSDKClient.prototype.setInAppMessageListener = function (listener) {
|
|
315
404
|
this.client.setInAppMessageListener(listener);
|
|
316
405
|
};
|
|
406
|
+
HackleReactSDKClient.prototype.close = function () {
|
|
407
|
+
this.client.close();
|
|
408
|
+
};
|
|
317
409
|
/**
|
|
318
410
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
319
411
|
*
|
|
320
412
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
321
413
|
*/
|
|
322
414
|
HackleReactSDKClient.prototype.setPhoneNumber = function (phoneNumber) {
|
|
323
|
-
this
|
|
415
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
416
|
+
return __generator(this, function (_a) {
|
|
417
|
+
this.client.setPhoneNumber(phoneNumber);
|
|
418
|
+
return [2 /*return*/];
|
|
419
|
+
});
|
|
420
|
+
});
|
|
324
421
|
};
|
|
325
422
|
/**
|
|
326
423
|
* Reset user's phone number to be an empty value.
|
|
327
424
|
*/
|
|
328
425
|
HackleReactSDKClient.prototype.unsetPhoneNumber = function () {
|
|
329
|
-
this
|
|
426
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
427
|
+
return __generator(this, function (_a) {
|
|
428
|
+
this.client.unsetPhoneNumber();
|
|
429
|
+
return [2 /*return*/];
|
|
430
|
+
});
|
|
431
|
+
});
|
|
330
432
|
};
|
|
331
433
|
return HackleReactSDKClient;
|
|
332
434
|
}(Emitter));
|