@stacksee/analytics 0.3.4 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-bVe2QF_t.js → client-CyxgEISv.js} +35 -24
- package/dist/client.js +8 -7
- package/dist/index.js +15 -14
- package/dist/providers.js +4 -2615
- package/dist/server-BKqARaUf.js +174 -0
- package/dist/server.js +18 -9
- package/dist/src/adapters/client/browser-analytics.d.ts +2 -1
- package/dist/src/adapters/server/server-analytics.d.ts +4 -1
- package/dist/src/client/index.d.ts +2 -2
- package/dist/src/client.d.ts +5 -1
- package/dist/src/core/events/types.d.ts +2 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/providers/base.provider.d.ts +2 -1
- package/dist/src/providers/index.d.ts +2 -1
- package/dist/src/providers/posthog/client.d.ts +5 -3
- package/dist/src/providers/posthog/server.d.ts +5 -3
- package/dist/src/server/index.d.ts +1 -1
- package/dist/test/mock-provider.d.ts +7 -2
- package/package.json +3 -3
- package/readme.md +40 -2
- package/dist/module-BfXpy-Wp.js +0 -4198
- package/dist/src/providers/posthog/types.d.ts +0 -27
package/dist/providers.js
CHANGED
|
@@ -1,2617 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var ue = (s, r, e) => r in s ? ae(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
-
var L = (s, r, e) => ue(s, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import { i as U } from "./environment-Bnc8FqHv.js";
|
|
5
|
-
class Z {
|
|
6
|
-
constructor(r) {
|
|
7
|
-
L(this, "debug", !1);
|
|
8
|
-
L(this, "enabled", !0);
|
|
9
|
-
(r == null ? void 0 : r.debug) !== void 0 && (this.debug = r.debug), (r == null ? void 0 : r.enabled) !== void 0 && (this.enabled = r.enabled);
|
|
10
|
-
}
|
|
11
|
-
log(r, e) {
|
|
12
|
-
this.debug && console.log(`[${this.name}] ${r}`, e);
|
|
13
|
-
}
|
|
14
|
-
isEnabled() {
|
|
15
|
-
return this.enabled;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
class je extends Z {
|
|
19
|
-
constructor(e) {
|
|
20
|
-
super({ debug: e.debug, enabled: e.enabled });
|
|
21
|
-
L(this, "name", "PostHog-Client");
|
|
22
|
-
L(this, "posthog");
|
|
23
|
-
L(this, "initialized", !1);
|
|
24
|
-
L(this, "config");
|
|
25
|
-
this.config = e;
|
|
26
|
-
}
|
|
27
|
-
async initialize() {
|
|
28
|
-
if (this.isEnabled() && !this.initialized) {
|
|
29
|
-
if (!U()) {
|
|
30
|
-
this.log("Skipping initialization - not in browser environment");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!this.config.apiKey || typeof this.config.apiKey != "string")
|
|
34
|
-
throw new Error("PostHog requires an apiKey");
|
|
35
|
-
try {
|
|
36
|
-
const { default: e } = await import("./module-BfXpy-Wp.js");
|
|
37
|
-
e.init(this.config.apiKey, {
|
|
38
|
-
api_host: this.config.host || "https://app.posthog.com",
|
|
39
|
-
autocapture: this.config.autocapture ?? !1,
|
|
40
|
-
capture_pageview: this.config.capturePageview ?? !1,
|
|
41
|
-
capture_pageleave: this.config.capturePageleave ?? !1,
|
|
42
|
-
debug: this.config.debug ?? this.debug,
|
|
43
|
-
disable_cookie: this.config.disableCookie ?? !1,
|
|
44
|
-
persistence: this.config.persistenceType ?? "localStorage",
|
|
45
|
-
person_profiles: this.config.personProfiles ?? "identified_only"
|
|
46
|
-
}), this.posthog = e, this.initialized = !0, this.log("Initialized successfully", this.config);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
throw console.error("[PostHog-Client] Failed to initialize:", e), e;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
identify(e, t) {
|
|
53
|
-
!this.isEnabled() || !this.initialized || !this.posthog || (this.posthog.identify(e, t), this.log("Identified user", { userId: e, traits: t }));
|
|
54
|
-
}
|
|
55
|
-
track(e, t) {
|
|
56
|
-
if (!this.isEnabled() || !this.initialized || !this.posthog) return;
|
|
57
|
-
const n = {
|
|
58
|
-
...e.properties,
|
|
59
|
-
category: e.category,
|
|
60
|
-
timestamp: e.timestamp || Date.now(),
|
|
61
|
-
...e.userId && { userId: e.userId },
|
|
62
|
-
...e.sessionId && { sessionId: e.sessionId },
|
|
63
|
-
...(t == null ? void 0 : t.page) && { $current_url: t.page.path },
|
|
64
|
-
...(t == null ? void 0 : t.device) && { device: t.device },
|
|
65
|
-
...(t == null ? void 0 : t.utm) && { utm: t.utm }
|
|
66
|
-
};
|
|
67
|
-
this.posthog.capture(e.action, n), this.log("Tracked event", { event: e, context: t });
|
|
68
|
-
}
|
|
69
|
-
page(e, t) {
|
|
70
|
-
if (!this.isEnabled() || !this.initialized || !this.posthog || !U())
|
|
71
|
-
return;
|
|
72
|
-
const n = {
|
|
73
|
-
...e,
|
|
74
|
-
...(t == null ? void 0 : t.page) && {
|
|
75
|
-
path: t.page.path,
|
|
76
|
-
title: t.page.title,
|
|
77
|
-
referrer: t.page.referrer
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
this.posthog.capture("$pageview", n), this.log("Tracked page view", { properties: e, context: t });
|
|
81
|
-
}
|
|
82
|
-
reset() {
|
|
83
|
-
!this.isEnabled() || !this.initialized || !this.posthog || !U() || (this.posthog.reset(), this.log("Reset user session"));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
var D = { exports: {} }, le = D.exports, W;
|
|
87
|
-
function ce() {
|
|
88
|
-
return W || (W = 1, function(s, r) {
|
|
89
|
-
(function(t, n) {
|
|
90
|
-
s.exports = n();
|
|
91
|
-
})(typeof self < "u" ? self : le, function() {
|
|
92
|
-
return (
|
|
93
|
-
/******/
|
|
94
|
-
function(e) {
|
|
95
|
-
var t = {};
|
|
96
|
-
function n(i) {
|
|
97
|
-
if (t[i])
|
|
98
|
-
return t[i].exports;
|
|
99
|
-
var o = t[i] = {
|
|
100
|
-
/******/
|
|
101
|
-
i,
|
|
102
|
-
/******/
|
|
103
|
-
l: !1,
|
|
104
|
-
/******/
|
|
105
|
-
exports: {}
|
|
106
|
-
/******/
|
|
107
|
-
};
|
|
108
|
-
return e[i].call(o.exports, o, o.exports, n), o.l = !0, o.exports;
|
|
109
|
-
}
|
|
110
|
-
return n.m = e, n.c = t, n.d = function(i, o, u) {
|
|
111
|
-
n.o(i, o) || Object.defineProperty(i, o, {
|
|
112
|
-
/******/
|
|
113
|
-
configurable: !1,
|
|
114
|
-
/******/
|
|
115
|
-
enumerable: !0,
|
|
116
|
-
/******/
|
|
117
|
-
get: u
|
|
118
|
-
/******/
|
|
119
|
-
});
|
|
120
|
-
}, n.n = function(i) {
|
|
121
|
-
var o = i && i.__esModule ? (
|
|
122
|
-
/******/
|
|
123
|
-
function() {
|
|
124
|
-
return i.default;
|
|
125
|
-
}
|
|
126
|
-
) : (
|
|
127
|
-
/******/
|
|
128
|
-
function() {
|
|
129
|
-
return i;
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
return n.d(o, "a", o), o;
|
|
133
|
-
}, n.o = function(i, o) {
|
|
134
|
-
return Object.prototype.hasOwnProperty.call(i, o);
|
|
135
|
-
}, n.p = "", n(n.s = 3);
|
|
136
|
-
}([
|
|
137
|
-
/* 0 */
|
|
138
|
-
/***/
|
|
139
|
-
function(e, t, n) {
|
|
140
|
-
function i(p, w) {
|
|
141
|
-
if (!(p instanceof w))
|
|
142
|
-
throw new TypeError("Cannot call a class as a function");
|
|
143
|
-
}
|
|
144
|
-
var o = n(5), u = n(1), l = u.toHex, c = u.ceilHeapSize, h = n(6), g = function(p) {
|
|
145
|
-
for (p += 9; p % 64 > 0; p += 1)
|
|
146
|
-
;
|
|
147
|
-
return p;
|
|
148
|
-
}, d = function(p, w) {
|
|
149
|
-
var y = new Uint8Array(p.buffer), m = w % 4, b = w - m;
|
|
150
|
-
switch (m) {
|
|
151
|
-
case 0:
|
|
152
|
-
y[b + 3] = 0;
|
|
153
|
-
case 1:
|
|
154
|
-
y[b + 2] = 0;
|
|
155
|
-
case 2:
|
|
156
|
-
y[b + 1] = 0;
|
|
157
|
-
case 3:
|
|
158
|
-
y[b + 0] = 0;
|
|
159
|
-
}
|
|
160
|
-
for (var P = (w >> 2) + 1; P < p.length; P++)
|
|
161
|
-
p[P] = 0;
|
|
162
|
-
}, f = function(p, w, y) {
|
|
163
|
-
p[w >> 2] |= 128 << 24 - (w % 4 << 3), p[((w >> 2) + 2 & -16) + 14] = y / (1 << 29) | 0, p[((w >> 2) + 2 & -16) + 15] = y << 3;
|
|
164
|
-
}, a = function(p, w) {
|
|
165
|
-
var y = new Int32Array(p, w + 320, 5), m = new Int32Array(5), b = new DataView(m.buffer);
|
|
166
|
-
return b.setInt32(0, y[0], !1), b.setInt32(4, y[1], !1), b.setInt32(8, y[2], !1), b.setInt32(12, y[3], !1), b.setInt32(16, y[4], !1), m;
|
|
167
|
-
}, v = function() {
|
|
168
|
-
function p(w) {
|
|
169
|
-
if (i(this, p), w = w || 64 * 1024, w % 64 > 0)
|
|
170
|
-
throw new Error("Chunk size must be a multiple of 128 bit");
|
|
171
|
-
this._offset = 0, this._maxChunkLen = w, this._padMaxChunkLen = g(w), this._heap = new ArrayBuffer(c(this._padMaxChunkLen + 320 + 20)), this._h32 = new Int32Array(this._heap), this._h8 = new Int8Array(this._heap), this._core = new o({ Int32Array }, {}, this._heap);
|
|
172
|
-
}
|
|
173
|
-
return p.prototype._initState = function(y, m) {
|
|
174
|
-
this._offset = 0;
|
|
175
|
-
var b = new Int32Array(y, m + 320, 5);
|
|
176
|
-
b[0] = 1732584193, b[1] = -271733879, b[2] = -1732584194, b[3] = 271733878, b[4] = -1009589776;
|
|
177
|
-
}, p.prototype._padChunk = function(y, m) {
|
|
178
|
-
var b = g(y), P = new Int32Array(this._heap, 0, b >> 2);
|
|
179
|
-
return d(P, y), f(P, y, m), b;
|
|
180
|
-
}, p.prototype._write = function(y, m, b, P) {
|
|
181
|
-
h(y, this._h8, this._h32, m, b, P || 0);
|
|
182
|
-
}, p.prototype._coreCall = function(y, m, b, P, S) {
|
|
183
|
-
var I = b;
|
|
184
|
-
this._write(y, m, b), S && (I = this._padChunk(b, P)), this._core.hash(I, this._padMaxChunkLen);
|
|
185
|
-
}, p.prototype.rawDigest = function(y) {
|
|
186
|
-
var m = y.byteLength || y.length || y.size || 0;
|
|
187
|
-
this._initState(this._heap, this._padMaxChunkLen);
|
|
188
|
-
var b = 0, P = this._maxChunkLen;
|
|
189
|
-
for (b = 0; m > b + P; b += P)
|
|
190
|
-
this._coreCall(y, b, P, m, !1);
|
|
191
|
-
return this._coreCall(y, b, m - b, m, !0), a(this._heap, this._padMaxChunkLen);
|
|
192
|
-
}, p.prototype.digest = function(y) {
|
|
193
|
-
return l(this.rawDigest(y).buffer);
|
|
194
|
-
}, p.prototype.digestFromString = function(y) {
|
|
195
|
-
return this.digest(y);
|
|
196
|
-
}, p.prototype.digestFromBuffer = function(y) {
|
|
197
|
-
return this.digest(y);
|
|
198
|
-
}, p.prototype.digestFromArrayBuffer = function(y) {
|
|
199
|
-
return this.digest(y);
|
|
200
|
-
}, p.prototype.resetState = function() {
|
|
201
|
-
return this._initState(this._heap, this._padMaxChunkLen), this;
|
|
202
|
-
}, p.prototype.append = function(y) {
|
|
203
|
-
var m = 0, b = y.byteLength || y.length || y.size || 0, P = this._offset % this._maxChunkLen, S = void 0;
|
|
204
|
-
for (this._offset += b; m < b; )
|
|
205
|
-
S = Math.min(b - m, this._maxChunkLen - P), this._write(y, m, S, P), P += S, m += S, P === this._maxChunkLen && (this._core.hash(this._maxChunkLen, this._padMaxChunkLen), P = 0);
|
|
206
|
-
return this;
|
|
207
|
-
}, p.prototype.getState = function() {
|
|
208
|
-
var y = this._offset % this._maxChunkLen, m = void 0;
|
|
209
|
-
if (y)
|
|
210
|
-
m = this._heap.slice(0);
|
|
211
|
-
else {
|
|
212
|
-
var b = new Int32Array(this._heap, this._padMaxChunkLen + 320, 5);
|
|
213
|
-
m = b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
offset: this._offset,
|
|
217
|
-
heap: m
|
|
218
|
-
};
|
|
219
|
-
}, p.prototype.setState = function(y) {
|
|
220
|
-
if (this._offset = y.offset, y.heap.byteLength === 20) {
|
|
221
|
-
var m = new Int32Array(this._heap, this._padMaxChunkLen + 320, 5);
|
|
222
|
-
m.set(new Int32Array(y.heap));
|
|
223
|
-
} else
|
|
224
|
-
this._h32.set(new Int32Array(y.heap));
|
|
225
|
-
return this;
|
|
226
|
-
}, p.prototype.rawEnd = function() {
|
|
227
|
-
var y = this._offset, m = y % this._maxChunkLen, b = this._padChunk(m, y);
|
|
228
|
-
this._core.hash(b, this._padMaxChunkLen);
|
|
229
|
-
var P = a(this._heap, this._padMaxChunkLen);
|
|
230
|
-
return this._initState(this._heap, this._padMaxChunkLen), P;
|
|
231
|
-
}, p.prototype.end = function() {
|
|
232
|
-
return l(this.rawEnd().buffer);
|
|
233
|
-
}, p;
|
|
234
|
-
}();
|
|
235
|
-
e.exports = v, e.exports._core = o;
|
|
236
|
-
},
|
|
237
|
-
/* 1 */
|
|
238
|
-
/***/
|
|
239
|
-
function(e, t) {
|
|
240
|
-
for (var n = new Array(256), i = 0; i < 256; i++)
|
|
241
|
-
n[i] = (i < 16 ? "0" : "") + i.toString(16);
|
|
242
|
-
e.exports.toHex = function(o) {
|
|
243
|
-
for (var u = new Uint8Array(o), l = new Array(o.byteLength), c = 0; c < l.length; c++)
|
|
244
|
-
l[c] = n[u[c]];
|
|
245
|
-
return l.join("");
|
|
246
|
-
}, e.exports.ceilHeapSize = function(o) {
|
|
247
|
-
var u = 0;
|
|
248
|
-
if (o <= 65536) return 65536;
|
|
249
|
-
if (o < 16777216)
|
|
250
|
-
for (u = 1; u < o; u = u << 1)
|
|
251
|
-
;
|
|
252
|
-
else
|
|
253
|
-
for (u = 16777216; u < o; u += 16777216)
|
|
254
|
-
;
|
|
255
|
-
return u;
|
|
256
|
-
}, e.exports.isDedicatedWorkerScope = function(o) {
|
|
257
|
-
var u = "WorkerGlobalScope" in o && o instanceof o.WorkerGlobalScope, l = "SharedWorkerGlobalScope" in o && o instanceof o.SharedWorkerGlobalScope, c = "ServiceWorkerGlobalScope" in o && o instanceof o.ServiceWorkerGlobalScope;
|
|
258
|
-
return u && !l && !c;
|
|
259
|
-
};
|
|
260
|
-
},
|
|
261
|
-
/* 2 */
|
|
262
|
-
/***/
|
|
263
|
-
function(e, t, n) {
|
|
264
|
-
e.exports = function() {
|
|
265
|
-
var i = n(0), o = function(c, h, g) {
|
|
266
|
-
try {
|
|
267
|
-
return g(null, c.digest(h));
|
|
268
|
-
} catch (d) {
|
|
269
|
-
return g(d);
|
|
270
|
-
}
|
|
271
|
-
}, u = function(c, h, g, d, f) {
|
|
272
|
-
var a = new self.FileReader();
|
|
273
|
-
a.onloadend = function() {
|
|
274
|
-
if (a.error)
|
|
275
|
-
return f(a.error);
|
|
276
|
-
var p = a.result;
|
|
277
|
-
h += a.result.byteLength;
|
|
278
|
-
try {
|
|
279
|
-
c.append(p);
|
|
280
|
-
} catch (w) {
|
|
281
|
-
f(w);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
h < d.size ? u(c, h, g, d, f) : f(null, c.end());
|
|
285
|
-
}, a.readAsArrayBuffer(d.slice(h, h + g));
|
|
286
|
-
}, l = !0;
|
|
287
|
-
return self.onmessage = function(c) {
|
|
288
|
-
if (l) {
|
|
289
|
-
var h = c.data.data, g = c.data.file, d = c.data.id;
|
|
290
|
-
if (!(typeof d > "u") && !(!g && !h)) {
|
|
291
|
-
var f = c.data.blockSize || 4 * 1024 * 1024, a = new i(f);
|
|
292
|
-
a.resetState();
|
|
293
|
-
var v = function(p, w) {
|
|
294
|
-
p ? self.postMessage({ id: d, error: p.name }) : self.postMessage({ id: d, hash: w });
|
|
295
|
-
};
|
|
296
|
-
h && o(a, h, v), g && u(a, 0, f, g, v);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}, function() {
|
|
300
|
-
l = !1;
|
|
301
|
-
};
|
|
302
|
-
};
|
|
303
|
-
},
|
|
304
|
-
/* 3 */
|
|
305
|
-
/***/
|
|
306
|
-
function(e, t, n) {
|
|
307
|
-
var i = n(4), o = n(0), u = n(7), l = n(2), c = n(1), h = c.isDedicatedWorkerScope, g = typeof self < "u" && h(self);
|
|
308
|
-
o.disableWorkerBehaviour = g ? l() : function() {
|
|
309
|
-
}, o.createWorker = function() {
|
|
310
|
-
var d = i(
|
|
311
|
-
/*require.resolve*/
|
|
312
|
-
2
|
|
313
|
-
), f = d.terminate;
|
|
314
|
-
return d.terminate = function() {
|
|
315
|
-
URL.revokeObjectURL(d.objectURL), f.call(d);
|
|
316
|
-
}, d;
|
|
317
|
-
}, o.createHash = u, e.exports = o;
|
|
318
|
-
},
|
|
319
|
-
/* 4 */
|
|
320
|
-
/***/
|
|
321
|
-
function(e, t, n) {
|
|
322
|
-
function i(d) {
|
|
323
|
-
var f = {};
|
|
324
|
-
function a(p) {
|
|
325
|
-
if (f[p])
|
|
326
|
-
return f[p].exports;
|
|
327
|
-
var w = f[p] = {
|
|
328
|
-
/******/
|
|
329
|
-
i: p,
|
|
330
|
-
/******/
|
|
331
|
-
l: !1,
|
|
332
|
-
/******/
|
|
333
|
-
exports: {}
|
|
334
|
-
/******/
|
|
335
|
-
};
|
|
336
|
-
return d[p].call(w.exports, w, w.exports, a), w.l = !0, w.exports;
|
|
337
|
-
}
|
|
338
|
-
a.m = d, a.c = f, a.i = function(p) {
|
|
339
|
-
return p;
|
|
340
|
-
}, a.d = function(p, w, y) {
|
|
341
|
-
a.o(p, w) || Object.defineProperty(p, w, {
|
|
342
|
-
/******/
|
|
343
|
-
configurable: !1,
|
|
344
|
-
/******/
|
|
345
|
-
enumerable: !0,
|
|
346
|
-
/******/
|
|
347
|
-
get: y
|
|
348
|
-
/******/
|
|
349
|
-
});
|
|
350
|
-
}, a.r = function(p) {
|
|
351
|
-
Object.defineProperty(p, "__esModule", { value: !0 });
|
|
352
|
-
}, a.n = function(p) {
|
|
353
|
-
var w = p && p.__esModule ? (
|
|
354
|
-
/******/
|
|
355
|
-
function() {
|
|
356
|
-
return p.default;
|
|
357
|
-
}
|
|
358
|
-
) : (
|
|
359
|
-
/******/
|
|
360
|
-
function() {
|
|
361
|
-
return p;
|
|
362
|
-
}
|
|
363
|
-
);
|
|
364
|
-
return a.d(w, "a", w), w;
|
|
365
|
-
}, a.o = function(p, w) {
|
|
366
|
-
return Object.prototype.hasOwnProperty.call(p, w);
|
|
367
|
-
}, a.p = "/", a.oe = function(p) {
|
|
368
|
-
throw console.error(p), p;
|
|
369
|
-
};
|
|
370
|
-
var v = a(a.s = ENTRY_MODULE);
|
|
371
|
-
return v.default || v;
|
|
372
|
-
}
|
|
373
|
-
var o = "[\\.|\\-|\\+|\\w|/|@]+", u = "\\((/\\*.*?\\*/)?s?.*?(" + o + ").*?\\)";
|
|
374
|
-
function l(d) {
|
|
375
|
-
return (d + "").replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
|
|
376
|
-
}
|
|
377
|
-
function c(d, f, a) {
|
|
378
|
-
var v = {};
|
|
379
|
-
v[a] = [];
|
|
380
|
-
var p = f.toString(), w = p.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);
|
|
381
|
-
if (!w) return v;
|
|
382
|
-
for (var y = w[1], m = new RegExp("(\\\\n|\\W)" + l(y) + u, "g"), b; b = m.exec(p); )
|
|
383
|
-
b[3] !== "dll-reference" && v[a].push(b[3]);
|
|
384
|
-
for (m = new RegExp("\\(" + l(y) + '\\("(dll-reference\\s(' + o + '))"\\)\\)' + u, "g"); b = m.exec(p); )
|
|
385
|
-
d[b[2]] || (v[a].push(b[1]), d[b[2]] = n(b[1]).m), v[b[2]] = v[b[2]] || [], v[b[2]].push(b[4]);
|
|
386
|
-
return v;
|
|
387
|
-
}
|
|
388
|
-
function h(d) {
|
|
389
|
-
var f = Object.keys(d);
|
|
390
|
-
return f.reduce(function(a, v) {
|
|
391
|
-
return a || d[v].length > 0;
|
|
392
|
-
}, !1);
|
|
393
|
-
}
|
|
394
|
-
function g(d, f) {
|
|
395
|
-
for (var a = {
|
|
396
|
-
main: [f]
|
|
397
|
-
}, v = {
|
|
398
|
-
main: []
|
|
399
|
-
}, p = {
|
|
400
|
-
main: {}
|
|
401
|
-
}; h(a); )
|
|
402
|
-
for (var w = Object.keys(a), y = 0; y < w.length; y++) {
|
|
403
|
-
var m = w[y], b = a[m], P = b.pop();
|
|
404
|
-
if (p[m] = p[m] || {}, !(p[m][P] || !d[m][P])) {
|
|
405
|
-
p[m][P] = !0, v[m] = v[m] || [], v[m].push(P);
|
|
406
|
-
for (var S = c(d, d[m][P], m), I = Object.keys(S), O = 0; O < I.length; O++)
|
|
407
|
-
a[I[O]] = a[I[O]] || [], a[I[O]] = a[I[O]].concat(S[I[O]]);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return v;
|
|
411
|
-
}
|
|
412
|
-
e.exports = function(d, f) {
|
|
413
|
-
f = f || {};
|
|
414
|
-
var a = {
|
|
415
|
-
main: n.m
|
|
416
|
-
}, v = f.all ? { main: Object.keys(a) } : g(a, d), p = "";
|
|
417
|
-
Object.keys(v).filter(function(P) {
|
|
418
|
-
return P !== "main";
|
|
419
|
-
}).forEach(function(P) {
|
|
420
|
-
for (var S = 0; v[P][S]; )
|
|
421
|
-
S++;
|
|
422
|
-
v[P].push(S), a[P][S] = "(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })", p = p + "var " + P + " = (" + i.toString().replace("ENTRY_MODULE", JSON.stringify(S)) + ")({" + v[P].map(function(I) {
|
|
423
|
-
return "" + JSON.stringify(I) + ": " + a[P][I].toString();
|
|
424
|
-
}).join(",") + `});
|
|
425
|
-
`;
|
|
426
|
-
}), p = p + "(" + i.toString().replace("ENTRY_MODULE", JSON.stringify(d)) + ")({" + v.main.map(function(P) {
|
|
427
|
-
return "" + JSON.stringify(P) + ": " + a.main[P].toString();
|
|
428
|
-
}).join(",") + "})(self);";
|
|
429
|
-
var w = new window.Blob([p], { type: "text/javascript" });
|
|
430
|
-
if (f.bare)
|
|
431
|
-
return w;
|
|
432
|
-
var y = window.URL || window.webkitURL || window.mozURL || window.msURL, m = y.createObjectURL(w), b = new window.Worker(m);
|
|
433
|
-
return b.objectURL = m, b;
|
|
434
|
-
};
|
|
435
|
-
},
|
|
436
|
-
/* 5 */
|
|
437
|
-
/***/
|
|
438
|
-
function(e, t) {
|
|
439
|
-
e.exports = function(i, o, u) {
|
|
440
|
-
var l = new i.Int32Array(u);
|
|
441
|
-
function c(h, g) {
|
|
442
|
-
h = h | 0, g = g | 0;
|
|
443
|
-
var d = 0, f = 0, a = 0, v = 0, p = 0, w = 0, y = 0, m = 0, b = 0, P = 0, S = 0, I = 0, O = 0, k = 0;
|
|
444
|
-
for (a = l[g + 320 >> 2] | 0, p = l[g + 324 >> 2] | 0, y = l[g + 328 >> 2] | 0, b = l[g + 332 >> 2] | 0, S = l[g + 336 >> 2] | 0, d = 0; (d | 0) < (h | 0); d = d + 64 | 0) {
|
|
445
|
-
for (v = a, w = p, m = y, P = b, I = S, f = 0; (f | 0) < 64; f = f + 4 | 0)
|
|
446
|
-
k = l[d + f >> 2] | 0, O = ((a << 5 | a >>> 27) + (p & y | ~p & b) | 0) + ((k + S | 0) + 1518500249 | 0) | 0, S = b, b = y, y = p << 30 | p >>> 2, p = a, a = O, l[h + f >> 2] = k;
|
|
447
|
-
for (f = h + 64 | 0; (f | 0) < (h + 80 | 0); f = f + 4 | 0)
|
|
448
|
-
k = (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) << 1 | (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) >>> 31, O = ((a << 5 | a >>> 27) + (p & y | ~p & b) | 0) + ((k + S | 0) + 1518500249 | 0) | 0, S = b, b = y, y = p << 30 | p >>> 2, p = a, a = O, l[f >> 2] = k;
|
|
449
|
-
for (f = h + 80 | 0; (f | 0) < (h + 160 | 0); f = f + 4 | 0)
|
|
450
|
-
k = (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) << 1 | (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) >>> 31, O = ((a << 5 | a >>> 27) + (p ^ y ^ b) | 0) + ((k + S | 0) + 1859775393 | 0) | 0, S = b, b = y, y = p << 30 | p >>> 2, p = a, a = O, l[f >> 2] = k;
|
|
451
|
-
for (f = h + 160 | 0; (f | 0) < (h + 240 | 0); f = f + 4 | 0)
|
|
452
|
-
k = (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) << 1 | (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) >>> 31, O = ((a << 5 | a >>> 27) + (p & y | p & b | y & b) | 0) + ((k + S | 0) - 1894007588 | 0) | 0, S = b, b = y, y = p << 30 | p >>> 2, p = a, a = O, l[f >> 2] = k;
|
|
453
|
-
for (f = h + 240 | 0; (f | 0) < (h + 320 | 0); f = f + 4 | 0)
|
|
454
|
-
k = (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) << 1 | (l[f - 12 >> 2] ^ l[f - 32 >> 2] ^ l[f - 56 >> 2] ^ l[f - 64 >> 2]) >>> 31, O = ((a << 5 | a >>> 27) + (p ^ y ^ b) | 0) + ((k + S | 0) - 899497514 | 0) | 0, S = b, b = y, y = p << 30 | p >>> 2, p = a, a = O, l[f >> 2] = k;
|
|
455
|
-
a = a + v | 0, p = p + w | 0, y = y + m | 0, b = b + P | 0, S = S + I | 0;
|
|
456
|
-
}
|
|
457
|
-
l[g + 320 >> 2] = a, l[g + 324 >> 2] = p, l[g + 328 >> 2] = y, l[g + 332 >> 2] = b, l[g + 336 >> 2] = S;
|
|
458
|
-
}
|
|
459
|
-
return { hash: c };
|
|
460
|
-
};
|
|
461
|
-
},
|
|
462
|
-
/* 6 */
|
|
463
|
-
/***/
|
|
464
|
-
function(e, t) {
|
|
465
|
-
var n = this, i = void 0;
|
|
466
|
-
typeof self < "u" && typeof self.FileReaderSync < "u" && (i = new self.FileReaderSync());
|
|
467
|
-
var o = function(c, h, g, d, f, a) {
|
|
468
|
-
var v = void 0, p = a % 4, w = (f + p) % 4, y = f - w;
|
|
469
|
-
switch (p) {
|
|
470
|
-
case 0:
|
|
471
|
-
h[a] = c.charCodeAt(d + 3);
|
|
472
|
-
case 1:
|
|
473
|
-
h[a + 1 - (p << 1) | 0] = c.charCodeAt(d + 2);
|
|
474
|
-
case 2:
|
|
475
|
-
h[a + 2 - (p << 1) | 0] = c.charCodeAt(d + 1);
|
|
476
|
-
case 3:
|
|
477
|
-
h[a + 3 - (p << 1) | 0] = c.charCodeAt(d);
|
|
478
|
-
}
|
|
479
|
-
if (!(f < w + (4 - p))) {
|
|
480
|
-
for (v = 4 - p; v < y; v = v + 4 | 0)
|
|
481
|
-
g[a + v >> 2] = c.charCodeAt(d + v) << 24 | c.charCodeAt(d + v + 1) << 16 | c.charCodeAt(d + v + 2) << 8 | c.charCodeAt(d + v + 3);
|
|
482
|
-
switch (w) {
|
|
483
|
-
case 3:
|
|
484
|
-
h[a + y + 1 | 0] = c.charCodeAt(d + y + 2);
|
|
485
|
-
case 2:
|
|
486
|
-
h[a + y + 2 | 0] = c.charCodeAt(d + y + 1);
|
|
487
|
-
case 1:
|
|
488
|
-
h[a + y + 3 | 0] = c.charCodeAt(d + y);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
}, u = function(c, h, g, d, f, a) {
|
|
492
|
-
var v = void 0, p = a % 4, w = (f + p) % 4, y = f - w;
|
|
493
|
-
switch (p) {
|
|
494
|
-
case 0:
|
|
495
|
-
h[a] = c[d + 3];
|
|
496
|
-
case 1:
|
|
497
|
-
h[a + 1 - (p << 1) | 0] = c[d + 2];
|
|
498
|
-
case 2:
|
|
499
|
-
h[a + 2 - (p << 1) | 0] = c[d + 1];
|
|
500
|
-
case 3:
|
|
501
|
-
h[a + 3 - (p << 1) | 0] = c[d];
|
|
502
|
-
}
|
|
503
|
-
if (!(f < w + (4 - p))) {
|
|
504
|
-
for (v = 4 - p; v < y; v = v + 4 | 0)
|
|
505
|
-
g[a + v >> 2 | 0] = c[d + v] << 24 | c[d + v + 1] << 16 | c[d + v + 2] << 8 | c[d + v + 3];
|
|
506
|
-
switch (w) {
|
|
507
|
-
case 3:
|
|
508
|
-
h[a + y + 1 | 0] = c[d + y + 2];
|
|
509
|
-
case 2:
|
|
510
|
-
h[a + y + 2 | 0] = c[d + y + 1];
|
|
511
|
-
case 1:
|
|
512
|
-
h[a + y + 3 | 0] = c[d + y];
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}, l = function(c, h, g, d, f, a) {
|
|
516
|
-
var v = void 0, p = a % 4, w = (f + p) % 4, y = f - w, m = new Uint8Array(i.readAsArrayBuffer(c.slice(d, d + f)));
|
|
517
|
-
switch (p) {
|
|
518
|
-
case 0:
|
|
519
|
-
h[a] = m[3];
|
|
520
|
-
case 1:
|
|
521
|
-
h[a + 1 - (p << 1) | 0] = m[2];
|
|
522
|
-
case 2:
|
|
523
|
-
h[a + 2 - (p << 1) | 0] = m[1];
|
|
524
|
-
case 3:
|
|
525
|
-
h[a + 3 - (p << 1) | 0] = m[0];
|
|
526
|
-
}
|
|
527
|
-
if (!(f < w + (4 - p))) {
|
|
528
|
-
for (v = 4 - p; v < y; v = v + 4 | 0)
|
|
529
|
-
g[a + v >> 2 | 0] = m[v] << 24 | m[v + 1] << 16 | m[v + 2] << 8 | m[v + 3];
|
|
530
|
-
switch (w) {
|
|
531
|
-
case 3:
|
|
532
|
-
h[a + y + 1 | 0] = m[y + 2];
|
|
533
|
-
case 2:
|
|
534
|
-
h[a + y + 2 | 0] = m[y + 1];
|
|
535
|
-
case 1:
|
|
536
|
-
h[a + y + 3 | 0] = m[y];
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
e.exports = function(c, h, g, d, f, a) {
|
|
541
|
-
if (typeof c == "string")
|
|
542
|
-
return o(c, h, g, d, f, a);
|
|
543
|
-
if (c instanceof Array || n && n.Buffer && n.Buffer.isBuffer(c))
|
|
544
|
-
return u(c, h, g, d, f, a);
|
|
545
|
-
if (c instanceof ArrayBuffer)
|
|
546
|
-
return u(new Uint8Array(c), h, g, d, f, a);
|
|
547
|
-
if (c.buffer instanceof ArrayBuffer)
|
|
548
|
-
return u(new Uint8Array(c.buffer, c.byteOffset, c.byteLength), h, g, d, f, a);
|
|
549
|
-
if (c instanceof Blob)
|
|
550
|
-
return l(c, h, g, d, f, a);
|
|
551
|
-
throw new Error("Unsupported data type.");
|
|
552
|
-
};
|
|
553
|
-
},
|
|
554
|
-
/* 7 */
|
|
555
|
-
/***/
|
|
556
|
-
function(e, t, n) {
|
|
557
|
-
var i = /* @__PURE__ */ function() {
|
|
558
|
-
function g(d, f) {
|
|
559
|
-
for (var a = 0; a < f.length; a++) {
|
|
560
|
-
var v = f[a];
|
|
561
|
-
v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(d, v.key, v);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
return function(d, f, a) {
|
|
565
|
-
return f && g(d.prototype, f), a && g(d, a), d;
|
|
566
|
-
};
|
|
567
|
-
}();
|
|
568
|
-
function o(g, d) {
|
|
569
|
-
if (!(g instanceof d))
|
|
570
|
-
throw new TypeError("Cannot call a class as a function");
|
|
571
|
-
}
|
|
572
|
-
var u = n(0), l = n(1), c = l.toHex, h = function() {
|
|
573
|
-
function g() {
|
|
574
|
-
o(this, g), this._rusha = new u(), this._rusha.resetState();
|
|
575
|
-
}
|
|
576
|
-
return g.prototype.update = function(f) {
|
|
577
|
-
return this._rusha.append(f), this;
|
|
578
|
-
}, g.prototype.digest = function(f) {
|
|
579
|
-
var a = this._rusha.rawEnd().buffer;
|
|
580
|
-
if (!f)
|
|
581
|
-
return a;
|
|
582
|
-
if (f === "hex")
|
|
583
|
-
return c(a);
|
|
584
|
-
throw new Error("unsupported digest encoding");
|
|
585
|
-
}, i(g, [{
|
|
586
|
-
key: "state",
|
|
587
|
-
get: function() {
|
|
588
|
-
return this._rusha.getState();
|
|
589
|
-
},
|
|
590
|
-
set: function(d) {
|
|
591
|
-
this._rusha.setState(d);
|
|
592
|
-
}
|
|
593
|
-
}]), g;
|
|
594
|
-
}();
|
|
595
|
-
e.exports = function() {
|
|
596
|
-
return new h();
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
/******/
|
|
600
|
-
])
|
|
601
|
-
);
|
|
602
|
-
});
|
|
603
|
-
}(D)), D.exports;
|
|
604
|
-
}
|
|
605
|
-
var fe = ce(), $ = function(s, r) {
|
|
606
|
-
return $ = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
|
|
607
|
-
e.__proto__ = t;
|
|
608
|
-
} || function(e, t) {
|
|
609
|
-
for (var n in t)
|
|
610
|
-
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
|
|
611
|
-
}, $(s, r);
|
|
612
|
-
};
|
|
613
|
-
function x(s, r) {
|
|
614
|
-
if (typeof r != "function" && r !== null)
|
|
615
|
-
throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
|
616
|
-
$(s, r);
|
|
617
|
-
function e() {
|
|
618
|
-
this.constructor = s;
|
|
619
|
-
}
|
|
620
|
-
s.prototype = r === null ? Object.create(r) : (e.prototype = r.prototype, new e());
|
|
621
|
-
}
|
|
622
|
-
var F = function() {
|
|
623
|
-
return F = Object.assign || function(r) {
|
|
624
|
-
for (var e, t = 1, n = arguments.length; t < n; t++) {
|
|
625
|
-
e = arguments[t];
|
|
626
|
-
for (var i in e)
|
|
627
|
-
Object.prototype.hasOwnProperty.call(e, i) && (r[i] = e[i]);
|
|
628
|
-
}
|
|
629
|
-
return r;
|
|
630
|
-
}, F.apply(this, arguments);
|
|
631
|
-
};
|
|
632
|
-
function he(s, r) {
|
|
633
|
-
var e = {};
|
|
634
|
-
for (var t in s)
|
|
635
|
-
Object.prototype.hasOwnProperty.call(s, t) && r.indexOf(t) < 0 && (e[t] = s[t]);
|
|
636
|
-
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
637
|
-
for (var n = 0, t = Object.getOwnPropertySymbols(s); n < t.length; n++)
|
|
638
|
-
r.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(s, t[n]) && (e[t[n]] = s[t[n]]);
|
|
639
|
-
return e;
|
|
640
|
-
}
|
|
641
|
-
function A(s, r, e, t) {
|
|
642
|
-
function n(i) {
|
|
643
|
-
return i instanceof e ? i : new e(function(o) {
|
|
644
|
-
o(i);
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
return new (e || (e = Promise))(function(i, o) {
|
|
648
|
-
function u(h) {
|
|
649
|
-
try {
|
|
650
|
-
c(t.next(h));
|
|
651
|
-
} catch (g) {
|
|
652
|
-
o(g);
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
function l(h) {
|
|
656
|
-
try {
|
|
657
|
-
c(t.throw(h));
|
|
658
|
-
} catch (g) {
|
|
659
|
-
o(g);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
function c(h) {
|
|
663
|
-
h.done ? i(h.value) : n(h.value).then(u, l);
|
|
664
|
-
}
|
|
665
|
-
c((t = t.apply(s, [])).next());
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
function E(s, r) {
|
|
669
|
-
var e = { label: 0, sent: function() {
|
|
670
|
-
if (i[0] & 1)
|
|
671
|
-
throw i[1];
|
|
672
|
-
return i[1];
|
|
673
|
-
}, trys: [], ops: [] }, t, n, i, o;
|
|
674
|
-
return o = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
|
|
675
|
-
return this;
|
|
676
|
-
}), o;
|
|
677
|
-
function u(c) {
|
|
678
|
-
return function(h) {
|
|
679
|
-
return l([c, h]);
|
|
680
|
-
};
|
|
681
|
-
}
|
|
682
|
-
function l(c) {
|
|
683
|
-
if (t)
|
|
684
|
-
throw new TypeError("Generator is already executing.");
|
|
685
|
-
for (; e; )
|
|
686
|
-
try {
|
|
687
|
-
if (t = 1, n && (i = c[0] & 2 ? n.return : c[0] ? n.throw || ((i = n.return) && i.call(n), 0) : n.next) && !(i = i.call(n, c[1])).done)
|
|
688
|
-
return i;
|
|
689
|
-
switch (n = 0, i && (c = [c[0] & 2, i.value]), c[0]) {
|
|
690
|
-
case 0:
|
|
691
|
-
case 1:
|
|
692
|
-
i = c;
|
|
693
|
-
break;
|
|
694
|
-
case 4:
|
|
695
|
-
return e.label++, { value: c[1], done: !1 };
|
|
696
|
-
case 5:
|
|
697
|
-
e.label++, n = c[1], c = [0];
|
|
698
|
-
continue;
|
|
699
|
-
case 7:
|
|
700
|
-
c = e.ops.pop(), e.trys.pop();
|
|
701
|
-
continue;
|
|
702
|
-
default:
|
|
703
|
-
if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (c[0] === 6 || c[0] === 2)) {
|
|
704
|
-
e = 0;
|
|
705
|
-
continue;
|
|
706
|
-
}
|
|
707
|
-
if (c[0] === 3 && (!i || c[1] > i[0] && c[1] < i[3])) {
|
|
708
|
-
e.label = c[1];
|
|
709
|
-
break;
|
|
710
|
-
}
|
|
711
|
-
if (c[0] === 6 && e.label < i[1]) {
|
|
712
|
-
e.label = i[1], i = c;
|
|
713
|
-
break;
|
|
714
|
-
}
|
|
715
|
-
if (i && e.label < i[2]) {
|
|
716
|
-
e.label = i[2], e.ops.push(c);
|
|
717
|
-
break;
|
|
718
|
-
}
|
|
719
|
-
i[2] && e.ops.pop(), e.trys.pop();
|
|
720
|
-
continue;
|
|
721
|
-
}
|
|
722
|
-
c = r.call(s, e);
|
|
723
|
-
} catch (h) {
|
|
724
|
-
c = [6, h], n = 0;
|
|
725
|
-
} finally {
|
|
726
|
-
t = i = 0;
|
|
727
|
-
}
|
|
728
|
-
if (c[0] & 5)
|
|
729
|
-
throw c[1];
|
|
730
|
-
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
function ee(s, r, e) {
|
|
734
|
-
for (var t = 0, n = r.length, i; t < n; t++)
|
|
735
|
-
(i || !(t in r)) && (i || (i = Array.prototype.slice.call(r, 0, t)), i[t] = r[t]);
|
|
736
|
-
return s.concat(i || Array.prototype.slice.call(r));
|
|
737
|
-
}
|
|
738
|
-
var z = "3.6.3", _;
|
|
739
|
-
(function(s) {
|
|
740
|
-
s.AnonymousId = "anonymous_id", s.DistinctId = "distinct_id", s.Props = "props", s.FeatureFlags = "feature_flags", s.FeatureFlagPayloads = "feature_flag_payloads", s.OverrideFeatureFlags = "override_feature_flags", s.Queue = "queue", s.OptedOut = "opted_out", s.SessionId = "session_id", s.SessionLastTimestamp = "session_timestamp", s.PersonProperties = "person_properties", s.GroupProperties = "group_properties", s.InstalledAppBuild = "installed_app_build", s.InstalledAppVersion = "installed_app_version";
|
|
741
|
-
})(_ || (_ = {}));
|
|
742
|
-
function de(s, r) {
|
|
743
|
-
if (!s)
|
|
744
|
-
throw new Error(r);
|
|
745
|
-
}
|
|
746
|
-
function pe(s) {
|
|
747
|
-
return s == null ? void 0 : s.replace(/\/+$/, "");
|
|
748
|
-
}
|
|
749
|
-
function ve(s, r) {
|
|
750
|
-
return r === void 0 && (r = {}), A(this, void 0, void 0, function() {
|
|
751
|
-
var e, t, n, i, o, u, l, c, h, g;
|
|
752
|
-
return E(this, function(d) {
|
|
753
|
-
switch (d.label) {
|
|
754
|
-
case 0:
|
|
755
|
-
e = r.retryCount, t = e === void 0 ? 3 : e, n = r.retryDelay, i = n === void 0 ? 5e3 : n, o = r.retryCheck, u = o === void 0 ? function() {
|
|
756
|
-
return !0;
|
|
757
|
-
} : o, l = null, c = 0, d.label = 1;
|
|
758
|
-
case 1:
|
|
759
|
-
return c < t + 1 ? c > 0 ? [4, new Promise(function(f) {
|
|
760
|
-
return setTimeout(f, i);
|
|
761
|
-
})] : [3, 3] : [3, 7];
|
|
762
|
-
case 2:
|
|
763
|
-
d.sent(), d.label = 3;
|
|
764
|
-
case 3:
|
|
765
|
-
return d.trys.push([3, 5, , 6]), [4, s()];
|
|
766
|
-
case 4:
|
|
767
|
-
return h = d.sent(), [2, h];
|
|
768
|
-
case 5:
|
|
769
|
-
if (g = d.sent(), l = g, !u(g))
|
|
770
|
-
throw g;
|
|
771
|
-
return [3, 6];
|
|
772
|
-
case 6:
|
|
773
|
-
return c++, [3, 1];
|
|
774
|
-
case 7:
|
|
775
|
-
throw l;
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
function ge() {
|
|
781
|
-
return (/* @__PURE__ */ new Date()).getTime();
|
|
782
|
-
}
|
|
783
|
-
function B() {
|
|
784
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
785
|
-
}
|
|
786
|
-
function te(s, r) {
|
|
787
|
-
var e = setTimeout(s, r);
|
|
788
|
-
return e != null && e.unref && (e == null || e.unref()), e;
|
|
789
|
-
}
|
|
790
|
-
var M = String.fromCharCode, H = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", R = {};
|
|
791
|
-
function ye(s, r) {
|
|
792
|
-
if (!R[s]) {
|
|
793
|
-
R[s] = {};
|
|
794
|
-
for (var e = 0; e < s.length; e++)
|
|
795
|
-
R[s][s.charAt(e)] = e;
|
|
796
|
-
}
|
|
797
|
-
return R[s][r];
|
|
798
|
-
}
|
|
799
|
-
var j = {
|
|
800
|
-
compressToBase64: function(s) {
|
|
801
|
-
if (s == null)
|
|
802
|
-
return "";
|
|
803
|
-
var r = j._compress(s, 6, function(e) {
|
|
804
|
-
return H.charAt(e);
|
|
805
|
-
});
|
|
806
|
-
switch (r.length % 4) {
|
|
807
|
-
default:
|
|
808
|
-
// When could this happen ?
|
|
809
|
-
case 0:
|
|
810
|
-
return r;
|
|
811
|
-
case 1:
|
|
812
|
-
return r + "===";
|
|
813
|
-
case 2:
|
|
814
|
-
return r + "==";
|
|
815
|
-
case 3:
|
|
816
|
-
return r + "=";
|
|
817
|
-
}
|
|
818
|
-
},
|
|
819
|
-
decompressFromBase64: function(s) {
|
|
820
|
-
return s == null ? "" : s == "" ? null : j._decompress(s.length, 32, function(r) {
|
|
821
|
-
return ye(H, s.charAt(r));
|
|
822
|
-
});
|
|
823
|
-
},
|
|
824
|
-
compress: function(s) {
|
|
825
|
-
return j._compress(s, 16, function(r) {
|
|
826
|
-
return M(r);
|
|
827
|
-
});
|
|
828
|
-
},
|
|
829
|
-
_compress: function(s, r, e) {
|
|
830
|
-
if (s == null)
|
|
831
|
-
return "";
|
|
832
|
-
var t = {}, n = {}, i = [], o, u, l = "", c = "", h = "", g = 2, d = 3, f = 2, a = 0, v = 0, p;
|
|
833
|
-
for (p = 0; p < s.length; p += 1)
|
|
834
|
-
if (l = s.charAt(p), Object.prototype.hasOwnProperty.call(t, l) || (t[l] = d++, n[l] = !0), c = h + l, Object.prototype.hasOwnProperty.call(t, c))
|
|
835
|
-
h = c;
|
|
836
|
-
else {
|
|
837
|
-
if (Object.prototype.hasOwnProperty.call(n, h)) {
|
|
838
|
-
if (h.charCodeAt(0) < 256) {
|
|
839
|
-
for (o = 0; o < f; o++)
|
|
840
|
-
a = a << 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++;
|
|
841
|
-
for (u = h.charCodeAt(0), o = 0; o < 8; o++)
|
|
842
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
843
|
-
} else {
|
|
844
|
-
for (u = 1, o = 0; o < f; o++)
|
|
845
|
-
a = a << 1 | u, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = 0;
|
|
846
|
-
for (u = h.charCodeAt(0), o = 0; o < 16; o++)
|
|
847
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
848
|
-
}
|
|
849
|
-
g--, g == 0 && (g = Math.pow(2, f), f++), delete n[h];
|
|
850
|
-
} else
|
|
851
|
-
for (u = t[h], o = 0; o < f; o++)
|
|
852
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
853
|
-
g--, g == 0 && (g = Math.pow(2, f), f++), t[c] = d++, h = String(l);
|
|
854
|
-
}
|
|
855
|
-
if (h !== "") {
|
|
856
|
-
if (Object.prototype.hasOwnProperty.call(n, h)) {
|
|
857
|
-
if (h.charCodeAt(0) < 256) {
|
|
858
|
-
for (o = 0; o < f; o++)
|
|
859
|
-
a = a << 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++;
|
|
860
|
-
for (u = h.charCodeAt(0), o = 0; o < 8; o++)
|
|
861
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
862
|
-
} else {
|
|
863
|
-
for (u = 1, o = 0; o < f; o++)
|
|
864
|
-
a = a << 1 | u, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = 0;
|
|
865
|
-
for (u = h.charCodeAt(0), o = 0; o < 16; o++)
|
|
866
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
867
|
-
}
|
|
868
|
-
g--, g == 0 && (g = Math.pow(2, f), f++), delete n[h];
|
|
869
|
-
} else
|
|
870
|
-
for (u = t[h], o = 0; o < f; o++)
|
|
871
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
872
|
-
g--, g == 0 && (g = Math.pow(2, f), f++);
|
|
873
|
-
}
|
|
874
|
-
for (u = 2, o = 0; o < f; o++)
|
|
875
|
-
a = a << 1 | u & 1, v == r - 1 ? (v = 0, i.push(e(a)), a = 0) : v++, u = u >> 1;
|
|
876
|
-
for (; ; )
|
|
877
|
-
if (a = a << 1, v == r - 1) {
|
|
878
|
-
i.push(e(a));
|
|
879
|
-
break;
|
|
880
|
-
} else
|
|
881
|
-
v++;
|
|
882
|
-
return i.join("");
|
|
883
|
-
},
|
|
884
|
-
decompress: function(s) {
|
|
885
|
-
return s == null ? "" : s == "" ? null : j._decompress(s.length, 32768, function(r) {
|
|
886
|
-
return s.charCodeAt(r);
|
|
887
|
-
});
|
|
888
|
-
},
|
|
889
|
-
_decompress: function(s, r, e) {
|
|
890
|
-
var t = [], n = [], i = { val: e(0), position: r, index: 1 }, o = 4, u = 4, l = 3, c = "", h, g, d, f, a, v, p;
|
|
891
|
-
for (h = 0; h < 3; h += 1)
|
|
892
|
-
t[h] = h;
|
|
893
|
-
for (d = 0, a = Math.pow(2, 2), v = 1; v != a; )
|
|
894
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
895
|
-
switch (d) {
|
|
896
|
-
case 0:
|
|
897
|
-
for (d = 0, a = Math.pow(2, 8), v = 1; v != a; )
|
|
898
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
899
|
-
p = M(d);
|
|
900
|
-
break;
|
|
901
|
-
case 1:
|
|
902
|
-
for (d = 0, a = Math.pow(2, 16), v = 1; v != a; )
|
|
903
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
904
|
-
p = M(d);
|
|
905
|
-
break;
|
|
906
|
-
case 2:
|
|
907
|
-
return "";
|
|
908
|
-
}
|
|
909
|
-
for (t[3] = p, g = p, n.push(p); ; ) {
|
|
910
|
-
if (i.index > s)
|
|
911
|
-
return "";
|
|
912
|
-
for (d = 0, a = Math.pow(2, l), v = 1; v != a; )
|
|
913
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
914
|
-
switch (p = d) {
|
|
915
|
-
case 0:
|
|
916
|
-
for (d = 0, a = Math.pow(2, 8), v = 1; v != a; )
|
|
917
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
918
|
-
t[u++] = M(d), p = u - 1, o--;
|
|
919
|
-
break;
|
|
920
|
-
case 1:
|
|
921
|
-
for (d = 0, a = Math.pow(2, 16), v = 1; v != a; )
|
|
922
|
-
f = i.val & i.position, i.position >>= 1, i.position == 0 && (i.position = r, i.val = e(i.index++)), d |= (f > 0 ? 1 : 0) * v, v <<= 1;
|
|
923
|
-
t[u++] = M(d), p = u - 1, o--;
|
|
924
|
-
break;
|
|
925
|
-
case 2:
|
|
926
|
-
return n.join("");
|
|
927
|
-
}
|
|
928
|
-
if (o == 0 && (o = Math.pow(2, l), l++), t[p])
|
|
929
|
-
c = t[p];
|
|
930
|
-
else if (p === u)
|
|
931
|
-
c = g + g.charAt(0);
|
|
932
|
-
else
|
|
933
|
-
return null;
|
|
934
|
-
n.push(c), t[u++] = g + c.charAt(0), o--, g = c, o == 0 && (o = Math.pow(2, l), l++);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}, we = (
|
|
938
|
-
/** @class */
|
|
939
|
-
function() {
|
|
940
|
-
function s() {
|
|
941
|
-
this.events = {}, this.events = {};
|
|
942
|
-
}
|
|
943
|
-
return s.prototype.on = function(r, e) {
|
|
944
|
-
var t = this;
|
|
945
|
-
return this.events[r] || (this.events[r] = []), this.events[r].push(e), function() {
|
|
946
|
-
t.events[r] = t.events[r].filter(function(n) {
|
|
947
|
-
return n !== e;
|
|
948
|
-
});
|
|
949
|
-
};
|
|
950
|
-
}, s.prototype.emit = function(r, e) {
|
|
951
|
-
for (var t = 0, n = this.events[r] || []; t < n.length; t++) {
|
|
952
|
-
var i = n[t];
|
|
953
|
-
i(e);
|
|
954
|
-
}
|
|
955
|
-
for (var o = 0, u = this.events["*"] || []; o < u.length; o++) {
|
|
956
|
-
var i = u[o];
|
|
957
|
-
i(r, e);
|
|
958
|
-
}
|
|
959
|
-
}, s;
|
|
960
|
-
}()
|
|
961
|
-
);
|
|
962
|
-
/**
|
|
963
|
-
* uuidv7: An experimental implementation of the proposed UUID Version 7
|
|
964
|
-
*
|
|
965
|
-
* @license Apache-2.0
|
|
966
|
-
* @copyright 2021-2023 LiosK
|
|
967
|
-
* @packageDocumentation
|
|
968
|
-
*/
|
|
969
|
-
var T = "0123456789abcdef", q = (
|
|
970
|
-
/** @class */
|
|
971
|
-
function() {
|
|
972
|
-
function s(r) {
|
|
973
|
-
this.bytes = r;
|
|
974
|
-
}
|
|
975
|
-
return s.ofInner = function(r) {
|
|
976
|
-
if (r.length !== 16)
|
|
977
|
-
throw new TypeError("not 128-bit length");
|
|
978
|
-
return new s(r);
|
|
979
|
-
}, s.fromFieldsV7 = function(r, e, t, n) {
|
|
980
|
-
if (!Number.isInteger(r) || !Number.isInteger(e) || !Number.isInteger(t) || !Number.isInteger(n) || r < 0 || e < 0 || t < 0 || n < 0 || r > 281474976710655 || e > 4095 || t > 1073741823 || n > 4294967295)
|
|
981
|
-
throw new RangeError("invalid field value");
|
|
982
|
-
var i = new Uint8Array(16);
|
|
983
|
-
return i[0] = r / Math.pow(2, 40), i[1] = r / Math.pow(2, 32), i[2] = r / Math.pow(2, 24), i[3] = r / Math.pow(2, 16), i[4] = r / Math.pow(2, 8), i[5] = r, i[6] = 112 | e >>> 8, i[7] = e, i[8] = 128 | t >>> 24, i[9] = t >>> 16, i[10] = t >>> 8, i[11] = t, i[12] = n >>> 24, i[13] = n >>> 16, i[14] = n >>> 8, i[15] = n, new s(i);
|
|
984
|
-
}, s.parse = function(r) {
|
|
985
|
-
var e, t, n, i, o = void 0;
|
|
986
|
-
switch (r.length) {
|
|
987
|
-
case 32:
|
|
988
|
-
o = (e = /^[0-9a-f]{32}$/i.exec(r)) === null || e === void 0 ? void 0 : e[0];
|
|
989
|
-
break;
|
|
990
|
-
case 36:
|
|
991
|
-
o = (t = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(r)) === null || t === void 0 ? void 0 : t.slice(1, 6).join("");
|
|
992
|
-
break;
|
|
993
|
-
case 38:
|
|
994
|
-
o = (n = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(r)) === null || n === void 0 ? void 0 : n.slice(1, 6).join("");
|
|
995
|
-
break;
|
|
996
|
-
case 45:
|
|
997
|
-
o = (i = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(r)) === null || i === void 0 ? void 0 : i.slice(1, 6).join("");
|
|
998
|
-
break;
|
|
999
|
-
}
|
|
1000
|
-
if (o) {
|
|
1001
|
-
for (var u = new Uint8Array(16), l = 0; l < 16; l += 4) {
|
|
1002
|
-
var c = parseInt(o.substring(2 * l, 2 * l + 8), 16);
|
|
1003
|
-
u[l + 0] = c >>> 24, u[l + 1] = c >>> 16, u[l + 2] = c >>> 8, u[l + 3] = c;
|
|
1004
|
-
}
|
|
1005
|
-
return new s(u);
|
|
1006
|
-
} else
|
|
1007
|
-
throw new SyntaxError("could not parse UUID string");
|
|
1008
|
-
}, s.prototype.toString = function() {
|
|
1009
|
-
for (var r = "", e = 0; e < this.bytes.length; e++)
|
|
1010
|
-
r += T.charAt(this.bytes[e] >>> 4), r += T.charAt(this.bytes[e] & 15), (e === 3 || e === 5 || e === 7 || e === 9) && (r += "-");
|
|
1011
|
-
return r;
|
|
1012
|
-
}, s.prototype.toHex = function() {
|
|
1013
|
-
for (var r = "", e = 0; e < this.bytes.length; e++)
|
|
1014
|
-
r += T.charAt(this.bytes[e] >>> 4), r += T.charAt(this.bytes[e] & 15);
|
|
1015
|
-
return r;
|
|
1016
|
-
}, s.prototype.toJSON = function() {
|
|
1017
|
-
return this.toString();
|
|
1018
|
-
}, s.prototype.getVariant = function() {
|
|
1019
|
-
var r = this.bytes[8] >>> 4;
|
|
1020
|
-
if (r < 0)
|
|
1021
|
-
throw new Error("unreachable");
|
|
1022
|
-
if (r <= 7)
|
|
1023
|
-
return this.bytes.every(function(e) {
|
|
1024
|
-
return e === 0;
|
|
1025
|
-
}) ? "NIL" : "VAR_0";
|
|
1026
|
-
if (r <= 11)
|
|
1027
|
-
return "VAR_10";
|
|
1028
|
-
if (r <= 13)
|
|
1029
|
-
return "VAR_110";
|
|
1030
|
-
if (r <= 15)
|
|
1031
|
-
return this.bytes.every(function(e) {
|
|
1032
|
-
return e === 255;
|
|
1033
|
-
}) ? "MAX" : "VAR_RESERVED";
|
|
1034
|
-
throw new Error("unreachable");
|
|
1035
|
-
}, s.prototype.getVersion = function() {
|
|
1036
|
-
return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : void 0;
|
|
1037
|
-
}, s.prototype.clone = function() {
|
|
1038
|
-
return new s(this.bytes.slice(0));
|
|
1039
|
-
}, s.prototype.equals = function(r) {
|
|
1040
|
-
return this.compareTo(r) === 0;
|
|
1041
|
-
}, s.prototype.compareTo = function(r) {
|
|
1042
|
-
for (var e = 0; e < 16; e++) {
|
|
1043
|
-
var t = this.bytes[e] - r.bytes[e];
|
|
1044
|
-
if (t !== 0)
|
|
1045
|
-
return Math.sign(t);
|
|
1046
|
-
}
|
|
1047
|
-
return 0;
|
|
1048
|
-
}, s;
|
|
1049
|
-
}()
|
|
1050
|
-
), be = (
|
|
1051
|
-
/** @class */
|
|
1052
|
-
function() {
|
|
1053
|
-
function s(r) {
|
|
1054
|
-
this.timestamp = 0, this.counter = 0, this.random = r ?? me();
|
|
1055
|
-
}
|
|
1056
|
-
return s.prototype.generate = function() {
|
|
1057
|
-
return this.generateOrResetCore(Date.now(), 1e4);
|
|
1058
|
-
}, s.prototype.generateOrAbort = function() {
|
|
1059
|
-
return this.generateOrAbortCore(Date.now(), 1e4);
|
|
1060
|
-
}, s.prototype.generateOrResetCore = function(r, e) {
|
|
1061
|
-
var t = this.generateOrAbortCore(r, e);
|
|
1062
|
-
return t === void 0 && (this.timestamp = 0, t = this.generateOrAbortCore(r, e)), t;
|
|
1063
|
-
}, s.prototype.generateOrAbortCore = function(r, e) {
|
|
1064
|
-
var t = 4398046511103;
|
|
1065
|
-
if (!Number.isInteger(r) || r < 1 || r > 281474976710655)
|
|
1066
|
-
throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
|
|
1067
|
-
if (e < 0 || e > 281474976710655)
|
|
1068
|
-
throw new RangeError("`rollbackAllowance` out of reasonable range");
|
|
1069
|
-
if (r > this.timestamp)
|
|
1070
|
-
this.timestamp = r, this.resetCounter();
|
|
1071
|
-
else if (r + e >= this.timestamp)
|
|
1072
|
-
this.counter++, this.counter > t && (this.timestamp++, this.resetCounter());
|
|
1073
|
-
else
|
|
1074
|
-
return;
|
|
1075
|
-
return q.fromFieldsV7(this.timestamp, Math.trunc(this.counter / Math.pow(2, 30)), this.counter & Math.pow(2, 30) - 1, this.random.nextUint32());
|
|
1076
|
-
}, s.prototype.resetCounter = function() {
|
|
1077
|
-
this.counter = this.random.nextUint32() * 1024 + (this.random.nextUint32() & 1023);
|
|
1078
|
-
}, s.prototype.generateV4 = function() {
|
|
1079
|
-
var r = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
|
|
1080
|
-
return r[6] = 64 | r[6] >>> 4, r[8] = 128 | r[8] >>> 2, q.ofInner(r);
|
|
1081
|
-
}, s;
|
|
1082
|
-
}()
|
|
1083
|
-
), me = function() {
|
|
1084
|
-
return {
|
|
1085
|
-
nextUint32: function() {
|
|
1086
|
-
return Math.trunc(Math.random() * 65536) * 65536 + Math.trunc(Math.random() * 65536);
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
}, N, G = function() {
|
|
1090
|
-
return Fe().toString();
|
|
1091
|
-
}, Fe = function() {
|
|
1092
|
-
return (N || (N = new be())).generate();
|
|
1093
|
-
}, Pe = (
|
|
1094
|
-
/** @class */
|
|
1095
|
-
function(s) {
|
|
1096
|
-
x(r, s);
|
|
1097
|
-
function r(e) {
|
|
1098
|
-
var t = s.call(this, "HTTP error while fetching PostHog: " + e.status) || this;
|
|
1099
|
-
return t.response = e, t.name = "PostHogFetchHttpError", t;
|
|
1100
|
-
}
|
|
1101
|
-
return r;
|
|
1102
|
-
}(Error)
|
|
1103
|
-
), _e = (
|
|
1104
|
-
/** @class */
|
|
1105
|
-
function(s) {
|
|
1106
|
-
x(r, s);
|
|
1107
|
-
function r(e) {
|
|
1108
|
-
var t = (
|
|
1109
|
-
// TRICKY: "cause" is a newer property but is just ignored otherwise. Cast to any to ignore the type issue.
|
|
1110
|
-
// @ts-ignore
|
|
1111
|
-
s.call(this, "Network error while fetching PostHog", e instanceof Error ? { cause: e } : {}) || this
|
|
1112
|
-
);
|
|
1113
|
-
return t.error = e, t.name = "PostHogFetchNetworkError", t;
|
|
1114
|
-
}
|
|
1115
|
-
return r;
|
|
1116
|
-
}(Error)
|
|
1117
|
-
);
|
|
1118
|
-
function J(s) {
|
|
1119
|
-
return typeof s == "object" && (s.name === "PostHogFetchHttpError" || s.name === "PostHogFetchNetworkError");
|
|
1120
|
-
}
|
|
1121
|
-
var re = (
|
|
1122
|
-
/** @class */
|
|
1123
|
-
function() {
|
|
1124
|
-
function s(r, e) {
|
|
1125
|
-
var t, n, i, o, u;
|
|
1126
|
-
this.debugMode = !1, this.disableGeoip = !0, this.pendingPromises = {}, this._events = new we(), de(r, "You must pass your PostHog project's api key."), this.apiKey = r, this.host = pe((e == null ? void 0 : e.host) || "https://app.posthog.com"), this.flushAt = e != null && e.flushAt ? Math.max(e == null ? void 0 : e.flushAt, 1) : 20, this.flushInterval = (t = e == null ? void 0 : e.flushInterval) !== null && t !== void 0 ? t : 1e4, this.captureMode = (e == null ? void 0 : e.captureMode) || "form", this._optoutOverride = (e == null ? void 0 : e.enable) === !1, this._retryOptions = {
|
|
1127
|
-
retryCount: (n = e == null ? void 0 : e.fetchRetryCount) !== null && n !== void 0 ? n : 3,
|
|
1128
|
-
retryDelay: (i = e == null ? void 0 : e.fetchRetryDelay) !== null && i !== void 0 ? i : 3e3,
|
|
1129
|
-
retryCheck: J
|
|
1130
|
-
}, this.requestTimeout = (o = e == null ? void 0 : e.requestTimeout) !== null && o !== void 0 ? o : 1e4, this.disableGeoip = (u = e == null ? void 0 : e.disableGeoip) !== null && u !== void 0 ? u : !0;
|
|
1131
|
-
}
|
|
1132
|
-
return s.prototype.getCommonEventProperties = function() {
|
|
1133
|
-
return {
|
|
1134
|
-
$lib: this.getLibraryId(),
|
|
1135
|
-
$lib_version: this.getLibraryVersion()
|
|
1136
|
-
};
|
|
1137
|
-
}, Object.defineProperty(s.prototype, "optedOut", {
|
|
1138
|
-
get: function() {
|
|
1139
|
-
var r, e;
|
|
1140
|
-
return (e = (r = this.getPersistedProperty(_.OptedOut)) !== null && r !== void 0 ? r : this._optoutOverride) !== null && e !== void 0 ? e : !1;
|
|
1141
|
-
},
|
|
1142
|
-
enumerable: !1,
|
|
1143
|
-
configurable: !0
|
|
1144
|
-
}), s.prototype.optIn = function() {
|
|
1145
|
-
this.setPersistedProperty(_.OptedOut, !1);
|
|
1146
|
-
}, s.prototype.optOut = function() {
|
|
1147
|
-
this.setPersistedProperty(_.OptedOut, !0);
|
|
1148
|
-
}, s.prototype.on = function(r, e) {
|
|
1149
|
-
return this._events.on(r, e);
|
|
1150
|
-
}, s.prototype.debug = function(r) {
|
|
1151
|
-
var e;
|
|
1152
|
-
r === void 0 && (r = !0), (e = this.removeDebugCallback) === null || e === void 0 || e.call(this), this.debugMode = r, r && (this.removeDebugCallback = this.on("*", function(t, n) {
|
|
1153
|
-
return console.log("PostHog Debug", t, n);
|
|
1154
|
-
}));
|
|
1155
|
-
}, s.prototype.buildPayload = function(r) {
|
|
1156
|
-
return {
|
|
1157
|
-
distinct_id: r.distinct_id,
|
|
1158
|
-
event: r.event,
|
|
1159
|
-
properties: F(F({}, r.properties || {}), this.getCommonEventProperties())
|
|
1160
|
-
};
|
|
1161
|
-
}, s.prototype.addPendingPromise = function(r) {
|
|
1162
|
-
var e = this, t = G();
|
|
1163
|
-
this.pendingPromises[t] = r, r.finally(function() {
|
|
1164
|
-
delete e.pendingPromises[t];
|
|
1165
|
-
});
|
|
1166
|
-
}, s.prototype.identifyStateless = function(r, e, t) {
|
|
1167
|
-
var n = F({}, this.buildPayload({
|
|
1168
|
-
distinct_id: r,
|
|
1169
|
-
event: "$identify",
|
|
1170
|
-
properties: e
|
|
1171
|
-
}));
|
|
1172
|
-
return this.enqueue("identify", n, t), this;
|
|
1173
|
-
}, s.prototype.captureStateless = function(r, e, t, n) {
|
|
1174
|
-
var i = this.buildPayload({ distinct_id: r, event: e, properties: t });
|
|
1175
|
-
return this.enqueue("capture", i, n), this;
|
|
1176
|
-
}, s.prototype.aliasStateless = function(r, e, t, n) {
|
|
1177
|
-
var i = this.buildPayload({
|
|
1178
|
-
event: "$create_alias",
|
|
1179
|
-
distinct_id: e,
|
|
1180
|
-
properties: F(F({}, t || {}), { distinct_id: e, alias: r })
|
|
1181
|
-
});
|
|
1182
|
-
return this.enqueue("alias", i, n), this;
|
|
1183
|
-
}, s.prototype.groupIdentifyStateless = function(r, e, t, n, i, o) {
|
|
1184
|
-
var u = this.buildPayload({
|
|
1185
|
-
distinct_id: i || "$".concat(r, "_").concat(e),
|
|
1186
|
-
event: "$groupidentify",
|
|
1187
|
-
properties: F({ $group_type: r, $group_key: e, $group_set: t || {} }, o || {})
|
|
1188
|
-
});
|
|
1189
|
-
return this.enqueue("capture", u, n), this;
|
|
1190
|
-
}, s.prototype.getDecide = function(r, e, t, n, i) {
|
|
1191
|
-
return e === void 0 && (e = {}), t === void 0 && (t = {}), n === void 0 && (n = {}), i === void 0 && (i = {}), A(this, void 0, void 0, function() {
|
|
1192
|
-
var o, u, l = this;
|
|
1193
|
-
return E(this, function(c) {
|
|
1194
|
-
return o = "".concat(this.host, "/decide/?v=3"), u = {
|
|
1195
|
-
method: "POST",
|
|
1196
|
-
headers: { "Content-Type": "application/json" },
|
|
1197
|
-
body: JSON.stringify(F({ token: this.apiKey, distinct_id: r, groups: e, person_properties: t, group_properties: n }, i))
|
|
1198
|
-
}, [2, this.fetchWithRetry(o, u).then(function(h) {
|
|
1199
|
-
return h.json();
|
|
1200
|
-
}).catch(function(h) {
|
|
1201
|
-
l._events.emit("error", h);
|
|
1202
|
-
})];
|
|
1203
|
-
});
|
|
1204
|
-
});
|
|
1205
|
-
}, s.prototype.getFeatureFlagStateless = function(r, e, t, n, i, o) {
|
|
1206
|
-
return t === void 0 && (t = {}), n === void 0 && (n = {}), i === void 0 && (i = {}), A(this, void 0, void 0, function() {
|
|
1207
|
-
var u, l;
|
|
1208
|
-
return E(this, function(c) {
|
|
1209
|
-
switch (c.label) {
|
|
1210
|
-
case 0:
|
|
1211
|
-
return [4, this.getFeatureFlagsStateless(e, t, n, i, o)];
|
|
1212
|
-
case 1:
|
|
1213
|
-
return u = c.sent(), u ? (l = u[r], l === void 0 && (l = !1), [2, l]) : [2, void 0];
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
});
|
|
1217
|
-
}, s.prototype.getFeatureFlagPayloadStateless = function(r, e, t, n, i, o) {
|
|
1218
|
-
return t === void 0 && (t = {}), n === void 0 && (n = {}), i === void 0 && (i = {}), A(this, void 0, void 0, function() {
|
|
1219
|
-
var u, l;
|
|
1220
|
-
return E(this, function(c) {
|
|
1221
|
-
switch (c.label) {
|
|
1222
|
-
case 0:
|
|
1223
|
-
return [4, this.getFeatureFlagPayloadsStateless(e, t, n, i, o)];
|
|
1224
|
-
case 1:
|
|
1225
|
-
return u = c.sent(), u ? (l = u[r], l === void 0 ? [2, null] : [2, this._parsePayload(l)]) : [2, void 0];
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
});
|
|
1229
|
-
}, s.prototype.getFeatureFlagPayloadsStateless = function(r, e, t, n, i) {
|
|
1230
|
-
return e === void 0 && (e = {}), t === void 0 && (t = {}), n === void 0 && (n = {}), A(this, void 0, void 0, function() {
|
|
1231
|
-
var o, u = this;
|
|
1232
|
-
return E(this, function(l) {
|
|
1233
|
-
switch (l.label) {
|
|
1234
|
-
case 0:
|
|
1235
|
-
return [4, this.getFeatureFlagsAndPayloadsStateless(r, e, t, n, i)];
|
|
1236
|
-
case 1:
|
|
1237
|
-
return o = l.sent().payloads, o ? [2, Object.fromEntries(Object.entries(o).map(function(c) {
|
|
1238
|
-
var h = c[0], g = c[1];
|
|
1239
|
-
return [h, u._parsePayload(g)];
|
|
1240
|
-
}))] : [2, o];
|
|
1241
|
-
}
|
|
1242
|
-
});
|
|
1243
|
-
});
|
|
1244
|
-
}, s.prototype._parsePayload = function(r) {
|
|
1245
|
-
try {
|
|
1246
|
-
return JSON.parse(r);
|
|
1247
|
-
} catch {
|
|
1248
|
-
return r;
|
|
1249
|
-
}
|
|
1250
|
-
}, s.prototype.getFeatureFlagsStateless = function(r, e, t, n, i) {
|
|
1251
|
-
return e === void 0 && (e = {}), t === void 0 && (t = {}), n === void 0 && (n = {}), A(this, void 0, void 0, function() {
|
|
1252
|
-
return E(this, function(o) {
|
|
1253
|
-
switch (o.label) {
|
|
1254
|
-
case 0:
|
|
1255
|
-
return [4, this.getFeatureFlagsAndPayloadsStateless(r, e, t, n, i)];
|
|
1256
|
-
case 1:
|
|
1257
|
-
return [2, o.sent().flags];
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1260
|
-
});
|
|
1261
|
-
}, s.prototype.getFeatureFlagsAndPayloadsStateless = function(r, e, t, n, i) {
|
|
1262
|
-
return e === void 0 && (e = {}), t === void 0 && (t = {}), n === void 0 && (n = {}), A(this, void 0, void 0, function() {
|
|
1263
|
-
var o, u, l, c;
|
|
1264
|
-
return E(this, function(h) {
|
|
1265
|
-
switch (h.label) {
|
|
1266
|
-
case 0:
|
|
1267
|
-
return o = {}, (i ?? this.disableGeoip) && (o.geoip_disable = !0), [4, this.getDecide(r, e, t, n, o)];
|
|
1268
|
-
case 1:
|
|
1269
|
-
return u = h.sent(), l = u == null ? void 0 : u.featureFlags, c = u == null ? void 0 : u.featureFlagPayloads, [2, {
|
|
1270
|
-
flags: l,
|
|
1271
|
-
payloads: c
|
|
1272
|
-
}];
|
|
1273
|
-
}
|
|
1274
|
-
});
|
|
1275
|
-
});
|
|
1276
|
-
}, s.prototype.enqueue = function(r, e, t) {
|
|
1277
|
-
var n = this, i;
|
|
1278
|
-
if (this.optedOut) {
|
|
1279
|
-
this._events.emit(r, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
1280
|
-
return;
|
|
1281
|
-
}
|
|
1282
|
-
var o = F(F({}, e), { type: r, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: t != null && t.timestamp ? t == null ? void 0 : t.timestamp : B(), uuid: t != null && t.uuid ? t.uuid : G() }), u = (i = t == null ? void 0 : t.disableGeoip) !== null && i !== void 0 ? i : this.disableGeoip;
|
|
1283
|
-
u && (o.properties || (o.properties = {}), o.properties.$geoip_disable = !0), o.distinctId && (o.distinct_id = o.distinctId, delete o.distinctId);
|
|
1284
|
-
var l = this.getPersistedProperty(_.Queue) || [];
|
|
1285
|
-
l.push({ message: o }), this.setPersistedProperty(_.Queue, l), this._events.emit(r, o), l.length >= this.flushAt && this.flush(), this.flushInterval && !this._flushTimer && (this._flushTimer = te(function() {
|
|
1286
|
-
return n.flush();
|
|
1287
|
-
}, this.flushInterval));
|
|
1288
|
-
}, s.prototype.flushAsync = function() {
|
|
1289
|
-
var r = this;
|
|
1290
|
-
return new Promise(function(e, t) {
|
|
1291
|
-
r.flush(function(n, i) {
|
|
1292
|
-
return n ? t(n) : e(i);
|
|
1293
|
-
});
|
|
1294
|
-
});
|
|
1295
|
-
}, s.prototype.flush = function(r) {
|
|
1296
|
-
var e = this;
|
|
1297
|
-
this._flushTimer && (clearTimeout(this._flushTimer), this._flushTimer = null);
|
|
1298
|
-
var t = this.getPersistedProperty(_.Queue) || [];
|
|
1299
|
-
if (!t.length)
|
|
1300
|
-
return r == null ? void 0 : r();
|
|
1301
|
-
var n = t.splice(0, this.flushAt);
|
|
1302
|
-
this.setPersistedProperty(_.Queue, t);
|
|
1303
|
-
var i = n.map(function(d) {
|
|
1304
|
-
return d.message;
|
|
1305
|
-
}), o = {
|
|
1306
|
-
api_key: this.apiKey,
|
|
1307
|
-
batch: i,
|
|
1308
|
-
sent_at: B()
|
|
1309
|
-
}, u = function(d) {
|
|
1310
|
-
d && e._events.emit("error", d), r == null || r(d, i), e._events.emit("flush", i);
|
|
1311
|
-
};
|
|
1312
|
-
this.getCustomUserAgent();
|
|
1313
|
-
var l = JSON.stringify(o), c = this.captureMode === "form" ? "".concat(this.host, "/e/?ip=1&_=").concat(ge(), "&v=").concat(this.getLibraryVersion()) : "".concat(this.host, "/batch/"), h = this.captureMode === "form" ? {
|
|
1314
|
-
method: "POST",
|
|
1315
|
-
mode: "no-cors",
|
|
1316
|
-
credentials: "omit",
|
|
1317
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1318
|
-
body: "data=".concat(encodeURIComponent(j.compressToBase64(l)), "&compression=lz64")
|
|
1319
|
-
} : {
|
|
1320
|
-
method: "POST",
|
|
1321
|
-
headers: { "Content-Type": "application/json" },
|
|
1322
|
-
body: l
|
|
1323
|
-
}, g = this.fetchWithRetry(c, h);
|
|
1324
|
-
this.addPendingPromise(g.then(function() {
|
|
1325
|
-
return u();
|
|
1326
|
-
}).catch(function(d) {
|
|
1327
|
-
u(d);
|
|
1328
|
-
}));
|
|
1329
|
-
}, s.prototype.fetchWithRetry = function(r, e, t) {
|
|
1330
|
-
var n, i;
|
|
1331
|
-
return A(this, void 0, void 0, function() {
|
|
1332
|
-
var o = this;
|
|
1333
|
-
return E(this, function(u) {
|
|
1334
|
-
switch (u.label) {
|
|
1335
|
-
case 0:
|
|
1336
|
-
return (n = (i = AbortSignal).timeout) !== null && n !== void 0 || (i.timeout = function(c) {
|
|
1337
|
-
var h = new AbortController();
|
|
1338
|
-
return setTimeout(function() {
|
|
1339
|
-
return h.abort();
|
|
1340
|
-
}, c), h.signal;
|
|
1341
|
-
}), [4, ve(function() {
|
|
1342
|
-
return A(o, void 0, void 0, function() {
|
|
1343
|
-
var l, c, h;
|
|
1344
|
-
return E(this, function(g) {
|
|
1345
|
-
switch (g.label) {
|
|
1346
|
-
case 0:
|
|
1347
|
-
l = null, g.label = 1;
|
|
1348
|
-
case 1:
|
|
1349
|
-
return g.trys.push([1, 3, , 4]), [4, this.fetch(r, F({ signal: AbortSignal.timeout(this.requestTimeout) }, e))];
|
|
1350
|
-
case 2:
|
|
1351
|
-
return l = g.sent(), [3, 4];
|
|
1352
|
-
case 3:
|
|
1353
|
-
throw c = g.sent(), new _e(c);
|
|
1354
|
-
case 4:
|
|
1355
|
-
if (h = e.mode === "no-cors", !h && (l.status < 200 || l.status >= 400))
|
|
1356
|
-
throw new Pe(l);
|
|
1357
|
-
return [2, l];
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
});
|
|
1361
|
-
}, F(F({}, this._retryOptions), t))];
|
|
1362
|
-
case 1:
|
|
1363
|
-
return [2, u.sent()];
|
|
1364
|
-
}
|
|
1365
|
-
});
|
|
1366
|
-
});
|
|
1367
|
-
}, s.prototype.shutdownAsync = function() {
|
|
1368
|
-
return A(this, void 0, void 0, function() {
|
|
1369
|
-
var r;
|
|
1370
|
-
return E(this, function(e) {
|
|
1371
|
-
switch (e.label) {
|
|
1372
|
-
case 0:
|
|
1373
|
-
clearTimeout(this._flushTimer), e.label = 1;
|
|
1374
|
-
case 1:
|
|
1375
|
-
return e.trys.push([1, 5, , 6]), [4, this.flushAsync()];
|
|
1376
|
-
case 2:
|
|
1377
|
-
return e.sent(), [
|
|
1378
|
-
4,
|
|
1379
|
-
Promise.all(Object.values(this.pendingPromises).map(function(t) {
|
|
1380
|
-
return t.catch(function() {
|
|
1381
|
-
});
|
|
1382
|
-
}))
|
|
1383
|
-
// flush again to make sure we send all events, some of which might've been added
|
|
1384
|
-
// while we were waiting for the pending promises to resolve
|
|
1385
|
-
// For example, see sendFeatureFlags in posthog-node/src/posthog-node.ts::capture
|
|
1386
|
-
];
|
|
1387
|
-
case 3:
|
|
1388
|
-
return e.sent(), [4, this.flushAsync()];
|
|
1389
|
-
case 4:
|
|
1390
|
-
return e.sent(), [3, 6];
|
|
1391
|
-
case 5:
|
|
1392
|
-
if (r = e.sent(), !J(r))
|
|
1393
|
-
throw r;
|
|
1394
|
-
return console.error("Error while shutting down PostHog", r), [3, 6];
|
|
1395
|
-
case 6:
|
|
1396
|
-
return [
|
|
1397
|
-
2
|
|
1398
|
-
/*return*/
|
|
1399
|
-
];
|
|
1400
|
-
}
|
|
1401
|
-
});
|
|
1402
|
-
});
|
|
1403
|
-
}, s.prototype.shutdown = function() {
|
|
1404
|
-
this.shutdownAsync();
|
|
1405
|
-
}, s;
|
|
1406
|
-
}()
|
|
1407
|
-
);
|
|
1408
|
-
(function(s) {
|
|
1409
|
-
x(r, s);
|
|
1410
|
-
function r(e, t) {
|
|
1411
|
-
var n = this, i, o, u, l = (i = t == null ? void 0 : t.disableGeoip) !== null && i !== void 0 ? i : !1;
|
|
1412
|
-
return n = s.call(this, e, F(F({}, t), { disableGeoip: l })) || this, n.flagCallReported = {}, n.sessionProps = {}, n.sendFeatureFlagEvent = (o = t == null ? void 0 : t.sendFeatureFlagEvent) !== null && o !== void 0 ? o : !0, n._sessionExpirationTimeSeconds = (u = t == null ? void 0 : t.sessionExpirationTimeSeconds) !== null && u !== void 0 ? u : 1800, n;
|
|
1413
|
-
}
|
|
1414
|
-
return r.prototype.setupBootstrap = function(e) {
|
|
1415
|
-
var t, n, i, o;
|
|
1416
|
-
if (!((t = e == null ? void 0 : e.bootstrap) === null || t === void 0) && t.distinctId && (!((n = e == null ? void 0 : e.bootstrap) === null || n === void 0) && n.isIdentifiedId ? this.setPersistedProperty(_.DistinctId, e.bootstrap.distinctId) : this.setPersistedProperty(_.AnonymousId, e.bootstrap.distinctId)), !((i = e == null ? void 0 : e.bootstrap) === null || i === void 0) && i.featureFlags) {
|
|
1417
|
-
var u = Object.keys(((o = e.bootstrap) === null || o === void 0 ? void 0 : o.featureFlags) || {}).filter(function(l) {
|
|
1418
|
-
var c, h;
|
|
1419
|
-
return !!(!((h = (c = e.bootstrap) === null || c === void 0 ? void 0 : c.featureFlags) === null || h === void 0) && h[l]);
|
|
1420
|
-
}).reduce(function(l, c) {
|
|
1421
|
-
var h, g;
|
|
1422
|
-
return l[c] = ((g = (h = e.bootstrap) === null || h === void 0 ? void 0 : h.featureFlags) === null || g === void 0 ? void 0 : g[c]) || !1, l;
|
|
1423
|
-
}, {});
|
|
1424
|
-
this.setKnownFeatureFlags(u), e != null && e.bootstrap.featureFlagPayloads && this.setKnownFeatureFlagPayloads(e == null ? void 0 : e.bootstrap.featureFlagPayloads);
|
|
1425
|
-
}
|
|
1426
|
-
}, Object.defineProperty(r.prototype, "props", {
|
|
1427
|
-
// NOTE: Props are lazy loaded from localstorage hence the complex getter setter logic
|
|
1428
|
-
get: function() {
|
|
1429
|
-
return this._props || (this._props = this.getPersistedProperty(_.Props)), this._props || {};
|
|
1430
|
-
},
|
|
1431
|
-
set: function(e) {
|
|
1432
|
-
this._props = e;
|
|
1433
|
-
},
|
|
1434
|
-
enumerable: !1,
|
|
1435
|
-
configurable: !0
|
|
1436
|
-
}), r.prototype.clearProps = function() {
|
|
1437
|
-
this.props = void 0, this.sessionProps = {};
|
|
1438
|
-
}, r.prototype.on = function(e, t) {
|
|
1439
|
-
return this._events.on(e, t);
|
|
1440
|
-
}, r.prototype.reset = function(e) {
|
|
1441
|
-
var t = ee([_.Queue], e || []);
|
|
1442
|
-
this.clearProps();
|
|
1443
|
-
for (var n = 0, i = Object.keys(_); n < i.length; n++) {
|
|
1444
|
-
var o = i[n];
|
|
1445
|
-
t.includes(_[o]) || this.setPersistedProperty(_[o], null);
|
|
1446
|
-
}
|
|
1447
|
-
}, r.prototype.getCommonEventProperties = function() {
|
|
1448
|
-
var e = this.getFeatureFlags(), t = {};
|
|
1449
|
-
if (e)
|
|
1450
|
-
for (var n = 0, i = Object.entries(e); n < i.length; n++) {
|
|
1451
|
-
var o = i[n], u = o[0], l = o[1];
|
|
1452
|
-
t["$feature/".concat(u)] = l;
|
|
1453
|
-
}
|
|
1454
|
-
return F(F({ $active_feature_flags: e ? Object.keys(e) : void 0 }, t), s.prototype.getCommonEventProperties.call(this));
|
|
1455
|
-
}, r.prototype.enrichProperties = function(e) {
|
|
1456
|
-
return F(F(F(F(F({}, this.props), this.sessionProps), e || {}), this.getCommonEventProperties()), { $session_id: this.getSessionId() });
|
|
1457
|
-
}, r.prototype.getSessionId = function() {
|
|
1458
|
-
var e = this.getPersistedProperty(_.SessionId), t = this.getPersistedProperty(_.SessionLastTimestamp) || 0;
|
|
1459
|
-
return (!e || Date.now() - t > this._sessionExpirationTimeSeconds * 1e3) && (e = G(), this.setPersistedProperty(_.SessionId, e)), this.setPersistedProperty(_.SessionLastTimestamp, Date.now()), e;
|
|
1460
|
-
}, r.prototype.resetSessionId = function() {
|
|
1461
|
-
this.setPersistedProperty(_.SessionId, null);
|
|
1462
|
-
}, r.prototype.getAnonymousId = function() {
|
|
1463
|
-
var e = this.getPersistedProperty(_.AnonymousId);
|
|
1464
|
-
return e || (e = G(), this.setPersistedProperty(_.AnonymousId, e)), e;
|
|
1465
|
-
}, r.prototype.getDistinctId = function() {
|
|
1466
|
-
return this.getPersistedProperty(_.DistinctId) || this.getAnonymousId();
|
|
1467
|
-
}, r.prototype.unregister = function(e) {
|
|
1468
|
-
delete this.props[e], this.setPersistedProperty(_.Props, this.props);
|
|
1469
|
-
}, r.prototype.register = function(e) {
|
|
1470
|
-
this.props = F(F({}, this.props), e), this.setPersistedProperty(_.Props, this.props);
|
|
1471
|
-
}, r.prototype.registerForSession = function(e) {
|
|
1472
|
-
this.sessionProps = F(F({}, this.sessionProps), e);
|
|
1473
|
-
}, r.prototype.unregisterForSession = function(e) {
|
|
1474
|
-
delete this.sessionProps[e];
|
|
1475
|
-
}, r.prototype.identify = function(e, t, n) {
|
|
1476
|
-
var i = this.getDistinctId();
|
|
1477
|
-
e = e || i, t != null && t.$groups && this.groups(t.$groups);
|
|
1478
|
-
var o = this.enrichProperties(F(F({}, t), { $anon_distinct_id: this.getAnonymousId(), $set: t }));
|
|
1479
|
-
return e !== i && (this.setPersistedProperty(_.AnonymousId, i), this.setPersistedProperty(_.DistinctId, e), this.reloadFeatureFlags()), s.prototype.identifyStateless.call(this, e, o, n), this;
|
|
1480
|
-
}, r.prototype.capture = function(e, t, n) {
|
|
1481
|
-
var i = this.getDistinctId();
|
|
1482
|
-
t != null && t.$groups && this.groups(t.$groups);
|
|
1483
|
-
var o = this.enrichProperties(t);
|
|
1484
|
-
return s.prototype.captureStateless.call(this, i, e, o, n), this;
|
|
1485
|
-
}, r.prototype.alias = function(e) {
|
|
1486
|
-
var t = this.getDistinctId(), n = this.enrichProperties({});
|
|
1487
|
-
return s.prototype.aliasStateless.call(this, e, t, n), this;
|
|
1488
|
-
}, r.prototype.autocapture = function(e, t, n, i) {
|
|
1489
|
-
n === void 0 && (n = {});
|
|
1490
|
-
var o = this.getDistinctId(), u = {
|
|
1491
|
-
distinct_id: o,
|
|
1492
|
-
event: "$autocapture",
|
|
1493
|
-
properties: F(F({}, this.enrichProperties(n)), { $event_type: e, $elements: t })
|
|
1494
|
-
};
|
|
1495
|
-
return this.enqueue("autocapture", u, i), this;
|
|
1496
|
-
}, r.prototype.groups = function(e) {
|
|
1497
|
-
var t = this.props.$groups || {};
|
|
1498
|
-
return this.register({
|
|
1499
|
-
$groups: F(F({}, t), e)
|
|
1500
|
-
}), Object.keys(e).find(function(n) {
|
|
1501
|
-
return t[n] !== e[n];
|
|
1502
|
-
}) && this.reloadFeatureFlags(), this;
|
|
1503
|
-
}, r.prototype.group = function(e, t, n, i) {
|
|
1504
|
-
var o;
|
|
1505
|
-
return this.groups((o = {}, o[e] = t, o)), n && this.groupIdentify(e, t, n, i), this;
|
|
1506
|
-
}, r.prototype.groupIdentify = function(e, t, n, i) {
|
|
1507
|
-
var o = this.getDistinctId(), u = this.enrichProperties({});
|
|
1508
|
-
return s.prototype.groupIdentifyStateless.call(this, e, t, n, i, o, u), this;
|
|
1509
|
-
}, r.prototype.setPersonPropertiesForFlags = function(e) {
|
|
1510
|
-
var t = this.getPersistedProperty(_.PersonProperties) || {};
|
|
1511
|
-
return this.setPersistedProperty(_.PersonProperties, F(F({}, t), e)), this;
|
|
1512
|
-
}, r.prototype.resetPersonPropertiesForFlags = function() {
|
|
1513
|
-
this.setPersistedProperty(_.PersonProperties, {});
|
|
1514
|
-
}, r.prototype.personProperties = function(e) {
|
|
1515
|
-
return this.setPersonPropertiesForFlags(e);
|
|
1516
|
-
}, r.prototype.setGroupPropertiesForFlags = function(e) {
|
|
1517
|
-
var t = this.getPersistedProperty(_.GroupProperties) || {};
|
|
1518
|
-
return Object.keys(t).length !== 0 && Object.keys(t).forEach(function(n) {
|
|
1519
|
-
t[n] = F(F({}, t[n]), e[n]), delete e[n];
|
|
1520
|
-
}), this.setPersistedProperty(_.GroupProperties, F(F({}, t), e)), this;
|
|
1521
|
-
}, r.prototype.resetGroupPropertiesForFlags = function() {
|
|
1522
|
-
this.setPersistedProperty(_.GroupProperties, {});
|
|
1523
|
-
}, r.prototype.groupProperties = function(e) {
|
|
1524
|
-
return this.setGroupPropertiesForFlags(e);
|
|
1525
|
-
}, r.prototype.decideAsync = function(e) {
|
|
1526
|
-
return e === void 0 && (e = !0), this._decideResponsePromise ? this._decideResponsePromise : this._decideAsync(e);
|
|
1527
|
-
}, r.prototype._decideAsync = function(e) {
|
|
1528
|
-
return e === void 0 && (e = !0), A(this, void 0, void 0, function() {
|
|
1529
|
-
var t, n, i, o, u, l = this;
|
|
1530
|
-
return E(this, function(c) {
|
|
1531
|
-
return t = this.getDistinctId(), n = this.props.$groups || {}, i = this.getPersistedProperty(_.PersonProperties) || {}, o = this.getPersistedProperty(_.GroupProperties) || {}, u = {
|
|
1532
|
-
$anon_distinct_id: e ? this.getAnonymousId() : void 0
|
|
1533
|
-
}, this._decideResponsePromise = s.prototype.getDecide.call(this, t, n, i, o, u).then(function(h) {
|
|
1534
|
-
if (h != null && h.featureFlags) {
|
|
1535
|
-
var g = h.featureFlags, d = h.featureFlagPayloads;
|
|
1536
|
-
if (h.errorsWhileComputingFlags) {
|
|
1537
|
-
var f = l.getPersistedProperty(_.FeatureFlags), a = l.getPersistedProperty(_.FeatureFlagPayloads);
|
|
1538
|
-
g = F(F({}, f), h.featureFlags), d = F(F({}, a), h.featureFlagPayloads);
|
|
1539
|
-
}
|
|
1540
|
-
l.setKnownFeatureFlags(g), l.setKnownFeatureFlagPayloads(d);
|
|
1541
|
-
}
|
|
1542
|
-
return h;
|
|
1543
|
-
}).finally(function() {
|
|
1544
|
-
l._decideResponsePromise = void 0;
|
|
1545
|
-
}), [2, this._decideResponsePromise];
|
|
1546
|
-
});
|
|
1547
|
-
});
|
|
1548
|
-
}, r.prototype.setKnownFeatureFlags = function(e) {
|
|
1549
|
-
this.setPersistedProperty(_.FeatureFlags, e), this._events.emit("featureflags", e);
|
|
1550
|
-
}, r.prototype.setKnownFeatureFlagPayloads = function(e) {
|
|
1551
|
-
this.setPersistedProperty(_.FeatureFlagPayloads, e);
|
|
1552
|
-
}, r.prototype.getFeatureFlag = function(e) {
|
|
1553
|
-
var t = this.getFeatureFlags();
|
|
1554
|
-
if (t) {
|
|
1555
|
-
var n = t[e];
|
|
1556
|
-
return n === void 0 && (n = !1), this.sendFeatureFlagEvent && !this.flagCallReported[e] && (this.flagCallReported[e] = !0, this.capture("$feature_flag_called", {
|
|
1557
|
-
$feature_flag: e,
|
|
1558
|
-
$feature_flag_response: n
|
|
1559
|
-
})), n;
|
|
1560
|
-
}
|
|
1561
|
-
}, r.prototype.getFeatureFlagPayload = function(e) {
|
|
1562
|
-
var t = this.getFeatureFlagPayloads();
|
|
1563
|
-
if (t) {
|
|
1564
|
-
var n = t[e];
|
|
1565
|
-
return n === void 0 ? null : this._parsePayload(n);
|
|
1566
|
-
}
|
|
1567
|
-
}, r.prototype.getFeatureFlagPayloads = function() {
|
|
1568
|
-
var e = this, t = this.getPersistedProperty(_.FeatureFlagPayloads);
|
|
1569
|
-
return t && Object.fromEntries(Object.entries(t).map(function(n) {
|
|
1570
|
-
var i = n[0], o = n[1];
|
|
1571
|
-
return [i, e._parsePayload(o)];
|
|
1572
|
-
}));
|
|
1573
|
-
}, r.prototype.getFeatureFlags = function() {
|
|
1574
|
-
var e = this.getPersistedProperty(_.FeatureFlags), t = this.getPersistedProperty(_.OverrideFeatureFlags);
|
|
1575
|
-
if (!t)
|
|
1576
|
-
return e;
|
|
1577
|
-
e = e || {};
|
|
1578
|
-
for (var n in t)
|
|
1579
|
-
t[n] ? e[n] = t[n] : delete e[n];
|
|
1580
|
-
return e;
|
|
1581
|
-
}, r.prototype.getFeatureFlagsAndPayloads = function() {
|
|
1582
|
-
var e = this.getFeatureFlags(), t = this.getFeatureFlagPayloads();
|
|
1583
|
-
return {
|
|
1584
|
-
flags: e,
|
|
1585
|
-
payloads: t
|
|
1586
|
-
};
|
|
1587
|
-
}, r.prototype.isFeatureEnabled = function(e) {
|
|
1588
|
-
var t = this.getFeatureFlag(e);
|
|
1589
|
-
if (t !== void 0)
|
|
1590
|
-
return !!t;
|
|
1591
|
-
}, r.prototype.reloadFeatureFlags = function(e) {
|
|
1592
|
-
this.decideAsync().then(function(t) {
|
|
1593
|
-
e == null || e(void 0, t == null ? void 0 : t.featureFlags);
|
|
1594
|
-
}).catch(function(t) {
|
|
1595
|
-
e == null || e(t, void 0), e || console.log("[PostHog] Error reloading feature flags", t);
|
|
1596
|
-
});
|
|
1597
|
-
}, r.prototype.reloadFeatureFlagsAsync = function(e) {
|
|
1598
|
-
var t;
|
|
1599
|
-
return e === void 0 && (e = !0), A(this, void 0, void 0, function() {
|
|
1600
|
-
return E(this, function(n) {
|
|
1601
|
-
switch (n.label) {
|
|
1602
|
-
case 0:
|
|
1603
|
-
return [4, this.decideAsync(e)];
|
|
1604
|
-
case 1:
|
|
1605
|
-
return [2, (t = n.sent()) === null || t === void 0 ? void 0 : t.featureFlags];
|
|
1606
|
-
}
|
|
1607
|
-
});
|
|
1608
|
-
});
|
|
1609
|
-
}, r.prototype.onFeatureFlags = function(e) {
|
|
1610
|
-
var t = this;
|
|
1611
|
-
return this.on("featureflags", function() {
|
|
1612
|
-
return A(t, void 0, void 0, function() {
|
|
1613
|
-
var n;
|
|
1614
|
-
return E(this, function(i) {
|
|
1615
|
-
return n = this.getFeatureFlags(), n && e(n), [
|
|
1616
|
-
2
|
|
1617
|
-
/*return*/
|
|
1618
|
-
];
|
|
1619
|
-
});
|
|
1620
|
-
});
|
|
1621
|
-
});
|
|
1622
|
-
}, r.prototype.onFeatureFlag = function(e, t) {
|
|
1623
|
-
var n = this;
|
|
1624
|
-
return this.on("featureflags", function() {
|
|
1625
|
-
return A(n, void 0, void 0, function() {
|
|
1626
|
-
var i;
|
|
1627
|
-
return E(this, function(o) {
|
|
1628
|
-
return i = this.getFeatureFlag(e), i !== void 0 && t(i), [
|
|
1629
|
-
2
|
|
1630
|
-
/*return*/
|
|
1631
|
-
];
|
|
1632
|
-
});
|
|
1633
|
-
});
|
|
1634
|
-
});
|
|
1635
|
-
}, r.prototype.overrideFeatureFlag = function(e) {
|
|
1636
|
-
return e === null ? this.setPersistedProperty(_.OverrideFeatureFlags, null) : this.setPersistedProperty(_.OverrideFeatureFlags, e);
|
|
1637
|
-
}, r;
|
|
1638
|
-
})(re);
|
|
1639
|
-
var Se = (
|
|
1640
|
-
/** @class */
|
|
1641
|
-
function() {
|
|
1642
|
-
function s() {
|
|
1643
|
-
this._memoryStorage = {};
|
|
1644
|
-
}
|
|
1645
|
-
return s.prototype.getProperty = function(r) {
|
|
1646
|
-
return this._memoryStorage[r];
|
|
1647
|
-
}, s.prototype.setProperty = function(r, e) {
|
|
1648
|
-
this._memoryStorage[r] = e !== null ? e : void 0;
|
|
1649
|
-
}, s;
|
|
1650
|
-
}()
|
|
1651
|
-
), K = (
|
|
1652
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
1653
|
-
// @ts-ignore
|
|
1654
|
-
typeof fetch < "u" ? fetch : typeof global.fetch < "u" ? global.fetch : void 0
|
|
1655
|
-
);
|
|
1656
|
-
if (!K) {
|
|
1657
|
-
var Ae = require("axios");
|
|
1658
|
-
K = function(s, r) {
|
|
1659
|
-
return A(void 0, void 0, void 0, function() {
|
|
1660
|
-
var e;
|
|
1661
|
-
return E(this, function(t) {
|
|
1662
|
-
switch (t.label) {
|
|
1663
|
-
case 0:
|
|
1664
|
-
return [
|
|
1665
|
-
4,
|
|
1666
|
-
Ae.request({
|
|
1667
|
-
url: s,
|
|
1668
|
-
headers: r.headers,
|
|
1669
|
-
method: r.method.toLowerCase(),
|
|
1670
|
-
data: r.body,
|
|
1671
|
-
signal: r.signal,
|
|
1672
|
-
// fetch only throws on network errors, not on HTTP errors
|
|
1673
|
-
validateStatus: function() {
|
|
1674
|
-
return !0;
|
|
1675
|
-
}
|
|
1676
|
-
})
|
|
1677
|
-
];
|
|
1678
|
-
case 1:
|
|
1679
|
-
return e = t.sent(), [
|
|
1680
|
-
2,
|
|
1681
|
-
{
|
|
1682
|
-
status: e.status,
|
|
1683
|
-
text: function() {
|
|
1684
|
-
return A(void 0, void 0, void 0, function() {
|
|
1685
|
-
return E(this, function(n) {
|
|
1686
|
-
return [
|
|
1687
|
-
2,
|
|
1688
|
-
e.data
|
|
1689
|
-
];
|
|
1690
|
-
});
|
|
1691
|
-
});
|
|
1692
|
-
},
|
|
1693
|
-
json: function() {
|
|
1694
|
-
return A(void 0, void 0, void 0, function() {
|
|
1695
|
-
return E(this, function(n) {
|
|
1696
|
-
return [
|
|
1697
|
-
2,
|
|
1698
|
-
e.data
|
|
1699
|
-
];
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
];
|
|
1705
|
-
}
|
|
1706
|
-
});
|
|
1707
|
-
});
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
var ie = K, Ee = 1152921504606847e3, V = (
|
|
1711
|
-
/** @class */
|
|
1712
|
-
function(s) {
|
|
1713
|
-
x(r, s);
|
|
1714
|
-
function r(e) {
|
|
1715
|
-
var t = s.call(this) || this;
|
|
1716
|
-
return Error.captureStackTrace(t, t.constructor), t.name = "ClientError", t.message = e, Object.setPrototypeOf(t, r.prototype), t;
|
|
1717
|
-
}
|
|
1718
|
-
return r;
|
|
1719
|
-
}(Error)
|
|
1720
|
-
), C = (
|
|
1721
|
-
/** @class */
|
|
1722
|
-
function(s) {
|
|
1723
|
-
x(r, s);
|
|
1724
|
-
function r(e) {
|
|
1725
|
-
var t = s.call(this, e) || this;
|
|
1726
|
-
return t.name = t.constructor.name, Error.captureStackTrace(t, t.constructor), Object.setPrototypeOf(t, r.prototype), t;
|
|
1727
|
-
}
|
|
1728
|
-
return r;
|
|
1729
|
-
}(Error)
|
|
1730
|
-
), Oe = (
|
|
1731
|
-
/** @class */
|
|
1732
|
-
function() {
|
|
1733
|
-
function s(r) {
|
|
1734
|
-
var e = r.pollingInterval, t = r.personalApiKey, n = r.projectApiKey, i = r.timeout, o = r.host, u = he(r, ["pollingInterval", "personalApiKey", "projectApiKey", "timeout", "host"]);
|
|
1735
|
-
this.debugMode = !1, this.pollingInterval = e, this.personalApiKey = t, this.featureFlags = [], this.featureFlagsByKey = {}, this.groupTypeMapping = {}, this.cohorts = {}, this.loadedSuccessfullyOnce = !1, this.timeout = i, this.projectApiKey = n, this.host = o, this.poller = void 0, this.fetch = u.fetch || ie, this.onError = u.onError, this.loadFeatureFlags();
|
|
1736
|
-
}
|
|
1737
|
-
return s.prototype.debug = function(r) {
|
|
1738
|
-
r === void 0 && (r = !0), this.debugMode = r;
|
|
1739
|
-
}, s.prototype.getFeatureFlag = function(r, e, t, n, i) {
|
|
1740
|
-
var o;
|
|
1741
|
-
return t === void 0 && (t = {}), n === void 0 && (n = {}), i === void 0 && (i = {}), A(this, void 0, void 0, function() {
|
|
1742
|
-
var u, l, c, h, g;
|
|
1743
|
-
return E(this, function(d) {
|
|
1744
|
-
switch (d.label) {
|
|
1745
|
-
case 0:
|
|
1746
|
-
return [
|
|
1747
|
-
4,
|
|
1748
|
-
this.loadFeatureFlags()
|
|
1749
|
-
];
|
|
1750
|
-
case 1:
|
|
1751
|
-
if (d.sent(), u = void 0, l = void 0, !this.loadedSuccessfullyOnce)
|
|
1752
|
-
return [
|
|
1753
|
-
2,
|
|
1754
|
-
u
|
|
1755
|
-
];
|
|
1756
|
-
for (c = 0, h = this.featureFlags; c < h.length; c++)
|
|
1757
|
-
if (g = h[c], r === g.key) {
|
|
1758
|
-
l = g;
|
|
1759
|
-
break;
|
|
1760
|
-
}
|
|
1761
|
-
if (l !== void 0)
|
|
1762
|
-
try {
|
|
1763
|
-
u = this.computeFlagLocally(l, e, t, n, i), this.debugMode && console.debug("Successfully computed flag locally: ".concat(r, " -> ").concat(u));
|
|
1764
|
-
} catch (f) {
|
|
1765
|
-
f instanceof C ? this.debugMode && console.debug("InconclusiveMatchError when computing flag locally: ".concat(r, ": ").concat(f)) : f instanceof Error && ((o = this.onError) === null || o === void 0 || o.call(this, new Error("Error computing flag locally: ".concat(r, ": ").concat(f))));
|
|
1766
|
-
}
|
|
1767
|
-
return [
|
|
1768
|
-
2,
|
|
1769
|
-
u
|
|
1770
|
-
];
|
|
1771
|
-
}
|
|
1772
|
-
});
|
|
1773
|
-
});
|
|
1774
|
-
}, s.prototype.computeFeatureFlagPayloadLocally = function(r, e) {
|
|
1775
|
-
var t, n, i, o, u, l, c, h;
|
|
1776
|
-
return A(this, void 0, void 0, function() {
|
|
1777
|
-
var g;
|
|
1778
|
-
return E(this, function(d) {
|
|
1779
|
-
switch (d.label) {
|
|
1780
|
-
case 0:
|
|
1781
|
-
return [
|
|
1782
|
-
4,
|
|
1783
|
-
this.loadFeatureFlags()
|
|
1784
|
-
];
|
|
1785
|
-
case 1:
|
|
1786
|
-
return d.sent(), g = void 0, this.loadedSuccessfullyOnce ? (typeof e == "boolean" ? g = (o = (i = (n = (t = this.featureFlagsByKey) === null || t === void 0 ? void 0 : t[r]) === null || n === void 0 ? void 0 : n.filters) === null || i === void 0 ? void 0 : i.payloads) === null || o === void 0 ? void 0 : o[e.toString()] : typeof e == "string" && (g = (h = (c = (l = (u = this.featureFlagsByKey) === null || u === void 0 ? void 0 : u[r]) === null || l === void 0 ? void 0 : l.filters) === null || c === void 0 ? void 0 : c.payloads) === null || h === void 0 ? void 0 : h[e]), g === void 0 ? [
|
|
1787
|
-
2,
|
|
1788
|
-
null
|
|
1789
|
-
] : [
|
|
1790
|
-
2,
|
|
1791
|
-
g
|
|
1792
|
-
]) : [
|
|
1793
|
-
2,
|
|
1794
|
-
void 0
|
|
1795
|
-
];
|
|
1796
|
-
}
|
|
1797
|
-
});
|
|
1798
|
-
});
|
|
1799
|
-
}, s.prototype.getAllFlagsAndPayloads = function(r, e, t, n) {
|
|
1800
|
-
return e === void 0 && (e = {}), t === void 0 && (t = {}), n === void 0 && (n = {}), A(this, void 0, void 0, function() {
|
|
1801
|
-
var i, o, u, l = this;
|
|
1802
|
-
return E(this, function(c) {
|
|
1803
|
-
switch (c.label) {
|
|
1804
|
-
case 0:
|
|
1805
|
-
return [
|
|
1806
|
-
4,
|
|
1807
|
-
this.loadFeatureFlags()
|
|
1808
|
-
];
|
|
1809
|
-
case 1:
|
|
1810
|
-
return c.sent(), i = {}, o = {}, u = this.featureFlags.length == 0, this.featureFlags.map(function(h) {
|
|
1811
|
-
return A(l, void 0, void 0, function() {
|
|
1812
|
-
var g, d, f, a;
|
|
1813
|
-
return E(this, function(v) {
|
|
1814
|
-
switch (v.label) {
|
|
1815
|
-
case 0:
|
|
1816
|
-
return v.trys.push([0, 2, , 3]), g = this.computeFlagLocally(h, r, e, t, n), i[h.key] = g, [
|
|
1817
|
-
4,
|
|
1818
|
-
this.computeFeatureFlagPayloadLocally(h.key, g)
|
|
1819
|
-
];
|
|
1820
|
-
case 1:
|
|
1821
|
-
return d = v.sent(), d && (o[h.key] = d), [
|
|
1822
|
-
3,
|
|
1823
|
-
3
|
|
1824
|
-
];
|
|
1825
|
-
case 2:
|
|
1826
|
-
return f = v.sent(), f instanceof C || f instanceof Error && ((a = this.onError) === null || a === void 0 || a.call(this, new Error("Error computing flag locally: ".concat(h.key, ": ").concat(f)))), u = !0, [
|
|
1827
|
-
3,
|
|
1828
|
-
3
|
|
1829
|
-
];
|
|
1830
|
-
case 3:
|
|
1831
|
-
return [
|
|
1832
|
-
2
|
|
1833
|
-
/*return*/
|
|
1834
|
-
];
|
|
1835
|
-
}
|
|
1836
|
-
});
|
|
1837
|
-
});
|
|
1838
|
-
}), [
|
|
1839
|
-
2,
|
|
1840
|
-
{
|
|
1841
|
-
response: i,
|
|
1842
|
-
payloads: o,
|
|
1843
|
-
fallbackToDecide: u
|
|
1844
|
-
}
|
|
1845
|
-
];
|
|
1846
|
-
}
|
|
1847
|
-
});
|
|
1848
|
-
});
|
|
1849
|
-
}, s.prototype.computeFlagLocally = function(r, e, t, n, i) {
|
|
1850
|
-
if (t === void 0 && (t = {}), n === void 0 && (n = {}), i === void 0 && (i = {}), r.ensure_experience_continuity)
|
|
1851
|
-
throw new C("Flag has experience continuity enabled");
|
|
1852
|
-
if (!r.active)
|
|
1853
|
-
return !1;
|
|
1854
|
-
var o = r.filters || {}, u = o.aggregation_group_type_index;
|
|
1855
|
-
if (u != null) {
|
|
1856
|
-
var l = this.groupTypeMapping[String(u)];
|
|
1857
|
-
if (!l)
|
|
1858
|
-
throw this.debugMode && console.warn("[FEATURE FLAGS] Unknown group type index ".concat(u, " for feature flag ").concat(r.key)), new C("Flag has unknown group type index");
|
|
1859
|
-
if (!(l in t))
|
|
1860
|
-
return this.debugMode && console.warn("[FEATURE FLAGS] Can't compute group feature flag: ".concat(r.key, " without group names passed in")), !1;
|
|
1861
|
-
var c = i[l];
|
|
1862
|
-
return this.matchFeatureFlagProperties(r, t[l], c);
|
|
1863
|
-
} else
|
|
1864
|
-
return this.matchFeatureFlagProperties(r, e, n);
|
|
1865
|
-
}, s.prototype.matchFeatureFlagProperties = function(r, e, t) {
|
|
1866
|
-
for (var n, i = r.filters || {}, o = i.groups || [], u = !1, l = void 0, c = ee([], o).sort(function(p, w) {
|
|
1867
|
-
var y = !!p.variant, m = !!w.variant;
|
|
1868
|
-
return y && m ? 0 : y ? -1 : m ? 1 : 0;
|
|
1869
|
-
}), h = function(p) {
|
|
1870
|
-
try {
|
|
1871
|
-
if (g.isConditionMatch(r, e, p, t)) {
|
|
1872
|
-
var w = p.variant, y = ((n = i.multivariate) === null || n === void 0 ? void 0 : n.variants) || [];
|
|
1873
|
-
return w && y.some(function(m) {
|
|
1874
|
-
return m.key === w;
|
|
1875
|
-
}) ? l = w : l = g.getMatchingVariant(r, e) || !0, "break";
|
|
1876
|
-
}
|
|
1877
|
-
} catch (m) {
|
|
1878
|
-
if (m instanceof C)
|
|
1879
|
-
u = !0;
|
|
1880
|
-
else
|
|
1881
|
-
throw m;
|
|
1882
|
-
}
|
|
1883
|
-
}, g = this, d = 0, f = c; d < f.length; d++) {
|
|
1884
|
-
var a = f[d], v = h(a);
|
|
1885
|
-
if (v === "break") break;
|
|
1886
|
-
}
|
|
1887
|
-
if (l !== void 0)
|
|
1888
|
-
return l;
|
|
1889
|
-
if (u)
|
|
1890
|
-
throw new C("Can't determine if feature flag is enabled or not with given properties");
|
|
1891
|
-
return !1;
|
|
1892
|
-
}, s.prototype.isConditionMatch = function(r, e, t, n) {
|
|
1893
|
-
var i = t.rollout_percentage;
|
|
1894
|
-
if ((t.properties || []).length > 0) {
|
|
1895
|
-
for (var o = 0, u = t.properties; o < u.length; o++) {
|
|
1896
|
-
var l = u[o], c = l.type, h = !1;
|
|
1897
|
-
if (c === "cohort" ? h = oe(l, n, this.cohorts) : h = ne(l, n), !h)
|
|
1898
|
-
return !1;
|
|
1899
|
-
}
|
|
1900
|
-
if (i == null)
|
|
1901
|
-
return !0;
|
|
1902
|
-
}
|
|
1903
|
-
return !(i != null && Q(r.key, e) > i / 100);
|
|
1904
|
-
}, s.prototype.getMatchingVariant = function(r, e) {
|
|
1905
|
-
var t = Q(r.key, e, "variant"), n = this.variantLookupTable(r).find(function(i) {
|
|
1906
|
-
return t >= i.valueMin && t < i.valueMax;
|
|
1907
|
-
});
|
|
1908
|
-
if (n)
|
|
1909
|
-
return n.key;
|
|
1910
|
-
}, s.prototype.variantLookupTable = function(r) {
|
|
1911
|
-
var e, t = [], n = 0, i = 0, o = r.filters || {}, u = ((e = o.multivariate) === null || e === void 0 ? void 0 : e.variants) || [];
|
|
1912
|
-
return u.forEach(function(l) {
|
|
1913
|
-
i = n + l.rollout_percentage / 100, t.push({
|
|
1914
|
-
valueMin: n,
|
|
1915
|
-
valueMax: i,
|
|
1916
|
-
key: l.key
|
|
1917
|
-
}), n = i;
|
|
1918
|
-
}), t;
|
|
1919
|
-
}, s.prototype.loadFeatureFlags = function(r) {
|
|
1920
|
-
return r === void 0 && (r = !1), A(this, void 0, void 0, function() {
|
|
1921
|
-
return E(this, function(e) {
|
|
1922
|
-
switch (e.label) {
|
|
1923
|
-
case 0:
|
|
1924
|
-
return !this.loadedSuccessfullyOnce || r ? [
|
|
1925
|
-
4,
|
|
1926
|
-
this._loadFeatureFlags()
|
|
1927
|
-
] : [
|
|
1928
|
-
3,
|
|
1929
|
-
2
|
|
1930
|
-
];
|
|
1931
|
-
case 1:
|
|
1932
|
-
e.sent(), e.label = 2;
|
|
1933
|
-
case 2:
|
|
1934
|
-
return [
|
|
1935
|
-
2
|
|
1936
|
-
/*return*/
|
|
1937
|
-
];
|
|
1938
|
-
}
|
|
1939
|
-
});
|
|
1940
|
-
});
|
|
1941
|
-
}, s.prototype._loadFeatureFlags = function() {
|
|
1942
|
-
var r, e;
|
|
1943
|
-
return A(this, void 0, void 0, function() {
|
|
1944
|
-
var t, n, i, o = this;
|
|
1945
|
-
return E(this, function(u) {
|
|
1946
|
-
switch (u.label) {
|
|
1947
|
-
case 0:
|
|
1948
|
-
this.poller && (clearTimeout(this.poller), this.poller = void 0), this.poller = setTimeout(function() {
|
|
1949
|
-
return o._loadFeatureFlags();
|
|
1950
|
-
}, this.pollingInterval), u.label = 1;
|
|
1951
|
-
case 1:
|
|
1952
|
-
return u.trys.push([1, 4, , 5]), [
|
|
1953
|
-
4,
|
|
1954
|
-
this._requestFeatureFlagDefinitions()
|
|
1955
|
-
];
|
|
1956
|
-
case 2:
|
|
1957
|
-
if (t = u.sent(), t && t.status === 401)
|
|
1958
|
-
throw new V("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");
|
|
1959
|
-
return t && t.status !== 200 ? [
|
|
1960
|
-
2
|
|
1961
|
-
/*return*/
|
|
1962
|
-
] : [
|
|
1963
|
-
4,
|
|
1964
|
-
t.json()
|
|
1965
|
-
];
|
|
1966
|
-
case 3:
|
|
1967
|
-
return n = u.sent(), "flags" in n || (r = this.onError) === null || r === void 0 || r.call(this, new Error("Invalid response when getting feature flags: ".concat(JSON.stringify(n)))), this.featureFlags = n.flags || [], this.featureFlagsByKey = this.featureFlags.reduce(function(l, c) {
|
|
1968
|
-
return l[c.key] = c, l;
|
|
1969
|
-
}, {}), this.groupTypeMapping = n.group_type_mapping || {}, this.cohorts = n.cohorts || [], this.loadedSuccessfullyOnce = !0, [
|
|
1970
|
-
3,
|
|
1971
|
-
5
|
|
1972
|
-
];
|
|
1973
|
-
case 4:
|
|
1974
|
-
return i = u.sent(), i instanceof V && ((e = this.onError) === null || e === void 0 || e.call(this, i)), [
|
|
1975
|
-
3,
|
|
1976
|
-
5
|
|
1977
|
-
];
|
|
1978
|
-
case 5:
|
|
1979
|
-
return [
|
|
1980
|
-
2
|
|
1981
|
-
/*return*/
|
|
1982
|
-
];
|
|
1983
|
-
}
|
|
1984
|
-
});
|
|
1985
|
-
});
|
|
1986
|
-
}, s.prototype._requestFeatureFlagDefinitions = function() {
|
|
1987
|
-
return A(this, void 0, void 0, function() {
|
|
1988
|
-
var r, e, t, n;
|
|
1989
|
-
return E(this, function(i) {
|
|
1990
|
-
switch (i.label) {
|
|
1991
|
-
case 0:
|
|
1992
|
-
r = "".concat(this.host, "/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey, "&send_cohorts"), e = {
|
|
1993
|
-
method: "GET",
|
|
1994
|
-
headers: {
|
|
1995
|
-
"Content-Type": "application/json",
|
|
1996
|
-
Authorization: "Bearer ".concat(this.personalApiKey),
|
|
1997
|
-
"user-agent": "posthog-node/".concat(z)
|
|
1998
|
-
}
|
|
1999
|
-
}, t = null, this.timeout && typeof this.timeout == "number" && (n = new AbortController(), t = te(function() {
|
|
2000
|
-
n.abort();
|
|
2001
|
-
}, this.timeout), e.signal = n.signal), i.label = 1;
|
|
2002
|
-
case 1:
|
|
2003
|
-
return i.trys.push([1, , 3, 4]), [
|
|
2004
|
-
4,
|
|
2005
|
-
this.fetch(r, e)
|
|
2006
|
-
];
|
|
2007
|
-
case 2:
|
|
2008
|
-
return [
|
|
2009
|
-
2,
|
|
2010
|
-
i.sent()
|
|
2011
|
-
];
|
|
2012
|
-
case 3:
|
|
2013
|
-
return clearTimeout(t), [
|
|
2014
|
-
7
|
|
2015
|
-
/*endfinally*/
|
|
2016
|
-
];
|
|
2017
|
-
case 4:
|
|
2018
|
-
return [
|
|
2019
|
-
2
|
|
2020
|
-
/*return*/
|
|
2021
|
-
];
|
|
2022
|
-
}
|
|
2023
|
-
});
|
|
2024
|
-
});
|
|
2025
|
-
}, s.prototype.stopPoller = function() {
|
|
2026
|
-
clearTimeout(this.poller);
|
|
2027
|
-
}, s;
|
|
2028
|
-
}()
|
|
2029
|
-
);
|
|
2030
|
-
function Q(s, r, e) {
|
|
2031
|
-
e === void 0 && (e = "");
|
|
2032
|
-
var t = fe.createHash();
|
|
2033
|
-
return t.update("".concat(s, ".").concat(r).concat(e)), parseInt(t.digest("hex").slice(0, 15), 16) / Ee;
|
|
2034
|
-
}
|
|
2035
|
-
function ne(s, r) {
|
|
2036
|
-
var e = s.key, t = s.value, n = s.operator || "exact";
|
|
2037
|
-
if (e in r) {
|
|
2038
|
-
if (n === "is_not_set")
|
|
2039
|
-
throw new C("Operator is_not_set is not supported");
|
|
2040
|
-
} else throw new C("Property ".concat(e, " not found in propertyValues"));
|
|
2041
|
-
var i = r[e];
|
|
2042
|
-
function o(g, d) {
|
|
2043
|
-
return Array.isArray(g) ? g.map(function(f) {
|
|
2044
|
-
return String(f).toLowerCase();
|
|
2045
|
-
}).includes(String(d).toLowerCase()) : String(g).toLowerCase() === String(d).toLowerCase();
|
|
2046
|
-
}
|
|
2047
|
-
function u(g, d, f) {
|
|
2048
|
-
if (f === "gt")
|
|
2049
|
-
return g > d;
|
|
2050
|
-
if (f === "gte")
|
|
2051
|
-
return g >= d;
|
|
2052
|
-
if (f === "lt")
|
|
2053
|
-
return g < d;
|
|
2054
|
-
if (f === "lte")
|
|
2055
|
-
return g <= d;
|
|
2056
|
-
throw new Error("Invalid operator: ".concat(f));
|
|
2057
|
-
}
|
|
2058
|
-
switch (n) {
|
|
2059
|
-
case "exact":
|
|
2060
|
-
return o(t, i);
|
|
2061
|
-
case "is_not":
|
|
2062
|
-
return !o(t, i);
|
|
2063
|
-
case "is_set":
|
|
2064
|
-
return e in r;
|
|
2065
|
-
case "icontains":
|
|
2066
|
-
return String(i).toLowerCase().includes(String(t).toLowerCase());
|
|
2067
|
-
case "not_icontains":
|
|
2068
|
-
return !String(i).toLowerCase().includes(String(t).toLowerCase());
|
|
2069
|
-
case "regex":
|
|
2070
|
-
return Y(String(t)) && String(i).match(String(t)) !== null;
|
|
2071
|
-
case "not_regex":
|
|
2072
|
-
return Y(String(t)) && String(i).match(String(t)) === null;
|
|
2073
|
-
case "gt":
|
|
2074
|
-
case "gte":
|
|
2075
|
-
case "lt":
|
|
2076
|
-
case "lte": {
|
|
2077
|
-
var l = typeof t == "number" ? t : null;
|
|
2078
|
-
if (typeof t == "string")
|
|
2079
|
-
try {
|
|
2080
|
-
l = parseFloat(t);
|
|
2081
|
-
} catch {
|
|
2082
|
-
}
|
|
2083
|
-
return l != null && i != null ? typeof i == "string" ? u(i, String(t), n) : u(i, l, n) : u(String(i), String(t), n);
|
|
2084
|
-
}
|
|
2085
|
-
case "is_date_after":
|
|
2086
|
-
case "is_date_before": {
|
|
2087
|
-
var c = Ce(String(t));
|
|
2088
|
-
if (c == null && (c = X(t)), c == null)
|
|
2089
|
-
throw new C("Invalid date: ".concat(t));
|
|
2090
|
-
var h = X(i);
|
|
2091
|
-
return ["is_date_before"].includes(n) ? h < c : h > c;
|
|
2092
|
-
}
|
|
2093
|
-
default:
|
|
2094
|
-
throw new C("Unknown operator: ".concat(n));
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
function oe(s, r, e) {
|
|
2098
|
-
var t = String(s.value);
|
|
2099
|
-
if (!(t in e))
|
|
2100
|
-
throw new C("can't match cohort without a given cohort property value");
|
|
2101
|
-
var n = e[t];
|
|
2102
|
-
return se(n, r, e);
|
|
2103
|
-
}
|
|
2104
|
-
function se(s, r, e) {
|
|
2105
|
-
if (!s)
|
|
2106
|
-
return !0;
|
|
2107
|
-
var t = s.type, n = s.values;
|
|
2108
|
-
if (!n || n.length === 0)
|
|
2109
|
-
return !0;
|
|
2110
|
-
var i = !1;
|
|
2111
|
-
if ("values" in n[0]) {
|
|
2112
|
-
for (var o = 0, u = n; o < u.length; o++) {
|
|
2113
|
-
var l = u[o];
|
|
2114
|
-
try {
|
|
2115
|
-
var c = se(l, r, e);
|
|
2116
|
-
if (t === "AND") {
|
|
2117
|
-
if (!c)
|
|
2118
|
-
return !1;
|
|
2119
|
-
} else if (c)
|
|
2120
|
-
return !0;
|
|
2121
|
-
} catch (f) {
|
|
2122
|
-
if (f instanceof C)
|
|
2123
|
-
console.debug("Failed to compute property ".concat(l, " locally: ").concat(f)), i = !0;
|
|
2124
|
-
else
|
|
2125
|
-
throw f;
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
if (i)
|
|
2129
|
-
throw new C("Can't match cohort without a given cohort property value");
|
|
2130
|
-
return t === "AND";
|
|
2131
|
-
} else {
|
|
2132
|
-
for (var h = 0, g = n; h < g.length; h++) {
|
|
2133
|
-
var l = g[h];
|
|
2134
|
-
try {
|
|
2135
|
-
var c = void 0;
|
|
2136
|
-
l.type === "cohort" ? c = oe(l, r, e) : c = ne(l, r);
|
|
2137
|
-
var d = l.negation || !1;
|
|
2138
|
-
if (t === "AND") {
|
|
2139
|
-
if (!c && !d || c && d)
|
|
2140
|
-
return !1;
|
|
2141
|
-
} else if (c && !d || !c && d)
|
|
2142
|
-
return !0;
|
|
2143
|
-
} catch (a) {
|
|
2144
|
-
if (a instanceof C)
|
|
2145
|
-
console.debug("Failed to compute property ".concat(l, " locally: ").concat(a)), i = !0;
|
|
2146
|
-
else
|
|
2147
|
-
throw a;
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
if (i)
|
|
2151
|
-
throw new C("can't match cohort without a given cohort property value");
|
|
2152
|
-
return t === "AND";
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
function Y(s) {
|
|
2156
|
-
try {
|
|
2157
|
-
return new RegExp(s), !0;
|
|
2158
|
-
} catch {
|
|
2159
|
-
return !1;
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
function X(s) {
|
|
2163
|
-
if (s instanceof Date)
|
|
2164
|
-
return s;
|
|
2165
|
-
if (typeof s == "string" || typeof s == "number") {
|
|
2166
|
-
var r = new Date(s);
|
|
2167
|
-
if (!isNaN(r.valueOf()))
|
|
2168
|
-
return r;
|
|
2169
|
-
throw new C("".concat(s, " is in an invalid date format"));
|
|
2170
|
-
} else
|
|
2171
|
-
throw new C("The date provided ".concat(s, " must be a string, number, or date object"));
|
|
2172
|
-
}
|
|
2173
|
-
function Ce(s) {
|
|
2174
|
-
var r = /^-?(?<number>[0-9]+)(?<interval>[a-z])$/, e = s.match(r), t = new Date((/* @__PURE__ */ new Date()).toISOString());
|
|
2175
|
-
if (e) {
|
|
2176
|
-
if (!e.groups)
|
|
2177
|
-
return null;
|
|
2178
|
-
var n = parseInt(e.groups.number);
|
|
2179
|
-
if (n >= 1e4)
|
|
2180
|
-
return null;
|
|
2181
|
-
var i = e.groups.interval;
|
|
2182
|
-
if (i == "h")
|
|
2183
|
-
t.setUTCHours(t.getUTCHours() - n);
|
|
2184
|
-
else if (i == "d")
|
|
2185
|
-
t.setUTCDate(t.getUTCDate() - n);
|
|
2186
|
-
else if (i == "w")
|
|
2187
|
-
t.setUTCDate(t.getUTCDate() - n * 7);
|
|
2188
|
-
else if (i == "m")
|
|
2189
|
-
t.setUTCMonth(t.getUTCMonth() - n);
|
|
2190
|
-
else if (i == "y")
|
|
2191
|
-
t.setUTCFullYear(t.getUTCFullYear() - n);
|
|
2192
|
-
else
|
|
2193
|
-
return null;
|
|
2194
|
-
return t;
|
|
2195
|
-
} else
|
|
2196
|
-
return null;
|
|
2197
|
-
}
|
|
2198
|
-
var Ie = 30 * 1e3, ke = 50 * 1e3, Le = (
|
|
2199
|
-
/** @class */
|
|
2200
|
-
function(s) {
|
|
2201
|
-
x(r, s);
|
|
2202
|
-
function r(e, t) {
|
|
2203
|
-
t === void 0 && (t = {});
|
|
2204
|
-
var n = this, i;
|
|
2205
|
-
return t.captureMode = (t == null ? void 0 : t.captureMode) || "json", n = s.call(this, e, t) || this, n._memoryStorage = new Se(), n.options = t, t.personalApiKey && (n.featureFlagsPoller = new Oe({
|
|
2206
|
-
pollingInterval: typeof t.featureFlagsPollingInterval == "number" ? t.featureFlagsPollingInterval : Ie,
|
|
2207
|
-
personalApiKey: t.personalApiKey,
|
|
2208
|
-
projectApiKey: e,
|
|
2209
|
-
timeout: (i = t.requestTimeout) !== null && i !== void 0 ? i : 1e4,
|
|
2210
|
-
host: n.host,
|
|
2211
|
-
fetch: t.fetch,
|
|
2212
|
-
onError: function(o) {
|
|
2213
|
-
n._events.emit("error", o);
|
|
2214
|
-
}
|
|
2215
|
-
})), n.distinctIdHasSentFlagCalls = {}, n.maxCacheSize = t.maxCacheSize || ke, n;
|
|
2216
|
-
}
|
|
2217
|
-
return r.prototype.getPersistedProperty = function(e) {
|
|
2218
|
-
return this._memoryStorage.getProperty(e);
|
|
2219
|
-
}, r.prototype.setPersistedProperty = function(e, t) {
|
|
2220
|
-
return this._memoryStorage.setProperty(e, t);
|
|
2221
|
-
}, r.prototype.fetch = function(e, t) {
|
|
2222
|
-
return this.options.fetch ? this.options.fetch(e, t) : ie(e, t);
|
|
2223
|
-
}, r.prototype.getLibraryId = function() {
|
|
2224
|
-
return "posthog-node";
|
|
2225
|
-
}, r.prototype.getLibraryVersion = function() {
|
|
2226
|
-
return z;
|
|
2227
|
-
}, r.prototype.getCustomUserAgent = function() {
|
|
2228
|
-
return "posthog-node/".concat(z);
|
|
2229
|
-
}, r.prototype.enable = function() {
|
|
2230
|
-
return s.prototype.optIn.call(this);
|
|
2231
|
-
}, r.prototype.disable = function() {
|
|
2232
|
-
return s.prototype.optOut.call(this);
|
|
2233
|
-
}, r.prototype.debug = function(e) {
|
|
2234
|
-
var t;
|
|
2235
|
-
e === void 0 && (e = !0), s.prototype.debug.call(this, e), (t = this.featureFlagsPoller) === null || t === void 0 || t.debug(e);
|
|
2236
|
-
}, r.prototype.capture = function(e) {
|
|
2237
|
-
var t = this, n = e.distinctId, i = e.event, o = e.properties, u = e.groups, l = e.sendFeatureFlags, c = e.timestamp, h = e.disableGeoip, g = e.uuid, d = function(a) {
|
|
2238
|
-
s.prototype.captureStateless.call(t, n, i, a, {
|
|
2239
|
-
timestamp: c,
|
|
2240
|
-
disableGeoip: h,
|
|
2241
|
-
uuid: g
|
|
2242
|
-
});
|
|
2243
|
-
}, f = Promise.resolve().then(function() {
|
|
2244
|
-
return A(t, void 0, void 0, function() {
|
|
2245
|
-
var a, v, p, w, y, m, b, P;
|
|
2246
|
-
return E(this, function(S) {
|
|
2247
|
-
switch (S.label) {
|
|
2248
|
-
case 0:
|
|
2249
|
-
return l ? [
|
|
2250
|
-
4,
|
|
2251
|
-
s.prototype.getFeatureFlagsStateless.call(this, n, u, void 0, void 0, h)
|
|
2252
|
-
] : [
|
|
2253
|
-
3,
|
|
2254
|
-
2
|
|
2255
|
-
];
|
|
2256
|
-
case 1:
|
|
2257
|
-
return [
|
|
2258
|
-
2,
|
|
2259
|
-
S.sent()
|
|
2260
|
-
];
|
|
2261
|
-
case 2:
|
|
2262
|
-
if (!((((P = (b = this.featureFlagsPoller) === null || b === void 0 ? void 0 : b.featureFlags) === null || P === void 0 ? void 0 : P.length) || 0) > 0)) return [
|
|
2263
|
-
3,
|
|
2264
|
-
4
|
|
2265
|
-
];
|
|
2266
|
-
for (a = {}, v = 0, p = Object.entries(u || {}); v < p.length; v++)
|
|
2267
|
-
w = p[v], y = w[0], m = w[1], a[y] = String(m);
|
|
2268
|
-
return [
|
|
2269
|
-
4,
|
|
2270
|
-
this.getAllFlags(n, {
|
|
2271
|
-
groups: a,
|
|
2272
|
-
disableGeoip: h,
|
|
2273
|
-
onlyEvaluateLocally: !0
|
|
2274
|
-
})
|
|
2275
|
-
];
|
|
2276
|
-
case 3:
|
|
2277
|
-
return [
|
|
2278
|
-
2,
|
|
2279
|
-
S.sent()
|
|
2280
|
-
];
|
|
2281
|
-
case 4:
|
|
2282
|
-
return [
|
|
2283
|
-
2,
|
|
2284
|
-
{}
|
|
2285
|
-
];
|
|
2286
|
-
}
|
|
2287
|
-
});
|
|
2288
|
-
});
|
|
2289
|
-
}).then(function(a) {
|
|
2290
|
-
var v = {};
|
|
2291
|
-
if (a)
|
|
2292
|
-
for (var p = 0, w = Object.entries(a); p < w.length; p++) {
|
|
2293
|
-
var y = w[p], m = y[0], b = y[1];
|
|
2294
|
-
v["$feature/".concat(m)] = b;
|
|
2295
|
-
}
|
|
2296
|
-
var P = Object.keys(a || {}).filter(function(S) {
|
|
2297
|
-
return (a == null ? void 0 : a[S]) !== !1;
|
|
2298
|
-
});
|
|
2299
|
-
return P.length > 0 && (v.$active_feature_flags = P), v;
|
|
2300
|
-
}).catch(function() {
|
|
2301
|
-
return {};
|
|
2302
|
-
}).then(function(a) {
|
|
2303
|
-
d(F(F(F({}, a), o), {
|
|
2304
|
-
$groups: u
|
|
2305
|
-
}));
|
|
2306
|
-
});
|
|
2307
|
-
this.addPendingPromise(f);
|
|
2308
|
-
}, r.prototype.identify = function(e) {
|
|
2309
|
-
var t = e.distinctId, n = e.properties, i = e.disableGeoip, o = (n == null ? void 0 : n.$set) || n;
|
|
2310
|
-
s.prototype.identifyStateless.call(this, t, {
|
|
2311
|
-
$set: o
|
|
2312
|
-
}, {
|
|
2313
|
-
disableGeoip: i
|
|
2314
|
-
});
|
|
2315
|
-
}, r.prototype.alias = function(e) {
|
|
2316
|
-
s.prototype.aliasStateless.call(this, e.alias, e.distinctId, void 0, {
|
|
2317
|
-
disableGeoip: e.disableGeoip
|
|
2318
|
-
});
|
|
2319
|
-
}, r.prototype.getFeatureFlag = function(e, t, n) {
|
|
2320
|
-
var i;
|
|
2321
|
-
return A(this, void 0, void 0, function() {
|
|
2322
|
-
var o, u, l, c, h, g, d, f, a, v, p, w, y;
|
|
2323
|
-
return E(this, function(m) {
|
|
2324
|
-
switch (m.label) {
|
|
2325
|
-
case 0:
|
|
2326
|
-
return o = n || {}, u = o.groups, l = o.disableGeoip, c = n || {}, h = c.onlyEvaluateLocally, g = c.sendFeatureFlagEvents, d = c.personProperties, f = c.groupProperties, a = this.addLocalPersonAndGroupProperties(t, u, d, f), d = a.allPersonProperties, f = a.allGroupProperties, h == null && (h = !1), g == null && (g = !0), [
|
|
2327
|
-
4,
|
|
2328
|
-
(i = this.featureFlagsPoller) === null || i === void 0 ? void 0 : i.getFeatureFlag(e, t, u, d, f)
|
|
2329
|
-
];
|
|
2330
|
-
case 1:
|
|
2331
|
-
return v = m.sent(), p = v !== void 0, !p && !h ? [
|
|
2332
|
-
4,
|
|
2333
|
-
s.prototype.getFeatureFlagStateless.call(this, e, t, u, d, f, l)
|
|
2334
|
-
] : [
|
|
2335
|
-
3,
|
|
2336
|
-
3
|
|
2337
|
-
];
|
|
2338
|
-
case 2:
|
|
2339
|
-
v = m.sent(), m.label = 3;
|
|
2340
|
-
case 3:
|
|
2341
|
-
return w = "".concat(e, "_").concat(v), g && (!(t in this.distinctIdHasSentFlagCalls) || !this.distinctIdHasSentFlagCalls[t].includes(w)) && (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize && (this.distinctIdHasSentFlagCalls = {}), Array.isArray(this.distinctIdHasSentFlagCalls[t]) ? this.distinctIdHasSentFlagCalls[t].push(w) : this.distinctIdHasSentFlagCalls[t] = [w], this.capture({
|
|
2342
|
-
distinctId: t,
|
|
2343
|
-
event: "$feature_flag_called",
|
|
2344
|
-
properties: (y = {
|
|
2345
|
-
$feature_flag: e,
|
|
2346
|
-
$feature_flag_response: v,
|
|
2347
|
-
locally_evaluated: p
|
|
2348
|
-
}, y["$feature/".concat(e)] = v, y),
|
|
2349
|
-
groups: u,
|
|
2350
|
-
disableGeoip: l
|
|
2351
|
-
})), [
|
|
2352
|
-
2,
|
|
2353
|
-
v
|
|
2354
|
-
];
|
|
2355
|
-
}
|
|
2356
|
-
});
|
|
2357
|
-
});
|
|
2358
|
-
}, r.prototype.getFeatureFlagPayload = function(e, t, n, i) {
|
|
2359
|
-
var o;
|
|
2360
|
-
return A(this, void 0, void 0, function() {
|
|
2361
|
-
var u, l, c, h, g, d, f, a, v, p;
|
|
2362
|
-
return E(this, function(w) {
|
|
2363
|
-
switch (w.label) {
|
|
2364
|
-
case 0:
|
|
2365
|
-
return u = i || {}, l = u.groups, c = u.disableGeoip, h = i || {}, g = h.onlyEvaluateLocally, h.sendFeatureFlagEvents, d = h.personProperties, f = h.groupProperties, a = this.addLocalPersonAndGroupProperties(t, l, d, f), d = a.allPersonProperties, f = a.allGroupProperties, v = void 0, n ? [
|
|
2366
|
-
3,
|
|
2367
|
-
2
|
|
2368
|
-
] : [
|
|
2369
|
-
4,
|
|
2370
|
-
this.getFeatureFlag(e, t, F(F({}, i), {
|
|
2371
|
-
onlyEvaluateLocally: !0
|
|
2372
|
-
}))
|
|
2373
|
-
];
|
|
2374
|
-
case 1:
|
|
2375
|
-
n = w.sent(), w.label = 2;
|
|
2376
|
-
case 2:
|
|
2377
|
-
return n ? [
|
|
2378
|
-
4,
|
|
2379
|
-
(o = this.featureFlagsPoller) === null || o === void 0 ? void 0 : o.computeFeatureFlagPayloadLocally(e, n)
|
|
2380
|
-
] : [
|
|
2381
|
-
3,
|
|
2382
|
-
4
|
|
2383
|
-
];
|
|
2384
|
-
case 3:
|
|
2385
|
-
v = w.sent(), w.label = 4;
|
|
2386
|
-
case 4:
|
|
2387
|
-
return g == null && (g = !1), g == null && (g = !1), p = v !== void 0, !p && !g ? [
|
|
2388
|
-
4,
|
|
2389
|
-
s.prototype.getFeatureFlagPayloadStateless.call(this, e, t, l, d, f, c)
|
|
2390
|
-
] : [
|
|
2391
|
-
3,
|
|
2392
|
-
6
|
|
2393
|
-
];
|
|
2394
|
-
case 5:
|
|
2395
|
-
v = w.sent(), w.label = 6;
|
|
2396
|
-
case 6:
|
|
2397
|
-
try {
|
|
2398
|
-
return [
|
|
2399
|
-
2,
|
|
2400
|
-
JSON.parse(v)
|
|
2401
|
-
];
|
|
2402
|
-
} catch {
|
|
2403
|
-
return [
|
|
2404
|
-
2,
|
|
2405
|
-
v
|
|
2406
|
-
];
|
|
2407
|
-
}
|
|
2408
|
-
return [
|
|
2409
|
-
2
|
|
2410
|
-
/*return*/
|
|
2411
|
-
];
|
|
2412
|
-
}
|
|
2413
|
-
});
|
|
2414
|
-
});
|
|
2415
|
-
}, r.prototype.isFeatureEnabled = function(e, t, n) {
|
|
2416
|
-
return A(this, void 0, void 0, function() {
|
|
2417
|
-
var i;
|
|
2418
|
-
return E(this, function(o) {
|
|
2419
|
-
switch (o.label) {
|
|
2420
|
-
case 0:
|
|
2421
|
-
return [
|
|
2422
|
-
4,
|
|
2423
|
-
this.getFeatureFlag(e, t, n)
|
|
2424
|
-
];
|
|
2425
|
-
case 1:
|
|
2426
|
-
return i = o.sent(), i === void 0 ? [
|
|
2427
|
-
2,
|
|
2428
|
-
void 0
|
|
2429
|
-
] : [
|
|
2430
|
-
2,
|
|
2431
|
-
!!i || !1
|
|
2432
|
-
];
|
|
2433
|
-
}
|
|
2434
|
-
});
|
|
2435
|
-
});
|
|
2436
|
-
}, r.prototype.getAllFlags = function(e, t) {
|
|
2437
|
-
return A(this, void 0, void 0, function() {
|
|
2438
|
-
var n;
|
|
2439
|
-
return E(this, function(i) {
|
|
2440
|
-
switch (i.label) {
|
|
2441
|
-
case 0:
|
|
2442
|
-
return [
|
|
2443
|
-
4,
|
|
2444
|
-
this.getAllFlagsAndPayloads(e, t)
|
|
2445
|
-
];
|
|
2446
|
-
case 1:
|
|
2447
|
-
return n = i.sent(), [
|
|
2448
|
-
2,
|
|
2449
|
-
n.featureFlags
|
|
2450
|
-
];
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
});
|
|
2454
|
-
}, r.prototype.getAllFlagsAndPayloads = function(e, t) {
|
|
2455
|
-
var n;
|
|
2456
|
-
return A(this, void 0, void 0, function() {
|
|
2457
|
-
var i, o, u, l, c, h, g, d, f, a, v, p, w;
|
|
2458
|
-
return E(this, function(y) {
|
|
2459
|
-
switch (y.label) {
|
|
2460
|
-
case 0:
|
|
2461
|
-
return i = t || {}, o = i.groups, u = i.disableGeoip, l = t || {}, c = l.onlyEvaluateLocally, h = l.personProperties, g = l.groupProperties, d = this.addLocalPersonAndGroupProperties(e, o, h, g), h = d.allPersonProperties, g = d.allGroupProperties, c == null && (c = !1), [
|
|
2462
|
-
4,
|
|
2463
|
-
(n = this.featureFlagsPoller) === null || n === void 0 ? void 0 : n.getAllFlagsAndPayloads(e, o, h, g)
|
|
2464
|
-
];
|
|
2465
|
-
case 1:
|
|
2466
|
-
return f = y.sent(), a = {}, v = {}, p = !0, f && (a = f.response, v = f.payloads, p = f.fallbackToDecide), p && !c ? [
|
|
2467
|
-
4,
|
|
2468
|
-
s.prototype.getFeatureFlagsAndPayloadsStateless.call(this, e, o, h, g, u)
|
|
2469
|
-
] : [
|
|
2470
|
-
3,
|
|
2471
|
-
3
|
|
2472
|
-
];
|
|
2473
|
-
case 2:
|
|
2474
|
-
w = y.sent(), a = F(F({}, a), w.flags || {}), v = F(F({}, v), w.payloads || {}), y.label = 3;
|
|
2475
|
-
case 3:
|
|
2476
|
-
return [
|
|
2477
|
-
2,
|
|
2478
|
-
{
|
|
2479
|
-
featureFlags: a,
|
|
2480
|
-
featureFlagPayloads: v
|
|
2481
|
-
}
|
|
2482
|
-
];
|
|
2483
|
-
}
|
|
2484
|
-
});
|
|
2485
|
-
});
|
|
2486
|
-
}, r.prototype.groupIdentify = function(e) {
|
|
2487
|
-
var t = e.groupType, n = e.groupKey, i = e.properties, o = e.distinctId, u = e.disableGeoip;
|
|
2488
|
-
s.prototype.groupIdentifyStateless.call(this, t, n, i, {
|
|
2489
|
-
disableGeoip: u
|
|
2490
|
-
}, o);
|
|
2491
|
-
}, r.prototype.reloadFeatureFlags = function() {
|
|
2492
|
-
var e;
|
|
2493
|
-
return A(this, void 0, void 0, function() {
|
|
2494
|
-
return E(this, function(t) {
|
|
2495
|
-
switch (t.label) {
|
|
2496
|
-
case 0:
|
|
2497
|
-
return [
|
|
2498
|
-
4,
|
|
2499
|
-
(e = this.featureFlagsPoller) === null || e === void 0 ? void 0 : e.loadFeatureFlags(!0)
|
|
2500
|
-
];
|
|
2501
|
-
case 1:
|
|
2502
|
-
return t.sent(), [
|
|
2503
|
-
2
|
|
2504
|
-
/*return*/
|
|
2505
|
-
];
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2508
|
-
});
|
|
2509
|
-
}, r.prototype.shutdown = function() {
|
|
2510
|
-
this.shutdownAsync();
|
|
2511
|
-
}, r.prototype.shutdownAsync = function() {
|
|
2512
|
-
var e;
|
|
2513
|
-
return A(this, void 0, void 0, function() {
|
|
2514
|
-
return E(this, function(t) {
|
|
2515
|
-
return (e = this.featureFlagsPoller) === null || e === void 0 || e.stopPoller(), [
|
|
2516
|
-
2,
|
|
2517
|
-
s.prototype.shutdownAsync.call(this)
|
|
2518
|
-
];
|
|
2519
|
-
});
|
|
2520
|
-
});
|
|
2521
|
-
}, r.prototype.addLocalPersonAndGroupProperties = function(e, t, n, i) {
|
|
2522
|
-
var o = F({
|
|
2523
|
-
distinct_id: e
|
|
2524
|
-
}, n || {}), u = {};
|
|
2525
|
-
if (t)
|
|
2526
|
-
for (var l = 0, c = Object.keys(t); l < c.length; l++) {
|
|
2527
|
-
var h = c[l];
|
|
2528
|
-
u[h] = F({
|
|
2529
|
-
$group_key: t[h]
|
|
2530
|
-
}, (i == null ? void 0 : i[h]) || {});
|
|
2531
|
-
}
|
|
2532
|
-
return {
|
|
2533
|
-
allPersonProperties: o,
|
|
2534
|
-
allGroupProperties: u
|
|
2535
|
-
};
|
|
2536
|
-
}, r;
|
|
2537
|
-
}(re)
|
|
2538
|
-
);
|
|
2539
|
-
class Re extends Z {
|
|
2540
|
-
constructor(e) {
|
|
2541
|
-
super({ debug: e.debug, enabled: e.enabled });
|
|
2542
|
-
L(this, "name", "PostHog-Server");
|
|
2543
|
-
L(this, "client");
|
|
2544
|
-
L(this, "initialized", !1);
|
|
2545
|
-
L(this, "config");
|
|
2546
|
-
this.config = e;
|
|
2547
|
-
}
|
|
2548
|
-
initialize() {
|
|
2549
|
-
if (this.isEnabled() && !this.initialized) {
|
|
2550
|
-
if (!this.config.apiKey || typeof this.config.apiKey != "string")
|
|
2551
|
-
throw new Error("PostHog requires an apiKey");
|
|
2552
|
-
try {
|
|
2553
|
-
this.client = new Le(this.config.apiKey, {
|
|
2554
|
-
host: this.config.host || "https://app.posthog.com",
|
|
2555
|
-
flushAt: 20,
|
|
2556
|
-
flushInterval: 1e4
|
|
2557
|
-
}), this.initialized = !0, this.log("Initialized successfully", this.config);
|
|
2558
|
-
} catch (e) {
|
|
2559
|
-
throw console.error("[PostHog-Server] Failed to initialize:", e), e;
|
|
2560
|
-
}
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
identify(e, t) {
|
|
2564
|
-
!this.isEnabled() || !this.initialized || !this.client || (this.client.identify({
|
|
2565
|
-
distinctId: e,
|
|
2566
|
-
properties: t
|
|
2567
|
-
}), this.log("Identified user", { userId: e, traits: t }));
|
|
2568
|
-
}
|
|
2569
|
-
track(e, t) {
|
|
2570
|
-
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
2571
|
-
const n = {
|
|
2572
|
-
...e.properties,
|
|
2573
|
-
category: e.category,
|
|
2574
|
-
timestamp: e.timestamp ? new Date(e.timestamp) : /* @__PURE__ */ new Date(),
|
|
2575
|
-
...e.sessionId && { sessionId: e.sessionId },
|
|
2576
|
-
...(t == null ? void 0 : t.page) && {
|
|
2577
|
-
$current_url: t.page.path,
|
|
2578
|
-
$page_title: t.page.title,
|
|
2579
|
-
$referrer: t.page.referrer
|
|
2580
|
-
},
|
|
2581
|
-
...(t == null ? void 0 : t.device) && { device: t.device },
|
|
2582
|
-
...(t == null ? void 0 : t.utm) && { utm: t.utm }
|
|
2583
|
-
};
|
|
2584
|
-
this.client.capture({
|
|
2585
|
-
distinctId: e.userId || "anonymous",
|
|
2586
|
-
event: e.action,
|
|
2587
|
-
properties: n
|
|
2588
|
-
}), this.log("Tracked event", { event: e, context: t });
|
|
2589
|
-
}
|
|
2590
|
-
page(e, t) {
|
|
2591
|
-
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
2592
|
-
const n = {
|
|
2593
|
-
...e,
|
|
2594
|
-
...(t == null ? void 0 : t.page) && {
|
|
2595
|
-
path: t.page.path,
|
|
2596
|
-
title: t.page.title,
|
|
2597
|
-
referrer: t.page.referrer
|
|
2598
|
-
}
|
|
2599
|
-
};
|
|
2600
|
-
this.client.capture({
|
|
2601
|
-
distinctId: "anonymous",
|
|
2602
|
-
event: "$pageview",
|
|
2603
|
-
properties: n
|
|
2604
|
-
}), this.log("Tracked page view", { properties: e, context: t });
|
|
2605
|
-
}
|
|
2606
|
-
async reset() {
|
|
2607
|
-
!this.isEnabled() || !this.initialized || !this.client || (await this.client.flush(), this.log("Flushed pending events"));
|
|
2608
|
-
}
|
|
2609
|
-
async shutdown() {
|
|
2610
|
-
this.client && (await this.client.shutdown(), this.log("Shutdown complete"));
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
1
|
+
import { B as e, P as s, a } from "./server-BKqARaUf.js";
|
|
2613
2
|
export {
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
3
|
+
e as BaseAnalyticsProvider,
|
|
4
|
+
s as PostHogClientProvider,
|
|
5
|
+
a as PostHogServerProvider
|
|
2617
6
|
};
|