@flagship.io/react-sdk 2.2.0-beta.6 → 3.0.2-alpha.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/README.md +2 -2
- package/dist/FlagshipContext.d.ts +99 -0
- package/dist/FlagshipContext.js +312 -0
- package/dist/FlagshipContext.js.map +1 -0
- package/dist/FlagshipErrorBoundary.d.ts +34 -0
- package/dist/FlagshipErrorBoundary.js +95 -0
- package/dist/FlagshipErrorBoundary.js.map +1 -0
- package/dist/FlagshipHooks.d.ts +33 -0
- package/dist/FlagshipHooks.js +198 -0
- package/dist/FlagshipHooks.js.map +1 -0
- package/dist/components/ReactErrorBoundaryContainer/index.d.ts +10 -0
- package/dist/components/ReactErrorBoundaryContainer/index.js +65 -0
- package/dist/components/ReactErrorBoundaryContainer/index.js.map +1 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -1
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/loggerHelper.d.ts +5 -0
- package/dist/lib/loggerHelper.js +14 -0
- package/dist/lib/loggerHelper.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +9 -0
- package/dist/setupTests.js.map +1 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.d.ts +3 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.js +51 -0
- package/dist/tests/mock/apiAnswers/oneModifInMoreThanOneCampaign.js.map +1 -0
- package/dist/tests/mock/env.d.ts +5 -0
- package/dist/tests/mock/env.js +8 -0
- package/dist/tests/mock/env.js.map +1 -0
- package/dist/tests/mock/index.d.ts +74 -0
- package/dist/tests/mock/index.js +90 -0
- package/dist/tests/mock/index.js.map +1 -0
- package/package.json +2 -2
- package/dist/es/FlagshipContext.js +0 -243
- package/dist/es/FlagshipHooks.js +0 -341
- package/dist/es/index.js +0 -3
- package/dist/es/utils.js +0 -46
- package/dist/esm/FlagshipContext.js +0 -265
- package/dist/esm/FlagshipHooks.js +0 -481
- package/dist/esm/index.js +0 -3
- package/dist/esm/utils.js +0 -46
- package/dist/index.browser.js +0 -2
- package/dist/index.browser.js.map +0 -1
- package/dist/types/FlagshipContext.d.ts +0 -79
- package/dist/types/FlagshipHooks.d.ts +0 -91
- package/dist/types/utils.d.ts +0 -5
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
14
|
-
|
|
15
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
-
|
|
17
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
18
|
-
|
|
19
|
-
import { useContext } from 'react';
|
|
20
|
-
import { FlagshipContext } from './FlagshipContext';
|
|
21
|
-
import { logError, logWarn } from './utils';
|
|
22
|
-
|
|
23
|
-
var checkType = function checkType(value, defaultValue) {
|
|
24
|
-
return _typeof(value) === 'object' && _typeof(defaultValue) === 'object' && Array.isArray(value) === Array.isArray(defaultValue) || _typeof(value) === _typeof(defaultValue);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
var fsModificationsSync = function fsModificationsSync(args) {
|
|
28
|
-
var visitor = args.visitor,
|
|
29
|
-
params = args.params,
|
|
30
|
-
activateAll = args.activateAll,
|
|
31
|
-
state = args.state,
|
|
32
|
-
functionName = args.functionName,
|
|
33
|
-
config = args.config;
|
|
34
|
-
|
|
35
|
-
if (visitor) {
|
|
36
|
-
return visitor.getModificationsSync(params, activateAll);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var check = !state.status.isSdkReady && !!state.modifications && state.modifications.size > 0;
|
|
40
|
-
var flags = {};
|
|
41
|
-
|
|
42
|
-
if (check) {
|
|
43
|
-
params.forEach(function (item) {
|
|
44
|
-
var _state$modifications;
|
|
45
|
-
|
|
46
|
-
var modification = (_state$modifications = state.modifications) === null || _state$modifications === void 0 ? void 0 : _state$modifications.get(item.key);
|
|
47
|
-
|
|
48
|
-
if (modification && checkType(modification === null || modification === void 0 ? void 0 : modification.value, item.defaultValue)) {
|
|
49
|
-
flags[item.key] = modification.value;
|
|
50
|
-
} else {
|
|
51
|
-
flags[item.key] = item.defaultValue;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return flags;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
logWarn(config, noVisitorDefault, functionName);
|
|
58
|
-
params.forEach(function (item) {
|
|
59
|
-
flags[item.key] = item.defaultValue;
|
|
60
|
-
});
|
|
61
|
-
return flags;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export var useFsModifications = function useFsModifications(params, activateAll) {
|
|
69
|
-
var _useContext = useContext(FlagshipContext),
|
|
70
|
-
state = _useContext.state;
|
|
71
|
-
|
|
72
|
-
var visitor = state.visitor,
|
|
73
|
-
config = state.config;
|
|
74
|
-
var functionName = 'useFsModifications';
|
|
75
|
-
return fsModificationsSync({
|
|
76
|
-
functionName: functionName,
|
|
77
|
-
state: state,
|
|
78
|
-
visitor: visitor,
|
|
79
|
-
config: config,
|
|
80
|
-
params: params,
|
|
81
|
-
activateAll: activateAll
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
86
|
-
*/
|
|
87
|
-
|
|
88
|
-
export var useFsModification = function useFsModification(params) {
|
|
89
|
-
var _state$modifications2;
|
|
90
|
-
|
|
91
|
-
var _useContext2 = useContext(FlagshipContext),
|
|
92
|
-
state = _useContext2.state;
|
|
93
|
-
|
|
94
|
-
var visitor = state.visitor,
|
|
95
|
-
config = state.config;
|
|
96
|
-
var functionName = 'useFsModifications';
|
|
97
|
-
|
|
98
|
-
if (visitor) {
|
|
99
|
-
return visitor.getModificationSync(params);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
var modification = (_state$modifications2 = state.modifications) === null || _state$modifications2 === void 0 ? void 0 : _state$modifications2.get(params.key);
|
|
103
|
-
|
|
104
|
-
if (!state.status.isSdkReady && modification && checkType(modification === null || modification === void 0 ? void 0 : modification.value, params.defaultValue)) {
|
|
105
|
-
return modification.value;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
logWarn(config, noVisitorDefault, functionName);
|
|
109
|
-
return params.defaultValue;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
var fsModificationInfoSync = function fsModificationInfoSync(args) {
|
|
113
|
-
var _state$modifications3;
|
|
114
|
-
|
|
115
|
-
var key = args.key,
|
|
116
|
-
visitor = args.visitor,
|
|
117
|
-
state = args.state;
|
|
118
|
-
|
|
119
|
-
if (visitor) {
|
|
120
|
-
return visitor.getModificationInfoSync(key);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var modification = (_state$modifications3 = state.modifications) === null || _state$modifications3 === void 0 ? void 0 : _state$modifications3.get(key);
|
|
124
|
-
|
|
125
|
-
if (!state.status.isSdkReady && modification) {
|
|
126
|
-
return modification;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return null;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Get the campaign modification information value matching the given key.
|
|
133
|
-
* @param {string} key key which identify the modification.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
export var useFsModificationInfo = function useFsModificationInfo(key) {
|
|
138
|
-
var _useContext3 = useContext(FlagshipContext),
|
|
139
|
-
state = _useContext3.state;
|
|
140
|
-
|
|
141
|
-
var visitor = state.visitor;
|
|
142
|
-
return fsModificationInfoSync({
|
|
143
|
-
key: key,
|
|
144
|
-
state: state,
|
|
145
|
-
visitor: visitor
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var fsSynchronizeModifications = /*#__PURE__*/function () {
|
|
150
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(functionName, visitor, config) {
|
|
151
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
152
|
-
while (1) {
|
|
153
|
-
switch (_context.prev = _context.next) {
|
|
154
|
-
case 0:
|
|
155
|
-
_context.prev = 0;
|
|
156
|
-
|
|
157
|
-
if (visitor) {
|
|
158
|
-
_context.next = 4;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
reportNoVisitor(config, functionName);
|
|
163
|
-
return _context.abrupt("return");
|
|
164
|
-
|
|
165
|
-
case 4:
|
|
166
|
-
_context.next = 6;
|
|
167
|
-
return visitor.synchronizeModifications();
|
|
168
|
-
|
|
169
|
-
case 6:
|
|
170
|
-
_context.next = 11;
|
|
171
|
-
break;
|
|
172
|
-
|
|
173
|
-
case 8:
|
|
174
|
-
_context.prev = 8;
|
|
175
|
-
_context.t0 = _context["catch"](0);
|
|
176
|
-
logError(config, _context.t0.message || _context.t0, functionName);
|
|
177
|
-
|
|
178
|
-
case 11:
|
|
179
|
-
case "end":
|
|
180
|
-
return _context.stop();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}, _callee, null, [[0, 8]]);
|
|
184
|
-
}));
|
|
185
|
-
|
|
186
|
-
return function fsSynchronizeModifications(_x, _x2, _x3) {
|
|
187
|
-
return _ref.apply(this, arguments);
|
|
188
|
-
};
|
|
189
|
-
}();
|
|
190
|
-
/**
|
|
191
|
-
* This function calls the decision api and update all the campaigns modifications from the server according to the visitor context.
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
export var useFsSynchronizeModifications = /*#__PURE__*/function () {
|
|
196
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
197
|
-
var _useContext4, state, visitor, config, functionName;
|
|
198
|
-
|
|
199
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
200
|
-
while (1) {
|
|
201
|
-
switch (_context2.prev = _context2.next) {
|
|
202
|
-
case 0:
|
|
203
|
-
_useContext4 = useContext(FlagshipContext), state = _useContext4.state;
|
|
204
|
-
visitor = state.visitor, config = state.config;
|
|
205
|
-
functionName = 'useFsSynchronizeModifications';
|
|
206
|
-
_context2.next = 5;
|
|
207
|
-
return fsSynchronizeModifications(functionName, visitor, config);
|
|
208
|
-
|
|
209
|
-
case 5:
|
|
210
|
-
case "end":
|
|
211
|
-
return _context2.stop();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}, _callee2);
|
|
215
|
-
}));
|
|
216
|
-
|
|
217
|
-
return function useFsSynchronizeModifications() {
|
|
218
|
-
return _ref2.apply(this, arguments);
|
|
219
|
-
};
|
|
220
|
-
}();
|
|
221
|
-
|
|
222
|
-
var fsActivate = /*#__PURE__*/function () {
|
|
223
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(params, functionName, visitor, config) {
|
|
224
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
225
|
-
while (1) {
|
|
226
|
-
switch (_context3.prev = _context3.next) {
|
|
227
|
-
case 0:
|
|
228
|
-
_context3.prev = 0;
|
|
229
|
-
|
|
230
|
-
if (visitor) {
|
|
231
|
-
_context3.next = 4;
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
logWarn(config, noVisitorMessage, functionName);
|
|
236
|
-
return _context3.abrupt("return");
|
|
237
|
-
|
|
238
|
-
case 4:
|
|
239
|
-
_context3.next = 6;
|
|
240
|
-
return visitor.activateModifications(params);
|
|
241
|
-
|
|
242
|
-
case 6:
|
|
243
|
-
_context3.next = 11;
|
|
244
|
-
break;
|
|
245
|
-
|
|
246
|
-
case 8:
|
|
247
|
-
_context3.prev = 8;
|
|
248
|
-
_context3.t0 = _context3["catch"](0);
|
|
249
|
-
logWarn(config, _context3.t0.message || _context3.t0, functionName);
|
|
250
|
-
|
|
251
|
-
case 11:
|
|
252
|
-
case "end":
|
|
253
|
-
return _context3.stop();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}, _callee3, null, [[0, 8]]);
|
|
257
|
-
}));
|
|
258
|
-
|
|
259
|
-
return function fsActivate(_x4, _x5, _x6, _x7) {
|
|
260
|
-
return _ref3.apply(this, arguments);
|
|
261
|
-
};
|
|
262
|
-
}();
|
|
263
|
-
/**
|
|
264
|
-
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
265
|
-
* @param params
|
|
266
|
-
* @returns
|
|
267
|
-
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
export var useFsActivate = /*#__PURE__*/function () {
|
|
271
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(params) {
|
|
272
|
-
var _useContext5, state, visitor, config, functionName;
|
|
273
|
-
|
|
274
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
275
|
-
while (1) {
|
|
276
|
-
switch (_context4.prev = _context4.next) {
|
|
277
|
-
case 0:
|
|
278
|
-
_useContext5 = useContext(FlagshipContext), state = _useContext5.state;
|
|
279
|
-
visitor = state.visitor, config = state.config;
|
|
280
|
-
functionName = 'useFsModifications';
|
|
281
|
-
_context4.next = 5;
|
|
282
|
-
return fsActivate(params, functionName, visitor, config);
|
|
283
|
-
|
|
284
|
-
case 5:
|
|
285
|
-
case "end":
|
|
286
|
-
return _context4.stop();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}, _callee4);
|
|
290
|
-
}));
|
|
291
|
-
|
|
292
|
-
return function useFsActivate(_x8) {
|
|
293
|
-
return _ref4.apply(this, arguments);
|
|
294
|
-
};
|
|
295
|
-
}();
|
|
296
|
-
export var useFlagship = function useFlagship() {
|
|
297
|
-
var _useContext6 = useContext(FlagshipContext),
|
|
298
|
-
state = _useContext6.state;
|
|
299
|
-
|
|
300
|
-
var visitor = state.visitor,
|
|
301
|
-
config = state.config;
|
|
302
|
-
|
|
303
|
-
var fsUpdateContext = function fsUpdateContext(context) {
|
|
304
|
-
var functionName = 'updateContext';
|
|
305
|
-
|
|
306
|
-
if (!visitor) {
|
|
307
|
-
logError(config, noVisitorMessage, functionName);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
visitor.clearContext();
|
|
312
|
-
visitor.updateContext(context);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
var fsClearContext = function fsClearContext() {
|
|
316
|
-
var functionName = 'cleanContext';
|
|
317
|
-
|
|
318
|
-
if (!visitor) {
|
|
319
|
-
logError(config, noVisitorMessage, functionName);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
visitor.clearContext();
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
var fsAuthenticate = function fsAuthenticate(visitorId) {
|
|
327
|
-
var functionName = 'authenticate';
|
|
328
|
-
|
|
329
|
-
if (!visitor) {
|
|
330
|
-
logError(config, noVisitorMessage, functionName);
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
visitor.authenticate(visitorId);
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
var fsUnauthenticate = function fsUnauthenticate() {
|
|
338
|
-
var functionName = 'unauthenticate';
|
|
339
|
-
|
|
340
|
-
if (!visitor) {
|
|
341
|
-
logError(config, noVisitorMessage, functionName);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
visitor.unauthenticate();
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Send a Hit to Flagship servers for reporting.
|
|
349
|
-
*/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
var fsSendHit = function fsSendHit(hit) {
|
|
353
|
-
var functionName = 'sendHit';
|
|
354
|
-
|
|
355
|
-
if (!visitor) {
|
|
356
|
-
logError(config, noVisitorMessage, functionName);
|
|
357
|
-
return Promise.resolve();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return visitor.sendHit(hit);
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* Send a Hit to Flagship servers for reporting.
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
var fsSendHits = function fsSendHits(hit) {
|
|
368
|
-
var functionName = 'sendHits';
|
|
369
|
-
|
|
370
|
-
if (!visitor) {
|
|
371
|
-
logError(config, noVisitorMessage, functionName);
|
|
372
|
-
return Promise.resolve();
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return visitor.sendHits(hit);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
var modifications = visitor === null || visitor === void 0 ? void 0 : visitor.getModificationsArray();
|
|
379
|
-
|
|
380
|
-
if (!state.status.isSdkReady && state.modifications) {
|
|
381
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
382
|
-
modifications = Array.from(state.modifications, function (_ref5) {
|
|
383
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
384
|
-
_key = _ref6[0],
|
|
385
|
-
item = _ref6[1];
|
|
386
|
-
|
|
387
|
-
return item;
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
var activateModification = /*#__PURE__*/function () {
|
|
392
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(params) {
|
|
393
|
-
var functionName;
|
|
394
|
-
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
395
|
-
while (1) {
|
|
396
|
-
switch (_context5.prev = _context5.next) {
|
|
397
|
-
case 0:
|
|
398
|
-
functionName = 'activateModification';
|
|
399
|
-
_context5.next = 3;
|
|
400
|
-
return fsActivate(params, functionName, visitor, config);
|
|
401
|
-
|
|
402
|
-
case 3:
|
|
403
|
-
case "end":
|
|
404
|
-
return _context5.stop();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}, _callee5);
|
|
408
|
-
}));
|
|
409
|
-
|
|
410
|
-
return function activateModification(_x9) {
|
|
411
|
-
return _ref7.apply(this, arguments);
|
|
412
|
-
};
|
|
413
|
-
}();
|
|
414
|
-
|
|
415
|
-
var synchronizeModifications = /*#__PURE__*/function () {
|
|
416
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
|
|
417
|
-
var functionName;
|
|
418
|
-
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
419
|
-
while (1) {
|
|
420
|
-
switch (_context6.prev = _context6.next) {
|
|
421
|
-
case 0:
|
|
422
|
-
functionName = 'synchronizeModifications';
|
|
423
|
-
_context6.next = 3;
|
|
424
|
-
return fsSynchronizeModifications(functionName, visitor, config);
|
|
425
|
-
|
|
426
|
-
case 3:
|
|
427
|
-
case "end":
|
|
428
|
-
return _context6.stop();
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}, _callee6);
|
|
432
|
-
}));
|
|
433
|
-
|
|
434
|
-
return function synchronizeModifications() {
|
|
435
|
-
return _ref8.apply(this, arguments);
|
|
436
|
-
};
|
|
437
|
-
}();
|
|
438
|
-
|
|
439
|
-
var getModifications = function getModifications(params, activateAll) {
|
|
440
|
-
var functionName = 'getModifications';
|
|
441
|
-
return fsModificationsSync({
|
|
442
|
-
functionName: functionName,
|
|
443
|
-
state: state,
|
|
444
|
-
visitor: visitor,
|
|
445
|
-
config: config,
|
|
446
|
-
params: params,
|
|
447
|
-
activateAll: activateAll
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
var getModificationInfo = function getModificationInfo(key) {
|
|
452
|
-
return fsModificationInfoSync({
|
|
453
|
-
key: key,
|
|
454
|
-
state: state,
|
|
455
|
-
visitor: visitor
|
|
456
|
-
});
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
return {
|
|
460
|
-
updateContext: fsUpdateContext,
|
|
461
|
-
clearContext: fsClearContext,
|
|
462
|
-
authenticate: fsAuthenticate,
|
|
463
|
-
unauthenticate: fsUnauthenticate,
|
|
464
|
-
status: state.status,
|
|
465
|
-
activateModification: activateModification,
|
|
466
|
-
synchronizeModifications: synchronizeModifications,
|
|
467
|
-
getModifications: getModifications,
|
|
468
|
-
modifications: modifications || [],
|
|
469
|
-
getModificationInfo: getModificationInfo,
|
|
470
|
-
hit: {
|
|
471
|
-
send: fsSendHit,
|
|
472
|
-
sendMultiple: fsSendHits
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
|
-
export var noVisitorMessage = 'sdk not correctly initialized... Make sure fsVisitor is ready.';
|
|
477
|
-
export var noVisitorDefault = 'fsVisitor not initialized, returns default value';
|
|
478
|
-
|
|
479
|
-
var reportNoVisitor = function reportNoVisitor(config, tag) {
|
|
480
|
-
logError(config, noVisitorMessage, tag);
|
|
481
|
-
};
|
package/dist/esm/index.js
DELETED
package/dist/esm/utils.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { LogLevel } from '@flagship.io/js-sdk';
|
|
2
|
-
export function logError(config, message, tag) {
|
|
3
|
-
if (!config || !config.logManager || typeof config.logManager.error !== 'function' || !config.logLevel || config.logLevel < LogLevel.ERROR) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
config.logManager.error(message, tag);
|
|
8
|
-
}
|
|
9
|
-
export function logInfo(config, message, tag) {
|
|
10
|
-
if (!config || !config.logManager || typeof config.logManager.info !== 'function' || !config.logLevel || config.logLevel < LogLevel.INFO) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
config.logManager.info(message, tag);
|
|
15
|
-
}
|
|
16
|
-
export function logWarn(config, message, tag) {
|
|
17
|
-
if (!config || !config.logManager || typeof config.logManager.warning !== 'function' || !config.logLevel || config.logLevel < LogLevel.WARNING) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
config.logManager.warning(message, tag);
|
|
22
|
-
}
|
|
23
|
-
export var getModificationsFromCampaigns = function getModificationsFromCampaigns(campaigns) {
|
|
24
|
-
var modifications = new Map();
|
|
25
|
-
|
|
26
|
-
if (!campaigns || !Array.isArray(campaigns)) {
|
|
27
|
-
return modifications;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
campaigns.forEach(function (campaign) {
|
|
31
|
-
var object = campaign.variation.modifications.value;
|
|
32
|
-
|
|
33
|
-
for (var key in object) {
|
|
34
|
-
var value = object[key];
|
|
35
|
-
modifications.set(key, {
|
|
36
|
-
key: key,
|
|
37
|
-
campaignId: campaign.id,
|
|
38
|
-
variationGroupId: campaign.variationGroupId,
|
|
39
|
-
variationId: campaign.variation.id,
|
|
40
|
-
isReference: campaign.variation.reference,
|
|
41
|
-
value: value
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return modifications;
|
|
46
|
-
};
|