autotel-subscribers 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +669 -0
- package/dist/amplitude.cjs +2486 -0
- package/dist/amplitude.cjs.map +1 -0
- package/dist/amplitude.d.cts +49 -0
- package/dist/amplitude.d.ts +49 -0
- package/dist/amplitude.js +2463 -0
- package/dist/amplitude.js.map +1 -0
- package/dist/event-subscriber-base-CnF3V56W.d.cts +182 -0
- package/dist/event-subscriber-base-CnF3V56W.d.ts +182 -0
- package/dist/factories.cjs +16660 -0
- package/dist/factories.cjs.map +1 -0
- package/dist/factories.d.cts +304 -0
- package/dist/factories.d.ts +304 -0
- package/dist/factories.js +16624 -0
- package/dist/factories.js.map +1 -0
- package/dist/index.cjs +16575 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +179 -0
- package/dist/index.d.ts +179 -0
- package/dist/index.js +16539 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.cjs +220 -0
- package/dist/middleware.cjs.map +1 -0
- package/dist/middleware.d.cts +227 -0
- package/dist/middleware.d.ts +227 -0
- package/dist/middleware.js +208 -0
- package/dist/middleware.js.map +1 -0
- package/dist/mixpanel.cjs +2940 -0
- package/dist/mixpanel.cjs.map +1 -0
- package/dist/mixpanel.d.cts +47 -0
- package/dist/mixpanel.d.ts +47 -0
- package/dist/mixpanel.js +2932 -0
- package/dist/mixpanel.js.map +1 -0
- package/dist/posthog.cjs +4115 -0
- package/dist/posthog.cjs.map +1 -0
- package/dist/posthog.d.cts +299 -0
- package/dist/posthog.d.ts +299 -0
- package/dist/posthog.js +4113 -0
- package/dist/posthog.js.map +1 -0
- package/dist/segment.cjs +6822 -0
- package/dist/segment.cjs.map +1 -0
- package/dist/segment.d.cts +49 -0
- package/dist/segment.d.ts +49 -0
- package/dist/segment.js +6794 -0
- package/dist/segment.js.map +1 -0
- package/dist/slack.cjs +368 -0
- package/dist/slack.cjs.map +1 -0
- package/dist/slack.d.cts +126 -0
- package/dist/slack.d.ts +126 -0
- package/dist/slack.js +366 -0
- package/dist/slack.js.map +1 -0
- package/dist/webhook.cjs +100 -0
- package/dist/webhook.cjs.map +1 -0
- package/dist/webhook.d.cts +53 -0
- package/dist/webhook.d.ts +53 -0
- package/dist/webhook.js +98 -0
- package/dist/webhook.js.map +1 -0
- package/examples/quickstart-custom-subscriber.ts +144 -0
- package/examples/subscriber-bigquery.ts +219 -0
- package/examples/subscriber-databricks.ts +280 -0
- package/examples/subscriber-kafka.ts +326 -0
- package/examples/subscriber-kinesis.ts +307 -0
- package/examples/subscriber-posthog.ts +421 -0
- package/examples/subscriber-pubsub.ts +336 -0
- package/examples/subscriber-snowflake.ts +232 -0
- package/package.json +141 -0
- package/src/amplitude.test.ts +231 -0
- package/src/amplitude.ts +148 -0
- package/src/event-subscriber-base.ts +325 -0
- package/src/factories.ts +197 -0
- package/src/index.ts +50 -0
- package/src/middleware.ts +489 -0
- package/src/mixpanel.test.ts +194 -0
- package/src/mixpanel.ts +134 -0
- package/src/mock-event-subscriber.ts +333 -0
- package/src/posthog.test.ts +629 -0
- package/src/posthog.ts +530 -0
- package/src/segment.test.ts +228 -0
- package/src/segment.ts +148 -0
- package/src/slack.ts +383 -0
- package/src/streaming-event-subscriber.ts +323 -0
- package/src/testing/index.ts +37 -0
- package/src/testing/mock-webhook-server.ts +242 -0
- package/src/testing/subscriber-test-harness.ts +365 -0
- package/src/webhook.test.ts +264 -0
- package/src/webhook.ts +158 -0
package/dist/mixpanel.js
ADDED
|
@@ -0,0 +1,2932 @@
|
|
|
1
|
+
import process2 from 'process';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import tty from 'tty';
|
|
4
|
+
|
|
5
|
+
var __create = Object.create;
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
+
}) : x)(function(x) {
|
|
14
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
});
|
|
17
|
+
var __esm = (fn, res) => function __init() {
|
|
18
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
19
|
+
};
|
|
20
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
21
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
|
+
};
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
36
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
41
|
+
mod
|
|
42
|
+
));
|
|
43
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
|
+
|
|
45
|
+
// ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
46
|
+
var require_ms = __commonJS({
|
|
47
|
+
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports$1, module) {
|
|
48
|
+
var s = 1e3;
|
|
49
|
+
var m = s * 60;
|
|
50
|
+
var h = m * 60;
|
|
51
|
+
var d = h * 24;
|
|
52
|
+
var w = d * 7;
|
|
53
|
+
var y = d * 365.25;
|
|
54
|
+
module.exports = function(val, options) {
|
|
55
|
+
options = options || {};
|
|
56
|
+
var type = typeof val;
|
|
57
|
+
if (type === "string" && val.length > 0) {
|
|
58
|
+
return parse(val);
|
|
59
|
+
} else if (type === "number" && isFinite(val)) {
|
|
60
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
61
|
+
}
|
|
62
|
+
throw new Error(
|
|
63
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
function parse(str) {
|
|
67
|
+
str = String(str);
|
|
68
|
+
if (str.length > 100) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
72
|
+
str
|
|
73
|
+
);
|
|
74
|
+
if (!match) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
var n = parseFloat(match[1]);
|
|
78
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
79
|
+
switch (type) {
|
|
80
|
+
case "years":
|
|
81
|
+
case "year":
|
|
82
|
+
case "yrs":
|
|
83
|
+
case "yr":
|
|
84
|
+
case "y":
|
|
85
|
+
return n * y;
|
|
86
|
+
case "weeks":
|
|
87
|
+
case "week":
|
|
88
|
+
case "w":
|
|
89
|
+
return n * w;
|
|
90
|
+
case "days":
|
|
91
|
+
case "day":
|
|
92
|
+
case "d":
|
|
93
|
+
return n * d;
|
|
94
|
+
case "hours":
|
|
95
|
+
case "hour":
|
|
96
|
+
case "hrs":
|
|
97
|
+
case "hr":
|
|
98
|
+
case "h":
|
|
99
|
+
return n * h;
|
|
100
|
+
case "minutes":
|
|
101
|
+
case "minute":
|
|
102
|
+
case "mins":
|
|
103
|
+
case "min":
|
|
104
|
+
case "m":
|
|
105
|
+
return n * m;
|
|
106
|
+
case "seconds":
|
|
107
|
+
case "second":
|
|
108
|
+
case "secs":
|
|
109
|
+
case "sec":
|
|
110
|
+
case "s":
|
|
111
|
+
return n * s;
|
|
112
|
+
case "milliseconds":
|
|
113
|
+
case "millisecond":
|
|
114
|
+
case "msecs":
|
|
115
|
+
case "msec":
|
|
116
|
+
case "ms":
|
|
117
|
+
return n;
|
|
118
|
+
default:
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function fmtShort(ms) {
|
|
123
|
+
var msAbs = Math.abs(ms);
|
|
124
|
+
if (msAbs >= d) {
|
|
125
|
+
return Math.round(ms / d) + "d";
|
|
126
|
+
}
|
|
127
|
+
if (msAbs >= h) {
|
|
128
|
+
return Math.round(ms / h) + "h";
|
|
129
|
+
}
|
|
130
|
+
if (msAbs >= m) {
|
|
131
|
+
return Math.round(ms / m) + "m";
|
|
132
|
+
}
|
|
133
|
+
if (msAbs >= s) {
|
|
134
|
+
return Math.round(ms / s) + "s";
|
|
135
|
+
}
|
|
136
|
+
return ms + "ms";
|
|
137
|
+
}
|
|
138
|
+
function fmtLong(ms) {
|
|
139
|
+
var msAbs = Math.abs(ms);
|
|
140
|
+
if (msAbs >= d) {
|
|
141
|
+
return plural(ms, msAbs, d, "day");
|
|
142
|
+
}
|
|
143
|
+
if (msAbs >= h) {
|
|
144
|
+
return plural(ms, msAbs, h, "hour");
|
|
145
|
+
}
|
|
146
|
+
if (msAbs >= m) {
|
|
147
|
+
return plural(ms, msAbs, m, "minute");
|
|
148
|
+
}
|
|
149
|
+
if (msAbs >= s) {
|
|
150
|
+
return plural(ms, msAbs, s, "second");
|
|
151
|
+
}
|
|
152
|
+
return ms + " ms";
|
|
153
|
+
}
|
|
154
|
+
function plural(ms, msAbs, n, name) {
|
|
155
|
+
var isPlural = msAbs >= n * 1.5;
|
|
156
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// ../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/common.js
|
|
162
|
+
var require_common = __commonJS({
|
|
163
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/common.js"(exports$1, module) {
|
|
164
|
+
function setup(env2) {
|
|
165
|
+
createDebug.debug = createDebug;
|
|
166
|
+
createDebug.default = createDebug;
|
|
167
|
+
createDebug.coerce = coerce;
|
|
168
|
+
createDebug.disable = disable;
|
|
169
|
+
createDebug.enable = enable;
|
|
170
|
+
createDebug.enabled = enabled;
|
|
171
|
+
createDebug.humanize = require_ms();
|
|
172
|
+
createDebug.destroy = destroy;
|
|
173
|
+
Object.keys(env2).forEach((key) => {
|
|
174
|
+
createDebug[key] = env2[key];
|
|
175
|
+
});
|
|
176
|
+
createDebug.names = [];
|
|
177
|
+
createDebug.skips = [];
|
|
178
|
+
createDebug.formatters = {};
|
|
179
|
+
function selectColor(namespace) {
|
|
180
|
+
let hash = 0;
|
|
181
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
182
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
183
|
+
hash |= 0;
|
|
184
|
+
}
|
|
185
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
186
|
+
}
|
|
187
|
+
createDebug.selectColor = selectColor;
|
|
188
|
+
function createDebug(namespace) {
|
|
189
|
+
let prevTime;
|
|
190
|
+
let enableOverride = null;
|
|
191
|
+
let namespacesCache;
|
|
192
|
+
let enabledCache;
|
|
193
|
+
function debug(...args) {
|
|
194
|
+
if (!debug.enabled) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const self = debug;
|
|
198
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
199
|
+
const ms = curr - (prevTime || curr);
|
|
200
|
+
self.diff = ms;
|
|
201
|
+
self.prev = prevTime;
|
|
202
|
+
self.curr = curr;
|
|
203
|
+
prevTime = curr;
|
|
204
|
+
args[0] = createDebug.coerce(args[0]);
|
|
205
|
+
if (typeof args[0] !== "string") {
|
|
206
|
+
args.unshift("%O");
|
|
207
|
+
}
|
|
208
|
+
let index = 0;
|
|
209
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
210
|
+
if (match === "%%") {
|
|
211
|
+
return "%";
|
|
212
|
+
}
|
|
213
|
+
index++;
|
|
214
|
+
const formatter = createDebug.formatters[format];
|
|
215
|
+
if (typeof formatter === "function") {
|
|
216
|
+
const val = args[index];
|
|
217
|
+
match = formatter.call(self, val);
|
|
218
|
+
args.splice(index, 1);
|
|
219
|
+
index--;
|
|
220
|
+
}
|
|
221
|
+
return match;
|
|
222
|
+
});
|
|
223
|
+
createDebug.formatArgs.call(self, args);
|
|
224
|
+
const logFn = self.log || createDebug.log;
|
|
225
|
+
logFn.apply(self, args);
|
|
226
|
+
}
|
|
227
|
+
debug.namespace = namespace;
|
|
228
|
+
debug.useColors = createDebug.useColors();
|
|
229
|
+
debug.color = createDebug.selectColor(namespace);
|
|
230
|
+
debug.extend = extend;
|
|
231
|
+
debug.destroy = createDebug.destroy;
|
|
232
|
+
Object.defineProperty(debug, "enabled", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
configurable: false,
|
|
235
|
+
get: () => {
|
|
236
|
+
if (enableOverride !== null) {
|
|
237
|
+
return enableOverride;
|
|
238
|
+
}
|
|
239
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
240
|
+
namespacesCache = createDebug.namespaces;
|
|
241
|
+
enabledCache = createDebug.enabled(namespace);
|
|
242
|
+
}
|
|
243
|
+
return enabledCache;
|
|
244
|
+
},
|
|
245
|
+
set: (v) => {
|
|
246
|
+
enableOverride = v;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
if (typeof createDebug.init === "function") {
|
|
250
|
+
createDebug.init(debug);
|
|
251
|
+
}
|
|
252
|
+
return debug;
|
|
253
|
+
}
|
|
254
|
+
function extend(namespace, delimiter) {
|
|
255
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
256
|
+
newDebug.log = this.log;
|
|
257
|
+
return newDebug;
|
|
258
|
+
}
|
|
259
|
+
function enable(namespaces) {
|
|
260
|
+
createDebug.save(namespaces);
|
|
261
|
+
createDebug.namespaces = namespaces;
|
|
262
|
+
createDebug.names = [];
|
|
263
|
+
createDebug.skips = [];
|
|
264
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
265
|
+
for (const ns of split) {
|
|
266
|
+
if (ns[0] === "-") {
|
|
267
|
+
createDebug.skips.push(ns.slice(1));
|
|
268
|
+
} else {
|
|
269
|
+
createDebug.names.push(ns);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function matchesTemplate(search, template) {
|
|
274
|
+
let searchIndex = 0;
|
|
275
|
+
let templateIndex = 0;
|
|
276
|
+
let starIndex = -1;
|
|
277
|
+
let matchIndex = 0;
|
|
278
|
+
while (searchIndex < search.length) {
|
|
279
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
280
|
+
if (template[templateIndex] === "*") {
|
|
281
|
+
starIndex = templateIndex;
|
|
282
|
+
matchIndex = searchIndex;
|
|
283
|
+
templateIndex++;
|
|
284
|
+
} else {
|
|
285
|
+
searchIndex++;
|
|
286
|
+
templateIndex++;
|
|
287
|
+
}
|
|
288
|
+
} else if (starIndex !== -1) {
|
|
289
|
+
templateIndex = starIndex + 1;
|
|
290
|
+
matchIndex++;
|
|
291
|
+
searchIndex = matchIndex;
|
|
292
|
+
} else {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
297
|
+
templateIndex++;
|
|
298
|
+
}
|
|
299
|
+
return templateIndex === template.length;
|
|
300
|
+
}
|
|
301
|
+
function disable() {
|
|
302
|
+
const namespaces = [
|
|
303
|
+
...createDebug.names,
|
|
304
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
305
|
+
].join(",");
|
|
306
|
+
createDebug.enable("");
|
|
307
|
+
return namespaces;
|
|
308
|
+
}
|
|
309
|
+
function enabled(name) {
|
|
310
|
+
for (const skip of createDebug.skips) {
|
|
311
|
+
if (matchesTemplate(name, skip)) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
for (const ns of createDebug.names) {
|
|
316
|
+
if (matchesTemplate(name, ns)) {
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
function coerce(val) {
|
|
323
|
+
if (val instanceof Error) {
|
|
324
|
+
return val.stack || val.message;
|
|
325
|
+
}
|
|
326
|
+
return val;
|
|
327
|
+
}
|
|
328
|
+
function destroy() {
|
|
329
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
330
|
+
}
|
|
331
|
+
createDebug.enable(createDebug.load());
|
|
332
|
+
return createDebug;
|
|
333
|
+
}
|
|
334
|
+
module.exports = setup;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
// ../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/browser.js
|
|
339
|
+
var require_browser = __commonJS({
|
|
340
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/browser.js"(exports$1, module) {
|
|
341
|
+
exports$1.formatArgs = formatArgs;
|
|
342
|
+
exports$1.save = save;
|
|
343
|
+
exports$1.load = load;
|
|
344
|
+
exports$1.useColors = useColors;
|
|
345
|
+
exports$1.storage = localstorage();
|
|
346
|
+
exports$1.destroy = /* @__PURE__ */ (() => {
|
|
347
|
+
let warned = false;
|
|
348
|
+
return () => {
|
|
349
|
+
if (!warned) {
|
|
350
|
+
warned = true;
|
|
351
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
})();
|
|
355
|
+
exports$1.colors = [
|
|
356
|
+
"#0000CC",
|
|
357
|
+
"#0000FF",
|
|
358
|
+
"#0033CC",
|
|
359
|
+
"#0033FF",
|
|
360
|
+
"#0066CC",
|
|
361
|
+
"#0066FF",
|
|
362
|
+
"#0099CC",
|
|
363
|
+
"#0099FF",
|
|
364
|
+
"#00CC00",
|
|
365
|
+
"#00CC33",
|
|
366
|
+
"#00CC66",
|
|
367
|
+
"#00CC99",
|
|
368
|
+
"#00CCCC",
|
|
369
|
+
"#00CCFF",
|
|
370
|
+
"#3300CC",
|
|
371
|
+
"#3300FF",
|
|
372
|
+
"#3333CC",
|
|
373
|
+
"#3333FF",
|
|
374
|
+
"#3366CC",
|
|
375
|
+
"#3366FF",
|
|
376
|
+
"#3399CC",
|
|
377
|
+
"#3399FF",
|
|
378
|
+
"#33CC00",
|
|
379
|
+
"#33CC33",
|
|
380
|
+
"#33CC66",
|
|
381
|
+
"#33CC99",
|
|
382
|
+
"#33CCCC",
|
|
383
|
+
"#33CCFF",
|
|
384
|
+
"#6600CC",
|
|
385
|
+
"#6600FF",
|
|
386
|
+
"#6633CC",
|
|
387
|
+
"#6633FF",
|
|
388
|
+
"#66CC00",
|
|
389
|
+
"#66CC33",
|
|
390
|
+
"#9900CC",
|
|
391
|
+
"#9900FF",
|
|
392
|
+
"#9933CC",
|
|
393
|
+
"#9933FF",
|
|
394
|
+
"#99CC00",
|
|
395
|
+
"#99CC33",
|
|
396
|
+
"#CC0000",
|
|
397
|
+
"#CC0033",
|
|
398
|
+
"#CC0066",
|
|
399
|
+
"#CC0099",
|
|
400
|
+
"#CC00CC",
|
|
401
|
+
"#CC00FF",
|
|
402
|
+
"#CC3300",
|
|
403
|
+
"#CC3333",
|
|
404
|
+
"#CC3366",
|
|
405
|
+
"#CC3399",
|
|
406
|
+
"#CC33CC",
|
|
407
|
+
"#CC33FF",
|
|
408
|
+
"#CC6600",
|
|
409
|
+
"#CC6633",
|
|
410
|
+
"#CC9900",
|
|
411
|
+
"#CC9933",
|
|
412
|
+
"#CCCC00",
|
|
413
|
+
"#CCCC33",
|
|
414
|
+
"#FF0000",
|
|
415
|
+
"#FF0033",
|
|
416
|
+
"#FF0066",
|
|
417
|
+
"#FF0099",
|
|
418
|
+
"#FF00CC",
|
|
419
|
+
"#FF00FF",
|
|
420
|
+
"#FF3300",
|
|
421
|
+
"#FF3333",
|
|
422
|
+
"#FF3366",
|
|
423
|
+
"#FF3399",
|
|
424
|
+
"#FF33CC",
|
|
425
|
+
"#FF33FF",
|
|
426
|
+
"#FF6600",
|
|
427
|
+
"#FF6633",
|
|
428
|
+
"#FF9900",
|
|
429
|
+
"#FF9933",
|
|
430
|
+
"#FFCC00",
|
|
431
|
+
"#FFCC33"
|
|
432
|
+
];
|
|
433
|
+
function useColors() {
|
|
434
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
let m;
|
|
441
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
442
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
443
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
444
|
+
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
445
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
446
|
+
}
|
|
447
|
+
function formatArgs(args) {
|
|
448
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
449
|
+
if (!this.useColors) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const c = "color: " + this.color;
|
|
453
|
+
args.splice(1, 0, c, "color: inherit");
|
|
454
|
+
let index = 0;
|
|
455
|
+
let lastC = 0;
|
|
456
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
457
|
+
if (match === "%%") {
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
index++;
|
|
461
|
+
if (match === "%c") {
|
|
462
|
+
lastC = index;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
args.splice(lastC, 0, c);
|
|
466
|
+
}
|
|
467
|
+
exports$1.log = console.debug || console.log || (() => {
|
|
468
|
+
});
|
|
469
|
+
function save(namespaces) {
|
|
470
|
+
try {
|
|
471
|
+
if (namespaces) {
|
|
472
|
+
exports$1.storage.setItem("debug", namespaces);
|
|
473
|
+
} else {
|
|
474
|
+
exports$1.storage.removeItem("debug");
|
|
475
|
+
}
|
|
476
|
+
} catch (error) {
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function load() {
|
|
480
|
+
let r;
|
|
481
|
+
try {
|
|
482
|
+
r = exports$1.storage.getItem("debug") || exports$1.storage.getItem("DEBUG");
|
|
483
|
+
} catch (error) {
|
|
484
|
+
}
|
|
485
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
486
|
+
r = process.env.DEBUG;
|
|
487
|
+
}
|
|
488
|
+
return r;
|
|
489
|
+
}
|
|
490
|
+
function localstorage() {
|
|
491
|
+
try {
|
|
492
|
+
return localStorage;
|
|
493
|
+
} catch (error) {
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
module.exports = require_common()(exports$1);
|
|
497
|
+
var { formatters } = module.exports;
|
|
498
|
+
formatters.j = function(v) {
|
|
499
|
+
try {
|
|
500
|
+
return JSON.stringify(v);
|
|
501
|
+
} catch (error) {
|
|
502
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
// ../../node_modules/.pnpm/supports-color@10.2.2/node_modules/supports-color/index.js
|
|
509
|
+
var supports_color_exports = {};
|
|
510
|
+
__export(supports_color_exports, {
|
|
511
|
+
createSupportsColor: () => createSupportsColor,
|
|
512
|
+
default: () => supports_color_default
|
|
513
|
+
});
|
|
514
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
|
|
515
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
516
|
+
const position = argv.indexOf(prefix + flag);
|
|
517
|
+
const terminatorPosition = argv.indexOf("--");
|
|
518
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
519
|
+
}
|
|
520
|
+
function envForceColor() {
|
|
521
|
+
if (!("FORCE_COLOR" in env)) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (env.FORCE_COLOR === "true") {
|
|
525
|
+
return 1;
|
|
526
|
+
}
|
|
527
|
+
if (env.FORCE_COLOR === "false") {
|
|
528
|
+
return 0;
|
|
529
|
+
}
|
|
530
|
+
if (env.FORCE_COLOR.length === 0) {
|
|
531
|
+
return 1;
|
|
532
|
+
}
|
|
533
|
+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
534
|
+
if (![0, 1, 2, 3].includes(level)) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
return level;
|
|
538
|
+
}
|
|
539
|
+
function translateLevel(level) {
|
|
540
|
+
if (level === 0) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
level,
|
|
545
|
+
hasBasic: true,
|
|
546
|
+
has256: level >= 2,
|
|
547
|
+
has16m: level >= 3
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
551
|
+
const noFlagForceColor = envForceColor();
|
|
552
|
+
if (noFlagForceColor !== void 0) {
|
|
553
|
+
flagForceColor = noFlagForceColor;
|
|
554
|
+
}
|
|
555
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
556
|
+
if (forceColor === 0) {
|
|
557
|
+
return 0;
|
|
558
|
+
}
|
|
559
|
+
if (sniffFlags) {
|
|
560
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
561
|
+
return 3;
|
|
562
|
+
}
|
|
563
|
+
if (hasFlag("color=256")) {
|
|
564
|
+
return 2;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
568
|
+
return 1;
|
|
569
|
+
}
|
|
570
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
571
|
+
return 0;
|
|
572
|
+
}
|
|
573
|
+
const min = forceColor || 0;
|
|
574
|
+
if (env.TERM === "dumb") {
|
|
575
|
+
return min;
|
|
576
|
+
}
|
|
577
|
+
if (process2.platform === "win32") {
|
|
578
|
+
const osRelease = os.release().split(".");
|
|
579
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
580
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
581
|
+
}
|
|
582
|
+
return 1;
|
|
583
|
+
}
|
|
584
|
+
if ("CI" in env) {
|
|
585
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
586
|
+
return 3;
|
|
587
|
+
}
|
|
588
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
589
|
+
return 1;
|
|
590
|
+
}
|
|
591
|
+
return min;
|
|
592
|
+
}
|
|
593
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
594
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
595
|
+
}
|
|
596
|
+
if (env.COLORTERM === "truecolor") {
|
|
597
|
+
return 3;
|
|
598
|
+
}
|
|
599
|
+
if (env.TERM === "xterm-kitty") {
|
|
600
|
+
return 3;
|
|
601
|
+
}
|
|
602
|
+
if (env.TERM === "xterm-ghostty") {
|
|
603
|
+
return 3;
|
|
604
|
+
}
|
|
605
|
+
if (env.TERM === "wezterm") {
|
|
606
|
+
return 3;
|
|
607
|
+
}
|
|
608
|
+
if ("TERM_PROGRAM" in env) {
|
|
609
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
610
|
+
switch (env.TERM_PROGRAM) {
|
|
611
|
+
case "iTerm.app": {
|
|
612
|
+
return version >= 3 ? 3 : 2;
|
|
613
|
+
}
|
|
614
|
+
case "Apple_Terminal": {
|
|
615
|
+
return 2;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
620
|
+
return 2;
|
|
621
|
+
}
|
|
622
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
623
|
+
return 1;
|
|
624
|
+
}
|
|
625
|
+
if ("COLORTERM" in env) {
|
|
626
|
+
return 1;
|
|
627
|
+
}
|
|
628
|
+
return min;
|
|
629
|
+
}
|
|
630
|
+
function createSupportsColor(stream, options = {}) {
|
|
631
|
+
const level = _supportsColor(stream, {
|
|
632
|
+
streamIsTTY: stream && stream.isTTY,
|
|
633
|
+
...options
|
|
634
|
+
});
|
|
635
|
+
return translateLevel(level);
|
|
636
|
+
}
|
|
637
|
+
var env, flagForceColor, supportsColor, supports_color_default;
|
|
638
|
+
var init_supports_color = __esm({
|
|
639
|
+
"../../node_modules/.pnpm/supports-color@10.2.2/node_modules/supports-color/index.js"() {
|
|
640
|
+
({ env } = process2);
|
|
641
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
642
|
+
flagForceColor = 0;
|
|
643
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
644
|
+
flagForceColor = 1;
|
|
645
|
+
}
|
|
646
|
+
supportsColor = {
|
|
647
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
648
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
649
|
+
};
|
|
650
|
+
supports_color_default = supportsColor;
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
// ../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/node.js
|
|
655
|
+
var require_node = __commonJS({
|
|
656
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/node.js"(exports$1, module) {
|
|
657
|
+
var tty2 = __require("tty");
|
|
658
|
+
var util = __require("util");
|
|
659
|
+
exports$1.init = init;
|
|
660
|
+
exports$1.log = log;
|
|
661
|
+
exports$1.formatArgs = formatArgs;
|
|
662
|
+
exports$1.save = save;
|
|
663
|
+
exports$1.load = load;
|
|
664
|
+
exports$1.useColors = useColors;
|
|
665
|
+
exports$1.destroy = util.deprecate(
|
|
666
|
+
() => {
|
|
667
|
+
},
|
|
668
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
669
|
+
);
|
|
670
|
+
exports$1.colors = [6, 2, 3, 4, 5, 1];
|
|
671
|
+
try {
|
|
672
|
+
const supportsColor2 = (init_supports_color(), __toCommonJS(supports_color_exports));
|
|
673
|
+
if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
|
|
674
|
+
exports$1.colors = [
|
|
675
|
+
20,
|
|
676
|
+
21,
|
|
677
|
+
26,
|
|
678
|
+
27,
|
|
679
|
+
32,
|
|
680
|
+
33,
|
|
681
|
+
38,
|
|
682
|
+
39,
|
|
683
|
+
40,
|
|
684
|
+
41,
|
|
685
|
+
42,
|
|
686
|
+
43,
|
|
687
|
+
44,
|
|
688
|
+
45,
|
|
689
|
+
56,
|
|
690
|
+
57,
|
|
691
|
+
62,
|
|
692
|
+
63,
|
|
693
|
+
68,
|
|
694
|
+
69,
|
|
695
|
+
74,
|
|
696
|
+
75,
|
|
697
|
+
76,
|
|
698
|
+
77,
|
|
699
|
+
78,
|
|
700
|
+
79,
|
|
701
|
+
80,
|
|
702
|
+
81,
|
|
703
|
+
92,
|
|
704
|
+
93,
|
|
705
|
+
98,
|
|
706
|
+
99,
|
|
707
|
+
112,
|
|
708
|
+
113,
|
|
709
|
+
128,
|
|
710
|
+
129,
|
|
711
|
+
134,
|
|
712
|
+
135,
|
|
713
|
+
148,
|
|
714
|
+
149,
|
|
715
|
+
160,
|
|
716
|
+
161,
|
|
717
|
+
162,
|
|
718
|
+
163,
|
|
719
|
+
164,
|
|
720
|
+
165,
|
|
721
|
+
166,
|
|
722
|
+
167,
|
|
723
|
+
168,
|
|
724
|
+
169,
|
|
725
|
+
170,
|
|
726
|
+
171,
|
|
727
|
+
172,
|
|
728
|
+
173,
|
|
729
|
+
178,
|
|
730
|
+
179,
|
|
731
|
+
184,
|
|
732
|
+
185,
|
|
733
|
+
196,
|
|
734
|
+
197,
|
|
735
|
+
198,
|
|
736
|
+
199,
|
|
737
|
+
200,
|
|
738
|
+
201,
|
|
739
|
+
202,
|
|
740
|
+
203,
|
|
741
|
+
204,
|
|
742
|
+
205,
|
|
743
|
+
206,
|
|
744
|
+
207,
|
|
745
|
+
208,
|
|
746
|
+
209,
|
|
747
|
+
214,
|
|
748
|
+
215,
|
|
749
|
+
220,
|
|
750
|
+
221
|
|
751
|
+
];
|
|
752
|
+
}
|
|
753
|
+
} catch (error) {
|
|
754
|
+
}
|
|
755
|
+
exports$1.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
756
|
+
return /^debug_/i.test(key);
|
|
757
|
+
}).reduce((obj, key) => {
|
|
758
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
759
|
+
return k.toUpperCase();
|
|
760
|
+
});
|
|
761
|
+
let val = process.env[key];
|
|
762
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
763
|
+
val = true;
|
|
764
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
765
|
+
val = false;
|
|
766
|
+
} else if (val === "null") {
|
|
767
|
+
val = null;
|
|
768
|
+
} else {
|
|
769
|
+
val = Number(val);
|
|
770
|
+
}
|
|
771
|
+
obj[prop] = val;
|
|
772
|
+
return obj;
|
|
773
|
+
}, {});
|
|
774
|
+
function useColors() {
|
|
775
|
+
return "colors" in exports$1.inspectOpts ? Boolean(exports$1.inspectOpts.colors) : tty2.isatty(process.stderr.fd);
|
|
776
|
+
}
|
|
777
|
+
function formatArgs(args) {
|
|
778
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
779
|
+
if (useColors2) {
|
|
780
|
+
const c = this.color;
|
|
781
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
782
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
783
|
+
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
784
|
+
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
785
|
+
} else {
|
|
786
|
+
args[0] = getDate() + name + " " + args[0];
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
function getDate() {
|
|
790
|
+
if (exports$1.inspectOpts.hideDate) {
|
|
791
|
+
return "";
|
|
792
|
+
}
|
|
793
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
794
|
+
}
|
|
795
|
+
function log(...args) {
|
|
796
|
+
return process.stderr.write(util.formatWithOptions(exports$1.inspectOpts, ...args) + "\n");
|
|
797
|
+
}
|
|
798
|
+
function save(namespaces) {
|
|
799
|
+
if (namespaces) {
|
|
800
|
+
process.env.DEBUG = namespaces;
|
|
801
|
+
} else {
|
|
802
|
+
delete process.env.DEBUG;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
function load() {
|
|
806
|
+
return process.env.DEBUG;
|
|
807
|
+
}
|
|
808
|
+
function init(debug) {
|
|
809
|
+
debug.inspectOpts = {};
|
|
810
|
+
const keys = Object.keys(exports$1.inspectOpts);
|
|
811
|
+
for (let i = 0; i < keys.length; i++) {
|
|
812
|
+
debug.inspectOpts[keys[i]] = exports$1.inspectOpts[keys[i]];
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
module.exports = require_common()(exports$1);
|
|
816
|
+
var { formatters } = module.exports;
|
|
817
|
+
formatters.o = function(v) {
|
|
818
|
+
this.inspectOpts.colors = this.useColors;
|
|
819
|
+
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
820
|
+
};
|
|
821
|
+
formatters.O = function(v) {
|
|
822
|
+
this.inspectOpts.colors = this.useColors;
|
|
823
|
+
return util.inspect(v, this.inspectOpts);
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
// ../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js
|
|
829
|
+
var require_src = __commonJS({
|
|
830
|
+
"../../node_modules/.pnpm/debug@4.4.3_supports-color@10.2.2/node_modules/debug/src/index.js"(exports$1, module) {
|
|
831
|
+
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
832
|
+
module.exports = require_browser();
|
|
833
|
+
} else {
|
|
834
|
+
module.exports = require_node();
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js
|
|
840
|
+
var require_helpers = __commonJS({
|
|
841
|
+
"../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js"(exports$1) {
|
|
842
|
+
var __createBinding = exports$1 && exports$1.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
843
|
+
if (k2 === void 0) k2 = k;
|
|
844
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
845
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
846
|
+
desc = { enumerable: true, get: function() {
|
|
847
|
+
return m[k];
|
|
848
|
+
} };
|
|
849
|
+
}
|
|
850
|
+
Object.defineProperty(o, k2, desc);
|
|
851
|
+
}) : (function(o, m, k, k2) {
|
|
852
|
+
if (k2 === void 0) k2 = k;
|
|
853
|
+
o[k2] = m[k];
|
|
854
|
+
}));
|
|
855
|
+
var __setModuleDefault = exports$1 && exports$1.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
856
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
857
|
+
}) : function(o, v) {
|
|
858
|
+
o["default"] = v;
|
|
859
|
+
});
|
|
860
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
861
|
+
if (mod && mod.__esModule) return mod;
|
|
862
|
+
var result = {};
|
|
863
|
+
if (mod != null) {
|
|
864
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
865
|
+
}
|
|
866
|
+
__setModuleDefault(result, mod);
|
|
867
|
+
return result;
|
|
868
|
+
};
|
|
869
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
870
|
+
exports$1.req = exports$1.json = exports$1.toBuffer = void 0;
|
|
871
|
+
var http = __importStar(__require("http"));
|
|
872
|
+
var https = __importStar(__require("https"));
|
|
873
|
+
async function toBuffer(stream) {
|
|
874
|
+
let length = 0;
|
|
875
|
+
const chunks = [];
|
|
876
|
+
for await (const chunk of stream) {
|
|
877
|
+
length += chunk.length;
|
|
878
|
+
chunks.push(chunk);
|
|
879
|
+
}
|
|
880
|
+
return Buffer.concat(chunks, length);
|
|
881
|
+
}
|
|
882
|
+
exports$1.toBuffer = toBuffer;
|
|
883
|
+
async function json(stream) {
|
|
884
|
+
const buf = await toBuffer(stream);
|
|
885
|
+
const str = buf.toString("utf8");
|
|
886
|
+
try {
|
|
887
|
+
return JSON.parse(str);
|
|
888
|
+
} catch (_err) {
|
|
889
|
+
const err = _err;
|
|
890
|
+
err.message += ` (input: ${str})`;
|
|
891
|
+
throw err;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
exports$1.json = json;
|
|
895
|
+
function req(url, opts = {}) {
|
|
896
|
+
const href = typeof url === "string" ? url : url.href;
|
|
897
|
+
const req2 = (href.startsWith("https:") ? https : http).request(url, opts);
|
|
898
|
+
const promise = new Promise((resolve, reject) => {
|
|
899
|
+
req2.once("response", resolve).once("error", reject).end();
|
|
900
|
+
});
|
|
901
|
+
req2.then = promise.then.bind(promise);
|
|
902
|
+
return req2;
|
|
903
|
+
}
|
|
904
|
+
exports$1.req = req;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
// ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js
|
|
909
|
+
var require_dist = __commonJS({
|
|
910
|
+
"../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js"(exports$1) {
|
|
911
|
+
var __createBinding = exports$1 && exports$1.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
912
|
+
if (k2 === void 0) k2 = k;
|
|
913
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
914
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
915
|
+
desc = { enumerable: true, get: function() {
|
|
916
|
+
return m[k];
|
|
917
|
+
} };
|
|
918
|
+
}
|
|
919
|
+
Object.defineProperty(o, k2, desc);
|
|
920
|
+
}) : (function(o, m, k, k2) {
|
|
921
|
+
if (k2 === void 0) k2 = k;
|
|
922
|
+
o[k2] = m[k];
|
|
923
|
+
}));
|
|
924
|
+
var __setModuleDefault = exports$1 && exports$1.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
925
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
926
|
+
}) : function(o, v) {
|
|
927
|
+
o["default"] = v;
|
|
928
|
+
});
|
|
929
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
930
|
+
if (mod && mod.__esModule) return mod;
|
|
931
|
+
var result = {};
|
|
932
|
+
if (mod != null) {
|
|
933
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
934
|
+
}
|
|
935
|
+
__setModuleDefault(result, mod);
|
|
936
|
+
return result;
|
|
937
|
+
};
|
|
938
|
+
var __exportStar = exports$1 && exports$1.__exportStar || function(m, exports2) {
|
|
939
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
940
|
+
};
|
|
941
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
942
|
+
exports$1.Agent = void 0;
|
|
943
|
+
var net = __importStar(__require("net"));
|
|
944
|
+
var http = __importStar(__require("http"));
|
|
945
|
+
var https_1 = __require("https");
|
|
946
|
+
__exportStar(require_helpers(), exports$1);
|
|
947
|
+
var INTERNAL = Symbol("AgentBaseInternalState");
|
|
948
|
+
var Agent = class extends http.Agent {
|
|
949
|
+
constructor(opts) {
|
|
950
|
+
super(opts);
|
|
951
|
+
this[INTERNAL] = {};
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Determine whether this is an `http` or `https` request.
|
|
955
|
+
*/
|
|
956
|
+
isSecureEndpoint(options) {
|
|
957
|
+
if (options) {
|
|
958
|
+
if (typeof options.secureEndpoint === "boolean") {
|
|
959
|
+
return options.secureEndpoint;
|
|
960
|
+
}
|
|
961
|
+
if (typeof options.protocol === "string") {
|
|
962
|
+
return options.protocol === "https:";
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
const { stack } = new Error();
|
|
966
|
+
if (typeof stack !== "string")
|
|
967
|
+
return false;
|
|
968
|
+
return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
|
|
969
|
+
}
|
|
970
|
+
// In order to support async signatures in `connect()` and Node's native
|
|
971
|
+
// connection pooling in `http.Agent`, the array of sockets for each origin
|
|
972
|
+
// has to be updated synchronously. This is so the length of the array is
|
|
973
|
+
// accurate when `addRequest()` is next called. We achieve this by creating a
|
|
974
|
+
// fake socket and adding it to `sockets[origin]` and incrementing
|
|
975
|
+
// `totalSocketCount`.
|
|
976
|
+
incrementSockets(name) {
|
|
977
|
+
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
|
|
978
|
+
return null;
|
|
979
|
+
}
|
|
980
|
+
if (!this.sockets[name]) {
|
|
981
|
+
this.sockets[name] = [];
|
|
982
|
+
}
|
|
983
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
984
|
+
this.sockets[name].push(fakeSocket);
|
|
985
|
+
this.totalSocketCount++;
|
|
986
|
+
return fakeSocket;
|
|
987
|
+
}
|
|
988
|
+
decrementSockets(name, socket) {
|
|
989
|
+
if (!this.sockets[name] || socket === null) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
const sockets = this.sockets[name];
|
|
993
|
+
const index = sockets.indexOf(socket);
|
|
994
|
+
if (index !== -1) {
|
|
995
|
+
sockets.splice(index, 1);
|
|
996
|
+
this.totalSocketCount--;
|
|
997
|
+
if (sockets.length === 0) {
|
|
998
|
+
delete this.sockets[name];
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
// In order to properly update the socket pool, we need to call `getName()` on
|
|
1003
|
+
// the core `https.Agent` if it is a secureEndpoint.
|
|
1004
|
+
getName(options) {
|
|
1005
|
+
const secureEndpoint = this.isSecureEndpoint(options);
|
|
1006
|
+
if (secureEndpoint) {
|
|
1007
|
+
return https_1.Agent.prototype.getName.call(this, options);
|
|
1008
|
+
}
|
|
1009
|
+
return super.getName(options);
|
|
1010
|
+
}
|
|
1011
|
+
createSocket(req, options, cb) {
|
|
1012
|
+
const connectOpts = {
|
|
1013
|
+
...options,
|
|
1014
|
+
secureEndpoint: this.isSecureEndpoint(options)
|
|
1015
|
+
};
|
|
1016
|
+
const name = this.getName(connectOpts);
|
|
1017
|
+
const fakeSocket = this.incrementSockets(name);
|
|
1018
|
+
Promise.resolve().then(() => this.connect(req, connectOpts)).then((socket) => {
|
|
1019
|
+
this.decrementSockets(name, fakeSocket);
|
|
1020
|
+
if (socket instanceof http.Agent) {
|
|
1021
|
+
try {
|
|
1022
|
+
return socket.addRequest(req, connectOpts);
|
|
1023
|
+
} catch (err) {
|
|
1024
|
+
return cb(err);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
this[INTERNAL].currentSocket = socket;
|
|
1028
|
+
super.createSocket(req, options, cb);
|
|
1029
|
+
}, (err) => {
|
|
1030
|
+
this.decrementSockets(name, fakeSocket);
|
|
1031
|
+
cb(err);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
createConnection() {
|
|
1035
|
+
const socket = this[INTERNAL].currentSocket;
|
|
1036
|
+
this[INTERNAL].currentSocket = void 0;
|
|
1037
|
+
if (!socket) {
|
|
1038
|
+
throw new Error("No socket was returned in the `connect()` function");
|
|
1039
|
+
}
|
|
1040
|
+
return socket;
|
|
1041
|
+
}
|
|
1042
|
+
get defaultPort() {
|
|
1043
|
+
return this[INTERNAL].defaultPort ?? (this.protocol === "https:" ? 443 : 80);
|
|
1044
|
+
}
|
|
1045
|
+
set defaultPort(v) {
|
|
1046
|
+
if (this[INTERNAL]) {
|
|
1047
|
+
this[INTERNAL].defaultPort = v;
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
get protocol() {
|
|
1051
|
+
return this[INTERNAL].protocol ?? (this.isSecureEndpoint() ? "https:" : "http:");
|
|
1052
|
+
}
|
|
1053
|
+
set protocol(v) {
|
|
1054
|
+
if (this[INTERNAL]) {
|
|
1055
|
+
this[INTERNAL].protocol = v;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
exports$1.Agent = Agent;
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
// ../../node_modules/.pnpm/https-proxy-agent@7.0.6_supports-color@10.2.2/node_modules/https-proxy-agent/dist/parse-proxy-response.js
|
|
1064
|
+
var require_parse_proxy_response = __commonJS({
|
|
1065
|
+
"../../node_modules/.pnpm/https-proxy-agent@7.0.6_supports-color@10.2.2/node_modules/https-proxy-agent/dist/parse-proxy-response.js"(exports$1) {
|
|
1066
|
+
var __importDefault = exports$1 && exports$1.__importDefault || function(mod) {
|
|
1067
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1068
|
+
};
|
|
1069
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1070
|
+
exports$1.parseProxyResponse = void 0;
|
|
1071
|
+
var debug_1 = __importDefault(require_src());
|
|
1072
|
+
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
1073
|
+
function parseProxyResponse(socket) {
|
|
1074
|
+
return new Promise((resolve, reject) => {
|
|
1075
|
+
let buffersLength = 0;
|
|
1076
|
+
const buffers = [];
|
|
1077
|
+
function read() {
|
|
1078
|
+
const b = socket.read();
|
|
1079
|
+
if (b)
|
|
1080
|
+
ondata(b);
|
|
1081
|
+
else
|
|
1082
|
+
socket.once("readable", read);
|
|
1083
|
+
}
|
|
1084
|
+
function cleanup() {
|
|
1085
|
+
socket.removeListener("end", onend);
|
|
1086
|
+
socket.removeListener("error", onerror);
|
|
1087
|
+
socket.removeListener("readable", read);
|
|
1088
|
+
}
|
|
1089
|
+
function onend() {
|
|
1090
|
+
cleanup();
|
|
1091
|
+
debug("onend");
|
|
1092
|
+
reject(new Error("Proxy connection ended before receiving CONNECT response"));
|
|
1093
|
+
}
|
|
1094
|
+
function onerror(err) {
|
|
1095
|
+
cleanup();
|
|
1096
|
+
debug("onerror %o", err);
|
|
1097
|
+
reject(err);
|
|
1098
|
+
}
|
|
1099
|
+
function ondata(b) {
|
|
1100
|
+
buffers.push(b);
|
|
1101
|
+
buffersLength += b.length;
|
|
1102
|
+
const buffered = Buffer.concat(buffers, buffersLength);
|
|
1103
|
+
const endOfHeaders = buffered.indexOf("\r\n\r\n");
|
|
1104
|
+
if (endOfHeaders === -1) {
|
|
1105
|
+
debug("have not received end of HTTP headers yet...");
|
|
1106
|
+
read();
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
const headerParts = buffered.slice(0, endOfHeaders).toString("ascii").split("\r\n");
|
|
1110
|
+
const firstLine = headerParts.shift();
|
|
1111
|
+
if (!firstLine) {
|
|
1112
|
+
socket.destroy();
|
|
1113
|
+
return reject(new Error("No header received from proxy CONNECT response"));
|
|
1114
|
+
}
|
|
1115
|
+
const firstLineParts = firstLine.split(" ");
|
|
1116
|
+
const statusCode = +firstLineParts[1];
|
|
1117
|
+
const statusText = firstLineParts.slice(2).join(" ");
|
|
1118
|
+
const headers = {};
|
|
1119
|
+
for (const header of headerParts) {
|
|
1120
|
+
if (!header)
|
|
1121
|
+
continue;
|
|
1122
|
+
const firstColon = header.indexOf(":");
|
|
1123
|
+
if (firstColon === -1) {
|
|
1124
|
+
socket.destroy();
|
|
1125
|
+
return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`));
|
|
1126
|
+
}
|
|
1127
|
+
const key = header.slice(0, firstColon).toLowerCase();
|
|
1128
|
+
const value = header.slice(firstColon + 1).trimStart();
|
|
1129
|
+
const current = headers[key];
|
|
1130
|
+
if (typeof current === "string") {
|
|
1131
|
+
headers[key] = [current, value];
|
|
1132
|
+
} else if (Array.isArray(current)) {
|
|
1133
|
+
current.push(value);
|
|
1134
|
+
} else {
|
|
1135
|
+
headers[key] = value;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
debug("got proxy server response: %o %o", firstLine, headers);
|
|
1139
|
+
cleanup();
|
|
1140
|
+
resolve({
|
|
1141
|
+
connect: {
|
|
1142
|
+
statusCode,
|
|
1143
|
+
statusText,
|
|
1144
|
+
headers
|
|
1145
|
+
},
|
|
1146
|
+
buffered
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
socket.on("error", onerror);
|
|
1150
|
+
socket.on("end", onend);
|
|
1151
|
+
read();
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
exports$1.parseProxyResponse = parseProxyResponse;
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
// ../../node_modules/.pnpm/https-proxy-agent@7.0.6_supports-color@10.2.2/node_modules/https-proxy-agent/dist/index.js
|
|
1159
|
+
var require_dist2 = __commonJS({
|
|
1160
|
+
"../../node_modules/.pnpm/https-proxy-agent@7.0.6_supports-color@10.2.2/node_modules/https-proxy-agent/dist/index.js"(exports$1) {
|
|
1161
|
+
var __createBinding = exports$1 && exports$1.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
1162
|
+
if (k2 === void 0) k2 = k;
|
|
1163
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1164
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1165
|
+
desc = { enumerable: true, get: function() {
|
|
1166
|
+
return m[k];
|
|
1167
|
+
} };
|
|
1168
|
+
}
|
|
1169
|
+
Object.defineProperty(o, k2, desc);
|
|
1170
|
+
}) : (function(o, m, k, k2) {
|
|
1171
|
+
if (k2 === void 0) k2 = k;
|
|
1172
|
+
o[k2] = m[k];
|
|
1173
|
+
}));
|
|
1174
|
+
var __setModuleDefault = exports$1 && exports$1.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
1175
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
1176
|
+
}) : function(o, v) {
|
|
1177
|
+
o["default"] = v;
|
|
1178
|
+
});
|
|
1179
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
1180
|
+
if (mod && mod.__esModule) return mod;
|
|
1181
|
+
var result = {};
|
|
1182
|
+
if (mod != null) {
|
|
1183
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
1184
|
+
}
|
|
1185
|
+
__setModuleDefault(result, mod);
|
|
1186
|
+
return result;
|
|
1187
|
+
};
|
|
1188
|
+
var __importDefault = exports$1 && exports$1.__importDefault || function(mod) {
|
|
1189
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
1190
|
+
};
|
|
1191
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1192
|
+
exports$1.HttpsProxyAgent = void 0;
|
|
1193
|
+
var net = __importStar(__require("net"));
|
|
1194
|
+
var tls = __importStar(__require("tls"));
|
|
1195
|
+
var assert_1 = __importDefault(__require("assert"));
|
|
1196
|
+
var debug_1 = __importDefault(require_src());
|
|
1197
|
+
var agent_base_1 = require_dist();
|
|
1198
|
+
var url_1 = __require("url");
|
|
1199
|
+
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
1200
|
+
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
1201
|
+
var setServernameFromNonIpHost = (options) => {
|
|
1202
|
+
if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
|
|
1203
|
+
return {
|
|
1204
|
+
...options,
|
|
1205
|
+
servername: options.host
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
return options;
|
|
1209
|
+
};
|
|
1210
|
+
var HttpsProxyAgent = class extends agent_base_1.Agent {
|
|
1211
|
+
constructor(proxy, opts) {
|
|
1212
|
+
super(opts);
|
|
1213
|
+
this.options = { path: void 0 };
|
|
1214
|
+
this.proxy = typeof proxy === "string" ? new url_1.URL(proxy) : proxy;
|
|
1215
|
+
this.proxyHeaders = opts?.headers ?? {};
|
|
1216
|
+
debug("Creating new HttpsProxyAgent instance: %o", this.proxy.href);
|
|
1217
|
+
const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, "");
|
|
1218
|
+
const port = this.proxy.port ? parseInt(this.proxy.port, 10) : this.proxy.protocol === "https:" ? 443 : 80;
|
|
1219
|
+
this.connectOpts = {
|
|
1220
|
+
// Attempt to negotiate http/1.1 for proxy servers that support http/2
|
|
1221
|
+
ALPNProtocols: ["http/1.1"],
|
|
1222
|
+
...opts ? omit(opts, "headers") : null,
|
|
1223
|
+
host,
|
|
1224
|
+
port
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Called when the node-core HTTP client library is creating a
|
|
1229
|
+
* new HTTP request.
|
|
1230
|
+
*/
|
|
1231
|
+
async connect(req, opts) {
|
|
1232
|
+
const { proxy } = this;
|
|
1233
|
+
if (!opts.host) {
|
|
1234
|
+
throw new TypeError('No "host" provided');
|
|
1235
|
+
}
|
|
1236
|
+
let socket;
|
|
1237
|
+
if (proxy.protocol === "https:") {
|
|
1238
|
+
debug("Creating `tls.Socket`: %o", this.connectOpts);
|
|
1239
|
+
socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
|
|
1240
|
+
} else {
|
|
1241
|
+
debug("Creating `net.Socket`: %o", this.connectOpts);
|
|
1242
|
+
socket = net.connect(this.connectOpts);
|
|
1243
|
+
}
|
|
1244
|
+
const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
|
|
1245
|
+
const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
|
|
1246
|
+
let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
|
|
1247
|
+
`;
|
|
1248
|
+
if (proxy.username || proxy.password) {
|
|
1249
|
+
const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
|
|
1250
|
+
headers["Proxy-Authorization"] = `Basic ${Buffer.from(auth).toString("base64")}`;
|
|
1251
|
+
}
|
|
1252
|
+
headers.Host = `${host}:${opts.port}`;
|
|
1253
|
+
if (!headers["Proxy-Connection"]) {
|
|
1254
|
+
headers["Proxy-Connection"] = this.keepAlive ? "Keep-Alive" : "close";
|
|
1255
|
+
}
|
|
1256
|
+
for (const name of Object.keys(headers)) {
|
|
1257
|
+
payload += `${name}: ${headers[name]}\r
|
|
1258
|
+
`;
|
|
1259
|
+
}
|
|
1260
|
+
const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket);
|
|
1261
|
+
socket.write(`${payload}\r
|
|
1262
|
+
`);
|
|
1263
|
+
const { connect, buffered } = await proxyResponsePromise;
|
|
1264
|
+
req.emit("proxyConnect", connect);
|
|
1265
|
+
this.emit("proxyConnect", connect, req);
|
|
1266
|
+
if (connect.statusCode === 200) {
|
|
1267
|
+
req.once("socket", resume);
|
|
1268
|
+
if (opts.secureEndpoint) {
|
|
1269
|
+
debug("Upgrading socket connection to TLS");
|
|
1270
|
+
return tls.connect({
|
|
1271
|
+
...omit(setServernameFromNonIpHost(opts), "host", "path", "port"),
|
|
1272
|
+
socket
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
return socket;
|
|
1276
|
+
}
|
|
1277
|
+
socket.destroy();
|
|
1278
|
+
const fakeSocket = new net.Socket({ writable: false });
|
|
1279
|
+
fakeSocket.readable = true;
|
|
1280
|
+
req.once("socket", (s) => {
|
|
1281
|
+
debug("Replaying proxy buffer for failed request");
|
|
1282
|
+
(0, assert_1.default)(s.listenerCount("data") > 0);
|
|
1283
|
+
s.push(buffered);
|
|
1284
|
+
s.push(null);
|
|
1285
|
+
});
|
|
1286
|
+
return fakeSocket;
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
HttpsProxyAgent.protocols = ["http", "https"];
|
|
1290
|
+
exports$1.HttpsProxyAgent = HttpsProxyAgent;
|
|
1291
|
+
function resume(socket) {
|
|
1292
|
+
socket.resume();
|
|
1293
|
+
}
|
|
1294
|
+
function omit(obj, ...keys) {
|
|
1295
|
+
const ret = {};
|
|
1296
|
+
let key;
|
|
1297
|
+
for (key in obj) {
|
|
1298
|
+
if (!keys.includes(key)) {
|
|
1299
|
+
ret[key] = obj[key];
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
return ret;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/package.json
|
|
1308
|
+
var require_package = __commonJS({
|
|
1309
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/package.json"(exports$1, module) {
|
|
1310
|
+
module.exports = {
|
|
1311
|
+
name: "mixpanel",
|
|
1312
|
+
description: "A simple server-side API for mixpanel",
|
|
1313
|
+
keywords: [
|
|
1314
|
+
"mixpanel",
|
|
1315
|
+
"analytics",
|
|
1316
|
+
"api",
|
|
1317
|
+
"stats"
|
|
1318
|
+
],
|
|
1319
|
+
version: "0.19.1",
|
|
1320
|
+
homepage: "https://github.com/mixpanel/mixpanel-node",
|
|
1321
|
+
author: "Carl Sverre",
|
|
1322
|
+
license: "MIT",
|
|
1323
|
+
main: "lib/mixpanel-node",
|
|
1324
|
+
directories: {
|
|
1325
|
+
lib: "lib"
|
|
1326
|
+
},
|
|
1327
|
+
repository: {
|
|
1328
|
+
type: "git",
|
|
1329
|
+
url: "git+ssh://git@github.com/mixpanel/mixpanel-node.git"
|
|
1330
|
+
},
|
|
1331
|
+
engines: {
|
|
1332
|
+
node: ">=10.0"
|
|
1333
|
+
},
|
|
1334
|
+
scripts: {
|
|
1335
|
+
test: "vitest"
|
|
1336
|
+
},
|
|
1337
|
+
types: "./lib/mixpanel-node.d.ts",
|
|
1338
|
+
devDependencies: {
|
|
1339
|
+
"@types/node": "^24.10.1",
|
|
1340
|
+
"@vitest/coverage-v8": "^4.0.8",
|
|
1341
|
+
nock: "^14.0.10",
|
|
1342
|
+
proxyquire: "^2.1.3",
|
|
1343
|
+
typescript: "^5.9.3",
|
|
1344
|
+
vitest: "^4.0.8"
|
|
1345
|
+
},
|
|
1346
|
+
dependencies: {
|
|
1347
|
+
"https-proxy-agent": "7.0.6"
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/utils.js
|
|
1354
|
+
var require_utils = __commonJS({
|
|
1355
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/utils.js"(exports$1) {
|
|
1356
|
+
exports$1.async_all = function(requests, handler, callback) {
|
|
1357
|
+
var total = requests.length, errors = null, results = [], done = function(err, result) {
|
|
1358
|
+
if (err) {
|
|
1359
|
+
errors = errors || [];
|
|
1360
|
+
errors.push(err);
|
|
1361
|
+
}
|
|
1362
|
+
results.push(result);
|
|
1363
|
+
if (--total === 0) {
|
|
1364
|
+
callback(errors, results);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
if (total === 0) {
|
|
1368
|
+
callback(errors, results);
|
|
1369
|
+
} else {
|
|
1370
|
+
for (var i = 0, l = requests.length; i < l; i++) {
|
|
1371
|
+
handler(requests[i], done);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
exports$1.ensure_timestamp = function(time) {
|
|
1376
|
+
if (!(time instanceof Date || typeof time === "number")) {
|
|
1377
|
+
throw new Error("`time` property must be a Date or Unix timestamp and is only required for `import` endpoint");
|
|
1378
|
+
}
|
|
1379
|
+
return time instanceof Date ? time.getTime() : time;
|
|
1380
|
+
};
|
|
1381
|
+
exports$1.assert_logger = function(logger) {
|
|
1382
|
+
if (typeof logger !== "object") {
|
|
1383
|
+
throw new TypeError(`"logger" must be a valid Logger object`);
|
|
1384
|
+
}
|
|
1385
|
+
["trace", "debug", "info", "warn", "error"].forEach((method) => {
|
|
1386
|
+
if (typeof logger[method] !== "function") {
|
|
1387
|
+
throw new TypeError(`Logger object missing "${method}" method`);
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
|
|
1394
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/profile_helpers.js
|
|
1395
|
+
var require_profile_helpers = __commonJS({
|
|
1396
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/profile_helpers.js"(exports$1) {
|
|
1397
|
+
var { ensure_timestamp } = require_utils();
|
|
1398
|
+
function merge_modifiers(data, modifiers) {
|
|
1399
|
+
if (modifiers) {
|
|
1400
|
+
if (modifiers.$ignore_alias) {
|
|
1401
|
+
data.$ignore_alias = modifiers.$ignore_alias;
|
|
1402
|
+
}
|
|
1403
|
+
if (modifiers.$ignore_time) {
|
|
1404
|
+
data.$ignore_time = modifiers.$ignore_time;
|
|
1405
|
+
}
|
|
1406
|
+
if (modifiers.hasOwnProperty("$ip")) {
|
|
1407
|
+
data.$ip = modifiers.$ip;
|
|
1408
|
+
}
|
|
1409
|
+
if (modifiers.hasOwnProperty("$time")) {
|
|
1410
|
+
data.$time = ensure_timestamp(modifiers.$time);
|
|
1411
|
+
}
|
|
1412
|
+
if (modifiers.hasOwnProperty("$latitude") && modifiers.hasOwnProperty("$longitude")) {
|
|
1413
|
+
data.$latitude = modifiers.$latitude;
|
|
1414
|
+
data.$longitude = modifiers.$longitude;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
return data;
|
|
1418
|
+
}
|
|
1419
|
+
exports$1.merge_modifiers = merge_modifiers;
|
|
1420
|
+
exports$1.ProfileHelpers = (Base = Object) => class extends Base {
|
|
1421
|
+
get token() {
|
|
1422
|
+
return this.mixpanel.token;
|
|
1423
|
+
}
|
|
1424
|
+
get config() {
|
|
1425
|
+
return this.mixpanel.config;
|
|
1426
|
+
}
|
|
1427
|
+
_set(prop, to, modifiers, callback, { identifiers, set_once = false }) {
|
|
1428
|
+
let $set = {};
|
|
1429
|
+
if (typeof prop === "object") {
|
|
1430
|
+
if (typeof to === "object") {
|
|
1431
|
+
callback = modifiers;
|
|
1432
|
+
modifiers = to;
|
|
1433
|
+
} else {
|
|
1434
|
+
callback = to;
|
|
1435
|
+
}
|
|
1436
|
+
$set = prop;
|
|
1437
|
+
} else {
|
|
1438
|
+
$set[prop] = to;
|
|
1439
|
+
if (typeof modifiers === "function" || !modifiers) {
|
|
1440
|
+
callback = modifiers;
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
let data = {
|
|
1444
|
+
"$token": this.token,
|
|
1445
|
+
...identifiers
|
|
1446
|
+
};
|
|
1447
|
+
const set_key = set_once ? "$set_once" : "$set";
|
|
1448
|
+
data[set_key] = $set;
|
|
1449
|
+
if ("ip" in $set) {
|
|
1450
|
+
data.$ip = $set.ip;
|
|
1451
|
+
delete $set.ip;
|
|
1452
|
+
}
|
|
1453
|
+
if ($set.$ignore_time) {
|
|
1454
|
+
data.$ignore_time = $set.$ignore_time;
|
|
1455
|
+
delete $set.$ignore_time;
|
|
1456
|
+
}
|
|
1457
|
+
data = merge_modifiers(data, modifiers);
|
|
1458
|
+
if (this.config.debug) {
|
|
1459
|
+
this.mixpanel.config.logger.debug(`Sending the following data to Mixpanel (${this.endpoint})`, { data });
|
|
1460
|
+
}
|
|
1461
|
+
this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
|
|
1462
|
+
}
|
|
1463
|
+
_delete_profile({ identifiers, modifiers, callback }) {
|
|
1464
|
+
let data = {
|
|
1465
|
+
"$delete": "",
|
|
1466
|
+
"$token": this.token,
|
|
1467
|
+
...identifiers
|
|
1468
|
+
};
|
|
1469
|
+
if (typeof modifiers === "function") {
|
|
1470
|
+
callback = modifiers;
|
|
1471
|
+
}
|
|
1472
|
+
data = merge_modifiers(data, modifiers);
|
|
1473
|
+
if (this.config.debug) {
|
|
1474
|
+
this.mixpanel.config.logger.debug("Deleting profile", { identifiers });
|
|
1475
|
+
}
|
|
1476
|
+
this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
|
|
1477
|
+
}
|
|
1478
|
+
_remove({ identifiers, data, modifiers, callback }) {
|
|
1479
|
+
let $remove = {};
|
|
1480
|
+
if (typeof data !== "object" || Array.isArray(data)) {
|
|
1481
|
+
if (this.config.debug) {
|
|
1482
|
+
this.mixpanel.config.logger.error("Invalid value passed to #remove - data must be an object with scalar values");
|
|
1483
|
+
}
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
for (const [key, val] of Object.entries(data)) {
|
|
1487
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
1488
|
+
$remove[key] = val;
|
|
1489
|
+
} else {
|
|
1490
|
+
if (this.config.debug) {
|
|
1491
|
+
this.mixpanel.config.logger.error(
|
|
1492
|
+
"Invalid argument passed to #remove - values must be scalar",
|
|
1493
|
+
{ key, value: val }
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
if (Object.keys($remove).length === 0) {
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
data = {
|
|
1503
|
+
"$remove": $remove,
|
|
1504
|
+
"$token": this.token,
|
|
1505
|
+
...identifiers
|
|
1506
|
+
};
|
|
1507
|
+
if (typeof modifiers === "function") {
|
|
1508
|
+
callback = modifiers;
|
|
1509
|
+
}
|
|
1510
|
+
data = merge_modifiers(data, modifiers);
|
|
1511
|
+
if (this.config.debug) {
|
|
1512
|
+
this.mixpanel.config.logger.debug(
|
|
1513
|
+
`Sending the following data to Mixpanel (${this.endpoint})`,
|
|
1514
|
+
{ data }
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
|
|
1518
|
+
}
|
|
1519
|
+
_union({ identifiers, data, modifiers, callback }) {
|
|
1520
|
+
let $union = {};
|
|
1521
|
+
if (typeof data !== "object" || Array.isArray(data)) {
|
|
1522
|
+
if (this.config.debug) {
|
|
1523
|
+
this.mixpanel.config.logger.error("Invalid value passed to #union - data must be an object with scalar or array values");
|
|
1524
|
+
}
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
for (const [key, val] of Object.entries(data)) {
|
|
1528
|
+
if (Array.isArray(val)) {
|
|
1529
|
+
var merge_values = val.filter(function(v) {
|
|
1530
|
+
return typeof v === "string" || typeof v === "number";
|
|
1531
|
+
});
|
|
1532
|
+
if (merge_values.length > 0) {
|
|
1533
|
+
$union[key] = merge_values;
|
|
1534
|
+
}
|
|
1535
|
+
} else if (typeof val === "string" || typeof val === "number") {
|
|
1536
|
+
$union[key] = [val];
|
|
1537
|
+
} else {
|
|
1538
|
+
if (this.config.debug) {
|
|
1539
|
+
this.mixpanel.config.logger.error(
|
|
1540
|
+
"Invalid argument passed to #union - values must be a scalar value or array",
|
|
1541
|
+
{ key, value: val }
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
if (Object.keys($union).length === 0) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
data = {
|
|
1550
|
+
"$union": $union,
|
|
1551
|
+
"$token": this.token,
|
|
1552
|
+
...identifiers
|
|
1553
|
+
};
|
|
1554
|
+
if (typeof modifiers === "function") {
|
|
1555
|
+
callback = modifiers;
|
|
1556
|
+
}
|
|
1557
|
+
data = merge_modifiers(data, modifiers);
|
|
1558
|
+
if (this.config.debug) {
|
|
1559
|
+
this.mixpanel.config.logger.debug(
|
|
1560
|
+
`Sending the following data to Mixpanel (${this.endpoint})`,
|
|
1561
|
+
{ data }
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
|
|
1565
|
+
}
|
|
1566
|
+
_unset({ identifiers, prop, modifiers, callback }) {
|
|
1567
|
+
let $unset = [];
|
|
1568
|
+
if (Array.isArray(prop)) {
|
|
1569
|
+
$unset = prop;
|
|
1570
|
+
} else if (typeof prop === "string") {
|
|
1571
|
+
$unset = [prop];
|
|
1572
|
+
} else {
|
|
1573
|
+
if (this.config.debug) {
|
|
1574
|
+
this.mixpanel.config.logger.error(
|
|
1575
|
+
"Invalid argument passed to #unset - must be a string or array",
|
|
1576
|
+
{ prop }
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1579
|
+
return;
|
|
1580
|
+
}
|
|
1581
|
+
let data = {
|
|
1582
|
+
"$unset": $unset,
|
|
1583
|
+
"$token": this.token,
|
|
1584
|
+
...identifiers
|
|
1585
|
+
};
|
|
1586
|
+
if (typeof modifiers === "function") {
|
|
1587
|
+
callback = modifiers;
|
|
1588
|
+
}
|
|
1589
|
+
data = merge_modifiers(data, modifiers);
|
|
1590
|
+
if (this.config.debug) {
|
|
1591
|
+
this.mixpanel.config.logger.debug(
|
|
1592
|
+
`Sending the following data to Mixpanel (${this.endpoint})`,
|
|
1593
|
+
{ data }
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/groups.js
|
|
1603
|
+
var require_groups = __commonJS({
|
|
1604
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/groups.js"(exports$1) {
|
|
1605
|
+
var { ProfileHelpers } = require_profile_helpers();
|
|
1606
|
+
var MixpanelGroups = class extends ProfileHelpers() {
|
|
1607
|
+
constructor(mp_instance) {
|
|
1608
|
+
super();
|
|
1609
|
+
this.mixpanel = mp_instance;
|
|
1610
|
+
this.endpoint = "/groups";
|
|
1611
|
+
}
|
|
1612
|
+
/** groups.set_once(group_key, group_id, prop, to, modifiers, callback)
|
|
1613
|
+
---
|
|
1614
|
+
The same as groups.set, but adds a property value to a group only if it has not been set before.
|
|
1615
|
+
*/
|
|
1616
|
+
set_once(group_key, group_id, prop, to, modifiers, callback) {
|
|
1617
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1618
|
+
this._set(prop, to, modifiers, callback, { identifiers, set_once: true });
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
groups.set(group_key, group_id, prop, to, modifiers, callback)
|
|
1622
|
+
---
|
|
1623
|
+
set properties on a group profile
|
|
1624
|
+
|
|
1625
|
+
usage:
|
|
1626
|
+
|
|
1627
|
+
mixpanel.groups.set('company', 'Acme Inc.', '$name', 'Acme Inc.');
|
|
1628
|
+
|
|
1629
|
+
mixpanel.groups.set('company', 'Acme Inc.', {
|
|
1630
|
+
'Industry': 'widgets',
|
|
1631
|
+
'$name': 'Acme Inc.',
|
|
1632
|
+
});
|
|
1633
|
+
*/
|
|
1634
|
+
set(group_key, group_id, prop, to, modifiers, callback) {
|
|
1635
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1636
|
+
this._set(prop, to, modifiers, callback, { identifiers });
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
groups.delete_group(group_key, group_id, modifiers, callback)
|
|
1640
|
+
---
|
|
1641
|
+
delete a group profile permanently
|
|
1642
|
+
|
|
1643
|
+
usage:
|
|
1644
|
+
|
|
1645
|
+
mixpanel.groups.delete_group('company', 'Acme Inc.');
|
|
1646
|
+
*/
|
|
1647
|
+
delete_group(group_key, group_id, modifiers, callback) {
|
|
1648
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1649
|
+
this._delete_profile({ identifiers, modifiers, callback });
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
groups.remove(group_key, group_id, data, modifiers, callback)
|
|
1653
|
+
---
|
|
1654
|
+
remove a value from a list-valued group profile property.
|
|
1655
|
+
|
|
1656
|
+
usage:
|
|
1657
|
+
|
|
1658
|
+
mixpanel.groups.remove('company', 'Acme Inc.', {'products': 'anvil'});
|
|
1659
|
+
|
|
1660
|
+
mixpanel.groups.remove('company', 'Acme Inc.', {
|
|
1661
|
+
'products': 'anvil',
|
|
1662
|
+
'customer segments': 'coyotes'
|
|
1663
|
+
});
|
|
1664
|
+
*/
|
|
1665
|
+
remove(group_key, group_id, data, modifiers, callback) {
|
|
1666
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1667
|
+
this._remove({ identifiers, data, modifiers, callback });
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
groups.union(group_key, group_id, data, modifiers, callback)
|
|
1671
|
+
---
|
|
1672
|
+
merge value(s) into a list-valued group profile property.
|
|
1673
|
+
|
|
1674
|
+
usage:
|
|
1675
|
+
|
|
1676
|
+
mixpanel.groups.union('company', 'Acme Inc.', {'products': 'anvil'});
|
|
1677
|
+
|
|
1678
|
+
mixpanel.groups.union('company', 'Acme Inc.', {'products': ['anvil'], 'customer segments': ['coyotes']});
|
|
1679
|
+
*/
|
|
1680
|
+
union(group_key, group_id, data, modifiers, callback) {
|
|
1681
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1682
|
+
this._union({ identifiers, data, modifiers, callback });
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
groups.unset(group_key, group_id, prop, modifiers, callback)
|
|
1686
|
+
---
|
|
1687
|
+
delete a property on a group profile
|
|
1688
|
+
|
|
1689
|
+
usage:
|
|
1690
|
+
|
|
1691
|
+
mixpanel.groups.unset('company', 'Acme Inc.', 'products');
|
|
1692
|
+
|
|
1693
|
+
mixpanel.groups.unset('company', 'Acme Inc.', ['products', 'customer segments']);
|
|
1694
|
+
*/
|
|
1695
|
+
unset(group_key, group_id, prop, modifiers, callback) {
|
|
1696
|
+
const identifiers = { $group_key: group_key, $group_id: group_id };
|
|
1697
|
+
this._unset({ identifiers, prop, modifiers, callback });
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
exports$1.MixpanelGroups = MixpanelGroups;
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/people.js
|
|
1705
|
+
var require_people = __commonJS({
|
|
1706
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/people.js"(exports$1) {
|
|
1707
|
+
var { merge_modifiers, ProfileHelpers } = require_profile_helpers();
|
|
1708
|
+
var MixpanelPeople = class extends ProfileHelpers() {
|
|
1709
|
+
constructor(mp_instance) {
|
|
1710
|
+
super();
|
|
1711
|
+
this.mixpanel = mp_instance;
|
|
1712
|
+
this.endpoint = "/engage";
|
|
1713
|
+
}
|
|
1714
|
+
/** people.set_once(distinct_id, prop, to, modifiers, callback)
|
|
1715
|
+
---
|
|
1716
|
+
The same as people.set but in the words of mixpanel:
|
|
1717
|
+
mixpanel.people.set_once
|
|
1718
|
+
|
|
1719
|
+
" This method allows you to set a user attribute, only if
|
|
1720
|
+
it is not currently set. It can be called multiple times
|
|
1721
|
+
safely, so is perfect for storing things like the first date
|
|
1722
|
+
you saw a user, or the referrer that brought them to your
|
|
1723
|
+
website for the first time. "
|
|
1724
|
+
|
|
1725
|
+
*/
|
|
1726
|
+
set_once(distinct_id, prop, to, modifiers, callback) {
|
|
1727
|
+
const identifiers = { $distinct_id: distinct_id };
|
|
1728
|
+
this._set(prop, to, modifiers, callback, { identifiers, set_once: true });
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
people.set(distinct_id, prop, to, modifiers, callback)
|
|
1732
|
+
---
|
|
1733
|
+
set properties on an user record in engage
|
|
1734
|
+
|
|
1735
|
+
usage:
|
|
1736
|
+
|
|
1737
|
+
mixpanel.people.set('bob', 'gender', 'm');
|
|
1738
|
+
|
|
1739
|
+
mixpanel.people.set('joe', {
|
|
1740
|
+
'company': 'acme',
|
|
1741
|
+
'plan': 'premium'
|
|
1742
|
+
});
|
|
1743
|
+
*/
|
|
1744
|
+
set(distinct_id, prop, to, modifiers, callback) {
|
|
1745
|
+
const identifiers = { $distinct_id: distinct_id };
|
|
1746
|
+
this._set(prop, to, modifiers, callback, { identifiers });
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
people.increment(distinct_id, prop, by, modifiers, callback)
|
|
1750
|
+
---
|
|
1751
|
+
increment/decrement properties on an user record in engage
|
|
1752
|
+
|
|
1753
|
+
usage:
|
|
1754
|
+
|
|
1755
|
+
mixpanel.people.increment('bob', 'page_views', 1);
|
|
1756
|
+
|
|
1757
|
+
// or, for convenience, if you're just incrementing a counter by 1, you can
|
|
1758
|
+
// simply do
|
|
1759
|
+
mixpanel.people.increment('bob', 'page_views');
|
|
1760
|
+
|
|
1761
|
+
// to decrement a counter, pass a negative number
|
|
1762
|
+
mixpanel.people.increment('bob', 'credits_left', -1);
|
|
1763
|
+
|
|
1764
|
+
// like mixpanel.people.set(), you can increment multiple properties at once:
|
|
1765
|
+
mixpanel.people.increment('bob', {
|
|
1766
|
+
counter1: 1,
|
|
1767
|
+
counter2: 3,
|
|
1768
|
+
counter3: -2
|
|
1769
|
+
});
|
|
1770
|
+
*/
|
|
1771
|
+
increment(distinct_id, prop, by, modifiers, callback) {
|
|
1772
|
+
var $add = {};
|
|
1773
|
+
if (typeof prop === "object") {
|
|
1774
|
+
if (typeof by === "object") {
|
|
1775
|
+
callback = modifiers;
|
|
1776
|
+
modifiers = by;
|
|
1777
|
+
} else {
|
|
1778
|
+
callback = by;
|
|
1779
|
+
}
|
|
1780
|
+
for (const [key, val] of Object.entries(prop)) {
|
|
1781
|
+
if (isNaN(parseFloat(val))) {
|
|
1782
|
+
if (this.mixpanel.config.debug) {
|
|
1783
|
+
this.mixpanel.config.logger.error(
|
|
1784
|
+
"Invalid increment value passed to mixpanel.people.increment - must be a number",
|
|
1785
|
+
{ key, value: val }
|
|
1786
|
+
);
|
|
1787
|
+
}
|
|
1788
|
+
} else {
|
|
1789
|
+
$add[key] = val;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
} else {
|
|
1793
|
+
if (typeof by === "number" || !by) {
|
|
1794
|
+
by = by || 1;
|
|
1795
|
+
$add[prop] = by;
|
|
1796
|
+
if (typeof modifiers === "function") {
|
|
1797
|
+
callback = modifiers;
|
|
1798
|
+
}
|
|
1799
|
+
} else if (typeof by === "function") {
|
|
1800
|
+
callback = by;
|
|
1801
|
+
$add[prop] = 1;
|
|
1802
|
+
} else {
|
|
1803
|
+
callback = modifiers;
|
|
1804
|
+
modifiers = typeof by === "object" ? by : {};
|
|
1805
|
+
$add[prop] = 1;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
var data = {
|
|
1809
|
+
"$add": $add,
|
|
1810
|
+
"$token": this.mixpanel.token,
|
|
1811
|
+
"$distinct_id": distinct_id
|
|
1812
|
+
};
|
|
1813
|
+
data = merge_modifiers(data, modifiers);
|
|
1814
|
+
if (this.mixpanel.config.debug) {
|
|
1815
|
+
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
|
|
1816
|
+
}
|
|
1817
|
+
this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
people.append(distinct_id, prop, value, modifiers, callback)
|
|
1821
|
+
---
|
|
1822
|
+
Append a value to a list-valued people analytics property.
|
|
1823
|
+
|
|
1824
|
+
usage:
|
|
1825
|
+
|
|
1826
|
+
// append a value to a list, creating it if needed
|
|
1827
|
+
mixpanel.people.append('bob', 'pages_visited', 'homepage');
|
|
1828
|
+
|
|
1829
|
+
// like mixpanel.people.set(), you can append multiple properties at once:
|
|
1830
|
+
mixpanel.people.append('bob', {
|
|
1831
|
+
list1: 'bob',
|
|
1832
|
+
list2: 123
|
|
1833
|
+
});
|
|
1834
|
+
*/
|
|
1835
|
+
append(distinct_id, prop, value, modifiers, callback) {
|
|
1836
|
+
var $append = {};
|
|
1837
|
+
if (typeof prop === "object") {
|
|
1838
|
+
if (typeof value === "object") {
|
|
1839
|
+
callback = modifiers;
|
|
1840
|
+
modifiers = value;
|
|
1841
|
+
} else {
|
|
1842
|
+
callback = value;
|
|
1843
|
+
}
|
|
1844
|
+
Object.keys(prop).forEach(function(key) {
|
|
1845
|
+
$append[key] = prop[key];
|
|
1846
|
+
});
|
|
1847
|
+
} else {
|
|
1848
|
+
$append[prop] = value;
|
|
1849
|
+
if (typeof modifiers === "function") {
|
|
1850
|
+
callback = modifiers;
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
var data = {
|
|
1854
|
+
"$append": $append,
|
|
1855
|
+
"$token": this.mixpanel.token,
|
|
1856
|
+
"$distinct_id": distinct_id
|
|
1857
|
+
};
|
|
1858
|
+
data = merge_modifiers(data, modifiers);
|
|
1859
|
+
if (this.mixpanel.config.debug) {
|
|
1860
|
+
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
|
|
1861
|
+
}
|
|
1862
|
+
this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
people.track_charge(distinct_id, amount, properties, modifiers, callback)
|
|
1866
|
+
---
|
|
1867
|
+
Record that you have charged the current user a certain
|
|
1868
|
+
amount of money.
|
|
1869
|
+
|
|
1870
|
+
usage:
|
|
1871
|
+
|
|
1872
|
+
// charge a user $29.99
|
|
1873
|
+
mixpanel.people.track_charge('bob', 29.99);
|
|
1874
|
+
|
|
1875
|
+
// charge a user $19 on the 1st of february
|
|
1876
|
+
mixpanel.people.track_charge('bob', 19, { '$time': new Date('feb 1 2012') });
|
|
1877
|
+
*/
|
|
1878
|
+
track_charge(distinct_id, amount, properties, modifiers, callback) {
|
|
1879
|
+
if (typeof properties === "function" || !properties) {
|
|
1880
|
+
callback = properties || void 0;
|
|
1881
|
+
properties = {};
|
|
1882
|
+
} else {
|
|
1883
|
+
if (typeof modifiers === "function" || !modifiers) {
|
|
1884
|
+
callback = modifiers || void 0;
|
|
1885
|
+
if (properties.$ignore_time || properties.hasOwnProperty("$ip")) {
|
|
1886
|
+
modifiers = {};
|
|
1887
|
+
Object.keys(properties).forEach(function(key) {
|
|
1888
|
+
modifiers[key] = properties[key];
|
|
1889
|
+
delete properties[key];
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
if (typeof amount !== "number") {
|
|
1895
|
+
amount = parseFloat(amount);
|
|
1896
|
+
if (isNaN(amount)) {
|
|
1897
|
+
this.mixpanel.config.logger.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
properties.$amount = amount;
|
|
1902
|
+
if (properties.hasOwnProperty("$time")) {
|
|
1903
|
+
var time = properties.$time;
|
|
1904
|
+
if (Object.prototype.toString.call(time) === "[object Date]") {
|
|
1905
|
+
properties.$time = time.toISOString();
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
var data = {
|
|
1909
|
+
"$append": { "$transactions": properties },
|
|
1910
|
+
"$token": this.mixpanel.token,
|
|
1911
|
+
"$distinct_id": distinct_id
|
|
1912
|
+
};
|
|
1913
|
+
data = merge_modifiers(data, modifiers);
|
|
1914
|
+
if (this.mixpanel.config.debug) {
|
|
1915
|
+
this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
|
|
1916
|
+
}
|
|
1917
|
+
this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
people.clear_charges(distinct_id, modifiers, callback)
|
|
1921
|
+
---
|
|
1922
|
+
Clear all the current user's transactions.
|
|
1923
|
+
|
|
1924
|
+
usage:
|
|
1925
|
+
|
|
1926
|
+
mixpanel.people.clear_charges('bob');
|
|
1927
|
+
*/
|
|
1928
|
+
clear_charges(distinct_id, modifiers, callback) {
|
|
1929
|
+
var data = {
|
|
1930
|
+
"$set": { "$transactions": [] },
|
|
1931
|
+
"$token": this.mixpanel.token,
|
|
1932
|
+
"$distinct_id": distinct_id
|
|
1933
|
+
};
|
|
1934
|
+
if (typeof modifiers === "function") {
|
|
1935
|
+
callback = modifiers;
|
|
1936
|
+
}
|
|
1937
|
+
data = merge_modifiers(data, modifiers);
|
|
1938
|
+
if (this.mixpanel.config.debug) {
|
|
1939
|
+
this.mixpanel.config.logger.debug("Clearing this user's charges", { "$distinct_id": distinct_id });
|
|
1940
|
+
}
|
|
1941
|
+
this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
people.delete_user(distinct_id, modifiers, callback)
|
|
1945
|
+
---
|
|
1946
|
+
delete an user record in engage
|
|
1947
|
+
|
|
1948
|
+
usage:
|
|
1949
|
+
|
|
1950
|
+
mixpanel.people.delete_user('bob');
|
|
1951
|
+
*/
|
|
1952
|
+
delete_user(distinct_id, modifiers, callback) {
|
|
1953
|
+
const identifiers = { $distinct_id: distinct_id };
|
|
1954
|
+
this._delete_profile({ identifiers, modifiers, callback });
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
people.remove(distinct_id, data, modifiers, callback)
|
|
1958
|
+
---
|
|
1959
|
+
remove a value from a list-valued user profile property.
|
|
1960
|
+
|
|
1961
|
+
usage:
|
|
1962
|
+
|
|
1963
|
+
mixpanel.people.remove('bob', {'browsers': 'firefox'});
|
|
1964
|
+
|
|
1965
|
+
mixpanel.people.remove('bob', {'browsers': 'chrome', 'os': 'linux'});
|
|
1966
|
+
*/
|
|
1967
|
+
remove(distinct_id, data, modifiers, callback) {
|
|
1968
|
+
const identifiers = { "$distinct_id": distinct_id };
|
|
1969
|
+
this._remove({ identifiers, data, modifiers, callback });
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
people.union(distinct_id, data, modifiers, callback)
|
|
1973
|
+
---
|
|
1974
|
+
merge value(s) into a list-valued people analytics property.
|
|
1975
|
+
|
|
1976
|
+
usage:
|
|
1977
|
+
|
|
1978
|
+
mixpanel.people.union('bob', {'browsers': 'firefox'});
|
|
1979
|
+
|
|
1980
|
+
mixpanel.people.union('bob', {'browsers': ['chrome'], os: ['linux']});
|
|
1981
|
+
*/
|
|
1982
|
+
union(distinct_id, data, modifiers, callback) {
|
|
1983
|
+
const identifiers = { $distinct_id: distinct_id };
|
|
1984
|
+
this._union({ identifiers, data, modifiers, callback });
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
people.unset(distinct_id, prop, modifiers, callback)
|
|
1988
|
+
---
|
|
1989
|
+
delete a property on an user record in engage
|
|
1990
|
+
|
|
1991
|
+
usage:
|
|
1992
|
+
|
|
1993
|
+
mixpanel.people.unset('bob', 'page_views');
|
|
1994
|
+
|
|
1995
|
+
mixpanel.people.unset('bob', ['page_views', 'last_login']);
|
|
1996
|
+
*/
|
|
1997
|
+
unset(distinct_id, prop, modifiers, callback) {
|
|
1998
|
+
const identifiers = { $distinct_id: distinct_id };
|
|
1999
|
+
this._unset({ identifiers, prop, modifiers, callback });
|
|
2000
|
+
}
|
|
2001
|
+
};
|
|
2002
|
+
exports$1.MixpanelPeople = MixpanelPeople;
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
|
|
2006
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/utils.js
|
|
2007
|
+
var require_utils2 = __commonJS({
|
|
2008
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/utils.js"(exports$1, module) {
|
|
2009
|
+
var crypto = __require("crypto");
|
|
2010
|
+
var EXPOSURE_EVENT = "$experiment_started";
|
|
2011
|
+
var REQUEST_HEADERS = {
|
|
2012
|
+
"Content-Type": "application/json"
|
|
2013
|
+
};
|
|
2014
|
+
function _fnv1a64(data) {
|
|
2015
|
+
const FNV_PRIME = BigInt("0x100000001B3");
|
|
2016
|
+
let hash = BigInt("0xCBF29CE484222325");
|
|
2017
|
+
for (let i = 0; i < data.length; i++) {
|
|
2018
|
+
hash ^= BigInt(data[i]);
|
|
2019
|
+
hash *= FNV_PRIME;
|
|
2020
|
+
hash &= BigInt("0xFFFFFFFFFFFFFFFF");
|
|
2021
|
+
}
|
|
2022
|
+
return hash;
|
|
2023
|
+
}
|
|
2024
|
+
function normalizedHash(key, salt) {
|
|
2025
|
+
const combined = Buffer.from(key + salt, "utf-8");
|
|
2026
|
+
const hashValue = _fnv1a64(combined);
|
|
2027
|
+
return Number(hashValue % BigInt(100)) / 100;
|
|
2028
|
+
}
|
|
2029
|
+
function prepareCommonQueryParams(token, sdkVersion) {
|
|
2030
|
+
return {
|
|
2031
|
+
mp_lib: "node",
|
|
2032
|
+
$lib_version: sdkVersion,
|
|
2033
|
+
token
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
function generateTraceparent() {
|
|
2037
|
+
const version = "00";
|
|
2038
|
+
const traceId = crypto.randomBytes(16).toString("hex");
|
|
2039
|
+
const parentId = crypto.randomBytes(8).toString("hex");
|
|
2040
|
+
const traceFlags = "01";
|
|
2041
|
+
return `${version}-${traceId}-${parentId}-${traceFlags}`;
|
|
2042
|
+
}
|
|
2043
|
+
module.exports = {
|
|
2044
|
+
EXPOSURE_EVENT,
|
|
2045
|
+
REQUEST_HEADERS,
|
|
2046
|
+
normalizedHash,
|
|
2047
|
+
prepareCommonQueryParams,
|
|
2048
|
+
generateTraceparent
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
|
|
2053
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/flags.js
|
|
2054
|
+
var require_flags = __commonJS({
|
|
2055
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/flags.js"(exports$1, module) {
|
|
2056
|
+
var https = __require("https");
|
|
2057
|
+
var packageInfo = require_package();
|
|
2058
|
+
var { prepareCommonQueryParams, generateTraceparent, EXPOSURE_EVENT, REQUEST_HEADERS } = require_utils2();
|
|
2059
|
+
var FeatureFlagsProvider = class {
|
|
2060
|
+
/**
|
|
2061
|
+
* @param {Object} providerConfig - Configuration object with token, api_host, request_timeout_in_seconds
|
|
2062
|
+
* @param {string} endpoint - API endpoint path (e.g., '/flags' or '/flags/definitions')
|
|
2063
|
+
* @param {Function} tracker - Function to track events (signature: track(distinct_id, event, properties, callback))
|
|
2064
|
+
* @param {string} evaluationMode - The feature flag evaluation mode
|
|
2065
|
+
* @param {CustomLogger} logger - Logger instance
|
|
2066
|
+
*/
|
|
2067
|
+
constructor(providerConfig, endpoint, tracker, evaluationMode, logger) {
|
|
2068
|
+
this.providerConfig = providerConfig;
|
|
2069
|
+
this.endpoint = endpoint;
|
|
2070
|
+
this.tracker = tracker;
|
|
2071
|
+
this.evaluationMode = evaluationMode;
|
|
2072
|
+
this.logger = logger;
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Common HTTP request handler for flags API endpoints
|
|
2076
|
+
* @param {Object} additionalParams - Additional query parameters to append
|
|
2077
|
+
* @returns {Promise<Object>} - Parsed JSON response
|
|
2078
|
+
*/
|
|
2079
|
+
async callFlagsEndpoint(additionalParams = null) {
|
|
2080
|
+
return new Promise((resolve, reject) => {
|
|
2081
|
+
const commonParams = prepareCommonQueryParams(this.providerConfig.token, packageInfo.version);
|
|
2082
|
+
const params = new URLSearchParams(commonParams);
|
|
2083
|
+
if (additionalParams) {
|
|
2084
|
+
for (const [key, value] of Object.entries(additionalParams)) {
|
|
2085
|
+
params.append(key, value);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
const path = `${this.endpoint}?${params.toString()}`;
|
|
2089
|
+
const requestOptions = {
|
|
2090
|
+
host: this.providerConfig.api_host,
|
|
2091
|
+
port: 443,
|
|
2092
|
+
path,
|
|
2093
|
+
method: "GET",
|
|
2094
|
+
headers: {
|
|
2095
|
+
...REQUEST_HEADERS,
|
|
2096
|
+
"Authorization": "Basic " + Buffer.from(this.providerConfig.token + ":").toString("base64"),
|
|
2097
|
+
"traceparent": generateTraceparent()
|
|
2098
|
+
},
|
|
2099
|
+
timeout: this.providerConfig.request_timeout_in_seconds * 1e3
|
|
2100
|
+
};
|
|
2101
|
+
const request = https.request(requestOptions, (res) => {
|
|
2102
|
+
let data = "";
|
|
2103
|
+
res.on("data", (chunk) => {
|
|
2104
|
+
data += chunk;
|
|
2105
|
+
});
|
|
2106
|
+
res.on("end", () => {
|
|
2107
|
+
if (res.statusCode !== 200) {
|
|
2108
|
+
this.logger?.error(`HTTP ${res.statusCode} error calling flags endpoint: ${data}`);
|
|
2109
|
+
return reject(new Error(`HTTP ${res.statusCode}: ${data}`));
|
|
2110
|
+
}
|
|
2111
|
+
try {
|
|
2112
|
+
const result = JSON.parse(data);
|
|
2113
|
+
resolve(result);
|
|
2114
|
+
} catch (parseErr) {
|
|
2115
|
+
this.logger?.error(`Failed to parse JSON response: ${parseErr.message}`);
|
|
2116
|
+
reject(parseErr);
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
});
|
|
2120
|
+
request.on("error", (err) => {
|
|
2121
|
+
this.logger?.error(`Network error calling flags endpoint: ${err.message}`);
|
|
2122
|
+
reject(err);
|
|
2123
|
+
});
|
|
2124
|
+
request.on("timeout", () => {
|
|
2125
|
+
this.logger?.error(`Request timeout calling flags endpoint`);
|
|
2126
|
+
request.destroy();
|
|
2127
|
+
reject(new Error("Request timeout"));
|
|
2128
|
+
});
|
|
2129
|
+
request.end();
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
/**
|
|
2133
|
+
* Manually tracks a feature flag exposure event to Mixpanel
|
|
2134
|
+
* This provides flexibility for reporting individual exposure events when using getAllVariants
|
|
2135
|
+
* If using getVariantValue or getVariant, exposure events are tracked automatically by default.
|
|
2136
|
+
* @param {string} flagKey - The key of the feature flag
|
|
2137
|
+
* @param {SelectedVariant} variant - The selected variant for the feature flag
|
|
2138
|
+
* @param {FlagContext} context - The user context used to evaluate the feature flag
|
|
2139
|
+
* @param {number|null} latencyMs - Optionally included latency in milliseconds that assignment took.
|
|
2140
|
+
*/
|
|
2141
|
+
trackExposureEvent(flagKey, selectedVariant, context, latencyMs = null) {
|
|
2142
|
+
if (!context.distinct_id) {
|
|
2143
|
+
this.logger?.error("Cannot track exposure event without a distinct_id in the context");
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
const properties = {
|
|
2147
|
+
"distinct_id": context.distinct_id,
|
|
2148
|
+
"Experiment name": flagKey,
|
|
2149
|
+
"Variant name": selectedVariant.variant_key,
|
|
2150
|
+
"$experiment_type": "feature_flag",
|
|
2151
|
+
"Flag evaluation mode": this.evaluationMode
|
|
2152
|
+
};
|
|
2153
|
+
if (latencyMs !== null && latencyMs !== void 0) {
|
|
2154
|
+
properties["Variant fetch latency (ms)"] = latencyMs;
|
|
2155
|
+
}
|
|
2156
|
+
if (selectedVariant.experiment_id !== void 0) {
|
|
2157
|
+
properties["$experiment_id"] = selectedVariant.experiment_id;
|
|
2158
|
+
}
|
|
2159
|
+
if (selectedVariant.is_experiment_active !== void 0) {
|
|
2160
|
+
properties["$is_experiment_active"] = selectedVariant.is_experiment_active;
|
|
2161
|
+
}
|
|
2162
|
+
if (selectedVariant.is_qa_tester !== void 0) {
|
|
2163
|
+
properties["$is_qa_tester"] = selectedVariant.is_qa_tester;
|
|
2164
|
+
}
|
|
2165
|
+
this.tracker(EXPOSURE_EVENT, properties, (err) => {
|
|
2166
|
+
if (err) {
|
|
2167
|
+
this.logger?.error(`[flags]Failed to track exposure event for flag '${flagKey}': ${err.message}`);
|
|
2168
|
+
}
|
|
2169
|
+
});
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
module.exports = FeatureFlagsProvider;
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2176
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/local_flags.js
|
|
2177
|
+
var require_local_flags = __commonJS({
|
|
2178
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/local_flags.js"(exports$1, module) {
|
|
2179
|
+
var FeatureFlagsProvider = require_flags();
|
|
2180
|
+
var { normalizedHash } = require_utils2();
|
|
2181
|
+
var LocalFeatureFlagsProvider = class extends FeatureFlagsProvider {
|
|
2182
|
+
/**
|
|
2183
|
+
* @param {string} token - Mixpanel project token
|
|
2184
|
+
* @param {LocalFlagsConfig} config - Local flags configuration
|
|
2185
|
+
* @param {Function} tracker - Function to track events (signature: track(distinct_id, event, properties, callback))
|
|
2186
|
+
* @param {CustomLogger} logger - Logger
|
|
2187
|
+
*/
|
|
2188
|
+
constructor(token, config, tracker, logger) {
|
|
2189
|
+
const mergedConfig = {
|
|
2190
|
+
api_host: "api.mixpanel.com",
|
|
2191
|
+
request_timeout_in_seconds: 10,
|
|
2192
|
+
enable_polling: true,
|
|
2193
|
+
polling_interval_in_seconds: 60,
|
|
2194
|
+
...config
|
|
2195
|
+
};
|
|
2196
|
+
const providerConfig = {
|
|
2197
|
+
token,
|
|
2198
|
+
api_host: mergedConfig.api_host,
|
|
2199
|
+
request_timeout_in_seconds: mergedConfig.request_timeout_in_seconds
|
|
2200
|
+
};
|
|
2201
|
+
super(providerConfig, "/flags/definitions", tracker, "local", logger);
|
|
2202
|
+
this.config = mergedConfig;
|
|
2203
|
+
this.flagDefinitions = /* @__PURE__ */ new Map();
|
|
2204
|
+
this.pollingInterval = null;
|
|
2205
|
+
}
|
|
2206
|
+
/**
|
|
2207
|
+
* Start polling for flag definitions.
|
|
2208
|
+
* Fetches immediately and then at regular intervals if polling is enabled
|
|
2209
|
+
* @returns {Promise<void>}
|
|
2210
|
+
*/
|
|
2211
|
+
async startPollingForDefinitions() {
|
|
2212
|
+
try {
|
|
2213
|
+
await this._fetchFlagDefinitions();
|
|
2214
|
+
if (this.config.enable_polling && !this.pollingInterval) {
|
|
2215
|
+
this.pollingInterval = setInterval(async () => {
|
|
2216
|
+
try {
|
|
2217
|
+
await this._fetchFlagDefinitions();
|
|
2218
|
+
} catch (err) {
|
|
2219
|
+
this.logger?.error(`Error polling for flag definition: ${err.message}`);
|
|
2220
|
+
}
|
|
2221
|
+
}, this.config.polling_interval_in_seconds * 1e3);
|
|
2222
|
+
}
|
|
2223
|
+
} catch (err) {
|
|
2224
|
+
this.logger?.error(`Initial flag definitions fetch failed: ${err.message}`);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Stop polling for flag definitions
|
|
2229
|
+
*/
|
|
2230
|
+
stopPollingForDefinitions() {
|
|
2231
|
+
if (this.pollingInterval) {
|
|
2232
|
+
clearInterval(this.pollingInterval);
|
|
2233
|
+
this.pollingInterval = null;
|
|
2234
|
+
} else {
|
|
2235
|
+
this.logger?.warn("stopPollingForDefinitions called but polling was not active");
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
* Check if a feature flag is enabled
|
|
2240
|
+
* This method is intended only for flags defined as Mixpanel Feature Gates (boolean flags)
|
|
2241
|
+
* This checks that the variant value of a selected variant is concretely the boolean 'true'
|
|
2242
|
+
* It does not coerce other truthy values.
|
|
2243
|
+
* @param {string} flagKey - Feature flag key
|
|
2244
|
+
* @param {FlagContext} context - Evaluation context (must include distinct_id)
|
|
2245
|
+
* @returns {boolean}
|
|
2246
|
+
*/
|
|
2247
|
+
isEnabled(flagKey, context) {
|
|
2248
|
+
const value = this.getVariantValue(flagKey, false, context);
|
|
2249
|
+
return value === true;
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Get the variant value for a feature flag
|
|
2253
|
+
* @param {string} flagKey - Feature flag key
|
|
2254
|
+
* @param {*} fallbackValue - Value to return if the user context is not in the rollout for a flag or if evaluation fails
|
|
2255
|
+
* @param {FlagContext} context - Evaluation context
|
|
2256
|
+
* @param {boolean} [reportExposure=true] - Whether to track exposure event
|
|
2257
|
+
* @returns {*} The variant value
|
|
2258
|
+
*/
|
|
2259
|
+
getVariantValue(flagKey, fallbackValue, context, reportExposure = true) {
|
|
2260
|
+
const result = this.getVariant(flagKey, { variant_value: fallbackValue }, context, reportExposure);
|
|
2261
|
+
return result.variant_value;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Get the complete variant information for a feature flag
|
|
2265
|
+
* @param {string} flagKey - Feature flag key
|
|
2266
|
+
* @param {SelectedVariant} fallbackVariant - Variant to return if flag evaluation fails
|
|
2267
|
+
* @param {FlagContext} context - Evaluation context (must include distinct_id)
|
|
2268
|
+
* @param {boolean} [reportExposure=true] - Whether to track exposure event
|
|
2269
|
+
* @returns {SelectedVariant}
|
|
2270
|
+
*/
|
|
2271
|
+
getVariant(flagKey, fallbackVariant, context, reportExposure = true) {
|
|
2272
|
+
const flag = this.flagDefinitions.get(flagKey);
|
|
2273
|
+
if (!flag) {
|
|
2274
|
+
this.logger?.warn(`Cannot find flag definition for key: '${flagKey}`);
|
|
2275
|
+
return fallbackVariant;
|
|
2276
|
+
}
|
|
2277
|
+
if (!Object.hasOwn(context, flag.context)) {
|
|
2278
|
+
this.logger?.warn(
|
|
2279
|
+
`The variant assignment key, '${flag.context}' for flag, '${flagKey}' is not present in the supplied user context dictionary`
|
|
2280
|
+
);
|
|
2281
|
+
return fallbackVariant;
|
|
2282
|
+
}
|
|
2283
|
+
const contextValue = context[flag.context];
|
|
2284
|
+
let selectedVariant = null;
|
|
2285
|
+
const testUserVariant = this._getVariantOverrideForTestUser(flag, context);
|
|
2286
|
+
if (testUserVariant) {
|
|
2287
|
+
selectedVariant = testUserVariant;
|
|
2288
|
+
} else {
|
|
2289
|
+
const rollout = this._getAssignedRollout(flag, contextValue, context);
|
|
2290
|
+
if (rollout) {
|
|
2291
|
+
selectedVariant = this._getAssignedVariant(flag, contextValue, flagKey, rollout);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
if (selectedVariant) {
|
|
2295
|
+
if (reportExposure) {
|
|
2296
|
+
this.trackExposureEvent(flagKey, selectedVariant, context);
|
|
2297
|
+
}
|
|
2298
|
+
return selectedVariant;
|
|
2299
|
+
}
|
|
2300
|
+
return fallbackVariant;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Get all feature flag variants for the current user context
|
|
2304
|
+
* Exposure events are not automatically tracked when this method is used
|
|
2305
|
+
* @param {FlagContext} context - Evaluation context (must include distinct_id)
|
|
2306
|
+
* @returns {{[key: string]: SelectedVariant}}
|
|
2307
|
+
*/
|
|
2308
|
+
getAllVariants(context) {
|
|
2309
|
+
const variants = {};
|
|
2310
|
+
for (const flagKey of this.flagDefinitions.keys()) {
|
|
2311
|
+
const variant = this.getVariant(flagKey, null, context, false);
|
|
2312
|
+
if (variant !== null) {
|
|
2313
|
+
variants[flagKey] = variant;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
return variants;
|
|
2317
|
+
}
|
|
2318
|
+
/**
|
|
2319
|
+
* Fetch flag definitions from API.
|
|
2320
|
+
* @returns {Promise<LocalFlagsResponse>}
|
|
2321
|
+
*/
|
|
2322
|
+
async _fetchFlagDefinitions() {
|
|
2323
|
+
const response = await this.callFlagsEndpoint();
|
|
2324
|
+
const newDefinitions = /* @__PURE__ */ new Map();
|
|
2325
|
+
response.flags.forEach((flag) => {
|
|
2326
|
+
newDefinitions.set(flag.key, flag);
|
|
2327
|
+
});
|
|
2328
|
+
this.flagDefinitions = newDefinitions;
|
|
2329
|
+
return response;
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Find a variant by key (case-insensitive) and return complete SelectedVariant
|
|
2333
|
+
* @param {string} variantKey - Variant key to find
|
|
2334
|
+
* @param {ExperimentationFlag} flag - Flag definition
|
|
2335
|
+
* @returns {SelectedVariant|null}
|
|
2336
|
+
*/
|
|
2337
|
+
_getMatchingVariant(variantKey, flag) {
|
|
2338
|
+
for (const variant of flag.ruleset.variants) {
|
|
2339
|
+
if (variantKey.toLowerCase() === variant.key.toLowerCase()) {
|
|
2340
|
+
return {
|
|
2341
|
+
variant_key: variant.key,
|
|
2342
|
+
variant_value: variant.value,
|
|
2343
|
+
experiment_id: flag.experiment_id,
|
|
2344
|
+
is_experiment_active: flag.is_experiment_active
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return null;
|
|
2349
|
+
}
|
|
2350
|
+
_getVariantOverrideForTestUser(flag, context) {
|
|
2351
|
+
if (!flag.ruleset.test?.users) {
|
|
2352
|
+
return null;
|
|
2353
|
+
}
|
|
2354
|
+
const distinctId = context.distinct_id;
|
|
2355
|
+
if (!distinctId) {
|
|
2356
|
+
return null;
|
|
2357
|
+
}
|
|
2358
|
+
const variantKey = flag.ruleset.test.users[distinctId];
|
|
2359
|
+
if (!variantKey) {
|
|
2360
|
+
return null;
|
|
2361
|
+
}
|
|
2362
|
+
let selected_variant = this._getMatchingVariant(variantKey, flag);
|
|
2363
|
+
if (selected_variant) {
|
|
2364
|
+
selected_variant.is_qa_tester = true;
|
|
2365
|
+
}
|
|
2366
|
+
return selected_variant;
|
|
2367
|
+
}
|
|
2368
|
+
_getAssignedRollout(flag, contextValue, context) {
|
|
2369
|
+
for (let index = 0; index < flag.ruleset.rollout.length; index++) {
|
|
2370
|
+
const rollout = flag.ruleset.rollout[index];
|
|
2371
|
+
let salt;
|
|
2372
|
+
if (flag.hash_salt !== null && flag.hash_salt !== void 0) {
|
|
2373
|
+
salt = flag.key + flag.hash_salt + index.toString();
|
|
2374
|
+
} else {
|
|
2375
|
+
salt = flag.key + "rollout";
|
|
2376
|
+
}
|
|
2377
|
+
const rolloutHash = normalizedHash(String(contextValue), salt);
|
|
2378
|
+
if (rolloutHash < rollout.rollout_percentage && this._isRuntimeEvaluationSatisfied(rollout, context)) {
|
|
2379
|
+
return rollout;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
return null;
|
|
2383
|
+
}
|
|
2384
|
+
_getAssignedVariant(flag, contextValue, flagKey, rollout) {
|
|
2385
|
+
if (rollout.variant_override) {
|
|
2386
|
+
const variant = this._getMatchingVariant(rollout.variant_override.key, flag);
|
|
2387
|
+
if (variant) {
|
|
2388
|
+
return { ...variant, is_qa_tester: false };
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
const storedSalt = flag.hash_salt !== null && flag.hash_salt !== void 0 ? flag.hash_salt : "";
|
|
2392
|
+
const salt = flagKey + storedSalt + "variant";
|
|
2393
|
+
const variantHash = normalizedHash(String(contextValue), salt);
|
|
2394
|
+
const variants = flag.ruleset.variants.map((v) => ({ ...v }));
|
|
2395
|
+
if (rollout.variant_splits) {
|
|
2396
|
+
for (const variant of variants) {
|
|
2397
|
+
if (variant.key in rollout.variant_splits) {
|
|
2398
|
+
variant.split = rollout.variant_splits[variant.key];
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
let selected = variants[0];
|
|
2403
|
+
let cumulative = 0;
|
|
2404
|
+
for (const variant of variants) {
|
|
2405
|
+
selected = variant;
|
|
2406
|
+
cumulative += variant.split || 0;
|
|
2407
|
+
if (variantHash < cumulative) {
|
|
2408
|
+
break;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return {
|
|
2412
|
+
variant_key: selected.key,
|
|
2413
|
+
variant_value: selected.value,
|
|
2414
|
+
experiment_id: flag.experiment_id,
|
|
2415
|
+
is_experiment_active: flag.is_experiment_active,
|
|
2416
|
+
is_qa_tester: false
|
|
2417
|
+
};
|
|
2418
|
+
}
|
|
2419
|
+
_isRuntimeEvaluationSatisfied(rollout, context) {
|
|
2420
|
+
if (!rollout.runtime_evaluation_definition) {
|
|
2421
|
+
return true;
|
|
2422
|
+
}
|
|
2423
|
+
const customProperties = context.custom_properties;
|
|
2424
|
+
if (!customProperties || typeof customProperties !== "object") {
|
|
2425
|
+
return false;
|
|
2426
|
+
}
|
|
2427
|
+
for (const [key, expectedValue] of Object.entries(rollout.runtime_evaluation_definition)) {
|
|
2428
|
+
if (!(key in customProperties)) {
|
|
2429
|
+
return false;
|
|
2430
|
+
}
|
|
2431
|
+
const actualValue = customProperties[key];
|
|
2432
|
+
if (String(actualValue).toLowerCase() !== String(expectedValue).toLowerCase()) {
|
|
2433
|
+
return false;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
return true;
|
|
2437
|
+
}
|
|
2438
|
+
};
|
|
2439
|
+
module.exports = LocalFeatureFlagsProvider;
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
|
|
2443
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/remote_flags.js
|
|
2444
|
+
var require_remote_flags = __commonJS({
|
|
2445
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/remote_flags.js"(exports$1, module) {
|
|
2446
|
+
var FeatureFlagsProvider = require_flags();
|
|
2447
|
+
var RemoteFeatureFlagsProvider = class extends FeatureFlagsProvider {
|
|
2448
|
+
/**
|
|
2449
|
+
* @param {string} token - Mixpanel project token
|
|
2450
|
+
* @param {RemoteFlagsConfig} config - Remote flags configuration
|
|
2451
|
+
* @param {Function} tracker - Function to track events (signature: track(distinct_id, event, properties, callback))
|
|
2452
|
+
* @param {CustomLogger} logger - Logger instance
|
|
2453
|
+
*/
|
|
2454
|
+
constructor(token, config, tracker, logger) {
|
|
2455
|
+
const mergedConfig = {
|
|
2456
|
+
api_host: "api.mixpanel.com",
|
|
2457
|
+
request_timeout_in_seconds: 10,
|
|
2458
|
+
...config
|
|
2459
|
+
};
|
|
2460
|
+
const providerConfig = {
|
|
2461
|
+
token,
|
|
2462
|
+
api_host: mergedConfig.api_host,
|
|
2463
|
+
request_timeout_in_seconds: mergedConfig.request_timeout_in_seconds
|
|
2464
|
+
};
|
|
2465
|
+
super(providerConfig, "/flags", tracker, "remote", logger);
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Get the variant value for a feature flag
|
|
2469
|
+
* If the user context is eligible for the rollout, one of the flag variants will be selected and an exposure event will be tracked to Mixpanel.
|
|
2470
|
+
* If the user context is not eligible, the fallback value is returned.
|
|
2471
|
+
* @param {string} flagKey - Feature flag key
|
|
2472
|
+
* @param {*} fallbackValue - Value to return if flag evaluation fails
|
|
2473
|
+
* @param {FlagContext} context - Evaluation context
|
|
2474
|
+
* @param {boolean} reportExposure - Whether to track exposure event
|
|
2475
|
+
* @returns {Promise<*>} - Variant value
|
|
2476
|
+
*/
|
|
2477
|
+
async getVariantValue(flagKey, fallbackValue, context, reportExposure = true) {
|
|
2478
|
+
try {
|
|
2479
|
+
const selectedVariant = await this.getVariant(flagKey, { variant_value: fallbackValue }, context, reportExposure);
|
|
2480
|
+
return selectedVariant.variant_value;
|
|
2481
|
+
} catch (err) {
|
|
2482
|
+
this.logger?.error(`Failed to get variant value for flag '${flagKey}': ${err.message}`);
|
|
2483
|
+
return fallbackValue;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Get the complete variant information for a feature flag
|
|
2488
|
+
* If the user context is eligible for the rollout, one of the flag variants will be selected and an exposure event will be tracked to Mixpanel.
|
|
2489
|
+
* If the user context is not eligible, the fallback value is returned.
|
|
2490
|
+
* @param {string} flagKey - Feature flag key
|
|
2491
|
+
* @param {SelectedVariant} fallbackVariant - Variant to return if flag evaluation fails
|
|
2492
|
+
* @param {FlagContext} context - Evaluation context
|
|
2493
|
+
* @param {boolean} reportExposure - Whether to track exposure event in the event that the user context is eligible for the rollout.
|
|
2494
|
+
* @returns {Promise<SelectedVariant>} - Selected variant
|
|
2495
|
+
*/
|
|
2496
|
+
async getVariant(flagKey, fallbackVariant, context, reportExposure = true) {
|
|
2497
|
+
try {
|
|
2498
|
+
const startTime = Date.now();
|
|
2499
|
+
const response = await this._fetchFlags(context, flagKey);
|
|
2500
|
+
const latencyMs = Date.now() - startTime;
|
|
2501
|
+
const flags = response.flags || {};
|
|
2502
|
+
const selectedVariant = flags[flagKey];
|
|
2503
|
+
if (!selectedVariant) {
|
|
2504
|
+
return fallbackVariant;
|
|
2505
|
+
}
|
|
2506
|
+
if (reportExposure) {
|
|
2507
|
+
this.trackExposureEvent(flagKey, selectedVariant, context, latencyMs);
|
|
2508
|
+
}
|
|
2509
|
+
return selectedVariant;
|
|
2510
|
+
} catch (err) {
|
|
2511
|
+
this.logger?.error(`Failed to get variant for flag '${flagKey}': ${err.message}`);
|
|
2512
|
+
return fallbackVariant;
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* This method is intended only for flags defined as Mixpanel Feature Gates (boolean flags)
|
|
2517
|
+
* This checks that the variant value of a selected variant is concretely the boolean 'true'
|
|
2518
|
+
* It does not coerce other truthy values.
|
|
2519
|
+
* @param {string} flagKey - Feature flag key
|
|
2520
|
+
* @param {FlagContext} context - User's evaluation context
|
|
2521
|
+
* @returns {Promise<boolean>} - Whether the flag is enabled
|
|
2522
|
+
*/
|
|
2523
|
+
async isEnabled(flagKey, context) {
|
|
2524
|
+
try {
|
|
2525
|
+
const value = await this.getVariantValue(flagKey, false, context);
|
|
2526
|
+
return value === true;
|
|
2527
|
+
} catch (err) {
|
|
2528
|
+
this.logger?.error(`Failed to check if flag '${flagKey}' is enabled: ${err.message}`);
|
|
2529
|
+
return false;
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
/**
|
|
2533
|
+
* Get all feature flag variants for the current user context from remote server
|
|
2534
|
+
* Exposure events are not automatically tracked when this method is used
|
|
2535
|
+
* @param {FlagContext} context - User's evaluation context
|
|
2536
|
+
* @returns {Promise<{[key: string]: SelectedVariant}|null>} - Dictionary mapping flag keys to variants, or null if the call fails
|
|
2537
|
+
*/
|
|
2538
|
+
async getAllVariants(context) {
|
|
2539
|
+
try {
|
|
2540
|
+
const response = await this._fetchFlags(context);
|
|
2541
|
+
return response.flags || {};
|
|
2542
|
+
} catch (err) {
|
|
2543
|
+
this.logger?.error(`Failed to get all remote variants: ${err.message}`);
|
|
2544
|
+
return null;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Fetch flags from remote flags evaluation API
|
|
2549
|
+
* @param {FlagContext} context - Evaluation context
|
|
2550
|
+
* @param {string} [flagKey] - Optional flag key (if omitted, fetches all flags)
|
|
2551
|
+
* @returns {Promise<RemoteFlagsResponse>} - API response containing flags dictionary
|
|
2552
|
+
*/
|
|
2553
|
+
_fetchFlags(context, flagKey = null) {
|
|
2554
|
+
const additionalParams = {
|
|
2555
|
+
context: JSON.stringify(context)
|
|
2556
|
+
};
|
|
2557
|
+
if (flagKey !== null) {
|
|
2558
|
+
additionalParams.flag_key = flagKey;
|
|
2559
|
+
}
|
|
2560
|
+
return this.callFlagsEndpoint(additionalParams);
|
|
2561
|
+
}
|
|
2562
|
+
};
|
|
2563
|
+
module.exports = RemoteFeatureFlagsProvider;
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
|
|
2567
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/index.js
|
|
2568
|
+
var require_flags2 = __commonJS({
|
|
2569
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/index.js"(exports$1, module) {
|
|
2570
|
+
var LocalFeatureFlagsProvider = require_local_flags();
|
|
2571
|
+
var RemoteFeatureFlagsProvider = require_remote_flags();
|
|
2572
|
+
module.exports = {
|
|
2573
|
+
LocalFeatureFlagsProvider,
|
|
2574
|
+
RemoteFeatureFlagsProvider
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2578
|
+
|
|
2579
|
+
// ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/mixpanel-node.js
|
|
2580
|
+
var require_mixpanel_node = __commonJS({
|
|
2581
|
+
"../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/mixpanel-node.js"(exports$1, module) {
|
|
2582
|
+
var querystring = __require("querystring");
|
|
2583
|
+
var Buffer2 = __require("buffer").Buffer;
|
|
2584
|
+
var http = __require("http");
|
|
2585
|
+
var https = __require("https");
|
|
2586
|
+
var HttpsProxyAgent = require_dist2();
|
|
2587
|
+
var url = __require("url");
|
|
2588
|
+
var packageInfo = require_package();
|
|
2589
|
+
var { async_all, ensure_timestamp, assert_logger } = require_utils();
|
|
2590
|
+
var { MixpanelGroups } = require_groups();
|
|
2591
|
+
var { MixpanelPeople } = require_people();
|
|
2592
|
+
var { LocalFeatureFlagsProvider, RemoteFeatureFlagsProvider } = require_flags2();
|
|
2593
|
+
var DEFAULT_CONFIG = {
|
|
2594
|
+
test: false,
|
|
2595
|
+
debug: false,
|
|
2596
|
+
verbose: false,
|
|
2597
|
+
host: "api.mixpanel.com",
|
|
2598
|
+
protocol: "https",
|
|
2599
|
+
path: "",
|
|
2600
|
+
keepAlive: true,
|
|
2601
|
+
// set this to true to automatically geolocate based on the client's ip.
|
|
2602
|
+
// e.g., when running under electron
|
|
2603
|
+
geolocate: false,
|
|
2604
|
+
logger: console
|
|
2605
|
+
};
|
|
2606
|
+
var create_client = function(token, config) {
|
|
2607
|
+
if (!token) {
|
|
2608
|
+
throw new Error("The Mixpanel Client needs a Mixpanel token: `init(token)`");
|
|
2609
|
+
}
|
|
2610
|
+
const metrics = {
|
|
2611
|
+
token,
|
|
2612
|
+
config: { ...DEFAULT_CONFIG }
|
|
2613
|
+
};
|
|
2614
|
+
const { keepAlive } = metrics.config;
|
|
2615
|
+
const MAX_BATCH_SIZE = 50;
|
|
2616
|
+
const REQUEST_LIBS = { http, https };
|
|
2617
|
+
const REQUEST_AGENTS = {
|
|
2618
|
+
http: new http.Agent({ keepAlive }),
|
|
2619
|
+
https: new https.Agent({ keepAlive })
|
|
2620
|
+
};
|
|
2621
|
+
const proxyPath = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
|
2622
|
+
const proxyAgent = proxyPath ? new HttpsProxyAgent(Object.assign(url.parse(proxyPath), {
|
|
2623
|
+
keepAlive
|
|
2624
|
+
})) : null;
|
|
2625
|
+
metrics.send_request = function(options, callback) {
|
|
2626
|
+
callback = callback || function() {
|
|
2627
|
+
};
|
|
2628
|
+
let content = Buffer2.from(JSON.stringify(options.data)).toString("base64");
|
|
2629
|
+
const endpoint = options.endpoint;
|
|
2630
|
+
const method = (options.method || "GET").toUpperCase();
|
|
2631
|
+
let query_params = {
|
|
2632
|
+
"ip": metrics.config.geolocate ? 1 : 0,
|
|
2633
|
+
"verbose": metrics.config.verbose ? 1 : 0
|
|
2634
|
+
};
|
|
2635
|
+
const key = metrics.config.key;
|
|
2636
|
+
const secret = metrics.config.secret;
|
|
2637
|
+
const request_lib = REQUEST_LIBS[metrics.config.protocol];
|
|
2638
|
+
let request_options = {
|
|
2639
|
+
host: metrics.config.host,
|
|
2640
|
+
port: metrics.config.port,
|
|
2641
|
+
headers: {},
|
|
2642
|
+
method
|
|
2643
|
+
};
|
|
2644
|
+
let request;
|
|
2645
|
+
if (!request_lib) {
|
|
2646
|
+
throw new Error(
|
|
2647
|
+
"Mixpanel Initialization Error: Unsupported protocol " + metrics.config.protocol + ". Supported protocols are: " + Object.keys(REQUEST_LIBS)
|
|
2648
|
+
);
|
|
2649
|
+
}
|
|
2650
|
+
if (method === "POST") {
|
|
2651
|
+
content = "data=" + content;
|
|
2652
|
+
request_options.headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
2653
|
+
request_options.headers["Content-Length"] = Buffer2.byteLength(content);
|
|
2654
|
+
} else if (method === "GET") {
|
|
2655
|
+
query_params.data = content;
|
|
2656
|
+
}
|
|
2657
|
+
if (secret) {
|
|
2658
|
+
if (request_lib !== https) {
|
|
2659
|
+
throw new Error("Must use HTTPS if authenticating with API Secret");
|
|
2660
|
+
}
|
|
2661
|
+
const encoded = Buffer2.from(secret + ":").toString("base64");
|
|
2662
|
+
request_options.headers["Authorization"] = "Basic " + encoded;
|
|
2663
|
+
} else if (key) {
|
|
2664
|
+
query_params.api_key = key;
|
|
2665
|
+
} else if (endpoint === "/import") {
|
|
2666
|
+
throw new Error("The Mixpanel Client needs a Mixpanel API Secret when importing old events: `init(token, { secret: ... })`");
|
|
2667
|
+
}
|
|
2668
|
+
request_options.agent = proxyAgent || REQUEST_AGENTS[metrics.config.protocol];
|
|
2669
|
+
if (metrics.config.test) {
|
|
2670
|
+
query_params.test = 1;
|
|
2671
|
+
}
|
|
2672
|
+
request_options.path = metrics.config.path + endpoint + "?" + querystring.stringify(query_params);
|
|
2673
|
+
request = request_lib.request(request_options, function(res) {
|
|
2674
|
+
var data = "";
|
|
2675
|
+
res.on("data", function(chunk2) {
|
|
2676
|
+
data += chunk2;
|
|
2677
|
+
});
|
|
2678
|
+
res.on("end", function() {
|
|
2679
|
+
var e;
|
|
2680
|
+
if (metrics.config.verbose) {
|
|
2681
|
+
try {
|
|
2682
|
+
var result = JSON.parse(data);
|
|
2683
|
+
if (result.status != 1) {
|
|
2684
|
+
e = new Error("Mixpanel Server Error: " + result.error);
|
|
2685
|
+
}
|
|
2686
|
+
} catch (ex) {
|
|
2687
|
+
e = new Error("Could not parse response from Mixpanel");
|
|
2688
|
+
}
|
|
2689
|
+
} else {
|
|
2690
|
+
e = data !== "1" ? new Error("Mixpanel Server Error: " + data) : void 0;
|
|
2691
|
+
}
|
|
2692
|
+
callback(e);
|
|
2693
|
+
});
|
|
2694
|
+
});
|
|
2695
|
+
request.on("error", function(e) {
|
|
2696
|
+
if (metrics.config.debug) {
|
|
2697
|
+
metrics.config.logger.error("Got Error: " + e.message);
|
|
2698
|
+
}
|
|
2699
|
+
callback(e);
|
|
2700
|
+
});
|
|
2701
|
+
if (method === "POST") {
|
|
2702
|
+
request.write(content);
|
|
2703
|
+
}
|
|
2704
|
+
request.end();
|
|
2705
|
+
};
|
|
2706
|
+
metrics.send_event_request = function(endpoint, event, properties, callback) {
|
|
2707
|
+
properties.token = metrics.token;
|
|
2708
|
+
properties.mp_lib = "node";
|
|
2709
|
+
properties.$lib_version = packageInfo.version;
|
|
2710
|
+
var data = {
|
|
2711
|
+
event,
|
|
2712
|
+
properties
|
|
2713
|
+
};
|
|
2714
|
+
if (metrics.config.debug) {
|
|
2715
|
+
metrics.config.logger.debug("Sending the following event to Mixpanel", { data });
|
|
2716
|
+
}
|
|
2717
|
+
metrics.send_request({ method: "GET", endpoint, data }, callback);
|
|
2718
|
+
};
|
|
2719
|
+
var chunk = function(arr, size) {
|
|
2720
|
+
var chunks = [], i = 0, total = arr.length;
|
|
2721
|
+
while (i < total) {
|
|
2722
|
+
chunks.push(arr.slice(i, i += size));
|
|
2723
|
+
}
|
|
2724
|
+
return chunks;
|
|
2725
|
+
};
|
|
2726
|
+
var send_batch_requests = function(options, callback) {
|
|
2727
|
+
var event_list = options.event_list, endpoint = options.endpoint, max_batch_size = options.max_batch_size ? Math.min(MAX_BATCH_SIZE, options.max_batch_size) : MAX_BATCH_SIZE, max_concurrent_requests = options.max_concurrent_requests || options.max_batch_size > MAX_BATCH_SIZE && Math.ceil(options.max_batch_size / MAX_BATCH_SIZE), event_batches = chunk(event_list, max_batch_size), request_batches = max_concurrent_requests ? chunk(event_batches, max_concurrent_requests) : [event_batches], total_event_batches = event_batches.length, total_request_batches = request_batches.length;
|
|
2728
|
+
function send_event_batch(batch, cb) {
|
|
2729
|
+
if (batch.length > 0) {
|
|
2730
|
+
batch = batch.map(function(event) {
|
|
2731
|
+
event.properties;
|
|
2732
|
+
if (endpoint === "/import" || event.properties.time) {
|
|
2733
|
+
event.properties.time = ensure_timestamp(event.properties.time);
|
|
2734
|
+
}
|
|
2735
|
+
event.properties.token = event.properties.token || metrics.token;
|
|
2736
|
+
return event;
|
|
2737
|
+
});
|
|
2738
|
+
metrics.send_request({ method: "POST", endpoint, data: batch }, cb);
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
function send_next_request_batch(index) {
|
|
2742
|
+
var request_batch = request_batches[index], cb = function(errors, results) {
|
|
2743
|
+
index += 1;
|
|
2744
|
+
if (index === total_request_batches) {
|
|
2745
|
+
callback && callback(errors, results);
|
|
2746
|
+
} else {
|
|
2747
|
+
send_next_request_batch(index);
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
async_all(request_batch, send_event_batch, cb);
|
|
2751
|
+
}
|
|
2752
|
+
send_next_request_batch(0);
|
|
2753
|
+
if (metrics.config.debug) {
|
|
2754
|
+
metrics.config.logger.debug(
|
|
2755
|
+
"Sending " + event_list.length + " events to Mixpanel in " + total_event_batches + " batches of events and " + total_request_batches + " batches of requests"
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
metrics.track = function(event, properties, callback) {
|
|
2760
|
+
if (!properties || typeof properties === "function") {
|
|
2761
|
+
callback = properties;
|
|
2762
|
+
properties = {};
|
|
2763
|
+
}
|
|
2764
|
+
if (properties.time) {
|
|
2765
|
+
properties.time = ensure_timestamp(properties.time);
|
|
2766
|
+
}
|
|
2767
|
+
metrics.send_event_request("/track", event, properties, callback);
|
|
2768
|
+
};
|
|
2769
|
+
metrics.track_batch = function(event_list, options, callback) {
|
|
2770
|
+
options = options || {};
|
|
2771
|
+
if (typeof options === "function") {
|
|
2772
|
+
callback = options;
|
|
2773
|
+
options = {};
|
|
2774
|
+
}
|
|
2775
|
+
var batch_options = {
|
|
2776
|
+
event_list,
|
|
2777
|
+
endpoint: "/track",
|
|
2778
|
+
max_concurrent_requests: options.max_concurrent_requests,
|
|
2779
|
+
max_batch_size: options.max_batch_size
|
|
2780
|
+
};
|
|
2781
|
+
send_batch_requests(batch_options, callback);
|
|
2782
|
+
};
|
|
2783
|
+
metrics.import = function(event, time, properties, callback) {
|
|
2784
|
+
if (!properties || typeof properties === "function") {
|
|
2785
|
+
callback = properties;
|
|
2786
|
+
properties = {};
|
|
2787
|
+
}
|
|
2788
|
+
properties.time = ensure_timestamp(time);
|
|
2789
|
+
metrics.send_event_request("/import", event, properties, callback);
|
|
2790
|
+
};
|
|
2791
|
+
metrics.import_batch = function(event_list, options, callback) {
|
|
2792
|
+
var batch_options;
|
|
2793
|
+
if (typeof options === "function" || !options) {
|
|
2794
|
+
callback = options;
|
|
2795
|
+
options = {};
|
|
2796
|
+
}
|
|
2797
|
+
batch_options = {
|
|
2798
|
+
event_list,
|
|
2799
|
+
endpoint: "/import",
|
|
2800
|
+
max_concurrent_requests: options.max_concurrent_requests,
|
|
2801
|
+
max_batch_size: options.max_batch_size
|
|
2802
|
+
};
|
|
2803
|
+
send_batch_requests(batch_options, callback);
|
|
2804
|
+
};
|
|
2805
|
+
metrics.alias = function(distinct_id, alias, callback) {
|
|
2806
|
+
var properties = {
|
|
2807
|
+
distinct_id,
|
|
2808
|
+
alias
|
|
2809
|
+
};
|
|
2810
|
+
metrics.track("$create_alias", properties, callback);
|
|
2811
|
+
};
|
|
2812
|
+
metrics.groups = new MixpanelGroups(metrics);
|
|
2813
|
+
metrics.people = new MixpanelPeople(metrics);
|
|
2814
|
+
metrics.set_config = function(config2) {
|
|
2815
|
+
if (config2 && config2.logger !== void 0) {
|
|
2816
|
+
assert_logger(config2.logger);
|
|
2817
|
+
}
|
|
2818
|
+
Object.assign(metrics.config, config2);
|
|
2819
|
+
if (config2.host) {
|
|
2820
|
+
const [host, port] = config2.host.split(":");
|
|
2821
|
+
metrics.config.host = host;
|
|
2822
|
+
if (port) {
|
|
2823
|
+
metrics.config.port = Number(port);
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2827
|
+
if (config) {
|
|
2828
|
+
metrics.set_config(config);
|
|
2829
|
+
}
|
|
2830
|
+
if (config && config.local_flags_config) {
|
|
2831
|
+
metrics.local_flags = new LocalFeatureFlagsProvider(
|
|
2832
|
+
token,
|
|
2833
|
+
config.local_flags_config,
|
|
2834
|
+
metrics.track.bind(metrics),
|
|
2835
|
+
config.logger
|
|
2836
|
+
);
|
|
2837
|
+
}
|
|
2838
|
+
if (config && config.remote_flags_config) {
|
|
2839
|
+
metrics.remote_flags = new RemoteFeatureFlagsProvider(
|
|
2840
|
+
token,
|
|
2841
|
+
config.remote_flags_config,
|
|
2842
|
+
metrics.track.bind(metrics),
|
|
2843
|
+
config.logger
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2846
|
+
return metrics;
|
|
2847
|
+
};
|
|
2848
|
+
module.exports = {
|
|
2849
|
+
init: create_client
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
});
|
|
2853
|
+
|
|
2854
|
+
// src/mixpanel.ts
|
|
2855
|
+
var MixpanelSubscriber = class {
|
|
2856
|
+
name = "MixpanelSubscriber";
|
|
2857
|
+
version = "1.0.0";
|
|
2858
|
+
mixpanel;
|
|
2859
|
+
enabled;
|
|
2860
|
+
config;
|
|
2861
|
+
initPromise = null;
|
|
2862
|
+
constructor(config) {
|
|
2863
|
+
this.enabled = config.enabled ?? true;
|
|
2864
|
+
this.config = config;
|
|
2865
|
+
if (this.enabled) {
|
|
2866
|
+
this.initPromise = this.initialize();
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
async initialize() {
|
|
2870
|
+
try {
|
|
2871
|
+
const Mixpanel = await Promise.resolve().then(() => __toESM(require_mixpanel_node(), 1));
|
|
2872
|
+
this.mixpanel = Mixpanel.default.init(this.config.token);
|
|
2873
|
+
} catch (error) {
|
|
2874
|
+
console.error(
|
|
2875
|
+
"Mixpanel subscriber failed to initialize. Install mixpanel: pnpm add mixpanel",
|
|
2876
|
+
error
|
|
2877
|
+
);
|
|
2878
|
+
this.enabled = false;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
async ensureInitialized() {
|
|
2882
|
+
if (this.initPromise) {
|
|
2883
|
+
await this.initPromise;
|
|
2884
|
+
this.initPromise = null;
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
async trackEvent(name, attributes) {
|
|
2888
|
+
if (!this.enabled) return;
|
|
2889
|
+
await this.ensureInitialized();
|
|
2890
|
+
const distinctId = attributes?.userId || attributes?.user_id || "anonymous";
|
|
2891
|
+
this.mixpanel?.track(name, {
|
|
2892
|
+
distinct_id: distinctId,
|
|
2893
|
+
...attributes
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
async trackFunnelStep(funnelName, step, attributes) {
|
|
2897
|
+
if (!this.enabled) return;
|
|
2898
|
+
await this.ensureInitialized();
|
|
2899
|
+
const distinctId = attributes?.userId || attributes?.user_id || "anonymous";
|
|
2900
|
+
this.mixpanel?.track(`${funnelName}.${step}`, {
|
|
2901
|
+
distinct_id: distinctId,
|
|
2902
|
+
funnel: funnelName,
|
|
2903
|
+
step,
|
|
2904
|
+
...attributes
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
async trackOutcome(operationName, outcome, attributes) {
|
|
2908
|
+
if (!this.enabled) return;
|
|
2909
|
+
await this.ensureInitialized();
|
|
2910
|
+
const distinctId = attributes?.userId || attributes?.user_id || "anonymous";
|
|
2911
|
+
this.mixpanel?.track(`${operationName}.${outcome}`, {
|
|
2912
|
+
distinct_id: distinctId,
|
|
2913
|
+
operation: operationName,
|
|
2914
|
+
outcome,
|
|
2915
|
+
...attributes
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
async trackValue(name, value, attributes) {
|
|
2919
|
+
if (!this.enabled) return;
|
|
2920
|
+
await this.ensureInitialized();
|
|
2921
|
+
const distinctId = attributes?.userId || attributes?.user_id || "anonymous";
|
|
2922
|
+
this.mixpanel?.track(name, {
|
|
2923
|
+
distinct_id: distinctId,
|
|
2924
|
+
value,
|
|
2925
|
+
...attributes
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
};
|
|
2929
|
+
|
|
2930
|
+
export { MixpanelSubscriber };
|
|
2931
|
+
//# sourceMappingURL=mixpanel.js.map
|
|
2932
|
+
//# sourceMappingURL=mixpanel.js.map
|