@p14c/ld-client 1.626.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @p14c/ld-client might be problematic. Click here for more details.
- package/build.js +30 -0
- package/lib/ld-client.js +1654 -0
- package/package.json +26 -0
package/lib/ld-client.js
ADDED
@@ -0,0 +1,1654 @@
|
|
1
|
+
!function (e, n) {
|
2
|
+
'object' == typeof exports && 'object' == typeof module ? module.exports = n() : 'function' == typeof define && define.amd ? define([], n) : 'object' == typeof exports ? exports['ld-client'] = n() : e['ld-client'] = n();
|
3
|
+
}(window, (function () {
|
4
|
+
return function (e) {
|
5
|
+
var n = {};
|
6
|
+
|
7
|
+
function t(r) {
|
8
|
+
if (n[r]) return n[r].exports;
|
9
|
+
var o = n[r] = { i: r, l: !1, exports: {} };
|
10
|
+
return e[r].call(o.exports, o, o.exports, t), o.l = !0, o.exports;
|
11
|
+
}
|
12
|
+
|
13
|
+
return t.m = e, t.c = n, t.d = function (e, n, r) {
|
14
|
+
t.o(e, n) || Object.defineProperty(e, n, { enumerable: !0, get: r });
|
15
|
+
}, t.r = function (e) {
|
16
|
+
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(e, '__esModule', { value: !0 });
|
17
|
+
}, t.t = function (e, n) {
|
18
|
+
if (1 & n && (e = t(e)), 8 & n) return e;
|
19
|
+
if (4 & n && 'object' == typeof e && e && e.__esModule) return e;
|
20
|
+
var r = Object.create(null);
|
21
|
+
if (t.r(r), Object.defineProperty(r, 'default', {
|
22
|
+
enumerable: !0,
|
23
|
+
value: e
|
24
|
+
}), 2 & n && 'string' != typeof e) for (var o in e) t.d(r, o, function (n) {
|
25
|
+
return e[n];
|
26
|
+
}.bind(null, o));
|
27
|
+
return r;
|
28
|
+
}, t.n = function (e) {
|
29
|
+
var n = e && e.__esModule ? function () {
|
30
|
+
return e.default;
|
31
|
+
} : function () {
|
32
|
+
return e;
|
33
|
+
};
|
34
|
+
return t.d(n, 'a', n), n;
|
35
|
+
}, t.o = function (e, n) {
|
36
|
+
return Object.prototype.hasOwnProperty.call(e, n);
|
37
|
+
}, t.p = '/', t(t.s = 0);
|
38
|
+
}([function (e, n, t) {
|
39
|
+
'use strict';
|
40
|
+
t.r(n);
|
41
|
+
var r;
|
42
|
+
|
43
|
+
function o(e, n) {
|
44
|
+
var t = Object.keys(e);
|
45
|
+
if (Object.getOwnPropertySymbols) {
|
46
|
+
var r = Object.getOwnPropertySymbols(e);
|
47
|
+
n && (r = r.filter((function (n) {
|
48
|
+
return Object.getOwnPropertyDescriptor(e, n).enumerable;
|
49
|
+
}))), t.push.apply(t, r);
|
50
|
+
}
|
51
|
+
return t;
|
52
|
+
}
|
53
|
+
|
54
|
+
function i(e, n, t) {
|
55
|
+
return n in e ? Object.defineProperty(e, n, {
|
56
|
+
value: t,
|
57
|
+
enumerable: !0,
|
58
|
+
configurable: !0,
|
59
|
+
writable: !0
|
60
|
+
}) : e[n] = t, e;
|
61
|
+
}
|
62
|
+
|
63
|
+
var a = function (e) {
|
64
|
+
return r && e in r || !1;
|
65
|
+
}, u = function (e) {
|
66
|
+
return r && r[e];
|
67
|
+
}, c = function (e) {
|
68
|
+
e && (r = function (e) {
|
69
|
+
var n = {};
|
70
|
+
for (var t in e) e[t] && (n[t] = e[t]);
|
71
|
+
return n;
|
72
|
+
}(e));
|
73
|
+
}, s = function (e) {
|
74
|
+
if (e) {
|
75
|
+
var n = function (e, n) {
|
76
|
+
for (var t = {}, r = 0, o = Object.keys(e); r < o.length; r++) {
|
77
|
+
var i = o[r];
|
78
|
+
t[i] = n(e[i], i);
|
79
|
+
}
|
80
|
+
return t;
|
81
|
+
}(e, (function (e) {
|
82
|
+
return e.current;
|
83
|
+
}));
|
84
|
+
c(function (e) {
|
85
|
+
for (var n = 1; n < arguments.length; n++) {
|
86
|
+
var t = null != arguments[n] ? arguments[n] : {};
|
87
|
+
n % 2 ? o(Object(t), !0).forEach((function (n) {
|
88
|
+
i(e, n, t[n]);
|
89
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : o(Object(t)).forEach((function (n) {
|
90
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
91
|
+
}));
|
92
|
+
}
|
93
|
+
return e;
|
94
|
+
}({}, r, {}, n));
|
95
|
+
}
|
96
|
+
}, l = function () {
|
97
|
+
return Boolean(r);
|
98
|
+
};
|
99
|
+
|
100
|
+
function f(e) {
|
101
|
+
return (f = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (e) {
|
102
|
+
return typeof e;
|
103
|
+
} : function (e) {
|
104
|
+
return e && 'function' == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? 'symbol' : typeof e;
|
105
|
+
})(e);
|
106
|
+
}
|
107
|
+
|
108
|
+
function d(e, n, t) {
|
109
|
+
return n in e ? Object.defineProperty(e, n, {
|
110
|
+
value: t,
|
111
|
+
enumerable: !0,
|
112
|
+
configurable: !0,
|
113
|
+
writable: !0
|
114
|
+
}) : e[n] = t, e;
|
115
|
+
}
|
116
|
+
|
117
|
+
function v(e, n) {
|
118
|
+
var t = Object.keys(e);
|
119
|
+
if (Object.getOwnPropertySymbols) {
|
120
|
+
var r = Object.getOwnPropertySymbols(e);
|
121
|
+
n && (r = r.filter((function (n) {
|
122
|
+
return Object.getOwnPropertyDescriptor(e, n).enumerable;
|
123
|
+
}))), t.push.apply(t, r);
|
124
|
+
}
|
125
|
+
return t;
|
126
|
+
}
|
127
|
+
|
128
|
+
function g(e) {
|
129
|
+
for (var n = 1; n < arguments.length; n++) {
|
130
|
+
var t = null != arguments[n] ? arguments[n] : {};
|
131
|
+
n % 2 ? v(t, !0).forEach((function (n) {
|
132
|
+
d(e, n, t[n]);
|
133
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : v(t).forEach((function (n) {
|
134
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
135
|
+
}));
|
136
|
+
}
|
137
|
+
return e;
|
138
|
+
}
|
139
|
+
|
140
|
+
function p(e) {
|
141
|
+
function n(e, n) {
|
142
|
+
Error.captureStackTrace && Error.captureStackTrace(this, this.constructor), this.message = e, this.code = n;
|
143
|
+
}
|
144
|
+
|
145
|
+
return n.prototype = new Error, n.prototype.name = e, n.prototype.constructor = n, n;
|
146
|
+
}
|
147
|
+
|
148
|
+
var m = p('LaunchDarklyUnexpectedResponseError'),
|
149
|
+
y = p('LaunchDarklyInvalidEnvironmentIdError'), h = p('LaunchDarklyInvalidUserError'),
|
150
|
+
b = p('LaunchDarklyInvalidEventKeyError'), w = p('LaunchDarklyInvalidArgumentError'),
|
151
|
+
k = p('LaunchDarklyFlagFetchError');
|
152
|
+
|
153
|
+
function E(e) {
|
154
|
+
return !(e >= 400 && e < 500) || 400 === e || 408 === e || 429 === e;
|
155
|
+
}
|
156
|
+
|
157
|
+
for (var O = Object.freeze({
|
158
|
+
__proto__: null,
|
159
|
+
LDUnexpectedResponseError: m,
|
160
|
+
LDInvalidEnvironmentIdError: y,
|
161
|
+
LDInvalidUserError: h,
|
162
|
+
LDInvalidEventKeyError: b,
|
163
|
+
LDInvalidArgumentError: w,
|
164
|
+
LDFlagFetchError: k,
|
165
|
+
isHttpErrorRecoverable: E
|
166
|
+
}), S = [], P = [], D = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', j = 0, U = D.length; j < U; ++j) S[j] = D[j], P[D.charCodeAt(j)] = j;
|
167
|
+
|
168
|
+
function I(e, n, t) {
|
169
|
+
for (var r, o, i = [], a = n; a < t; a += 3) r = (e[a] << 16 & 16711680) + (e[a + 1] << 8 & 65280) + (255 & e[a + 2]), i.push(S[(o = r) >> 18 & 63] + S[o >> 12 & 63] + S[o >> 6 & 63] + S[63 & o]);
|
170
|
+
return i.join('');
|
171
|
+
}
|
172
|
+
|
173
|
+
P['-'.charCodeAt(0)] = 62, P['_'.charCodeAt(0)] = 63;
|
174
|
+
var R = Array.isArray, T = Object.keys, N = Object.prototype.hasOwnProperty,
|
175
|
+
F = ['key', 'secondary', 'ip', 'country', 'email', 'firstName', 'lastName', 'avatar', 'name'];
|
176
|
+
|
177
|
+
function x(e) {
|
178
|
+
return function (e) {
|
179
|
+
for (var n, t = e.length, r = t % 3, o = [], i = 0, a = t - r; i < a; i += 16383) o.push(I(e, i, i + 16383 > a ? a : i + 16383));
|
180
|
+
return 1 === r ? (n = e[t - 1], o.push(S[n >> 2] + S[n << 4 & 63] + '==')) : 2 === r && (n = (e[t - 2] << 8) + e[t - 1], o.push(S[n >> 10] + S[n >> 4 & 63] + S[n << 2 & 63] + '=')), o.join('');
|
181
|
+
}(function (e) {
|
182
|
+
for (var n = [], t = 0; t < e.length; t++) n.push(e.charCodeAt(t));
|
183
|
+
return n;
|
184
|
+
}(unescape(encodeURIComponent(e))));
|
185
|
+
}
|
186
|
+
|
187
|
+
function L(e) {
|
188
|
+
return x(e).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
189
|
+
}
|
190
|
+
|
191
|
+
function C(e) {
|
192
|
+
return JSON.parse(JSON.stringify(e));
|
193
|
+
}
|
194
|
+
|
195
|
+
function A(e, n) {
|
196
|
+
return function e(n, t) {
|
197
|
+
if (n === t) return !0;
|
198
|
+
if (n && t && 'object' == typeof n && 'object' == typeof t) {
|
199
|
+
var r, o, i, a = R(n), u = R(t);
|
200
|
+
if (a && u) {
|
201
|
+
if ((o = n.length) != t.length) return !1;
|
202
|
+
for (r = o; 0 != r--;) if (!e(n[r], t[r])) return !1;
|
203
|
+
return !0;
|
204
|
+
}
|
205
|
+
if (a != u) return !1;
|
206
|
+
var c = n instanceof Date, s = t instanceof Date;
|
207
|
+
if (c != s) return !1;
|
208
|
+
if (c && s) return n.getTime() == t.getTime();
|
209
|
+
var l = n instanceof RegExp, f = t instanceof RegExp;
|
210
|
+
if (l != f) return !1;
|
211
|
+
if (l && f) return n.toString() == t.toString();
|
212
|
+
var d = T(n);
|
213
|
+
if ((o = d.length) !== T(t).length) return !1;
|
214
|
+
for (r = o; 0 != r--;) if (!N.call(t, d[r])) return !1;
|
215
|
+
for (r = o; 0 != r--;) if (!e(n[i = d[r]], t[i])) return !1;
|
216
|
+
return !0;
|
217
|
+
}
|
218
|
+
return n != n && t != t;
|
219
|
+
}(e, n);
|
220
|
+
}
|
221
|
+
|
222
|
+
function q(e) {
|
223
|
+
setTimeout(e, 0);
|
224
|
+
}
|
225
|
+
|
226
|
+
function _(e, n) {
|
227
|
+
var t = e.then((function (e) {
|
228
|
+
return n && setTimeout((function () {
|
229
|
+
n(null, e);
|
230
|
+
}), 0), e;
|
231
|
+
}), (function (e) {
|
232
|
+
if (!n) return Promise.reject(e);
|
233
|
+
setTimeout((function () {
|
234
|
+
n(e, null);
|
235
|
+
}), 0);
|
236
|
+
}));
|
237
|
+
return n ? void 0 : t;
|
238
|
+
}
|
239
|
+
|
240
|
+
function M(e) {
|
241
|
+
var n = {};
|
242
|
+
for (var t in e) H(e, t) && (n[t] = { value: e[t], version: 0 });
|
243
|
+
return n;
|
244
|
+
}
|
245
|
+
|
246
|
+
function V(e) {
|
247
|
+
var n = {};
|
248
|
+
for (var t in e) H(e, t) && (n[t] = e[t].value);
|
249
|
+
return n;
|
250
|
+
}
|
251
|
+
|
252
|
+
function J(e, n) {
|
253
|
+
for (var t, r = n.slice(0), o = [], i = e; r.length > 0;) {
|
254
|
+
for (t = []; i > 0;) {
|
255
|
+
var a = r.shift();
|
256
|
+
if (!a) break;
|
257
|
+
(i -= L(JSON.stringify(a)).length) < 0 && t.length > 0 ? r.unshift(a) : t.push(a);
|
258
|
+
}
|
259
|
+
i = e, o.push(t);
|
260
|
+
}
|
261
|
+
return o;
|
262
|
+
}
|
263
|
+
|
264
|
+
function z(e) {
|
265
|
+
var n = e.version || '3.3.2';
|
266
|
+
return e.userAgent + '/' + n;
|
267
|
+
}
|
268
|
+
|
269
|
+
function K(e, n) {
|
270
|
+
if (n && !n.sendLDHeaders) return {};
|
271
|
+
var t = { 'X-LaunchDarkly-User-Agent': z(e) };
|
272
|
+
return n && n.wrapperName && (t['X-LaunchDarkly-Wrapper'] = n.wrapperVersion ? n.wrapperName + '/' + n.wrapperVersion : n.wrapperName), t;
|
273
|
+
}
|
274
|
+
|
275
|
+
function $() {
|
276
|
+
for (var e = arguments.length, n = new Array(e), t = 0; t < e; t++) n[t] = arguments[t];
|
277
|
+
return n.reduce((function (e, n) {
|
278
|
+
return g({}, e, {}, n);
|
279
|
+
}), {});
|
280
|
+
}
|
281
|
+
|
282
|
+
function H(e, n) {
|
283
|
+
return Object.prototype.hasOwnProperty.call(e, n);
|
284
|
+
}
|
285
|
+
|
286
|
+
function B(e) {
|
287
|
+
if (!e) return e;
|
288
|
+
var n;
|
289
|
+
for (var t in F) {
|
290
|
+
var r = F[t], o = e[r];
|
291
|
+
void 0 !== o && 'string' != typeof o && ((n = n || g({}, e))[r] = String(o));
|
292
|
+
}
|
293
|
+
return n || e;
|
294
|
+
}
|
295
|
+
|
296
|
+
Object.freeze({
|
297
|
+
__proto__: null,
|
298
|
+
btoa: x,
|
299
|
+
base64URLEncode: L,
|
300
|
+
clone: C,
|
301
|
+
deepEquals: A,
|
302
|
+
onNextTick: q,
|
303
|
+
wrapPromiseCallback: _,
|
304
|
+
transformValuesToVersionedValues: M,
|
305
|
+
transformVersionedValuesToValues: V,
|
306
|
+
chunkUserEventsForUrl: J,
|
307
|
+
getLDUserAgentString: z,
|
308
|
+
getLDHeaders: K,
|
309
|
+
extend: $,
|
310
|
+
objectHasOwnProperty: H,
|
311
|
+
sanitizeUser: B
|
312
|
+
});
|
313
|
+
for (var G = function (e, n) {
|
314
|
+
return function (e) {
|
315
|
+
var n = 'undefined' != typeof crypto && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || 'undefined' != typeof msCrypto && 'function' == typeof window.msCrypto.getRandomValues && msCrypto.getRandomValues.bind(msCrypto);
|
316
|
+
if (n) {
|
317
|
+
var t = new Uint8Array(16);
|
318
|
+
e.exports = function () {
|
319
|
+
return n(t), t;
|
320
|
+
};
|
321
|
+
} else {
|
322
|
+
var r = new Array(16);
|
323
|
+
e.exports = function () {
|
324
|
+
for (var e, n = 0; n < 16; n++) 0 == (3 & n) && (e = 4294967296 * Math.random()), r[n] = e >>> ((3 & n) << 3) & 255;
|
325
|
+
return r;
|
326
|
+
};
|
327
|
+
}
|
328
|
+
}(n = { exports: {} }), n.exports;
|
329
|
+
}(), X = [], W = 0; W < 256; ++W) X[W] = (W + 256).toString(16).substr(1);
|
330
|
+
var Q, Y, Z = 0, ee = 0, ne = function (e, n, t) {
|
331
|
+
var r = n && t || 0, o = n || [], i = (e = e || {}).node || Q,
|
332
|
+
a = void 0 !== e.clockseq ? e.clockseq : Y;
|
333
|
+
if (null == i || null == a) {
|
334
|
+
var u = G();
|
335
|
+
null == i && (i = Q = [1 | u[0], u[1], u[2], u[3], u[4], u[5]]), null == a && (a = Y = 16383 & (u[6] << 8 | u[7]));
|
336
|
+
}
|
337
|
+
var c = void 0 !== e.msecs ? e.msecs : (new Date).getTime(),
|
338
|
+
s = void 0 !== e.nsecs ? e.nsecs : ee + 1, l = c - Z + (s - ee) / 1e4;
|
339
|
+
if (l < 0 && void 0 === e.clockseq && (a = a + 1 & 16383), (l < 0 || c > Z) && void 0 === e.nsecs && (s = 0), s >= 1e4) throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
|
340
|
+
Z = c, ee = s, Y = a;
|
341
|
+
var f = (1e4 * (268435455 & (c += 122192928e5)) + s) % 4294967296;
|
342
|
+
o[r++] = f >>> 24 & 255, o[r++] = f >>> 16 & 255, o[r++] = f >>> 8 & 255, o[r++] = 255 & f;
|
343
|
+
var d = c / 4294967296 * 1e4 & 268435455;
|
344
|
+
o[r++] = d >>> 8 & 255, o[r++] = 255 & d, o[r++] = d >>> 24 & 15 | 16, o[r++] = d >>> 16 & 255, o[r++] = a >>> 8 | 128, o[r++] = 255 & a;
|
345
|
+
for (var v = 0; v < 6; ++v) o[r + v] = i[v];
|
346
|
+
return n || function (e, n) {
|
347
|
+
var t = 0, r = X;
|
348
|
+
return [r[e[t++]], r[e[t++]], r[e[t++]], r[e[t++]], '-', r[e[t++]], r[e[t++]], '-', r[e[t++]], r[e[t++]], '-', r[e[t++]], r[e[t++]], '-', r[e[t++]], r[e[t++]], r[e[t++]], r[e[t++]], r[e[t++]], r[e[t++]]].join('');
|
349
|
+
}(o);
|
350
|
+
};
|
351
|
+
|
352
|
+
function te(e, n, t) {
|
353
|
+
var r = '/a/' + n + '.gif', o = $({ 'Content-Type': 'application/json' }, K(e, t)),
|
354
|
+
i = e.httpFallbackPing, a = {
|
355
|
+
sendChunk: function (n, t, a, u) {
|
356
|
+
var c = JSON.stringify(n), s = a ? null : ne();
|
357
|
+
return u ? function n(r) {
|
358
|
+
var i = a ? o : $({}, o, {
|
359
|
+
'X-LaunchDarkly-Event-Schema': '3',
|
360
|
+
'X-LaunchDarkly-Payload-ID': s
|
361
|
+
});
|
362
|
+
return e.httpRequest('POST', t, i, c).promise.then((function (e) {
|
363
|
+
if (e) return e.status >= 400 && E(e.status) && r ? n(!1) : function (e) {
|
364
|
+
var n = { status: e.status }, t = e.header('date');
|
365
|
+
if (t) {
|
366
|
+
var r = Date.parse(t);
|
367
|
+
r && (n.serverTime = r);
|
368
|
+
}
|
369
|
+
return n;
|
370
|
+
}(e);
|
371
|
+
})).catch((function () {
|
372
|
+
return r ? n(!1) : Promise.reject();
|
373
|
+
}));
|
374
|
+
}(!0).catch((function () {
|
375
|
+
})) : (i && i(t + r + '?d=' + L(c)), Promise.resolve());
|
376
|
+
}, sendEvents: function (n, t, r) {
|
377
|
+
if (!e.httpRequest) return Promise.resolve();
|
378
|
+
var o, i = e.httpAllowsPost();
|
379
|
+
o = i ? [n] : J(2e3 - t.length, n);
|
380
|
+
for (var u = [], c = 0; c < o.length; c++) u.push(a.sendChunk(o[c], t, r, i));
|
381
|
+
return Promise.all(u);
|
382
|
+
}
|
383
|
+
};
|
384
|
+
return a;
|
385
|
+
}
|
386
|
+
|
387
|
+
function re() {
|
388
|
+
var e = {}, n = 0, t = 0, r = {};
|
389
|
+
return e.summarizeEvent = function (e) {
|
390
|
+
if ('feature' === e.kind) {
|
391
|
+
var o = e.key + ':' + (null !== e.variation && void 0 !== e.variation ? e.variation : '') + ':' + (null !== e.version && void 0 !== e.version ? e.version : ''),
|
392
|
+
i = r[o];
|
393
|
+
i ? i.count = i.count + 1 : r[o] = {
|
394
|
+
count: 1,
|
395
|
+
key: e.key,
|
396
|
+
variation: e.variation,
|
397
|
+
version: e.version,
|
398
|
+
value: e.value,
|
399
|
+
default: e.default
|
400
|
+
}, (0 === n || e.creationDate < n) && (n = e.creationDate), e.creationDate > t && (t = e.creationDate);
|
401
|
+
}
|
402
|
+
}, e.getSummary = function () {
|
403
|
+
var e = {}, o = !0;
|
404
|
+
for (var i in r) {
|
405
|
+
var a = r[i], u = e[a.key];
|
406
|
+
u || (u = { default: a.default, counters: [] }, e[a.key] = u);
|
407
|
+
var c = { value: a.value, count: a.count };
|
408
|
+
void 0 !== a.variation && null !== a.variation && (c.variation = a.variation), a.version ? c.version = a.version : c.unknown = !0, u.counters.push(c), o = !1;
|
409
|
+
}
|
410
|
+
return o ? null : { startDate: n, endDate: t, features: e };
|
411
|
+
}, e.clearSummary = function () {
|
412
|
+
n = 0, t = 0, r = {};
|
413
|
+
}, e;
|
414
|
+
}
|
415
|
+
|
416
|
+
function oe(e) {
|
417
|
+
var n = {}, t = e.allAttributesPrivate, r = e.privateAttributeNames || [],
|
418
|
+
o = { key: !0, custom: !0, anonymous: !0 }, i = {
|
419
|
+
key: !0,
|
420
|
+
secondary: !0,
|
421
|
+
ip: !0,
|
422
|
+
country: !0,
|
423
|
+
email: !0,
|
424
|
+
firstName: !0,
|
425
|
+
lastName: !0,
|
426
|
+
avatar: !0,
|
427
|
+
name: !0,
|
428
|
+
anonymous: !0,
|
429
|
+
custom: !0
|
430
|
+
};
|
431
|
+
return n.filterUser = function (e) {
|
432
|
+
if (!e) return null;
|
433
|
+
var n = e.privateAttributeNames || [], a = function (e, i) {
|
434
|
+
return Object.keys(e).reduce((function (a, u) {
|
435
|
+
var c = a;
|
436
|
+
return i(u) && (function (e) {
|
437
|
+
return !o[e] && (t || -1 !== n.indexOf(e) || -1 !== r.indexOf(e));
|
438
|
+
}(u) ? c[1][u] = !0 : c[0][u] = e[u]), c;
|
439
|
+
}), [{}, {}]);
|
440
|
+
}, u = a(e, (function (e) {
|
441
|
+
return i[e];
|
442
|
+
})), c = u[0], s = u[1];
|
443
|
+
if (e.custom) {
|
444
|
+
var l = a(e.custom, (function () {
|
445
|
+
return !0;
|
446
|
+
}));
|
447
|
+
c.custom = l[0], s = $({}, s, l[1]);
|
448
|
+
}
|
449
|
+
var f = Object.keys(s);
|
450
|
+
return f.length && (f.sort(), c.privateAttrs = f), c;
|
451
|
+
}, n;
|
452
|
+
}
|
453
|
+
|
454
|
+
function ie(e) {
|
455
|
+
return e && e.message ? e.message : 'string' == typeof e || e instanceof String ? e : JSON.stringify(e);
|
456
|
+
}
|
457
|
+
|
458
|
+
var ae = ' Please see https://docs.launchdarkly.com/docs/js-sdk-reference#initializing-the-client for instructions on SDK initialization.',
|
459
|
+
ue = function (e) {
|
460
|
+
return 'Expected application/json content type but got "' + e + '"';
|
461
|
+
}, ce = function (e) {
|
462
|
+
return 'network error' + (e ? ' (' + e + ')' : '');
|
463
|
+
}, se = function (e) {
|
464
|
+
return 'Custom event "' + e + '" does not exist';
|
465
|
+
}, le = function () {
|
466
|
+
return 'Environment not found. Double check that you specified a valid environment/client-side ID.' + ae;
|
467
|
+
}, fe = function () {
|
468
|
+
return 'No environment/client-side ID was specified.' + ae;
|
469
|
+
}, de = function (e) {
|
470
|
+
return 'Error fetching flag settings: ' + ie(e);
|
471
|
+
}, ve = function () {
|
472
|
+
return 'No user specified.' + ae;
|
473
|
+
}, ge = function () {
|
474
|
+
return 'Invalid user specified.' + ae;
|
475
|
+
}, pe = function () {
|
476
|
+
return 'LaunchDarkly client was initialized with bootstrap data that did not include flag metadata. Events may not be sent correctly.' + ae;
|
477
|
+
}, me = function (e, n) {
|
478
|
+
return n ? '"' + e + '" is deprecated, please use "' + n + '"' : '"' + e + '" is deprecated';
|
479
|
+
}, ye = function (e, n, t) {
|
480
|
+
return 'Received error ' + e + (401 === e ? ' (invalid SDK key)' : '') + ' for ' + n + ' - ' + (E(e) ? t : 'giving up permanently');
|
481
|
+
}, he = function () {
|
482
|
+
return 'Cannot make HTTP requests in this environment.' + ae;
|
483
|
+
}, be = function (e) {
|
484
|
+
return 'Opening stream connection to ' + e;
|
485
|
+
}, we = function (e, n) {
|
486
|
+
return 'Error on stream connection: ' + ie(e) + ', will continue retrying every ' + n + ' milliseconds.';
|
487
|
+
}, ke = function (e) {
|
488
|
+
return 'Ignoring unknown config option "' + e + '"';
|
489
|
+
}, Ee = function (e, n, t) {
|
490
|
+
return 'Config option "' + e + '" should be of type ' + n + ', got ' + t + ', using default value';
|
491
|
+
}, Oe = function (e, n) {
|
492
|
+
return 'Config option "' + e + '" should be a boolean, got ' + n + ', converting to boolean';
|
493
|
+
}, Se = function (e, n, t) {
|
494
|
+
return 'Config option "' + e + '" was set to ' + n + ', changing to minimum value of ' + t;
|
495
|
+
}, Pe = function (e) {
|
496
|
+
return 'polling for feature flags at ' + e;
|
497
|
+
}, De = function (e) {
|
498
|
+
return 'received streaming update for flag "' + e + '"';
|
499
|
+
}, je = function (e) {
|
500
|
+
return 'received streaming update for flag "' + e + '" but ignored due to version check';
|
501
|
+
}, Ue = function (e) {
|
502
|
+
return 'received streaming deletion for flag "' + e + '"';
|
503
|
+
}, Ie = function (e) {
|
504
|
+
return 'received streaming deletion for flag "' + e + '" but ignored due to version check';
|
505
|
+
}, Re = function (e) {
|
506
|
+
return 'enqueueing "' + e + '" event';
|
507
|
+
}, Te = function (e) {
|
508
|
+
return 'sending ' + e + ' events';
|
509
|
+
}, Ne = Object.freeze({
|
510
|
+
__proto__: null,
|
511
|
+
clientInitialized: function () {
|
512
|
+
return 'LaunchDarkly client initialized';
|
513
|
+
},
|
514
|
+
clientNotReady: function () {
|
515
|
+
return 'LaunchDarkly client is not ready';
|
516
|
+
},
|
517
|
+
eventCapacityExceeded: function () {
|
518
|
+
return 'Exceeded event queue capacity. Increase capacity to avoid dropping events.';
|
519
|
+
},
|
520
|
+
eventWithoutUser: function () {
|
521
|
+
return 'Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events';
|
522
|
+
},
|
523
|
+
invalidContentType: ue,
|
524
|
+
invalidKey: function () {
|
525
|
+
return 'Event key must be a string';
|
526
|
+
},
|
527
|
+
localStorageUnavailable: function () {
|
528
|
+
return 'localStorage is unavailable';
|
529
|
+
},
|
530
|
+
localStorageUnavailableForUserId: function () {
|
531
|
+
return 'localStorage is unavailable, so anonymous user ID cannot be cached';
|
532
|
+
},
|
533
|
+
networkError: ce,
|
534
|
+
unknownCustomEventKey: se,
|
535
|
+
environmentNotFound: le,
|
536
|
+
environmentNotSpecified: fe,
|
537
|
+
errorFetchingFlags: de,
|
538
|
+
userNotSpecified: ve,
|
539
|
+
invalidUser: ge,
|
540
|
+
bootstrapOldFormat: pe,
|
541
|
+
bootstrapInvalid: function () {
|
542
|
+
return 'LaunchDarkly bootstrap data is not available because the back end could not read the flags.';
|
543
|
+
},
|
544
|
+
deprecated: me,
|
545
|
+
httpErrorMessage: ye,
|
546
|
+
httpUnavailable: he,
|
547
|
+
identifyDisabled: function () {
|
548
|
+
return 'identify() has no effect here; it must be called on the main client instance';
|
549
|
+
},
|
550
|
+
streamClosing: function () {
|
551
|
+
return 'Closing stream connection';
|
552
|
+
},
|
553
|
+
streamConnecting: be,
|
554
|
+
streamError: we,
|
555
|
+
unknownOption: ke,
|
556
|
+
wrongOptionType: Ee,
|
557
|
+
wrongOptionTypeBoolean: Oe,
|
558
|
+
optionBelowMinimum: Se,
|
559
|
+
debugPolling: Pe,
|
560
|
+
debugStreamPing: function () {
|
561
|
+
return 'received ping message from stream';
|
562
|
+
},
|
563
|
+
debugStreamPut: function () {
|
564
|
+
return 'received streaming update for all flags';
|
565
|
+
},
|
566
|
+
debugStreamPatch: De,
|
567
|
+
debugStreamPatchIgnored: je,
|
568
|
+
debugStreamDelete: Ue,
|
569
|
+
debugStreamDeleteIgnored: Ie,
|
570
|
+
debugEnqueueingEvent: Re,
|
571
|
+
debugPostingEvents: Te,
|
572
|
+
debugPostingDiagnosticEvent: function (e) {
|
573
|
+
return 'sending diagnostic event (' + e.kind + ')';
|
574
|
+
}
|
575
|
+
});
|
576
|
+
|
577
|
+
function Fe(e, n, t, r, o) {
|
578
|
+
var i = {};
|
579
|
+
|
580
|
+
function a() {
|
581
|
+
var e = '', o = r.getUser();
|
582
|
+
return o && (e = t || x(JSON.stringify(o))), 'ld:' + n + ':' + e;
|
583
|
+
}
|
584
|
+
|
585
|
+
return i.loadFlags = function () {
|
586
|
+
return e.get(a()).then((function (e) {
|
587
|
+
if (null == e) return null;
|
588
|
+
try {
|
589
|
+
var n = JSON.parse(e);
|
590
|
+
if (n) {
|
591
|
+
var t = n.$schema;
|
592
|
+
void 0 === t || t < 1 ? n = M(n) : delete n.$schema;
|
593
|
+
}
|
594
|
+
return n;
|
595
|
+
} catch (e) {
|
596
|
+
return i.clearFlags().then((function () {
|
597
|
+
return Promise.reject(e);
|
598
|
+
}));
|
599
|
+
}
|
600
|
+
})).catch((function (e) {
|
601
|
+
return o.warn('localStorage is unavailable'), Promise.reject(e);
|
602
|
+
}));
|
603
|
+
}, i.saveFlags = function (n) {
|
604
|
+
var t = $({}, n, { $schema: 1 });
|
605
|
+
return e.set(a(), JSON.stringify(t)).catch((function (e) {
|
606
|
+
return o.warn('localStorage is unavailable'), Promise.reject(e);
|
607
|
+
}));
|
608
|
+
}, i.clearFlags = function () {
|
609
|
+
return e.clear(a()).catch((function (e) {
|
610
|
+
return o.warn('localStorage is unavailable'), Promise.reject(e);
|
611
|
+
}));
|
612
|
+
}, i;
|
613
|
+
}
|
614
|
+
|
615
|
+
function xe(e, n, t, r) {
|
616
|
+
var o, i = n.streamUrl, a = n.logger, u = {}, c = i + '/eval/' + t, s = n.useReport,
|
617
|
+
l = n.evaluationReasons, f = n.streamReconnectDelay, d = K(e, n), v = !1, g = null,
|
618
|
+
p = null, m = null, y = null, h = null;
|
619
|
+
|
620
|
+
function b(e) {
|
621
|
+
v || (a.warn(we(e, f)), v = !0), O(!1), E(), w(f);
|
622
|
+
}
|
623
|
+
|
624
|
+
function w(e) {
|
625
|
+
p || (e ? p = setTimeout(k, e) : k());
|
626
|
+
}
|
627
|
+
|
628
|
+
function k() {
|
629
|
+
var n;
|
630
|
+
p = null;
|
631
|
+
var r = '', u = { headers: d, readTimeoutMillis: 3e5 };
|
632
|
+
if (e.eventSourceFactory) {
|
633
|
+
for (var f in null != y && (r = 'h=' + y), s ? e.eventSourceAllowsReport ? (n = c, u.method = 'REPORT', u.headers['Content-Type'] = 'application/json', u.body = JSON.stringify(m)) : (n = i + '/ping/' + t, r = '') : n = c + '/' + L(JSON.stringify(m)), l && (r = r + (r ? '&' : '') + 'withReasons=true'), n = n + (r ? '?' : '') + r, E(), a.info(be(n)), o = (new Date).getTime(), g = e.eventSourceFactory(n, u), h) H(h, f) && g.addEventListener(f, h[f]);
|
634
|
+
g.onerror = b;
|
635
|
+
}
|
636
|
+
}
|
637
|
+
|
638
|
+
function E() {
|
639
|
+
g && (a.info('Closing stream connection'), g.close(), g = null);
|
640
|
+
}
|
641
|
+
|
642
|
+
function O(e) {
|
643
|
+
o && r && r.recordStreamInit(o, !e, (new Date).getTime() - o), o = null;
|
644
|
+
}
|
645
|
+
|
646
|
+
return u.connect = function (e, n, t) {
|
647
|
+
m = e, y = n, h = {};
|
648
|
+
var r = function (e) {
|
649
|
+
h[e] = function (n) {
|
650
|
+
v = !1, O(!0), t[e] && t[e](n);
|
651
|
+
};
|
652
|
+
};
|
653
|
+
for (var o in t || {}) r(o);
|
654
|
+
w();
|
655
|
+
}, u.disconnect = function () {
|
656
|
+
clearTimeout(p), p = null, E();
|
657
|
+
}, u.isConnected = function () {
|
658
|
+
return !!(g && e.eventSourceIsActive && e.eventSourceIsActive(g));
|
659
|
+
}, u;
|
660
|
+
}
|
661
|
+
|
662
|
+
function Le(e, n, t) {
|
663
|
+
var r = n.baseUrl, o = n.useReport, i = n.evaluationReasons, a = n.logger, u = {}, c = {};
|
664
|
+
|
665
|
+
function s(t, r) {
|
666
|
+
if (!e.httpRequest) return new Promise((function (e, n) {
|
667
|
+
n(new k(he()));
|
668
|
+
}));
|
669
|
+
var o = r ? 'REPORT' : 'GET', i = K(e, n);
|
670
|
+
r && (i['Content-Type'] = 'application/json');
|
671
|
+
var a = c[t];
|
672
|
+
a || (a = function (e) {
|
673
|
+
var n, t, r, o, i = {
|
674
|
+
addPromise: function (i, a) {
|
675
|
+
n = i, t && t(), t = a, i.then((function (t) {
|
676
|
+
n === i && (r(t), e && e());
|
677
|
+
}), (function (t) {
|
678
|
+
n === i && (o(t), e && e());
|
679
|
+
}));
|
680
|
+
}
|
681
|
+
};
|
682
|
+
return i.resultPromise = new Promise((function (e, n) {
|
683
|
+
r = e, o = n;
|
684
|
+
})), i;
|
685
|
+
}((function () {
|
686
|
+
delete c[t];
|
687
|
+
})), c[t] = a);
|
688
|
+
var u = e.httpRequest(o, t, i, r), s = u.promise.then((function (e) {
|
689
|
+
if (200 === e.status) {
|
690
|
+
if (e.header('content-type') && 'application/json' === e.header('content-type').substring(0, 'application/json'.length)) return JSON.parse(e.body);
|
691
|
+
var n = ue(e.header('content-type') || '');
|
692
|
+
return Promise.reject(new k(n));
|
693
|
+
}
|
694
|
+
return Promise.reject(function (e) {
|
695
|
+
return 404 === e.status ? new y(le()) : new k(de(e.statusText || String(e.status)));
|
696
|
+
}(e));
|
697
|
+
}), (function (e) {
|
698
|
+
return Promise.reject(new k(ce(e)));
|
699
|
+
}));
|
700
|
+
return a.addPromise(s, (function () {
|
701
|
+
u.cancel && u.cancel();
|
702
|
+
})), a.resultPromise;
|
703
|
+
}
|
704
|
+
|
705
|
+
return u.fetchJSON = function (e) {
|
706
|
+
return s(r + e, null);
|
707
|
+
}, u.fetchFlagSettings = function (e, n) {
|
708
|
+
var u, c, l, f = '';
|
709
|
+
return o ? (c = [r, '/sdk/evalx/', t, '/user'].join(''), l = JSON.stringify(e)) : (u = L(JSON.stringify(e)), c = [r, '/sdk/evalx/', t, '/users/', u].join('')), n && (f = 'h=' + n), i && (f = f + (f ? '&' : '') + 'withReasons=true'), c = c + (f ? '?' : '') + f, a.debug(Pe(c)), s(c, l);
|
710
|
+
}, u;
|
711
|
+
}
|
712
|
+
|
713
|
+
function Ce(e, n) {
|
714
|
+
return {
|
715
|
+
validateUser: function (t) {
|
716
|
+
if (!t) return Promise.reject(new h(ve()));
|
717
|
+
var r = C(t);
|
718
|
+
return null !== r.key && void 0 !== r.key ? (r.key = r.key.toString(), Promise.resolve(r)) : r.anonymous ? (e ? e.get('ld:$anonUserId').catch((function () {
|
719
|
+
return null;
|
720
|
+
})) : Promise.resolve(null)).then((function (t) {
|
721
|
+
if (t) return r.key = t, r;
|
722
|
+
var o = ne();
|
723
|
+
return r.key = o, function (t) {
|
724
|
+
return e ? e.set('ld:$anonUserId', t).catch((function () {
|
725
|
+
n.warn('localStorage is unavailable, so anonymous user ID cannot be cached');
|
726
|
+
})) : Promise.resolve();
|
727
|
+
}(o).then((function () {
|
728
|
+
return r;
|
729
|
+
}));
|
730
|
+
})) : Promise.reject(new h(ge()));
|
731
|
+
}
|
732
|
+
};
|
733
|
+
}
|
734
|
+
|
735
|
+
var Ae = {
|
736
|
+
baseUrl: { default: 'https://app.launchdarkly.com' },
|
737
|
+
streamUrl: { default: 'https://clientstream.launchdarkly.com' },
|
738
|
+
eventsUrl: { default: 'https://events.launchdarkly.com' },
|
739
|
+
sendEvents: { default: !0 },
|
740
|
+
streaming: { type: 'boolean' },
|
741
|
+
sendLDHeaders: { default: !0 },
|
742
|
+
inlineUsersInEvents: { default: !1 },
|
743
|
+
allowFrequentDuplicateEvents: { default: !1 },
|
744
|
+
sendEventsOnlyForVariation: { default: !1 },
|
745
|
+
useReport: { default: !1 },
|
746
|
+
evaluationReasons: { default: !1 },
|
747
|
+
eventCapacity: { default: 100, minimum: 1 },
|
748
|
+
flushInterval: { default: 2e3, minimum: 2e3 },
|
749
|
+
samplingInterval: { default: 0, minimum: 0 },
|
750
|
+
streamReconnectDelay: { default: 1e3, minimum: 0 },
|
751
|
+
allAttributesPrivate: { default: !1 },
|
752
|
+
privateAttributeNames: { default: [] },
|
753
|
+
bootstrap: { type: 'string|object' },
|
754
|
+
diagnosticRecordingInterval: { default: 9e5, minimum: 2e3 },
|
755
|
+
diagnosticOptOut: { default: !1 },
|
756
|
+
wrapperName: { type: 'string' },
|
757
|
+
wrapperVersion: { type: 'string' },
|
758
|
+
stateProvider: { type: 'object' },
|
759
|
+
autoAliasingOptOut: { default: !1 }
|
760
|
+
};
|
761
|
+
|
762
|
+
function qe(e, n, t, r) {
|
763
|
+
var o = $({ logger: { default: r } }, Ae, t), i = {
|
764
|
+
all_attributes_private: 'allAttributesPrivate',
|
765
|
+
private_attribute_names: 'privateAttributeNames',
|
766
|
+
samplingInterval: null
|
767
|
+
};
|
768
|
+
|
769
|
+
function a(e) {
|
770
|
+
q((function () {
|
771
|
+
n && n.maybeReportError(new w(e));
|
772
|
+
}));
|
773
|
+
}
|
774
|
+
|
775
|
+
var u = $({}, e || {});
|
776
|
+
return function (e) {
|
777
|
+
var n = e;
|
778
|
+
Object.keys(i).forEach((function (e) {
|
779
|
+
if (void 0 !== n[e]) {
|
780
|
+
var t = i[e];
|
781
|
+
r && r.warn(me(e, t)), t && (void 0 === n[t] && (n[t] = n[e]), delete n[e]);
|
782
|
+
}
|
783
|
+
}));
|
784
|
+
}(u), function (e) {
|
785
|
+
var n = $({}, e), t = function (e) {
|
786
|
+
if (null === e) return 'any';
|
787
|
+
if (void 0 !== e) {
|
788
|
+
if (Array.isArray(e)) return 'array';
|
789
|
+
var n = f(e);
|
790
|
+
return 'boolean' === n || 'string' === n || 'number' === n || 'function' === n ? n : 'object';
|
791
|
+
}
|
792
|
+
};
|
793
|
+
return Object.keys(e).forEach((function (r) {
|
794
|
+
var i = e[r];
|
795
|
+
if (null != i) {
|
796
|
+
var u = o[r];
|
797
|
+
if (void 0 === u) a(ke(r)); else {
|
798
|
+
var c = u.type || t(u.default);
|
799
|
+
if ('any' !== c) {
|
800
|
+
var s = c.split('|'), l = t(i);
|
801
|
+
s.indexOf(l) < 0 ? 'boolean' === c ? (n[r] = !!i, a(Oe(r, l))) : (a(Ee(r, c, l)), n[r] = u.default) : 'number' === l && void 0 !== u.minimum && i < u.minimum && (a(Se(r, i, u.minimum)), n[r] = u.minimum);
|
802
|
+
}
|
803
|
+
}
|
804
|
+
}
|
805
|
+
})), n;
|
806
|
+
}(u = function (e) {
|
807
|
+
var n = $({}, e);
|
808
|
+
return Object.keys(o).forEach((function (e) {
|
809
|
+
void 0 !== n[e] && null !== n[e] || (n[e] = o[e] && o[e].default);
|
810
|
+
})), n;
|
811
|
+
}(u));
|
812
|
+
}
|
813
|
+
|
814
|
+
var _e = Object.freeze({ __proto__: null, baseOptionDefs: Ae, validate: qe }).baseOptionDefs,
|
815
|
+
Me = function (e) {
|
816
|
+
var n = { diagnosticId: ne() };
|
817
|
+
return e && (n.sdkKeySuffix = e.length > 6 ? e.substring(e.length - 6) : e), n;
|
818
|
+
};
|
819
|
+
|
820
|
+
function Ve(e, n) {
|
821
|
+
var t, r = ['debug', 'info', 'warn', 'error'];
|
822
|
+
t = null != n ? '' === n ? '' : n + ' ' : 'LD: ';
|
823
|
+
var o = 0;
|
824
|
+
e && (o = 'none' === e ? 100 : r.indexOf(e));
|
825
|
+
var i = {};
|
826
|
+
|
827
|
+
function a(e, n, i) {
|
828
|
+
if (e >= o && console) {
|
829
|
+
var a = console[n];
|
830
|
+
if (a) {
|
831
|
+
var u = e < r.length ? r[e] : '?';
|
832
|
+
a.call(console, t + '[' + u + '] ' + i);
|
833
|
+
}
|
834
|
+
}
|
835
|
+
}
|
836
|
+
|
837
|
+
return i.debug = function (e) {
|
838
|
+
return a(0, 'log', e);
|
839
|
+
}, i.info = function (e) {
|
840
|
+
return a(1, 'info', e);
|
841
|
+
}, i.warn = function (e) {
|
842
|
+
return a(2, 'warn', e);
|
843
|
+
}, i.error = function (e) {
|
844
|
+
return a(3, 'error', e);
|
845
|
+
}, i;
|
846
|
+
}
|
847
|
+
|
848
|
+
function Je(e, n, t, r, o) {
|
849
|
+
var i, a, u, c,
|
850
|
+
s = t && t.logger ? t.logger : o && o.logger && o.logger.default || Ve('warn'),
|
851
|
+
l = function (e) {
|
852
|
+
var n = {}, t = {};
|
853
|
+
return n.on = function (e, n, r) {
|
854
|
+
t[e] = t[e] || [], t[e] = t[e].concat({ handler: n, context: r });
|
855
|
+
}, n.off = function (e, n, r) {
|
856
|
+
if (t[e]) for (var o = 0; o < t[e].length; o++) t[e][o].handler === n && t[e][o].context === r && (t[e] = t[e].slice(0, o).concat(t[e].slice(o + 1)));
|
857
|
+
}, n.emit = function (e) {
|
858
|
+
if (t[e]) for (var n = t[e].slice(0), r = 0; r < n.length; r++) n[r].handler.apply(n[r].context, Array.prototype.slice.call(arguments, 1));
|
859
|
+
}, n.getEvents = function () {
|
860
|
+
return Object.keys(t);
|
861
|
+
}, n.getEventListenerCount = function (e) {
|
862
|
+
return t[e] ? t[e].length : 0;
|
863
|
+
}, n.maybeReportError = function (n) {
|
864
|
+
n && (t.error ? this.emit('error', n) : (e || console).error(n.message));
|
865
|
+
}, n;
|
866
|
+
}(s), d = function (e) {
|
867
|
+
var n = !1, t = !1, r = null, o = null, i = new Promise((function (n) {
|
868
|
+
e.on('ready', (function t() {
|
869
|
+
e.off('ready', t), n();
|
870
|
+
}));
|
871
|
+
})).catch((function () {
|
872
|
+
}));
|
873
|
+
return {
|
874
|
+
getInitializationPromise: function () {
|
875
|
+
return o || (n ? Promise.resolve() : t ? Promise.reject(r) : o = new Promise((function (n, t) {
|
876
|
+
e.on('initialized', (function t() {
|
877
|
+
e.off('initialized', t), n();
|
878
|
+
})), e.on('failed', (function n(r) {
|
879
|
+
e.off('failed', n), t(r);
|
880
|
+
}));
|
881
|
+
})));
|
882
|
+
}, getReadyPromise: function () {
|
883
|
+
return i;
|
884
|
+
}, signalSuccess: function () {
|
885
|
+
n || t || (n = !0, e.emit('initialized'), e.emit('ready'));
|
886
|
+
}, signalFailure: function (o) {
|
887
|
+
n || t || (t = !0, r = o, e.emit('failed', o), e.emit('ready')), e.maybeReportError(o);
|
888
|
+
}
|
889
|
+
};
|
890
|
+
}(l), v = qe(t, l, o, s), p = v.sendEvents, h = e, w = v.hash, O = te(r, h, v),
|
891
|
+
S = v.sendEvents && !v.diagnosticOptOut, P = S ? Me(h) : null, D = S ? function (e) {
|
892
|
+
var n, t, r, o;
|
893
|
+
|
894
|
+
function i(e) {
|
895
|
+
n = e, t = 0, r = 0, o = [];
|
896
|
+
}
|
897
|
+
|
898
|
+
return i((new Date).getTime()), {
|
899
|
+
getProps: function () {
|
900
|
+
return { dataSinceDate: n, droppedEvents: t, eventsInLastBatch: r, streamInits: o };
|
901
|
+
}, setProps: function (e) {
|
902
|
+
n = e.dataSinceDate, t = e.droppedEvents || 0, r = e.eventsInLastBatch || 0, o = e.streamInits || [];
|
903
|
+
}, incrementDroppedEvents: function () {
|
904
|
+
t++;
|
905
|
+
}, setEventsInLastBatch: function (e) {
|
906
|
+
r = e;
|
907
|
+
}, recordStreamInit: function (e, n, t) {
|
908
|
+
var r = { timestamp: e, failed: n, durationMillis: t };
|
909
|
+
o.push(r);
|
910
|
+
}, reset: i
|
911
|
+
};
|
912
|
+
}() : null, j = S ? function (e, n, t, r, o, i) {
|
913
|
+
var a, u, c = !!e.diagnosticUseCombinedEvent, s = 'ld:' + r + ':$diagnostics',
|
914
|
+
l = o.eventsUrl + '/events/diagnostic/' + r, f = o.diagnosticRecordingInterval, d = n,
|
915
|
+
v = !!o.streaming, p = {};
|
916
|
+
|
917
|
+
function m() {
|
918
|
+
return {
|
919
|
+
sdk: b(),
|
920
|
+
configuration: (n = {
|
921
|
+
customBaseURI: o.baseUrl !== _e.baseUrl.default,
|
922
|
+
customStreamURI: o.streamUrl !== _e.streamUrl.default,
|
923
|
+
customEventsURI: o.eventsUrl !== _e.eventsUrl.default,
|
924
|
+
eventsCapacity: o.eventCapacity,
|
925
|
+
eventsFlushIntervalMillis: o.flushInterval,
|
926
|
+
reconnectTimeMillis: o.streamReconnectDelay,
|
927
|
+
streamingDisabled: !v,
|
928
|
+
allAttributesPrivate: !!o.allAttributesPrivate,
|
929
|
+
inlineUsersInEvents: !!o.inlineUsersInEvents,
|
930
|
+
diagnosticRecordingIntervalMillis: o.diagnosticRecordingInterval,
|
931
|
+
usingSecureMode: !!o.hash,
|
932
|
+
bootstrapMode: !!o.bootstrap,
|
933
|
+
fetchGoalsDisabled: !o.fetchGoals,
|
934
|
+
allowFrequentDuplicateEvents: !!o.allowFrequentDuplicateEvents,
|
935
|
+
sendEventsOnlyForVariation: !!o.sendEventsOnlyForVariation,
|
936
|
+
autoAliasingOptOut: !!o.autoAliasingOptOut
|
937
|
+
}, n),
|
938
|
+
platform: e.diagnosticPlatformData
|
939
|
+
};
|
940
|
+
var n;
|
941
|
+
}
|
942
|
+
|
943
|
+
function y(e) {
|
944
|
+
o.logger && o.logger.debug(Ne.debugPostingDiagnosticEvent(e)), t.sendEvents(e, l, !0).then((function () {
|
945
|
+
})).catch((function () {
|
946
|
+
}));
|
947
|
+
}
|
948
|
+
|
949
|
+
function h() {
|
950
|
+
var n, t;
|
951
|
+
y((n = (new Date).getTime(), t = g({
|
952
|
+
kind: c ? 'diagnostic-combined' : 'diagnostic',
|
953
|
+
id: i,
|
954
|
+
creationDate: n
|
955
|
+
}, d.getProps()), c && (t = g({}, t, {}, m())), d.reset(n), t)), u = setTimeout(h, f), a = (new Date).getTime(), c && function () {
|
956
|
+
if (e.localStorage) {
|
957
|
+
var n = g({}, d.getProps());
|
958
|
+
e.localStorage.set(s, JSON.stringify(n), (function () {
|
959
|
+
}));
|
960
|
+
}
|
961
|
+
}();
|
962
|
+
}
|
963
|
+
|
964
|
+
function b() {
|
965
|
+
var n = g({}, e.diagnosticSdkData);
|
966
|
+
return o.wrapperName && (n.wrapperName = o.wrapperName), o.wrapperVersion && (n.wrapperVersion = o.wrapperVersion), n;
|
967
|
+
}
|
968
|
+
|
969
|
+
return p.start = function () {
|
970
|
+
c ? function (n) {
|
971
|
+
if (!e.localStorage) return n(!1);
|
972
|
+
e.localStorage.get(s).then((function (e) {
|
973
|
+
if (e) try {
|
974
|
+
var t = JSON.parse(e);
|
975
|
+
d.setProps(t), a = t.dataSinceDate;
|
976
|
+
} catch (e) {
|
977
|
+
}
|
978
|
+
n(!0);
|
979
|
+
})).catch((function () {
|
980
|
+
n(!1);
|
981
|
+
}));
|
982
|
+
}((function (e) {
|
983
|
+
if (e) {
|
984
|
+
var n = (a || 0) + f, t = (new Date).getTime();
|
985
|
+
t >= n ? h() : u = setTimeout(h, n - t);
|
986
|
+
} else 0 === Math.floor(4 * Math.random()) ? h() : u = setTimeout(h, f);
|
987
|
+
})) : (y(g({
|
988
|
+
kind: 'diagnostic-init',
|
989
|
+
id: i,
|
990
|
+
creationDate: d.getProps().dataSinceDate
|
991
|
+
}, m())), u = setTimeout(h, f));
|
992
|
+
}, p.stop = function () {
|
993
|
+
u && clearTimeout(u);
|
994
|
+
}, p.setStreaming = function (e) {
|
995
|
+
v = e;
|
996
|
+
}, p;
|
997
|
+
}(r, D, O, h, v, P) : null, U = xe(r, v, h, D), I = v.eventProcessor || function (e, n, t) {
|
998
|
+
var r, o = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : null,
|
999
|
+
i = arguments.length > 4 && void 0 !== arguments[4] ? arguments[4] : null,
|
1000
|
+
a = arguments.length > 5 && void 0 !== arguments[5] ? arguments[5] : null, u = {},
|
1001
|
+
c = a || te(e, t, n), s = n.eventsUrl + '/events/bulk/' + t, l = re(), f = oe(n),
|
1002
|
+
d = n.inlineUsersInEvents, v = n.samplingInterval, g = n.eventCapacity,
|
1003
|
+
p = n.flushInterval, y = n.logger, h = [], b = 0, w = !1, k = !1;
|
1004
|
+
|
1005
|
+
function O() {
|
1006
|
+
return 0 === v || 0 === Math.floor(Math.random() * v);
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
function S(e) {
|
1010
|
+
return !!e.debugEventsUntilDate && e.debugEventsUntilDate > b && e.debugEventsUntilDate > (new Date).getTime();
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
function P(e) {
|
1014
|
+
var n = $({}, e);
|
1015
|
+
return 'alias' === e.kind || (d || 'identify' === e.kind ? n.user = f.filterUser(e.user) : (n.userKey = e.user.key, delete n.user), 'feature' === e.kind && (delete n.trackEvents, delete n.debugEventsUntilDate)), n;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
function D(e) {
|
1019
|
+
h.length < g ? (h.push(e), k = !1) : (k || (k = !0, y.warn('Exceeded event queue capacity. Increase capacity to avoid dropping events.')), o && o.incrementDroppedEvents());
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
return u.enqueue = function (e) {
|
1023
|
+
if (!w) {
|
1024
|
+
var n = !1, t = !1;
|
1025
|
+
if (l.summarizeEvent(e), 'feature' === e.kind ? O() && (n = !!e.trackEvents, t = S(e)) : n = O(), n && D(P(e)), t) {
|
1026
|
+
var r = $({}, e, { kind: 'debug' });
|
1027
|
+
r.user = f.filterUser(r.user), delete r.trackEvents, delete r.debugEventsUntilDate, D(r);
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
}, u.flush = function () {
|
1031
|
+
if (w) return Promise.resolve();
|
1032
|
+
var e = h, n = l.getSummary();
|
1033
|
+
return l.clearSummary(), n && (n.kind = 'summary', e.push(n)), o && o.setEventsInLastBatch(e.length), 0 === e.length ? Promise.resolve() : (h = [], y.debug(Te(e.length)), c.sendEvents(e, s).then((function (e) {
|
1034
|
+
e && (e.serverTime && (b = e.serverTime), E(e.status) || (w = !0), e.status >= 400 && q((function () {
|
1035
|
+
i.maybeReportError(new m(ye(e.status, 'event posting', 'some events were dropped')));
|
1036
|
+
})));
|
1037
|
+
})));
|
1038
|
+
}, u.start = function () {
|
1039
|
+
r = setTimeout((function e() {
|
1040
|
+
u.flush(), r = setTimeout(e, p);
|
1041
|
+
}), p);
|
1042
|
+
}, u.stop = function () {
|
1043
|
+
clearTimeout(r);
|
1044
|
+
}, u;
|
1045
|
+
}(r, v, h, D, l, O), R = Le(r, v, h), T = {}, N = {}, F = v.streaming, x = !1, L = !1, M = !0,
|
1046
|
+
J = v.stateProvider, z = function (e, n) {
|
1047
|
+
var t;
|
1048
|
+
return {
|
1049
|
+
setUser: function (e) {
|
1050
|
+
var r = t && C(t);
|
1051
|
+
(t = B(e)) && n && n(C(t), r);
|
1052
|
+
}, getUser: function () {
|
1053
|
+
return t ? C(t) : null;
|
1054
|
+
}
|
1055
|
+
};
|
1056
|
+
}(0, (function (e, n) {
|
1057
|
+
(function (e) {
|
1058
|
+
J || e && G({ kind: 'identify', key: e.key, user: e, creationDate: (new Date).getTime() });
|
1059
|
+
})(e), !v.autoAliasingOptOut && n && n.anonymous && e && !e.anonymous && Z(e, n);
|
1060
|
+
})), K = Ce(r.localStorage, s);
|
1061
|
+
|
1062
|
+
function G(e) {
|
1063
|
+
if (h && !(J && J.enqueueEvent && J.enqueueEvent(e))) {
|
1064
|
+
if ('alias' !== e.kind) {
|
1065
|
+
if (!e.user) return void (M && (s.warn('Be sure to call `identify` in the LaunchDarkly client: https://docs.launchdarkly.com/docs/js-sdk-reference#section-analytics-events'), M = !1));
|
1066
|
+
M = !1;
|
1067
|
+
}
|
1068
|
+
!p || L || r.isDoNotTrack() || (s.debug(Re(e.kind)), I.enqueue(e));
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
|
1072
|
+
function X(e, n, t, r) {
|
1073
|
+
var o = z.getUser(), i = new Date, a = n ? n.value : null;
|
1074
|
+
if (!v.allowFrequentDuplicateEvents) {
|
1075
|
+
var u = JSON.stringify(a) + (o && o.key ? o.key : '') + e, c = T[u];
|
1076
|
+
if (c && i - c < 3e5) return;
|
1077
|
+
T[u] = i;
|
1078
|
+
}
|
1079
|
+
var s = {
|
1080
|
+
kind: 'feature',
|
1081
|
+
key: e,
|
1082
|
+
user: o,
|
1083
|
+
value: a,
|
1084
|
+
variation: n ? n.variationIndex : null,
|
1085
|
+
default: t,
|
1086
|
+
creationDate: i.getTime()
|
1087
|
+
};
|
1088
|
+
o && o.anonymous && (s.contextKind = Y(o));
|
1089
|
+
var l = N[e];
|
1090
|
+
l && (s.version = l.flagVersion ? l.flagVersion : l.version, s.trackEvents = l.trackEvents, s.debugEventsUntilDate = l.debugEventsUntilDate), (r || l && l.trackReason) && n && (s.reason = n.reason), G(s);
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
function W(e, n, t, r) {
|
1094
|
+
var o;
|
1095
|
+
if (N && H(N, e) && N[e] && !N[e].deleted) {
|
1096
|
+
var i = N[e];
|
1097
|
+
o = Q(i), null !== i.value && void 0 !== i.value || (o.value = n);
|
1098
|
+
} else o = {
|
1099
|
+
value: n,
|
1100
|
+
variationIndex: null,
|
1101
|
+
reason: { kind: 'ERROR', errorKind: 'FLAG_NOT_FOUND' }
|
1102
|
+
};
|
1103
|
+
return t && X(e, o, n, r), o;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
function Q(e) {
|
1107
|
+
return {
|
1108
|
+
value: e.value,
|
1109
|
+
variationIndex: void 0 === e.variation ? null : e.variation,
|
1110
|
+
reason: e.reason || null
|
1111
|
+
};
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
function Y(e) {
|
1115
|
+
return e.anonymous ? 'anonymousUser' : 'user';
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
function Z(e, n) {
|
1119
|
+
J || e && n && G({
|
1120
|
+
kind: 'alias',
|
1121
|
+
key: e.key,
|
1122
|
+
contextKind: Y(e),
|
1123
|
+
previousKey: n.key,
|
1124
|
+
previousContextKind: Y(n),
|
1125
|
+
creationDate: (new Date).getTime()
|
1126
|
+
});
|
1127
|
+
}
|
1128
|
+
|
1129
|
+
function ee() {
|
1130
|
+
a = !0, z.getUser() && U.connect(z.getUser(), w, {
|
1131
|
+
ping: function () {
|
1132
|
+
s.debug('received ping message from stream');
|
1133
|
+
var e = z.getUser();
|
1134
|
+
R.fetchFlagSettings(e, w).then((function (n) {
|
1135
|
+
A(e, z.getUser()) && ie(n || {});
|
1136
|
+
})).catch((function (e) {
|
1137
|
+
l.maybeReportError(new k(de(e)));
|
1138
|
+
}));
|
1139
|
+
}, put: function (e) {
|
1140
|
+
var n = JSON.parse(e.data);
|
1141
|
+
s.debug('received streaming update for all flags'), ie(n);
|
1142
|
+
}, patch: function (e) {
|
1143
|
+
var n = JSON.parse(e.data), t = N[n.key];
|
1144
|
+
if (!t || !t.version || !n.version || t.version < n.version) {
|
1145
|
+
s.debug(De(n.key));
|
1146
|
+
var r = {}, o = $({}, n);
|
1147
|
+
delete o.key, N[n.key] = o;
|
1148
|
+
var i = Q(o);
|
1149
|
+
r[n.key] = t ? { previous: t.value, current: i } : { current: i }, ae(r);
|
1150
|
+
} else s.debug(je(n.key));
|
1151
|
+
}, delete: function (e) {
|
1152
|
+
var n = JSON.parse(e.data);
|
1153
|
+
if (!N[n.key] || N[n.key].version < n.version) {
|
1154
|
+
s.debug(Ue(n.key));
|
1155
|
+
var t = {};
|
1156
|
+
N[n.key] && !N[n.key].deleted && (t[n.key] = { previous: N[n.key].value }), N[n.key] = {
|
1157
|
+
version: n.version,
|
1158
|
+
deleted: !0
|
1159
|
+
}, ae(t);
|
1160
|
+
} else s.debug(Ie(n.key));
|
1161
|
+
}
|
1162
|
+
});
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
function ne() {
|
1166
|
+
a && (U.disconnect(), a = !1);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
function ie(e) {
|
1170
|
+
var n = {};
|
1171
|
+
if (!e) return Promise.resolve();
|
1172
|
+
for (var t in N) H(N, t) && N[t] && (e[t] && !A(e[t].value, N[t].value) ? n[t] = {
|
1173
|
+
previous: N[t].value,
|
1174
|
+
current: Q(e[t])
|
1175
|
+
} : e[t] && !e[t].deleted || (n[t] = { previous: N[t].value }));
|
1176
|
+
for (var r in e) H(e, r) && e[r] && (!N[r] || N[r].deleted) && (n[r] = { current: Q(e[r]) });
|
1177
|
+
return N = g({}, e), ae(n).catch((function () {
|
1178
|
+
}));
|
1179
|
+
}
|
1180
|
+
|
1181
|
+
function ae(e) {
|
1182
|
+
var n = Object.keys(e);
|
1183
|
+
if (n.length > 0) {
|
1184
|
+
var t = {};
|
1185
|
+
n.forEach((function (n) {
|
1186
|
+
var r = e[n].current, o = r ? r.value : void 0, i = e[n].previous;
|
1187
|
+
l.emit('change:' + n, o, i), t[n] = r ? { current: o, previous: i } : { previous: i };
|
1188
|
+
})), l.emit('change', t), l.emit('internal-change', N), v.sendEventsOnlyForVariation || J || n.forEach((function (n) {
|
1189
|
+
X(n, e[n].current);
|
1190
|
+
}));
|
1191
|
+
}
|
1192
|
+
return i && c ? c.saveFlags(N).catch((function () {
|
1193
|
+
return null;
|
1194
|
+
})) : Promise.resolve();
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
function ue() {
|
1198
|
+
var e = F || u && void 0 === F;
|
1199
|
+
e && !a ? ee() : !e && a && ne(), j && j.setStreaming(e);
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
function ce(e) {
|
1203
|
+
return 'change' === e || 'change:' === e.substr(0, 'change'.length + 1);
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
if (r.localStorage && (c = new Fe(r.localStorage, h, w, z, s)), 'string' == typeof v.bootstrap && 'LOCALSTORAGE' === v.bootstrap.toUpperCase() && (c ? i = !0 : s.warn('localStorage is unavailable')), 'object' === f(v.bootstrap) && (N = function (e) {
|
1207
|
+
var n = Object.keys(e), t = e.$flagsState;
|
1208
|
+
!t && n.length && s.warn(pe()), !1 === e.$valid && s.warn('LaunchDarkly bootstrap data is not available because the back end could not read the flags.');
|
1209
|
+
var r = {};
|
1210
|
+
return n.forEach((function (n) {
|
1211
|
+
if ('$flagsState' !== n && '$valid' !== n) {
|
1212
|
+
var o = { value: e[n] };
|
1213
|
+
t && t[n] ? o = $(o, t[n]) : o.version = 0, r[n] = o;
|
1214
|
+
}
|
1215
|
+
})), r;
|
1216
|
+
}(v.bootstrap)), J) {
|
1217
|
+
var le = J.getInitialState();
|
1218
|
+
le ? ve(le) : J.on('init', ve), J.on('update', (function (e) {
|
1219
|
+
e.user && z.setUser(e.user), e.flags && ie(e.flags);
|
1220
|
+
}));
|
1221
|
+
} else (e ? K.validateUser(n).then((function (e) {
|
1222
|
+
return z.setUser(e), 'object' === f(v.bootstrap) ? ge() : i ? c.loadFlags().catch((function () {
|
1223
|
+
return null;
|
1224
|
+
})).then((function (e) {
|
1225
|
+
return null == e ? (N = {}, R.fetchFlagSettings(z.getUser(), w).then((function (e) {
|
1226
|
+
return ie(e || {});
|
1227
|
+
})).then(ge).catch((function (e) {
|
1228
|
+
me(new k(de(e)));
|
1229
|
+
}))) : (N = e, q(ge), R.fetchFlagSettings(z.getUser(), w).then((function (e) {
|
1230
|
+
return ie(e);
|
1231
|
+
})).catch((function (e) {
|
1232
|
+
return l.maybeReportError(e);
|
1233
|
+
})));
|
1234
|
+
})) : R.fetchFlagSettings(z.getUser(), w).then((function (e) {
|
1235
|
+
N = e || {}, ge();
|
1236
|
+
})).catch((function (e) {
|
1237
|
+
N = {}, me(e);
|
1238
|
+
}));
|
1239
|
+
})) : Promise.reject(new y(fe()))).catch(me);
|
1240
|
+
|
1241
|
+
function ve(e) {
|
1242
|
+
h = e.environment, z.setUser(e.user), N = g({}, e.flags), q(ge);
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
function ge() {
|
1246
|
+
s.info('LaunchDarkly client initialized'), x = !0, ue(), d.signalSuccess();
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
function me(e) {
|
1250
|
+
d.signalFailure(e);
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
return {
|
1254
|
+
client: {
|
1255
|
+
waitForInitialization: function () {
|
1256
|
+
return d.getInitializationPromise();
|
1257
|
+
}, waitUntilReady: function () {
|
1258
|
+
return d.getReadyPromise();
|
1259
|
+
}, identify: function (e, n, t) {
|
1260
|
+
return L ? _(Promise.resolve({}), t) : J ? (s.warn('identify() has no effect here; it must be called on the main client instance'), _(Promise.resolve(V(N)), t)) : _((i && c ? c.clearFlags() : Promise.resolve()).then((function () {
|
1261
|
+
return K.validateUser(e);
|
1262
|
+
})).then((function (e) {
|
1263
|
+
return R.fetchFlagSettings(e, n).then((function (t) {
|
1264
|
+
var r = V(t);
|
1265
|
+
return z.setUser(e), w = n, t ? ie(t).then((function () {
|
1266
|
+
return r;
|
1267
|
+
})) : r;
|
1268
|
+
}));
|
1269
|
+
})).then((function (e) {
|
1270
|
+
return a && ee(), e;
|
1271
|
+
})).catch((function (e) {
|
1272
|
+
return l.maybeReportError(e), Promise.reject(e);
|
1273
|
+
})), t);
|
1274
|
+
}, getUser: function () {
|
1275
|
+
return z.getUser();
|
1276
|
+
}, variation: function (e, n) {
|
1277
|
+
return W(e, n, !0, !1).value;
|
1278
|
+
}, variationDetail: function (e, n) {
|
1279
|
+
return W(e, n, !0, !0);
|
1280
|
+
}, track: function (e, n, t) {
|
1281
|
+
if ('string' == typeof e) {
|
1282
|
+
r.customEventFilter && !r.customEventFilter(e) && s.warn(se(e));
|
1283
|
+
var o = z.getUser(), i = {
|
1284
|
+
kind: 'custom',
|
1285
|
+
key: e,
|
1286
|
+
user: o,
|
1287
|
+
url: r.getCurrentUrl(),
|
1288
|
+
creationDate: (new Date).getTime()
|
1289
|
+
};
|
1290
|
+
o && o.anonymous && (i.contextKind = Y(o)), null != n && (i.data = n), null != t && (i.metricValue = t), G(i);
|
1291
|
+
} else l.maybeReportError(new b(se(e)));
|
1292
|
+
}, alias: Z, on: function (e, n, t) {
|
1293
|
+
ce(e) ? (u = !0, x && ue(), l.on(e, n, t)) : l.on.apply(l, arguments);
|
1294
|
+
}, off: function (e) {
|
1295
|
+
if (l.off.apply(l, arguments), ce(e)) {
|
1296
|
+
var n = !1;
|
1297
|
+
l.getEvents().forEach((function (e) {
|
1298
|
+
ce(e) && l.getEventListenerCount(e) > 0 && (n = !0);
|
1299
|
+
})), n || (u = !1, a && void 0 === F && ne());
|
1300
|
+
}
|
1301
|
+
}, setStreaming: function (e) {
|
1302
|
+
var n = null === e ? void 0 : e;
|
1303
|
+
n !== F && (F = n, ue());
|
1304
|
+
}, flush: function (e) {
|
1305
|
+
return _(p ? I.flush() : Promise.resolve(), e);
|
1306
|
+
}, allFlags: function () {
|
1307
|
+
var e = {};
|
1308
|
+
if (!N) return e;
|
1309
|
+
for (var n in N) H(N, n) && (e[n] = W(n, null, !v.sendEventsOnlyForVariation).value);
|
1310
|
+
return e;
|
1311
|
+
}, close: function (e) {
|
1312
|
+
if (L) return _(Promise.resolve(), e);
|
1313
|
+
var n = function () {
|
1314
|
+
L = !0, N = {};
|
1315
|
+
};
|
1316
|
+
return _(Promise.resolve().then((function () {
|
1317
|
+
if (ne(), j && j.stop(), p) return I.stop(), I.flush();
|
1318
|
+
})).then(n).catch(n), e);
|
1319
|
+
}
|
1320
|
+
}, options: v, emitter: l, ident: z, logger: s, requestor: R, start: function () {
|
1321
|
+
p && (j && j.start(), I.start());
|
1322
|
+
}, enqueueEvent: G, getFlagsInternal: function () {
|
1323
|
+
return N;
|
1324
|
+
}, getEnvironmentId: function () {
|
1325
|
+
return h;
|
1326
|
+
}, internalChangeEventName: 'internal-change'
|
1327
|
+
};
|
1328
|
+
}
|
1329
|
+
|
1330
|
+
function ze(e, n, t) {
|
1331
|
+
return n in e ? Object.defineProperty(e, n, {
|
1332
|
+
value: t,
|
1333
|
+
enumerable: !0,
|
1334
|
+
configurable: !0,
|
1335
|
+
writable: !0
|
1336
|
+
}) : e[n] = t, e;
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
function Ke(e, n) {
|
1340
|
+
var t = Object.keys(e);
|
1341
|
+
if (Object.getOwnPropertySymbols) {
|
1342
|
+
var r = Object.getOwnPropertySymbols(e);
|
1343
|
+
n && (r = r.filter((function (n) {
|
1344
|
+
return Object.getOwnPropertyDescriptor(e, n).enumerable;
|
1345
|
+
}))), t.push.apply(t, r);
|
1346
|
+
}
|
1347
|
+
return t;
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
function $e(e) {
|
1351
|
+
for (var n = 1; n < arguments.length; n++) {
|
1352
|
+
var t = null != arguments[n] ? arguments[n] : {};
|
1353
|
+
n % 2 ? Ke(Object(t), !0).forEach((function (n) {
|
1354
|
+
ze(e, n, t[n]);
|
1355
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Ke(Object(t)).forEach((function (n) {
|
1356
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
1357
|
+
}));
|
1358
|
+
}
|
1359
|
+
return e;
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
var He = {
|
1363
|
+
promise: Promise.resolve({
|
1364
|
+
status: 200, header: function () {
|
1365
|
+
return null;
|
1366
|
+
}, body: null
|
1367
|
+
})
|
1368
|
+
};
|
1369
|
+
|
1370
|
+
function Be(e) {
|
1371
|
+
var n, t = { synchronousFlush: !1 };
|
1372
|
+
if (window.XMLHttpRequest) {
|
1373
|
+
var r = e && e.disableSyncEventPost;
|
1374
|
+
t.httpRequest = function (e, n, o, i) {
|
1375
|
+
var a = t.synchronousFlush & !r;
|
1376
|
+
return t.synchronousFlush = !1, function (e, n, t, r, o) {
|
1377
|
+
if (o && !function () {
|
1378
|
+
var e = window.navigator && window.navigator.userAgent;
|
1379
|
+
if (e) {
|
1380
|
+
var n = e.match(/Chrom(e|ium)\/([0-9]+)\./);
|
1381
|
+
if (n) return parseInt(n[2], 10) < 73;
|
1382
|
+
}
|
1383
|
+
return !0;
|
1384
|
+
}()) return He;
|
1385
|
+
var i, a = new window.XMLHttpRequest;
|
1386
|
+
for (var u in a.open(e, n, !o), t || {}) Object.prototype.hasOwnProperty.call(t, u) && a.setRequestHeader(u, t[u]);
|
1387
|
+
return o ? (a.send(r), He) : {
|
1388
|
+
promise: new Promise((function (e, n) {
|
1389
|
+
a.addEventListener('load', (function () {
|
1390
|
+
i || e({
|
1391
|
+
status: a.status, header: function (e) {
|
1392
|
+
return a.getResponseHeader(e);
|
1393
|
+
}, body: a.responseText
|
1394
|
+
});
|
1395
|
+
})), a.addEventListener('error', (function () {
|
1396
|
+
i || n(new Error);
|
1397
|
+
})), a.send(r);
|
1398
|
+
})), cancel: function () {
|
1399
|
+
i = !0, a.abort();
|
1400
|
+
}
|
1401
|
+
};
|
1402
|
+
}(e, n, o, i, a);
|
1403
|
+
};
|
1404
|
+
}
|
1405
|
+
t.httpAllowsPost = function () {
|
1406
|
+
return void 0 === n && (n = !!window.XMLHttpRequest && 'withCredentials' in new window.XMLHttpRequest), n;
|
1407
|
+
}, t.httpFallbackPing = function (e) {
|
1408
|
+
(new window.Image).src = e;
|
1409
|
+
};
|
1410
|
+
var o, i = e && e.eventUrlTransformer;
|
1411
|
+
t.getCurrentUrl = function () {
|
1412
|
+
return i ? i(window.location.href) : window.location.href;
|
1413
|
+
}, t.isDoNotTrack = function () {
|
1414
|
+
var e;
|
1415
|
+
return 1 === (e = window.navigator && void 0 !== window.navigator.doNotTrack ? window.navigator.doNotTrack : window.navigator && void 0 !== window.navigator.msDoNotTrack ? window.navigator.msDoNotTrack : window.doNotTrack) || !0 === e || '1' === e || 'yes' === e;
|
1416
|
+
};
|
1417
|
+
try {
|
1418
|
+
window.localStorage && (t.localStorage = {
|
1419
|
+
get: function (e) {
|
1420
|
+
return new Promise((function (n) {
|
1421
|
+
n(window.localStorage.getItem(e));
|
1422
|
+
}));
|
1423
|
+
}, set: function (e, n) {
|
1424
|
+
return new Promise((function (t) {
|
1425
|
+
window.localStorage.setItem(e, n), t();
|
1426
|
+
}));
|
1427
|
+
}, clear: function (e) {
|
1428
|
+
return new Promise((function (n) {
|
1429
|
+
window.localStorage.removeItem(e), n();
|
1430
|
+
}));
|
1431
|
+
}
|
1432
|
+
});
|
1433
|
+
} catch (e) {
|
1434
|
+
t.localStorage = null;
|
1435
|
+
}
|
1436
|
+
if (e && e.useReport && 'function' == typeof window.EventSourcePolyfill && window.EventSourcePolyfill.supportedOptions && window.EventSourcePolyfill.supportedOptions.method ? (t.eventSourceAllowsReport = !0, o = window.EventSourcePolyfill) : (t.eventSourceAllowsReport = !1, o = window.EventSource), window.EventSource) {
|
1437
|
+
var a = 3e5;
|
1438
|
+
t.eventSourceFactory = function (e, n) {
|
1439
|
+
var t = $e($e({}, { heartbeatTimeout: a, silentTimeout: a, skipDefaultHeaders: !0 }), n);
|
1440
|
+
return new o(e, t);
|
1441
|
+
}, t.eventSourceIsActive = function (e) {
|
1442
|
+
return e.readyState === window.EventSource.OPEN || e.readyState === window.EventSource.CONNECTING;
|
1443
|
+
};
|
1444
|
+
}
|
1445
|
+
return t.userAgent = 'JSClient', t.version = '2.19.2', t.diagnosticSdkData = {
|
1446
|
+
name: 'js-client-sdk',
|
1447
|
+
version: '2.19.2'
|
1448
|
+
}, t.diagnosticPlatformData = { name: 'JS' }, t.diagnosticUseCombinedEvent = !0, t;
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
var Ge = /[|\\{}()[\]^$+*?.]/g, Xe = function (e) {
|
1452
|
+
if ('string' != typeof e) throw new TypeError('Expected a string');
|
1453
|
+
return e.replace(Ge, '\\$&');
|
1454
|
+
};
|
1455
|
+
|
1456
|
+
function We(e, n, t, r) {
|
1457
|
+
var o, i,
|
1458
|
+
a = ('substring' !== e.kind && 'regex' !== e.kind || !r.includes('/') ? n.replace(r, '') : n).replace(t, '');
|
1459
|
+
switch (e.kind) {
|
1460
|
+
case'exact':
|
1461
|
+
i = n, o = new RegExp('^' + Xe(e.url) + '/?$');
|
1462
|
+
break;
|
1463
|
+
case'canonical':
|
1464
|
+
i = a, o = new RegExp('^' + Xe(e.url) + '/?$');
|
1465
|
+
break;
|
1466
|
+
case'substring':
|
1467
|
+
i = a, o = new RegExp('.*' + Xe(e.substring) + '.*$');
|
1468
|
+
break;
|
1469
|
+
case'regex':
|
1470
|
+
i = a, o = new RegExp(e.pattern);
|
1471
|
+
break;
|
1472
|
+
default:
|
1473
|
+
return !1;
|
1474
|
+
}
|
1475
|
+
return o.test(i);
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
function Qe(e, n) {
|
1479
|
+
for (var t = {}, r = null, o = [], i = 0; i < e.length; i++) for (var a = e[i], u = a.urls || [], c = 0; c < u.length; c++) if (We(u[c], window.location.href, window.location.search, window.location.hash)) {
|
1480
|
+
'pageview' === a.kind ? n('pageview', a) : (o.push(a), n('click_pageview', a));
|
1481
|
+
break;
|
1482
|
+
}
|
1483
|
+
return o.length > 0 && (r = function (e) {
|
1484
|
+
for (var t = function (e, n) {
|
1485
|
+
for (var t = [], r = 0; r < n.length; r++) for (var o = e.target, i = n[r], a = i.selector, u = document.querySelectorAll(a); o && u.length > 0;) {
|
1486
|
+
for (var c = 0; c < u.length; c++) o === u[c] && t.push(i);
|
1487
|
+
o = o.parentNode;
|
1488
|
+
}
|
1489
|
+
return t;
|
1490
|
+
}(e, o), r = 0; r < t.length; r++) n('click', t[r]);
|
1491
|
+
}, document.addEventListener('click', r)), t.dispose = function () {
|
1492
|
+
document.removeEventListener('click', r);
|
1493
|
+
}, t;
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
function Ye(e, n) {
|
1497
|
+
var t, r, o = {};
|
1498
|
+
|
1499
|
+
function i() {
|
1500
|
+
r && r.dispose(), t && t.length && (r = Qe(t, a));
|
1501
|
+
}
|
1502
|
+
|
1503
|
+
function a(n, t) {
|
1504
|
+
var r = e.ident.getUser(), o = {
|
1505
|
+
kind: n,
|
1506
|
+
key: t.key,
|
1507
|
+
data: null,
|
1508
|
+
url: window.location.href,
|
1509
|
+
user: r,
|
1510
|
+
creationDate: (new Date).getTime()
|
1511
|
+
};
|
1512
|
+
return r && r.anonymous && (o.contextKind = 'anonymousUser'), 'click' === n && (o.selector = t.selector), e.enqueueEvent(o);
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
return o.goalKeyExists = function (e) {
|
1516
|
+
if (!t) return !0;
|
1517
|
+
for (var n = 0; n < t.length; n++) if ('custom' === t[n].kind && t[n].key === e) return !0;
|
1518
|
+
return !1;
|
1519
|
+
}, e.requestor.fetchJSON('/sdk/goals/' + e.getEnvironmentId()).then((function (e) {
|
1520
|
+
e && e.length > 0 && (r = Qe(t = e, a), function (e, n) {
|
1521
|
+
var t, r = window.location.href;
|
1522
|
+
|
1523
|
+
function o() {
|
1524
|
+
(t = window.location.href) !== r && (r = t, n());
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
!function e(n, t) {
|
1528
|
+
n(), setTimeout((function () {
|
1529
|
+
e(n, t);
|
1530
|
+
}), t);
|
1531
|
+
}(o, 300), window.history && window.history.pushState ? window.addEventListener('popstate', o) : window.addEventListener('hashchange', o);
|
1532
|
+
}(0, i)), n();
|
1533
|
+
})).catch((function (t) {
|
1534
|
+
e.emitter.maybeReportError(new O.LDUnexpectedResponseError((t && t.message, t.message))), n();
|
1535
|
+
})), o;
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
var Ze = {
|
1539
|
+
fetchGoals: { default: !0 },
|
1540
|
+
hash: { type: 'string' },
|
1541
|
+
eventProcessor: { type: 'object' },
|
1542
|
+
eventUrlTransformer: { type: 'function' },
|
1543
|
+
disableSyncEventPost: { default: !1 }
|
1544
|
+
};
|
1545
|
+
|
1546
|
+
function en(e, n) {
|
1547
|
+
var t = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, r = Be(t),
|
1548
|
+
o = Je(e, n, t, r, Ze), i = o.client, a = o.options, u = o.emitter,
|
1549
|
+
c = new Promise((function (e) {
|
1550
|
+
var n = u.on('goalsReady', (function () {
|
1551
|
+
u.off('goalsReady', n), e();
|
1552
|
+
}));
|
1553
|
+
}));
|
1554
|
+
if (i.waitUntilGoalsReady = function () {
|
1555
|
+
return c;
|
1556
|
+
}, a.fetchGoals) {
|
1557
|
+
var s = Ye(o, (function () {
|
1558
|
+
return u.emit('goalsReady');
|
1559
|
+
}));
|
1560
|
+
r.customEventFilter = s.goalKeyExists;
|
1561
|
+
} else u.emit('goalsReady');
|
1562
|
+
'complete' !== document.readyState ? window.addEventListener('load', o.start) : o.start();
|
1563
|
+
var l = function () {
|
1564
|
+
r.synchronousFlush = !0, i.flush().catch((function () {
|
1565
|
+
})), r.synchronousFlush = !1;
|
1566
|
+
};
|
1567
|
+
return window.addEventListener('beforeunload', l), window.addEventListener('unload', l), i;
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
var nn, tn = {
|
1571
|
+
local: { clsid: '5e73beba4fd38d073ad486ee' },
|
1572
|
+
test: { clsid: '5e73bebac747320730a46e55' },
|
1573
|
+
staging: { clsid: '5e73bebad597ec06ee90b4af' },
|
1574
|
+
na: { clsid: '5e73beba6edcf0076d131eb2' },
|
1575
|
+
eu: { clsid: '5e73bebabf8f54072b7966d5' },
|
1576
|
+
asia: { clsid: '5e73beba6edcf0076d131eaf' },
|
1577
|
+
ca: { clsid: '60a57b270e48880e22c4b745' }
|
1578
|
+
};
|
1579
|
+
|
1580
|
+
function rn(e, n) {
|
1581
|
+
var t = Object.keys(e);
|
1582
|
+
if (Object.getOwnPropertySymbols) {
|
1583
|
+
var r = Object.getOwnPropertySymbols(e);
|
1584
|
+
n && (r = r.filter((function (n) {
|
1585
|
+
return Object.getOwnPropertyDescriptor(e, n).enumerable;
|
1586
|
+
}))), t.push.apply(t, r);
|
1587
|
+
}
|
1588
|
+
return t;
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
function on(e) {
|
1592
|
+
for (var n = 1; n < arguments.length; n++) {
|
1593
|
+
var t = null != arguments[n] ? arguments[n] : {};
|
1594
|
+
n % 2 ? rn(Object(t), !0).forEach((function (n) {
|
1595
|
+
an(e, n, t[n]);
|
1596
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : rn(Object(t)).forEach((function (n) {
|
1597
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
1598
|
+
}));
|
1599
|
+
}
|
1600
|
+
return e;
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
function an(e, n, t) {
|
1604
|
+
return n in e ? Object.defineProperty(e, n, {
|
1605
|
+
value: t,
|
1606
|
+
enumerable: !0,
|
1607
|
+
configurable: !0,
|
1608
|
+
writable: !0
|
1609
|
+
}) : e[n] = t, e;
|
1610
|
+
}
|
1611
|
+
|
1612
|
+
var un = {
|
1613
|
+
manageState: !0, onReady: function () {
|
1614
|
+
}, onUpdate: function () {
|
1615
|
+
}, onFailure: function () {
|
1616
|
+
}, timeoutInMillis: 5e3
|
1617
|
+
}, cn = function (e) {
|
1618
|
+
var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
1619
|
+
if (!e.envId || !e.region) throw new Error('Illegal argument: \'envId\' and \'region\' are required, but received: ', e);
|
1620
|
+
var t = on({}, un, {}, n), r = { key: e.envId };
|
1621
|
+
e.orgName && (r.firstName = e.orgName, r.custom = on({}, r.custom, { orgName: e.orgName })), e.envName && (r.lastName = e.envName, r.custom = on({}, r.custom, { envName: e.envName })), e.orgId && (r.custom = on({}, r.custom, { orgId: e.orgId })), e.envType && (r.custom = on({}, r.custom, { envType: e.envType }));
|
1622
|
+
var o = function () {
|
1623
|
+
t.manageState && c(nn.allFlags()), t.onReady(nn.allFlags());
|
1624
|
+
}, i = function () {
|
1625
|
+
console.log('LaunchDarkly client failed to initialize within %d ms. Falling back to default feature flags.', t.timeoutInMillis), t.onTimeout ? t.onTimeout() : t.onFailure();
|
1626
|
+
};
|
1627
|
+
if (nn) nn.identify(r, null, o); else {
|
1628
|
+
if (!tn[e.region]) throw new Error('Invalid region requested: \'%o\'', e.region);
|
1629
|
+
nn = en(tn[e.region].clsid, r, { useReport: !0 });
|
1630
|
+
var a = setTimeout(i, t.timeoutInMillis);
|
1631
|
+
nn && (nn.on('ready', (function () {
|
1632
|
+
clearTimeout(a);
|
1633
|
+
})), nn.on('initialized', (function () {
|
1634
|
+
clearTimeout(a), o();
|
1635
|
+
})), nn.on('failed', (function () {
|
1636
|
+
clearTimeout(a), t.onFailure();
|
1637
|
+
})), nn.on('error', (function () {
|
1638
|
+
clearTimeout(a), t.onFailure();
|
1639
|
+
})), nn.on('change', (function (e) {
|
1640
|
+
t.manageState && s(e), t.onUpdate(e);
|
1641
|
+
})));
|
1642
|
+
}
|
1643
|
+
};
|
1644
|
+
t.d(n, 'isFeatureEnabled', (function () {
|
1645
|
+
return a;
|
1646
|
+
})), t.d(n, 'featureFlag', (function () {
|
1647
|
+
return u;
|
1648
|
+
})), t.d(n, 'isReady', (function () {
|
1649
|
+
return l;
|
1650
|
+
})), t.d(n, 'ld', (function () {
|
1651
|
+
return cn;
|
1652
|
+
}));
|
1653
|
+
}]);
|
1654
|
+
}));
|