@hackler/react-sdk 11.43.0 → 11.45.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 +23 -16
- package/lib/client.d.ts.map +1 -1
- package/lib/index.es.js +145 -16
- package/lib/index.js +145 -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, HackleSubscriptionOperations } from "@hackler/javascript-sdk";
|
|
2
2
|
import { Emitter } from "./emitter";
|
|
3
3
|
interface Config {
|
|
4
4
|
user?: User;
|
|
@@ -17,23 +17,28 @@ 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
|
-
|
|
37
|
+
updateUserProperties(operations: PropertyOperations): Promise<void>;
|
|
38
|
+
updatePushSubscriptions(operations: HackleSubscriptionOperations): Promise<void>;
|
|
39
|
+
updateSmsSubscriptions(operations: HackleSubscriptionOperations): Promise<void>;
|
|
40
|
+
updateKakaoSubscriptions(operations: HackleSubscriptionOperations): Promise<void>;
|
|
41
|
+
resetUser(): Promise<void>;
|
|
37
42
|
/**
|
|
38
43
|
* Determine the variation to expose to the user for experiment.
|
|
39
44
|
*
|
|
@@ -49,7 +54,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
49
54
|
*
|
|
50
55
|
* @return string the decided variation for the user, or the default variation.
|
|
51
56
|
*/
|
|
52
|
-
variation(experimentKey: number, user?: User | null, defaultVariation?: string): string;
|
|
57
|
+
variation(experimentKey: number, user?: User | string | null, defaultVariation?: string): string;
|
|
53
58
|
/**
|
|
54
59
|
* Determine the variation to expose to the user for experiment, and returns an object that
|
|
55
60
|
* describes the way the variation was determined.
|
|
@@ -60,7 +65,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
60
65
|
*
|
|
61
66
|
* @return {Decision} object
|
|
62
67
|
*/
|
|
63
|
-
variationDetail(experimentKey: number, user?: User | null, defaultVariation?: string): Decision;
|
|
68
|
+
variationDetail(experimentKey: number, user?: User | string | null, defaultVariation?: string): Decision;
|
|
64
69
|
/**
|
|
65
70
|
* Determine whether the feature is turned on to the user.
|
|
66
71
|
*
|
|
@@ -71,7 +76,7 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
71
76
|
*
|
|
72
77
|
* @since 2.0.0
|
|
73
78
|
*/
|
|
74
|
-
isFeatureOn(featureKey: number, user?: User | null): boolean;
|
|
79
|
+
isFeatureOn(featureKey: number, user?: User | string | null): boolean;
|
|
75
80
|
/**
|
|
76
81
|
* Determine whether the feature is turned on to the user, and returns an object that
|
|
77
82
|
* describes the way the value was determined.
|
|
@@ -83,22 +88,23 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
83
88
|
*
|
|
84
89
|
* @since 2.0.0
|
|
85
90
|
*/
|
|
86
|
-
featureFlagDetail(featureKey: number, user?: User | null): FeatureFlagDecision;
|
|
91
|
+
featureFlagDetail(featureKey: number, user?: User | string | null): FeatureFlagDecision;
|
|
87
92
|
/**
|
|
88
93
|
* Records the event performed by the user.
|
|
89
94
|
*
|
|
90
95
|
* @param event the unique key of the event. MUST NOT be null.
|
|
91
96
|
* @param user the identifier of user that performed the event. id MUST NOT be null. (e.g. { id: "userId"} )
|
|
92
97
|
*/
|
|
93
|
-
track(event: string | HackleEvent, user?: User | null): void;
|
|
98
|
+
track(event: string | HackleEvent, user?: User | string | null): void;
|
|
94
99
|
trackPageView(option?: PageView): void;
|
|
95
100
|
/**
|
|
96
101
|
* Return a instance of Hackle Remote Config.
|
|
97
102
|
*
|
|
98
103
|
* @param user the identifier of user.
|
|
99
104
|
*/
|
|
100
|
-
remoteConfig(user?: User | null): HackleRemoteConfig;
|
|
105
|
+
remoteConfig(user?: User | string | null): HackleRemoteConfig;
|
|
101
106
|
onReady(cb: any, timeout?: number): void;
|
|
107
|
+
getExperiment(experimentKey: number): HackleExperiment | undefined;
|
|
102
108
|
onInitialized(config?: {
|
|
103
109
|
timeout: number;
|
|
104
110
|
}): Promise<{
|
|
@@ -109,16 +115,17 @@ export declare class HackleReactSDKClient extends Emitter<HackleReactSDKClientEv
|
|
|
109
115
|
hideUserExplorer(): void;
|
|
110
116
|
fetch(): Promise<void>;
|
|
111
117
|
setInAppMessageListener(listener: HackleInAppMessageListener | null): void;
|
|
118
|
+
close(): void;
|
|
112
119
|
/**
|
|
113
120
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
114
121
|
*
|
|
115
122
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
116
123
|
*/
|
|
117
|
-
setPhoneNumber(phoneNumber: string): void
|
|
124
|
+
setPhoneNumber(phoneNumber: string): Promise<void>;
|
|
118
125
|
/**
|
|
119
126
|
* Reset user's phone number to be an empty value.
|
|
120
127
|
*/
|
|
121
|
-
unsetPhoneNumber(): void
|
|
128
|
+
unsetPhoneNumber(): Promise<void>;
|
|
122
129
|
}
|
|
123
130
|
export declare function createInstance(sdkKey: string, config?: Config): HackleReactSDKClient;
|
|
124
131
|
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,EAChB,4BAA4B,EAC7B,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,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AAI;IAIb;;;;OAIG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAEpF"}
|
package/lib/index.es.js
CHANGED
|
@@ -46,6 +46,44 @@ var __assign = function() {
|
|
|
46
46
|
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.45.0" ;
|
|
68
106
|
|
|
69
107
|
var Emitter = /** @class */ (function () {
|
|
70
108
|
function Emitter() {
|
|
@@ -128,12 +166,17 @@ 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);
|
|
177
|
+
_this.updatePushSubscriptions = _this.updatePushSubscriptions.bind(_this);
|
|
178
|
+
_this.updateSmsSubscriptions = _this.updateSmsSubscriptions.bind(_this);
|
|
179
|
+
_this.updateKakaoSubscriptions = _this.updateKakaoSubscriptions.bind(_this);
|
|
137
180
|
_this.resetUser = _this.resetUser.bind(_this);
|
|
138
181
|
_this.variation = _this.variation.bind(_this);
|
|
139
182
|
_this.variationDetail = _this.variationDetail.bind(_this);
|
|
@@ -144,34 +187,70 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
144
187
|
_this.remoteConfig = _this.remoteConfig.bind(_this);
|
|
145
188
|
_this.onReady = _this.onReady.bind(_this);
|
|
146
189
|
_this.onInitialized = _this.onInitialized.bind(_this);
|
|
147
|
-
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
148
190
|
_this.showUserExplorer = _this.showUserExplorer.bind(_this);
|
|
149
191
|
_this.hideUserExplorer = _this.hideUserExplorer.bind(_this);
|
|
150
192
|
_this.fetch = _this.fetch.bind(_this);
|
|
193
|
+
_this.close = _this.close.bind(_this);
|
|
151
194
|
_this.setInAppMessageListener = _this.setInAppMessageListener.bind(_this);
|
|
195
|
+
_this.getExperiment = _this.getExperiment.bind(_this);
|
|
196
|
+
_this.setPhoneNumber = _this.setPhoneNumber.bind(_this);
|
|
197
|
+
_this.unsetPhoneNumber = _this.unsetPhoneNumber.bind(_this);
|
|
198
|
+
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
152
199
|
if ((config === null || config === void 0 ? void 0 : config.devTool) && (config === null || config === void 0 ? void 0 : config.autoOpenDevTool) && typeof window !== "undefined") {
|
|
153
200
|
_this.showUserExplorer();
|
|
154
201
|
}
|
|
155
202
|
return _this;
|
|
156
203
|
}
|
|
204
|
+
HackleReactSDKClient.prototype.getSessionId = function () {
|
|
205
|
+
return this.client.getSessionId();
|
|
206
|
+
};
|
|
157
207
|
HackleReactSDKClient.prototype.getUser = function () {
|
|
158
208
|
return this.client.getUser();
|
|
159
209
|
};
|
|
160
210
|
HackleReactSDKClient.prototype.setUser = function (user) {
|
|
161
|
-
this
|
|
162
|
-
|
|
211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
this.client.setUser(user);
|
|
214
|
+
this.emitUpdatedUser(this.getUser());
|
|
215
|
+
return [2 /*return*/];
|
|
216
|
+
});
|
|
217
|
+
});
|
|
163
218
|
};
|
|
164
219
|
HackleReactSDKClient.prototype.setUserId = function (userId) {
|
|
165
|
-
this
|
|
166
|
-
|
|
220
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
this.client.setUserId(userId);
|
|
223
|
+
this.emitUpdatedUser(this.getUser());
|
|
224
|
+
return [2 /*return*/];
|
|
225
|
+
});
|
|
226
|
+
});
|
|
167
227
|
};
|
|
168
228
|
HackleReactSDKClient.prototype.setDeviceId = function (deviceId) {
|
|
169
|
-
this
|
|
170
|
-
|
|
229
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
this.client.setDeviceId(deviceId);
|
|
232
|
+
this.emitUpdatedUser(this.getUser());
|
|
233
|
+
return [2 /*return*/];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
171
236
|
};
|
|
172
237
|
HackleReactSDKClient.prototype.setUserProperty = function (key, value) {
|
|
173
|
-
this
|
|
174
|
-
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
return __generator(this, function (_a) {
|
|
240
|
+
this.client.setUserProperty(key, value);
|
|
241
|
+
this.emitUpdatedUser(this.getUser());
|
|
242
|
+
return [2 /*return*/];
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
HackleReactSDKClient.prototype.setUserProperties = function (properties) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
this.client.setUserProperties(properties);
|
|
250
|
+
this.emitUpdatedUser(this.getUser());
|
|
251
|
+
return [2 /*return*/];
|
|
252
|
+
});
|
|
253
|
+
});
|
|
175
254
|
};
|
|
176
255
|
/**
|
|
177
256
|
* Updates the user's properties.
|
|
@@ -180,12 +259,46 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
180
259
|
*
|
|
181
260
|
*/
|
|
182
261
|
HackleReactSDKClient.prototype.updateUserProperties = function (operations) {
|
|
183
|
-
this
|
|
184
|
-
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
this.client.updateUserProperties(operations);
|
|
265
|
+
this.emitUpdatedUser(this.getUser());
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
HackleReactSDKClient.prototype.updatePushSubscriptions = function (operations) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
+
return __generator(this, function (_a) {
|
|
273
|
+
this.client.updatePushSubscriptions(operations);
|
|
274
|
+
return [2 /*return*/];
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
HackleReactSDKClient.prototype.updateSmsSubscriptions = function (operations) {
|
|
279
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
280
|
+
return __generator(this, function (_a) {
|
|
281
|
+
this.client.updateSmsSubscriptions(operations);
|
|
282
|
+
return [2 /*return*/];
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
HackleReactSDKClient.prototype.updateKakaoSubscriptions = function (operations) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
this.client.updateKakaoSubscriptions(operations);
|
|
290
|
+
return [2 /*return*/];
|
|
291
|
+
});
|
|
292
|
+
});
|
|
185
293
|
};
|
|
186
294
|
HackleReactSDKClient.prototype.resetUser = function () {
|
|
187
|
-
this
|
|
188
|
-
|
|
295
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
+
return __generator(this, function (_a) {
|
|
297
|
+
this.client.resetUser();
|
|
298
|
+
this.emitUpdatedUser(this.getUser());
|
|
299
|
+
return [2 /*return*/];
|
|
300
|
+
});
|
|
301
|
+
});
|
|
189
302
|
};
|
|
190
303
|
/**
|
|
191
304
|
* Determine the variation to expose to the user for experiment.
|
|
@@ -268,6 +381,9 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
268
381
|
HackleReactSDKClient.prototype.onReady = function (cb, timeout) {
|
|
269
382
|
this.client.onReady(cb, timeout);
|
|
270
383
|
};
|
|
384
|
+
HackleReactSDKClient.prototype.getExperiment = function (experimentKey) {
|
|
385
|
+
return this.client.getExperiment(experimentKey);
|
|
386
|
+
};
|
|
271
387
|
HackleReactSDKClient.prototype.onInitialized = function (config) {
|
|
272
388
|
return this.client.onInitialized(config);
|
|
273
389
|
};
|
|
@@ -289,19 +405,32 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
289
405
|
HackleReactSDKClient.prototype.setInAppMessageListener = function (listener) {
|
|
290
406
|
this.client.setInAppMessageListener(listener);
|
|
291
407
|
};
|
|
408
|
+
HackleReactSDKClient.prototype.close = function () {
|
|
409
|
+
this.client.close();
|
|
410
|
+
};
|
|
292
411
|
/**
|
|
293
412
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
294
413
|
*
|
|
295
414
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
296
415
|
*/
|
|
297
416
|
HackleReactSDKClient.prototype.setPhoneNumber = function (phoneNumber) {
|
|
298
|
-
this
|
|
417
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
418
|
+
return __generator(this, function (_a) {
|
|
419
|
+
this.client.setPhoneNumber(phoneNumber);
|
|
420
|
+
return [2 /*return*/];
|
|
421
|
+
});
|
|
422
|
+
});
|
|
299
423
|
};
|
|
300
424
|
/**
|
|
301
425
|
* Reset user's phone number to be an empty value.
|
|
302
426
|
*/
|
|
303
427
|
HackleReactSDKClient.prototype.unsetPhoneNumber = function () {
|
|
304
|
-
this
|
|
428
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
429
|
+
return __generator(this, function (_a) {
|
|
430
|
+
this.client.unsetPhoneNumber();
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
});
|
|
433
|
+
});
|
|
305
434
|
};
|
|
306
435
|
return HackleReactSDKClient;
|
|
307
436
|
}(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.45.0" ;
|
|
93
131
|
|
|
94
132
|
var Emitter = /** @class */ (function () {
|
|
95
133
|
function Emitter() {
|
|
@@ -153,12 +191,17 @@ 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);
|
|
202
|
+
_this.updatePushSubscriptions = _this.updatePushSubscriptions.bind(_this);
|
|
203
|
+
_this.updateSmsSubscriptions = _this.updateSmsSubscriptions.bind(_this);
|
|
204
|
+
_this.updateKakaoSubscriptions = _this.updateKakaoSubscriptions.bind(_this);
|
|
162
205
|
_this.resetUser = _this.resetUser.bind(_this);
|
|
163
206
|
_this.variation = _this.variation.bind(_this);
|
|
164
207
|
_this.variationDetail = _this.variationDetail.bind(_this);
|
|
@@ -169,34 +212,70 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
169
212
|
_this.remoteConfig = _this.remoteConfig.bind(_this);
|
|
170
213
|
_this.onReady = _this.onReady.bind(_this);
|
|
171
214
|
_this.onInitialized = _this.onInitialized.bind(_this);
|
|
172
|
-
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
173
215
|
_this.showUserExplorer = _this.showUserExplorer.bind(_this);
|
|
174
216
|
_this.hideUserExplorer = _this.hideUserExplorer.bind(_this);
|
|
175
217
|
_this.fetch = _this.fetch.bind(_this);
|
|
218
|
+
_this.close = _this.close.bind(_this);
|
|
176
219
|
_this.setInAppMessageListener = _this.setInAppMessageListener.bind(_this);
|
|
220
|
+
_this.getExperiment = _this.getExperiment.bind(_this);
|
|
221
|
+
_this.setPhoneNumber = _this.setPhoneNumber.bind(_this);
|
|
222
|
+
_this.unsetPhoneNumber = _this.unsetPhoneNumber.bind(_this);
|
|
223
|
+
_this.emitUpdatedUser = _this.emitUpdatedUser.bind(_this);
|
|
177
224
|
if ((config === null || config === void 0 ? void 0 : config.devTool) && (config === null || config === void 0 ? void 0 : config.autoOpenDevTool) && typeof window !== "undefined") {
|
|
178
225
|
_this.showUserExplorer();
|
|
179
226
|
}
|
|
180
227
|
return _this;
|
|
181
228
|
}
|
|
229
|
+
HackleReactSDKClient.prototype.getSessionId = function () {
|
|
230
|
+
return this.client.getSessionId();
|
|
231
|
+
};
|
|
182
232
|
HackleReactSDKClient.prototype.getUser = function () {
|
|
183
233
|
return this.client.getUser();
|
|
184
234
|
};
|
|
185
235
|
HackleReactSDKClient.prototype.setUser = function (user) {
|
|
186
|
-
this
|
|
187
|
-
|
|
236
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
this.client.setUser(user);
|
|
239
|
+
this.emitUpdatedUser(this.getUser());
|
|
240
|
+
return [2 /*return*/];
|
|
241
|
+
});
|
|
242
|
+
});
|
|
188
243
|
};
|
|
189
244
|
HackleReactSDKClient.prototype.setUserId = function (userId) {
|
|
190
|
-
this
|
|
191
|
-
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
this.client.setUserId(userId);
|
|
248
|
+
this.emitUpdatedUser(this.getUser());
|
|
249
|
+
return [2 /*return*/];
|
|
250
|
+
});
|
|
251
|
+
});
|
|
192
252
|
};
|
|
193
253
|
HackleReactSDKClient.prototype.setDeviceId = function (deviceId) {
|
|
194
|
-
this
|
|
195
|
-
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
return __generator(this, function (_a) {
|
|
256
|
+
this.client.setDeviceId(deviceId);
|
|
257
|
+
this.emitUpdatedUser(this.getUser());
|
|
258
|
+
return [2 /*return*/];
|
|
259
|
+
});
|
|
260
|
+
});
|
|
196
261
|
};
|
|
197
262
|
HackleReactSDKClient.prototype.setUserProperty = function (key, value) {
|
|
198
|
-
this
|
|
199
|
-
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
this.client.setUserProperty(key, value);
|
|
266
|
+
this.emitUpdatedUser(this.getUser());
|
|
267
|
+
return [2 /*return*/];
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
HackleReactSDKClient.prototype.setUserProperties = function (properties) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
273
|
+
return __generator(this, function (_a) {
|
|
274
|
+
this.client.setUserProperties(properties);
|
|
275
|
+
this.emitUpdatedUser(this.getUser());
|
|
276
|
+
return [2 /*return*/];
|
|
277
|
+
});
|
|
278
|
+
});
|
|
200
279
|
};
|
|
201
280
|
/**
|
|
202
281
|
* Updates the user's properties.
|
|
@@ -205,12 +284,46 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
205
284
|
*
|
|
206
285
|
*/
|
|
207
286
|
HackleReactSDKClient.prototype.updateUserProperties = function (operations) {
|
|
208
|
-
this
|
|
209
|
-
|
|
287
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
this.client.updateUserProperties(operations);
|
|
290
|
+
this.emitUpdatedUser(this.getUser());
|
|
291
|
+
return [2 /*return*/];
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
HackleReactSDKClient.prototype.updatePushSubscriptions = function (operations) {
|
|
296
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
+
return __generator(this, function (_a) {
|
|
298
|
+
this.client.updatePushSubscriptions(operations);
|
|
299
|
+
return [2 /*return*/];
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
HackleReactSDKClient.prototype.updateSmsSubscriptions = function (operations) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
+
return __generator(this, function (_a) {
|
|
306
|
+
this.client.updateSmsSubscriptions(operations);
|
|
307
|
+
return [2 /*return*/];
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
HackleReactSDKClient.prototype.updateKakaoSubscriptions = function (operations) {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
313
|
+
return __generator(this, function (_a) {
|
|
314
|
+
this.client.updateKakaoSubscriptions(operations);
|
|
315
|
+
return [2 /*return*/];
|
|
316
|
+
});
|
|
317
|
+
});
|
|
210
318
|
};
|
|
211
319
|
HackleReactSDKClient.prototype.resetUser = function () {
|
|
212
|
-
this
|
|
213
|
-
|
|
320
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
+
return __generator(this, function (_a) {
|
|
322
|
+
this.client.resetUser();
|
|
323
|
+
this.emitUpdatedUser(this.getUser());
|
|
324
|
+
return [2 /*return*/];
|
|
325
|
+
});
|
|
326
|
+
});
|
|
214
327
|
};
|
|
215
328
|
/**
|
|
216
329
|
* Determine the variation to expose to the user for experiment.
|
|
@@ -293,6 +406,9 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
293
406
|
HackleReactSDKClient.prototype.onReady = function (cb, timeout) {
|
|
294
407
|
this.client.onReady(cb, timeout);
|
|
295
408
|
};
|
|
409
|
+
HackleReactSDKClient.prototype.getExperiment = function (experimentKey) {
|
|
410
|
+
return this.client.getExperiment(experimentKey);
|
|
411
|
+
};
|
|
296
412
|
HackleReactSDKClient.prototype.onInitialized = function (config) {
|
|
297
413
|
return this.client.onInitialized(config);
|
|
298
414
|
};
|
|
@@ -314,19 +430,32 @@ var HackleReactSDKClient = /** @class */ (function (_super) {
|
|
|
314
430
|
HackleReactSDKClient.prototype.setInAppMessageListener = function (listener) {
|
|
315
431
|
this.client.setInAppMessageListener(listener);
|
|
316
432
|
};
|
|
433
|
+
HackleReactSDKClient.prototype.close = function () {
|
|
434
|
+
this.client.close();
|
|
435
|
+
};
|
|
317
436
|
/**
|
|
318
437
|
* Set user's phone number. Existing value will be replaced by new value if you call this method again.
|
|
319
438
|
*
|
|
320
439
|
* @param phoneNumber String satisfying valid E.164 format is accepted.
|
|
321
440
|
*/
|
|
322
441
|
HackleReactSDKClient.prototype.setPhoneNumber = function (phoneNumber) {
|
|
323
|
-
this
|
|
442
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
443
|
+
return __generator(this, function (_a) {
|
|
444
|
+
this.client.setPhoneNumber(phoneNumber);
|
|
445
|
+
return [2 /*return*/];
|
|
446
|
+
});
|
|
447
|
+
});
|
|
324
448
|
};
|
|
325
449
|
/**
|
|
326
450
|
* Reset user's phone number to be an empty value.
|
|
327
451
|
*/
|
|
328
452
|
HackleReactSDKClient.prototype.unsetPhoneNumber = function () {
|
|
329
|
-
this
|
|
453
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
454
|
+
return __generator(this, function (_a) {
|
|
455
|
+
this.client.unsetPhoneNumber();
|
|
456
|
+
return [2 /*return*/];
|
|
457
|
+
});
|
|
458
|
+
});
|
|
330
459
|
};
|
|
331
460
|
return HackleReactSDKClient;
|
|
332
461
|
}(Emitter));
|