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
|
@@ -0,0 +1,2486 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var http = require('http');
|
|
4
|
+
var https = require('https');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var http__namespace = /*#__PURE__*/_interopNamespace(http);
|
|
25
|
+
var https__namespace = /*#__PURE__*/_interopNamespace(https);
|
|
26
|
+
|
|
27
|
+
var __defProp = Object.defineProperty;
|
|
28
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
29
|
+
var __esm = (fn, res) => function __init() {
|
|
30
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
31
|
+
};
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
38
|
+
function __extends(d, b) {
|
|
39
|
+
if (typeof b !== "function" && b !== null)
|
|
40
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
41
|
+
extendStatics(d, b);
|
|
42
|
+
function __() {
|
|
43
|
+
this.constructor = d;
|
|
44
|
+
}
|
|
45
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
46
|
+
}
|
|
47
|
+
function __rest(s, e) {
|
|
48
|
+
var t = {};
|
|
49
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
50
|
+
t[p] = s[p];
|
|
51
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
52
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
53
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
54
|
+
t[p[i]] = s[p[i]];
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
}
|
|
58
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
59
|
+
function adopt(value) {
|
|
60
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
61
|
+
resolve(value);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
65
|
+
function fulfilled(value) {
|
|
66
|
+
try {
|
|
67
|
+
step(generator.next(value));
|
|
68
|
+
} catch (e) {
|
|
69
|
+
reject(e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function rejected(value) {
|
|
73
|
+
try {
|
|
74
|
+
step(generator["throw"](value));
|
|
75
|
+
} catch (e) {
|
|
76
|
+
reject(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function step(result) {
|
|
80
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
81
|
+
}
|
|
82
|
+
step((generator = generator.apply(thisArg, [])).next());
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function __generator(thisArg, body) {
|
|
86
|
+
var _ = { label: 0, sent: function() {
|
|
87
|
+
if (t[0] & 1) throw t[1];
|
|
88
|
+
return t[1];
|
|
89
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
90
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
91
|
+
return this;
|
|
92
|
+
}), g;
|
|
93
|
+
function verb(n) {
|
|
94
|
+
return function(v) {
|
|
95
|
+
return step([n, v]);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function step(op) {
|
|
99
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
100
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
101
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
102
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
103
|
+
switch (op[0]) {
|
|
104
|
+
case 0:
|
|
105
|
+
case 1:
|
|
106
|
+
t = op;
|
|
107
|
+
break;
|
|
108
|
+
case 4:
|
|
109
|
+
_.label++;
|
|
110
|
+
return { value: op[1], done: false };
|
|
111
|
+
case 5:
|
|
112
|
+
_.label++;
|
|
113
|
+
y = op[1];
|
|
114
|
+
op = [0];
|
|
115
|
+
continue;
|
|
116
|
+
case 7:
|
|
117
|
+
op = _.ops.pop();
|
|
118
|
+
_.trys.pop();
|
|
119
|
+
continue;
|
|
120
|
+
default:
|
|
121
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
122
|
+
_ = 0;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
126
|
+
_.label = op[1];
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
130
|
+
_.label = t[1];
|
|
131
|
+
t = op;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (t && _.label < t[2]) {
|
|
135
|
+
_.label = t[2];
|
|
136
|
+
_.ops.push(op);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (t[2]) _.ops.pop();
|
|
140
|
+
_.trys.pop();
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
op = body.call(thisArg, _);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
op = [6, e];
|
|
146
|
+
y = 0;
|
|
147
|
+
} finally {
|
|
148
|
+
f = t = 0;
|
|
149
|
+
}
|
|
150
|
+
if (op[0] & 5) throw op[1];
|
|
151
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function __values(o) {
|
|
155
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
156
|
+
if (m) return m.call(o);
|
|
157
|
+
if (o && typeof o.length === "number") return {
|
|
158
|
+
next: function() {
|
|
159
|
+
if (o && i >= o.length) o = void 0;
|
|
160
|
+
return { value: o && o[i++], done: !o };
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
164
|
+
}
|
|
165
|
+
function __read(o, n) {
|
|
166
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
167
|
+
if (!m) return o;
|
|
168
|
+
var i = m.call(o), r, ar = [], e;
|
|
169
|
+
try {
|
|
170
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
e = { error };
|
|
173
|
+
} finally {
|
|
174
|
+
try {
|
|
175
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
176
|
+
} finally {
|
|
177
|
+
if (e) throw e.error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return ar;
|
|
181
|
+
}
|
|
182
|
+
function __spreadArray(to, from, pack) {
|
|
183
|
+
if (arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
184
|
+
if (ar || !(i in from)) {
|
|
185
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
186
|
+
ar[i] = from[i];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
190
|
+
}
|
|
191
|
+
var extendStatics, __assign;
|
|
192
|
+
var init_tslib_es6 = __esm({
|
|
193
|
+
"../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"() {
|
|
194
|
+
extendStatics = function(d, b) {
|
|
195
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
196
|
+
d2.__proto__ = b2;
|
|
197
|
+
} || function(d2, b2) {
|
|
198
|
+
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
199
|
+
};
|
|
200
|
+
return extendStatics(d, b);
|
|
201
|
+
};
|
|
202
|
+
__assign = function() {
|
|
203
|
+
__assign = Object.assign || function __assign2(t) {
|
|
204
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
205
|
+
s = arguments[i];
|
|
206
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
207
|
+
}
|
|
208
|
+
return t;
|
|
209
|
+
};
|
|
210
|
+
return __assign.apply(this, arguments);
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/event/event.js
|
|
216
|
+
var IdentifyOperation, SpecialEventType;
|
|
217
|
+
var init_event = __esm({
|
|
218
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/event/event.js"() {
|
|
219
|
+
(function(IdentifyOperation3) {
|
|
220
|
+
IdentifyOperation3["SET"] = "$set";
|
|
221
|
+
IdentifyOperation3["SET_ONCE"] = "$setOnce";
|
|
222
|
+
IdentifyOperation3["ADD"] = "$add";
|
|
223
|
+
IdentifyOperation3["APPEND"] = "$append";
|
|
224
|
+
IdentifyOperation3["PREPEND"] = "$prepend";
|
|
225
|
+
IdentifyOperation3["REMOVE"] = "$remove";
|
|
226
|
+
IdentifyOperation3["PREINSERT"] = "$preInsert";
|
|
227
|
+
IdentifyOperation3["POSTINSERT"] = "$postInsert";
|
|
228
|
+
IdentifyOperation3["UNSET"] = "$unset";
|
|
229
|
+
IdentifyOperation3["CLEAR_ALL"] = "$clearAll";
|
|
230
|
+
})(IdentifyOperation || (IdentifyOperation = {}));
|
|
231
|
+
(function(SpecialEventType2) {
|
|
232
|
+
SpecialEventType2["IDENTIFY"] = "$identify";
|
|
233
|
+
SpecialEventType2["GROUP_IDENTIFY"] = "$groupidentify";
|
|
234
|
+
SpecialEventType2["REVENUE"] = "revenue_amount";
|
|
235
|
+
})(SpecialEventType || (SpecialEventType = {}));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/constants.js
|
|
240
|
+
var UNSET_VALUE, AMPLITUDE_PREFIX, STORAGE_PREFIX, DEFAULT_INSTANCE_NAME, AMPLITUDE_SERVER_URL, EU_AMPLITUDE_SERVER_URL, AMPLITUDE_BATCH_SERVER_URL, EU_AMPLITUDE_BATCH_SERVER_URL;
|
|
241
|
+
var init_constants = __esm({
|
|
242
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/constants.js"() {
|
|
243
|
+
UNSET_VALUE = "-";
|
|
244
|
+
AMPLITUDE_PREFIX = "AMP";
|
|
245
|
+
STORAGE_PREFIX = "".concat(AMPLITUDE_PREFIX, "_unsent");
|
|
246
|
+
DEFAULT_INSTANCE_NAME = "$default_instance";
|
|
247
|
+
AMPLITUDE_SERVER_URL = "https://api2.amplitude.com/2/httpapi";
|
|
248
|
+
EU_AMPLITUDE_SERVER_URL = "https://api.eu.amplitude.com/2/httpapi";
|
|
249
|
+
AMPLITUDE_BATCH_SERVER_URL = "https://api2.amplitude.com/batch";
|
|
250
|
+
EU_AMPLITUDE_BATCH_SERVER_URL = "https://api.eu.amplitude.com/batch";
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.js
|
|
255
|
+
var MAX_PROPERTY_KEYS, isValidObject, isValidProperties;
|
|
256
|
+
var init_valid_properties = __esm({
|
|
257
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/valid-properties.js"() {
|
|
258
|
+
init_tslib_es6();
|
|
259
|
+
MAX_PROPERTY_KEYS = 1e3;
|
|
260
|
+
isValidObject = function(properties) {
|
|
261
|
+
if (Object.keys(properties).length > MAX_PROPERTY_KEYS) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
for (var key in properties) {
|
|
265
|
+
var value = properties[key];
|
|
266
|
+
if (!isValidProperties(key, value))
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
};
|
|
271
|
+
isValidProperties = function(property, value) {
|
|
272
|
+
var e_1, _a;
|
|
273
|
+
if (typeof property !== "string")
|
|
274
|
+
return false;
|
|
275
|
+
if (Array.isArray(value)) {
|
|
276
|
+
var isValid = true;
|
|
277
|
+
try {
|
|
278
|
+
for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
279
|
+
var valueElement = value_1_1.value;
|
|
280
|
+
if (Array.isArray(valueElement)) {
|
|
281
|
+
return false;
|
|
282
|
+
} else if (typeof valueElement === "object") {
|
|
283
|
+
isValid = isValid && isValidObject(valueElement);
|
|
284
|
+
} else if (!["number", "string"].includes(typeof valueElement)) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (!isValid) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} catch (e_1_1) {
|
|
292
|
+
e_1 = { error: e_1_1 };
|
|
293
|
+
} finally {
|
|
294
|
+
try {
|
|
295
|
+
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
296
|
+
} finally {
|
|
297
|
+
if (e_1) throw e_1.error;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} else if (value === null || value === void 0) {
|
|
301
|
+
return false;
|
|
302
|
+
} else if (typeof value === "object") {
|
|
303
|
+
return isValidObject(value);
|
|
304
|
+
} else if (!["number", "string", "boolean"].includes(typeof value)) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/identify.js
|
|
313
|
+
var Identify, IdentifyOperation2, OrderedIdentifyOperations;
|
|
314
|
+
var init_identify = __esm({
|
|
315
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/identify.js"() {
|
|
316
|
+
init_tslib_es6();
|
|
317
|
+
init_constants();
|
|
318
|
+
init_valid_properties();
|
|
319
|
+
Identify = /** @class */
|
|
320
|
+
(function() {
|
|
321
|
+
function Identify2() {
|
|
322
|
+
this._propertySet = /* @__PURE__ */ new Set();
|
|
323
|
+
this._properties = {};
|
|
324
|
+
}
|
|
325
|
+
Identify2.prototype.getUserProperties = function() {
|
|
326
|
+
return __assign({}, this._properties);
|
|
327
|
+
};
|
|
328
|
+
Identify2.prototype.set = function(property, value) {
|
|
329
|
+
this._safeSet(IdentifyOperation2.SET, property, value);
|
|
330
|
+
return this;
|
|
331
|
+
};
|
|
332
|
+
Identify2.prototype.setOnce = function(property, value) {
|
|
333
|
+
this._safeSet(IdentifyOperation2.SET_ONCE, property, value);
|
|
334
|
+
return this;
|
|
335
|
+
};
|
|
336
|
+
Identify2.prototype.append = function(property, value) {
|
|
337
|
+
this._safeSet(IdentifyOperation2.APPEND, property, value);
|
|
338
|
+
return this;
|
|
339
|
+
};
|
|
340
|
+
Identify2.prototype.prepend = function(property, value) {
|
|
341
|
+
this._safeSet(IdentifyOperation2.PREPEND, property, value);
|
|
342
|
+
return this;
|
|
343
|
+
};
|
|
344
|
+
Identify2.prototype.postInsert = function(property, value) {
|
|
345
|
+
this._safeSet(IdentifyOperation2.POSTINSERT, property, value);
|
|
346
|
+
return this;
|
|
347
|
+
};
|
|
348
|
+
Identify2.prototype.preInsert = function(property, value) {
|
|
349
|
+
this._safeSet(IdentifyOperation2.PREINSERT, property, value);
|
|
350
|
+
return this;
|
|
351
|
+
};
|
|
352
|
+
Identify2.prototype.remove = function(property, value) {
|
|
353
|
+
this._safeSet(IdentifyOperation2.REMOVE, property, value);
|
|
354
|
+
return this;
|
|
355
|
+
};
|
|
356
|
+
Identify2.prototype.add = function(property, value) {
|
|
357
|
+
this._safeSet(IdentifyOperation2.ADD, property, value);
|
|
358
|
+
return this;
|
|
359
|
+
};
|
|
360
|
+
Identify2.prototype.unset = function(property) {
|
|
361
|
+
this._safeSet(IdentifyOperation2.UNSET, property, UNSET_VALUE);
|
|
362
|
+
return this;
|
|
363
|
+
};
|
|
364
|
+
Identify2.prototype.clearAll = function() {
|
|
365
|
+
this._properties = {};
|
|
366
|
+
this._properties[IdentifyOperation2.CLEAR_ALL] = UNSET_VALUE;
|
|
367
|
+
return this;
|
|
368
|
+
};
|
|
369
|
+
Identify2.prototype._safeSet = function(operation, property, value) {
|
|
370
|
+
if (this._validate(operation, property, value)) {
|
|
371
|
+
var userPropertyMap = this._properties[operation];
|
|
372
|
+
if (userPropertyMap === void 0) {
|
|
373
|
+
userPropertyMap = {};
|
|
374
|
+
this._properties[operation] = userPropertyMap;
|
|
375
|
+
}
|
|
376
|
+
userPropertyMap[property] = value;
|
|
377
|
+
this._propertySet.add(property);
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
};
|
|
382
|
+
Identify2.prototype._validate = function(operation, property, value) {
|
|
383
|
+
if (this._properties[IdentifyOperation2.CLEAR_ALL] !== void 0) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
if (this._propertySet.has(property)) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
if (operation === IdentifyOperation2.ADD) {
|
|
390
|
+
return typeof value === "number";
|
|
391
|
+
}
|
|
392
|
+
if (operation !== IdentifyOperation2.UNSET && operation !== IdentifyOperation2.REMOVE) {
|
|
393
|
+
return isValidProperties(property, value);
|
|
394
|
+
}
|
|
395
|
+
return true;
|
|
396
|
+
};
|
|
397
|
+
return Identify2;
|
|
398
|
+
})();
|
|
399
|
+
(function(IdentifyOperation3) {
|
|
400
|
+
IdentifyOperation3["SET"] = "$set";
|
|
401
|
+
IdentifyOperation3["SET_ONCE"] = "$setOnce";
|
|
402
|
+
IdentifyOperation3["ADD"] = "$add";
|
|
403
|
+
IdentifyOperation3["APPEND"] = "$append";
|
|
404
|
+
IdentifyOperation3["PREPEND"] = "$prepend";
|
|
405
|
+
IdentifyOperation3["REMOVE"] = "$remove";
|
|
406
|
+
IdentifyOperation3["PREINSERT"] = "$preInsert";
|
|
407
|
+
IdentifyOperation3["POSTINSERT"] = "$postInsert";
|
|
408
|
+
IdentifyOperation3["UNSET"] = "$unset";
|
|
409
|
+
IdentifyOperation3["CLEAR_ALL"] = "$clearAll";
|
|
410
|
+
})(IdentifyOperation2 || (IdentifyOperation2 = {}));
|
|
411
|
+
OrderedIdentifyOperations = [
|
|
412
|
+
IdentifyOperation2.CLEAR_ALL,
|
|
413
|
+
IdentifyOperation2.UNSET,
|
|
414
|
+
IdentifyOperation2.SET,
|
|
415
|
+
IdentifyOperation2.SET_ONCE,
|
|
416
|
+
IdentifyOperation2.ADD,
|
|
417
|
+
IdentifyOperation2.APPEND,
|
|
418
|
+
IdentifyOperation2.PREPEND,
|
|
419
|
+
IdentifyOperation2.PREINSERT,
|
|
420
|
+
IdentifyOperation2.POSTINSERT,
|
|
421
|
+
IdentifyOperation2.REMOVE
|
|
422
|
+
];
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/messages.js
|
|
427
|
+
var SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE, MAX_RETRIES_EXCEEDED_MESSAGE, OPT_OUT_MESSAGE, MISSING_API_KEY_MESSAGE, INVALID_API_KEY, CLIENT_NOT_INITIALIZED;
|
|
428
|
+
var init_messages = __esm({
|
|
429
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/messages.js"() {
|
|
430
|
+
SUCCESS_MESSAGE = "Event tracked successfully";
|
|
431
|
+
UNEXPECTED_ERROR_MESSAGE = "Unexpected error occurred";
|
|
432
|
+
MAX_RETRIES_EXCEEDED_MESSAGE = "Event rejected due to exceeded retry count";
|
|
433
|
+
OPT_OUT_MESSAGE = "Event skipped due to optOut config";
|
|
434
|
+
MISSING_API_KEY_MESSAGE = "Event rejected due to missing API key";
|
|
435
|
+
INVALID_API_KEY = "Invalid API key";
|
|
436
|
+
CLIENT_NOT_INITIALIZED = "Client not initialized";
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/status.js
|
|
441
|
+
var Status;
|
|
442
|
+
var init_status = __esm({
|
|
443
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/status.js"() {
|
|
444
|
+
(function(Status2) {
|
|
445
|
+
Status2["Unknown"] = "unknown";
|
|
446
|
+
Status2["Skipped"] = "skipped";
|
|
447
|
+
Status2["Success"] = "success";
|
|
448
|
+
Status2["RateLimit"] = "rate_limit";
|
|
449
|
+
Status2["PayloadTooLarge"] = "payload_too_large";
|
|
450
|
+
Status2["Invalid"] = "invalid";
|
|
451
|
+
Status2["Failed"] = "failed";
|
|
452
|
+
Status2["Timeout"] = "Timeout";
|
|
453
|
+
Status2["SystemError"] = "SystemError";
|
|
454
|
+
})(Status || (Status = {}));
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/result-builder.js
|
|
459
|
+
var buildResult;
|
|
460
|
+
var init_result_builder = __esm({
|
|
461
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/result-builder.js"() {
|
|
462
|
+
init_status();
|
|
463
|
+
buildResult = function(event, code, message) {
|
|
464
|
+
if (code === void 0) {
|
|
465
|
+
code = 0;
|
|
466
|
+
}
|
|
467
|
+
if (message === void 0) {
|
|
468
|
+
message = Status.Unknown;
|
|
469
|
+
}
|
|
470
|
+
return { event, code, message };
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/global-scope.js
|
|
476
|
+
var getGlobalScope;
|
|
477
|
+
var init_global_scope = __esm({
|
|
478
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/global-scope.js"() {
|
|
479
|
+
getGlobalScope = function() {
|
|
480
|
+
var ampIntegrationContextName = "ampIntegrationContext";
|
|
481
|
+
if (typeof globalThis !== "undefined" && typeof globalThis[ampIntegrationContextName] !== "undefined") {
|
|
482
|
+
return globalThis[ampIntegrationContextName];
|
|
483
|
+
}
|
|
484
|
+
if (typeof globalThis !== "undefined") {
|
|
485
|
+
return globalThis;
|
|
486
|
+
}
|
|
487
|
+
if (typeof window !== "undefined") {
|
|
488
|
+
return window;
|
|
489
|
+
}
|
|
490
|
+
if (typeof self !== "undefined") {
|
|
491
|
+
return self;
|
|
492
|
+
}
|
|
493
|
+
if (typeof global !== "undefined") {
|
|
494
|
+
return global;
|
|
495
|
+
}
|
|
496
|
+
return void 0;
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/uuid.js
|
|
502
|
+
var legacyUUID, hex, UUID;
|
|
503
|
+
var init_uuid = __esm({
|
|
504
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/uuid.js"() {
|
|
505
|
+
init_tslib_es6();
|
|
506
|
+
init_global_scope();
|
|
507
|
+
legacyUUID = function(a) {
|
|
508
|
+
return a ? (
|
|
509
|
+
// a random number from 0 to 15
|
|
510
|
+
(a ^ // unless b is 8,
|
|
511
|
+
Math.random() * // in which case
|
|
512
|
+
16 >> // a random number from
|
|
513
|
+
a / 4).toString(16)
|
|
514
|
+
) : (
|
|
515
|
+
// or otherwise a concatenated string:
|
|
516
|
+
(String(1e7) + // 10000000 +
|
|
517
|
+
String(-1e3) + // -1000 +
|
|
518
|
+
String(-4e3) + // -4000 +
|
|
519
|
+
String(-8e3) + // -80000000 +
|
|
520
|
+
String(-1e11)).replace(
|
|
521
|
+
// replacing
|
|
522
|
+
/[018]/g,
|
|
523
|
+
// zeroes, ones, and eights with
|
|
524
|
+
UUID
|
|
525
|
+
)
|
|
526
|
+
);
|
|
527
|
+
};
|
|
528
|
+
hex = __spreadArray([], __read(Array(256).keys()), false).map(function(index) {
|
|
529
|
+
return index.toString(16).padStart(2, "0");
|
|
530
|
+
});
|
|
531
|
+
UUID = function(a) {
|
|
532
|
+
var _a;
|
|
533
|
+
var globalScope = getGlobalScope();
|
|
534
|
+
if (!((_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.crypto) === null || _a === void 0 ? void 0 : _a.getRandomValues)) {
|
|
535
|
+
return legacyUUID(a);
|
|
536
|
+
}
|
|
537
|
+
var r = globalScope.crypto.getRandomValues(new Uint8Array(16));
|
|
538
|
+
r[6] = r[6] & 15 | 64;
|
|
539
|
+
r[8] = r[8] & 63 | 128;
|
|
540
|
+
return __spreadArray([], __read(r.entries()), false).map(function(_a2) {
|
|
541
|
+
var _b = __read(_a2, 2), index = _b[0], int = _b[1];
|
|
542
|
+
return [4, 6, 8, 10].includes(index) ? "-".concat(hex[int]) : hex[int];
|
|
543
|
+
}).join("");
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/timeline.js
|
|
549
|
+
var Timeline;
|
|
550
|
+
var init_timeline = __esm({
|
|
551
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/timeline.js"() {
|
|
552
|
+
init_tslib_es6();
|
|
553
|
+
init_result_builder();
|
|
554
|
+
init_uuid();
|
|
555
|
+
Timeline = /** @class */
|
|
556
|
+
(function() {
|
|
557
|
+
function Timeline2(client) {
|
|
558
|
+
this.client = client;
|
|
559
|
+
this.queue = [];
|
|
560
|
+
this.applying = false;
|
|
561
|
+
this.plugins = [];
|
|
562
|
+
}
|
|
563
|
+
Timeline2.prototype.register = function(plugin, config) {
|
|
564
|
+
var _a, _b;
|
|
565
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
566
|
+
return __generator(this, function(_c) {
|
|
567
|
+
switch (_c.label) {
|
|
568
|
+
case 0:
|
|
569
|
+
if (this.plugins.some(function(existingPlugin) {
|
|
570
|
+
return existingPlugin.name === plugin.name;
|
|
571
|
+
})) {
|
|
572
|
+
this.loggerProvider.warn("Plugin with name ".concat(plugin.name, " already exists, skipping registration"));
|
|
573
|
+
return [
|
|
574
|
+
2
|
|
575
|
+
/*return*/
|
|
576
|
+
];
|
|
577
|
+
}
|
|
578
|
+
if (plugin.name === void 0) {
|
|
579
|
+
plugin.name = UUID();
|
|
580
|
+
this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(plugin.name, ". \n Set a name for the plugin to prevent it from being added multiple times."));
|
|
581
|
+
}
|
|
582
|
+
plugin.type = (_a = plugin.type) !== null && _a !== void 0 ? _a : "enrichment";
|
|
583
|
+
return [4, (_b = plugin.setup) === null || _b === void 0 ? void 0 : _b.call(plugin, config, this.client)];
|
|
584
|
+
case 1:
|
|
585
|
+
_c.sent();
|
|
586
|
+
this.plugins.push(plugin);
|
|
587
|
+
return [
|
|
588
|
+
2
|
|
589
|
+
/*return*/
|
|
590
|
+
];
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
Timeline2.prototype.deregister = function(pluginName, config) {
|
|
596
|
+
var _a;
|
|
597
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
598
|
+
var index, plugin;
|
|
599
|
+
return __generator(this, function(_b) {
|
|
600
|
+
switch (_b.label) {
|
|
601
|
+
case 0:
|
|
602
|
+
index = this.plugins.findIndex(function(plugin2) {
|
|
603
|
+
return plugin2.name === pluginName;
|
|
604
|
+
});
|
|
605
|
+
if (index === -1) {
|
|
606
|
+
config.loggerProvider.warn("Plugin with name ".concat(pluginName, " does not exist, skipping deregistration"));
|
|
607
|
+
return [
|
|
608
|
+
2
|
|
609
|
+
/*return*/
|
|
610
|
+
];
|
|
611
|
+
}
|
|
612
|
+
plugin = this.plugins[index];
|
|
613
|
+
this.plugins.splice(index, 1);
|
|
614
|
+
return [4, (_a = plugin.teardown) === null || _a === void 0 ? void 0 : _a.call(plugin)];
|
|
615
|
+
case 1:
|
|
616
|
+
_b.sent();
|
|
617
|
+
return [
|
|
618
|
+
2
|
|
619
|
+
/*return*/
|
|
620
|
+
];
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
};
|
|
625
|
+
Timeline2.prototype.reset = function(client) {
|
|
626
|
+
this.applying = false;
|
|
627
|
+
var plugins = this.plugins;
|
|
628
|
+
plugins.map(function(plugin) {
|
|
629
|
+
var _a;
|
|
630
|
+
return (_a = plugin.teardown) === null || _a === void 0 ? void 0 : _a.call(plugin);
|
|
631
|
+
});
|
|
632
|
+
this.plugins = [];
|
|
633
|
+
this.client = client;
|
|
634
|
+
};
|
|
635
|
+
Timeline2.prototype.push = function(event) {
|
|
636
|
+
var _this = this;
|
|
637
|
+
return new Promise(function(resolve) {
|
|
638
|
+
_this.queue.push([event, resolve]);
|
|
639
|
+
_this.scheduleApply(0);
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
Timeline2.prototype.scheduleApply = function(timeout) {
|
|
643
|
+
var _this = this;
|
|
644
|
+
if (this.applying)
|
|
645
|
+
return;
|
|
646
|
+
this.applying = true;
|
|
647
|
+
setTimeout(function() {
|
|
648
|
+
void _this.apply(_this.queue.shift()).then(function() {
|
|
649
|
+
_this.applying = false;
|
|
650
|
+
if (_this.queue.length > 0) {
|
|
651
|
+
_this.scheduleApply(0);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}, timeout);
|
|
655
|
+
};
|
|
656
|
+
Timeline2.prototype.apply = function(item) {
|
|
657
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
658
|
+
var _a, event, _b, resolve, before, before_1, before_1_1, plugin, e, e_1_1, enrichment, enrichment_1, enrichment_1_1, plugin, e, e_2_1, destination, executeDestinations;
|
|
659
|
+
var e_1, _c, e_2, _d;
|
|
660
|
+
return __generator(this, function(_e) {
|
|
661
|
+
switch (_e.label) {
|
|
662
|
+
case 0:
|
|
663
|
+
if (!item) {
|
|
664
|
+
return [
|
|
665
|
+
2
|
|
666
|
+
/*return*/
|
|
667
|
+
];
|
|
668
|
+
}
|
|
669
|
+
_a = __read(item, 1), event = _a[0];
|
|
670
|
+
_b = __read(item, 2), resolve = _b[1];
|
|
671
|
+
this.loggerProvider.log("Timeline.apply: Initial event", event);
|
|
672
|
+
before = this.plugins.filter(function(plugin2) {
|
|
673
|
+
return plugin2.type === "before";
|
|
674
|
+
});
|
|
675
|
+
_e.label = 1;
|
|
676
|
+
case 1:
|
|
677
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
678
|
+
before_1 = __values(before), before_1_1 = before_1.next();
|
|
679
|
+
_e.label = 2;
|
|
680
|
+
case 2:
|
|
681
|
+
if (!!before_1_1.done) return [3, 5];
|
|
682
|
+
plugin = before_1_1.value;
|
|
683
|
+
if (!plugin.execute) {
|
|
684
|
+
return [3, 4];
|
|
685
|
+
}
|
|
686
|
+
return [4, plugin.execute(__assign({}, event))];
|
|
687
|
+
case 3:
|
|
688
|
+
e = _e.sent();
|
|
689
|
+
if (e === null) {
|
|
690
|
+
this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
691
|
+
resolve({ event, code: 0, message: "" });
|
|
692
|
+
return [
|
|
693
|
+
2
|
|
694
|
+
/*return*/
|
|
695
|
+
];
|
|
696
|
+
} else {
|
|
697
|
+
event = e;
|
|
698
|
+
this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
699
|
+
}
|
|
700
|
+
_e.label = 4;
|
|
701
|
+
case 4:
|
|
702
|
+
before_1_1 = before_1.next();
|
|
703
|
+
return [3, 2];
|
|
704
|
+
case 5:
|
|
705
|
+
return [3, 8];
|
|
706
|
+
case 6:
|
|
707
|
+
e_1_1 = _e.sent();
|
|
708
|
+
e_1 = { error: e_1_1 };
|
|
709
|
+
return [3, 8];
|
|
710
|
+
case 7:
|
|
711
|
+
try {
|
|
712
|
+
if (before_1_1 && !before_1_1.done && (_c = before_1.return)) _c.call(before_1);
|
|
713
|
+
} finally {
|
|
714
|
+
if (e_1) throw e_1.error;
|
|
715
|
+
}
|
|
716
|
+
return [
|
|
717
|
+
7
|
|
718
|
+
/*endfinally*/
|
|
719
|
+
];
|
|
720
|
+
case 8:
|
|
721
|
+
enrichment = this.plugins.filter(function(plugin2) {
|
|
722
|
+
return plugin2.type === "enrichment" || plugin2.type === void 0;
|
|
723
|
+
});
|
|
724
|
+
_e.label = 9;
|
|
725
|
+
case 9:
|
|
726
|
+
_e.trys.push([9, 14, 15, 16]);
|
|
727
|
+
enrichment_1 = __values(enrichment), enrichment_1_1 = enrichment_1.next();
|
|
728
|
+
_e.label = 10;
|
|
729
|
+
case 10:
|
|
730
|
+
if (!!enrichment_1_1.done) return [3, 13];
|
|
731
|
+
plugin = enrichment_1_1.value;
|
|
732
|
+
if (!plugin.execute) {
|
|
733
|
+
return [3, 12];
|
|
734
|
+
}
|
|
735
|
+
return [4, plugin.execute(__assign({}, event))];
|
|
736
|
+
case 11:
|
|
737
|
+
e = _e.sent();
|
|
738
|
+
if (e === null) {
|
|
739
|
+
this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
740
|
+
resolve({ event, code: 0, message: "" });
|
|
741
|
+
return [
|
|
742
|
+
2
|
|
743
|
+
/*return*/
|
|
744
|
+
];
|
|
745
|
+
} else {
|
|
746
|
+
event = e;
|
|
747
|
+
this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(plugin.name), "', event: ").concat(JSON.stringify(event)));
|
|
748
|
+
}
|
|
749
|
+
_e.label = 12;
|
|
750
|
+
case 12:
|
|
751
|
+
enrichment_1_1 = enrichment_1.next();
|
|
752
|
+
return [3, 10];
|
|
753
|
+
case 13:
|
|
754
|
+
return [3, 16];
|
|
755
|
+
case 14:
|
|
756
|
+
e_2_1 = _e.sent();
|
|
757
|
+
e_2 = { error: e_2_1 };
|
|
758
|
+
return [3, 16];
|
|
759
|
+
case 15:
|
|
760
|
+
try {
|
|
761
|
+
if (enrichment_1_1 && !enrichment_1_1.done && (_d = enrichment_1.return)) _d.call(enrichment_1);
|
|
762
|
+
} finally {
|
|
763
|
+
if (e_2) throw e_2.error;
|
|
764
|
+
}
|
|
765
|
+
return [
|
|
766
|
+
7
|
|
767
|
+
/*endfinally*/
|
|
768
|
+
];
|
|
769
|
+
case 16:
|
|
770
|
+
destination = this.plugins.filter(function(plugin2) {
|
|
771
|
+
return plugin2.type === "destination";
|
|
772
|
+
});
|
|
773
|
+
this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(event)));
|
|
774
|
+
executeDestinations = destination.map(function(plugin2) {
|
|
775
|
+
var eventClone = __assign({}, event);
|
|
776
|
+
return plugin2.execute(eventClone).catch(function(e2) {
|
|
777
|
+
return buildResult(eventClone, 0, String(e2));
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
void Promise.all(executeDestinations).then(function(_a2) {
|
|
781
|
+
var _b2 = __read(_a2, 1), result = _b2[0];
|
|
782
|
+
var resolveResult = result || buildResult(event, 100, "Event not tracked, no destination plugins on the instance");
|
|
783
|
+
resolve(resolveResult);
|
|
784
|
+
});
|
|
785
|
+
return [
|
|
786
|
+
2
|
|
787
|
+
/*return*/
|
|
788
|
+
];
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
};
|
|
793
|
+
Timeline2.prototype.flush = function() {
|
|
794
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
795
|
+
var queue, destination, executeDestinations;
|
|
796
|
+
var _this = this;
|
|
797
|
+
return __generator(this, function(_a) {
|
|
798
|
+
switch (_a.label) {
|
|
799
|
+
case 0:
|
|
800
|
+
queue = this.queue;
|
|
801
|
+
this.queue = [];
|
|
802
|
+
return [4, Promise.all(queue.map(function(item) {
|
|
803
|
+
return _this.apply(item);
|
|
804
|
+
}))];
|
|
805
|
+
case 1:
|
|
806
|
+
_a.sent();
|
|
807
|
+
destination = this.plugins.filter(function(plugin) {
|
|
808
|
+
return plugin.type === "destination";
|
|
809
|
+
});
|
|
810
|
+
executeDestinations = destination.map(function(plugin) {
|
|
811
|
+
return plugin.flush && plugin.flush();
|
|
812
|
+
});
|
|
813
|
+
return [4, Promise.all(executeDestinations)];
|
|
814
|
+
case 2:
|
|
815
|
+
_a.sent();
|
|
816
|
+
return [
|
|
817
|
+
2
|
|
818
|
+
/*return*/
|
|
819
|
+
];
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
Timeline2.prototype.onIdentityChanged = function(identity) {
|
|
825
|
+
this.plugins.forEach(function(plugin) {
|
|
826
|
+
var _a;
|
|
827
|
+
void ((_a = plugin.onIdentityChanged) === null || _a === void 0 ? void 0 : _a.call(plugin, identity));
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
Timeline2.prototype.onSessionIdChanged = function(sessionId) {
|
|
831
|
+
this.plugins.forEach(function(plugin) {
|
|
832
|
+
var _a;
|
|
833
|
+
void ((_a = plugin.onSessionIdChanged) === null || _a === void 0 ? void 0 : _a.call(plugin, sessionId));
|
|
834
|
+
});
|
|
835
|
+
};
|
|
836
|
+
Timeline2.prototype.onOptOutChanged = function(optOut) {
|
|
837
|
+
this.plugins.forEach(function(plugin) {
|
|
838
|
+
var _a;
|
|
839
|
+
void ((_a = plugin.onOptOutChanged) === null || _a === void 0 ? void 0 : _a.call(plugin, optOut));
|
|
840
|
+
});
|
|
841
|
+
};
|
|
842
|
+
Timeline2.prototype.onReset = function() {
|
|
843
|
+
this.plugins.forEach(function(plugin) {
|
|
844
|
+
var _a;
|
|
845
|
+
void ((_a = plugin.onReset) === null || _a === void 0 ? void 0 : _a.call(plugin));
|
|
846
|
+
});
|
|
847
|
+
};
|
|
848
|
+
return Timeline2;
|
|
849
|
+
})();
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/event-builder.js
|
|
854
|
+
var createTrackEvent, createIdentifyEvent, createGroupIdentifyEvent, createGroupEvent, createRevenueEvent;
|
|
855
|
+
var init_event_builder = __esm({
|
|
856
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/event-builder.js"() {
|
|
857
|
+
init_tslib_es6();
|
|
858
|
+
init_identify();
|
|
859
|
+
init_event();
|
|
860
|
+
createTrackEvent = function(eventInput, eventProperties, eventOptions) {
|
|
861
|
+
var baseEvent = typeof eventInput === "string" ? { event_type: eventInput } : eventInput;
|
|
862
|
+
return __assign(__assign(__assign({}, baseEvent), eventOptions), eventProperties && { event_properties: eventProperties });
|
|
863
|
+
};
|
|
864
|
+
createIdentifyEvent = function(identify2, eventOptions) {
|
|
865
|
+
var identifyEvent = __assign(__assign({}, eventOptions), { event_type: SpecialEventType.IDENTIFY, user_properties: identify2.getUserProperties() });
|
|
866
|
+
return identifyEvent;
|
|
867
|
+
};
|
|
868
|
+
createGroupIdentifyEvent = function(groupType, groupName, identify2, eventOptions) {
|
|
869
|
+
var _a;
|
|
870
|
+
var groupIdentify2 = __assign(__assign({}, eventOptions), { event_type: SpecialEventType.GROUP_IDENTIFY, group_properties: identify2.getUserProperties(), groups: (_a = {}, _a[groupType] = groupName, _a) });
|
|
871
|
+
return groupIdentify2;
|
|
872
|
+
};
|
|
873
|
+
createGroupEvent = function(groupType, groupName, eventOptions) {
|
|
874
|
+
var _a;
|
|
875
|
+
var identify2 = new Identify();
|
|
876
|
+
identify2.set(groupType, groupName);
|
|
877
|
+
var groupEvent = __assign(__assign({}, eventOptions), { event_type: SpecialEventType.IDENTIFY, user_properties: identify2.getUserProperties(), groups: (_a = {}, _a[groupType] = groupName, _a) });
|
|
878
|
+
return groupEvent;
|
|
879
|
+
};
|
|
880
|
+
createRevenueEvent = function(revenue2, eventOptions) {
|
|
881
|
+
return __assign(__assign({}, eventOptions), { event_type: SpecialEventType.REVENUE, event_properties: revenue2.getEventProperties() });
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/return-wrapper.js
|
|
887
|
+
var returnWrapper;
|
|
888
|
+
var init_return_wrapper = __esm({
|
|
889
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/return-wrapper.js"() {
|
|
890
|
+
returnWrapper = function(awaitable) {
|
|
891
|
+
return {
|
|
892
|
+
promise: awaitable || Promise.resolve()
|
|
893
|
+
};
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/core-client.js
|
|
899
|
+
var AmplitudeCore;
|
|
900
|
+
var init_core_client = __esm({
|
|
901
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/core-client.js"() {
|
|
902
|
+
init_tslib_es6();
|
|
903
|
+
init_event();
|
|
904
|
+
init_identify();
|
|
905
|
+
init_messages();
|
|
906
|
+
init_timeline();
|
|
907
|
+
init_event_builder();
|
|
908
|
+
init_result_builder();
|
|
909
|
+
init_return_wrapper();
|
|
910
|
+
AmplitudeCore = /** @class */
|
|
911
|
+
(function() {
|
|
912
|
+
function AmplitudeCore2(name) {
|
|
913
|
+
if (name === void 0) {
|
|
914
|
+
name = "$default";
|
|
915
|
+
}
|
|
916
|
+
this.initializing = false;
|
|
917
|
+
this.isReady = false;
|
|
918
|
+
this.q = [];
|
|
919
|
+
this.dispatchQ = [];
|
|
920
|
+
this.logEvent = this.track.bind(this);
|
|
921
|
+
this.timeline = new Timeline(this);
|
|
922
|
+
this.name = name;
|
|
923
|
+
}
|
|
924
|
+
AmplitudeCore2.prototype._init = function(config) {
|
|
925
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
926
|
+
return __generator(this, function(_a) {
|
|
927
|
+
switch (_a.label) {
|
|
928
|
+
case 0:
|
|
929
|
+
this.config = config;
|
|
930
|
+
this.timeline.reset(this);
|
|
931
|
+
this.timeline.loggerProvider = this.config.loggerProvider;
|
|
932
|
+
return [4, this.runQueuedFunctions("q")];
|
|
933
|
+
case 1:
|
|
934
|
+
_a.sent();
|
|
935
|
+
this.isReady = true;
|
|
936
|
+
return [
|
|
937
|
+
2
|
|
938
|
+
/*return*/
|
|
939
|
+
];
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
};
|
|
944
|
+
AmplitudeCore2.prototype.runQueuedFunctions = function(queueName) {
|
|
945
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
946
|
+
var queuedFunctions, queuedFunctions_1, queuedFunctions_1_1, queuedFunction, val, e_1_1;
|
|
947
|
+
var e_1, _a;
|
|
948
|
+
return __generator(this, function(_b) {
|
|
949
|
+
switch (_b.label) {
|
|
950
|
+
case 0:
|
|
951
|
+
queuedFunctions = this[queueName];
|
|
952
|
+
this[queueName] = [];
|
|
953
|
+
_b.label = 1;
|
|
954
|
+
case 1:
|
|
955
|
+
_b.trys.push([1, 8, 9, 10]);
|
|
956
|
+
queuedFunctions_1 = __values(queuedFunctions), queuedFunctions_1_1 = queuedFunctions_1.next();
|
|
957
|
+
_b.label = 2;
|
|
958
|
+
case 2:
|
|
959
|
+
if (!!queuedFunctions_1_1.done) return [3, 7];
|
|
960
|
+
queuedFunction = queuedFunctions_1_1.value;
|
|
961
|
+
val = queuedFunction();
|
|
962
|
+
if (!(val && "promise" in val)) return [3, 4];
|
|
963
|
+
return [4, val.promise];
|
|
964
|
+
case 3:
|
|
965
|
+
_b.sent();
|
|
966
|
+
return [3, 6];
|
|
967
|
+
case 4:
|
|
968
|
+
return [4, val];
|
|
969
|
+
case 5:
|
|
970
|
+
_b.sent();
|
|
971
|
+
_b.label = 6;
|
|
972
|
+
case 6:
|
|
973
|
+
queuedFunctions_1_1 = queuedFunctions_1.next();
|
|
974
|
+
return [3, 2];
|
|
975
|
+
case 7:
|
|
976
|
+
return [3, 10];
|
|
977
|
+
case 8:
|
|
978
|
+
e_1_1 = _b.sent();
|
|
979
|
+
e_1 = { error: e_1_1 };
|
|
980
|
+
return [3, 10];
|
|
981
|
+
case 9:
|
|
982
|
+
try {
|
|
983
|
+
if (queuedFunctions_1_1 && !queuedFunctions_1_1.done && (_a = queuedFunctions_1.return)) _a.call(queuedFunctions_1);
|
|
984
|
+
} finally {
|
|
985
|
+
if (e_1) throw e_1.error;
|
|
986
|
+
}
|
|
987
|
+
return [
|
|
988
|
+
7
|
|
989
|
+
/*endfinally*/
|
|
990
|
+
];
|
|
991
|
+
case 10:
|
|
992
|
+
if (!this[queueName].length) return [3, 12];
|
|
993
|
+
return [4, this.runQueuedFunctions(queueName)];
|
|
994
|
+
case 11:
|
|
995
|
+
_b.sent();
|
|
996
|
+
_b.label = 12;
|
|
997
|
+
case 12:
|
|
998
|
+
return [
|
|
999
|
+
2
|
|
1000
|
+
/*return*/
|
|
1001
|
+
];
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
AmplitudeCore2.prototype.track = function(eventInput, eventProperties, eventOptions) {
|
|
1007
|
+
var event = createTrackEvent(eventInput, eventProperties, eventOptions);
|
|
1008
|
+
return returnWrapper(this.dispatch(event));
|
|
1009
|
+
};
|
|
1010
|
+
AmplitudeCore2.prototype.identify = function(identify2, eventOptions) {
|
|
1011
|
+
var event = createIdentifyEvent(identify2, eventOptions);
|
|
1012
|
+
return returnWrapper(this.dispatch(event));
|
|
1013
|
+
};
|
|
1014
|
+
AmplitudeCore2.prototype.groupIdentify = function(groupType, groupName, identify2, eventOptions) {
|
|
1015
|
+
var event = createGroupIdentifyEvent(groupType, groupName, identify2, eventOptions);
|
|
1016
|
+
return returnWrapper(this.dispatch(event));
|
|
1017
|
+
};
|
|
1018
|
+
AmplitudeCore2.prototype.setGroup = function(groupType, groupName, eventOptions) {
|
|
1019
|
+
var event = createGroupEvent(groupType, groupName, eventOptions);
|
|
1020
|
+
return returnWrapper(this.dispatch(event));
|
|
1021
|
+
};
|
|
1022
|
+
AmplitudeCore2.prototype.revenue = function(revenue2, eventOptions) {
|
|
1023
|
+
var event = createRevenueEvent(revenue2, eventOptions);
|
|
1024
|
+
return returnWrapper(this.dispatch(event));
|
|
1025
|
+
};
|
|
1026
|
+
AmplitudeCore2.prototype.add = function(plugin) {
|
|
1027
|
+
if (!this.isReady) {
|
|
1028
|
+
this.q.push(this._addPlugin.bind(this, plugin));
|
|
1029
|
+
return returnWrapper();
|
|
1030
|
+
}
|
|
1031
|
+
return this._addPlugin(plugin);
|
|
1032
|
+
};
|
|
1033
|
+
AmplitudeCore2.prototype._addPlugin = function(plugin) {
|
|
1034
|
+
return returnWrapper(this.timeline.register(plugin, this.config));
|
|
1035
|
+
};
|
|
1036
|
+
AmplitudeCore2.prototype.remove = function(pluginName) {
|
|
1037
|
+
if (!this.isReady) {
|
|
1038
|
+
this.q.push(this._removePlugin.bind(this, pluginName));
|
|
1039
|
+
return returnWrapper();
|
|
1040
|
+
}
|
|
1041
|
+
return this._removePlugin(pluginName);
|
|
1042
|
+
};
|
|
1043
|
+
AmplitudeCore2.prototype._removePlugin = function(pluginName) {
|
|
1044
|
+
return returnWrapper(this.timeline.deregister(pluginName, this.config));
|
|
1045
|
+
};
|
|
1046
|
+
AmplitudeCore2.prototype.dispatchWithCallback = function(event, callback) {
|
|
1047
|
+
if (!this.isReady) {
|
|
1048
|
+
return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));
|
|
1049
|
+
}
|
|
1050
|
+
void this.process(event).then(callback);
|
|
1051
|
+
};
|
|
1052
|
+
AmplitudeCore2.prototype.dispatch = function(event) {
|
|
1053
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1054
|
+
var _this = this;
|
|
1055
|
+
return __generator(this, function(_a) {
|
|
1056
|
+
if (!this.isReady) {
|
|
1057
|
+
return [2, new Promise(function(resolve) {
|
|
1058
|
+
_this.dispatchQ.push(_this.dispatchWithCallback.bind(_this, event, resolve));
|
|
1059
|
+
})];
|
|
1060
|
+
}
|
|
1061
|
+
return [2, this.process(event)];
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
AmplitudeCore2.prototype.getOperationAppliedUserProperties = function(userProperties) {
|
|
1066
|
+
var updatedProperties = {};
|
|
1067
|
+
if (userProperties === void 0) {
|
|
1068
|
+
return updatedProperties;
|
|
1069
|
+
}
|
|
1070
|
+
var nonOpProperties = {};
|
|
1071
|
+
Object.keys(userProperties).forEach(function(key) {
|
|
1072
|
+
if (!Object.values(IdentifyOperation).includes(key)) {
|
|
1073
|
+
nonOpProperties[key] = userProperties[key];
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
OrderedIdentifyOperations.forEach(function(operation) {
|
|
1077
|
+
if (!Object.keys(userProperties).includes(operation))
|
|
1078
|
+
return;
|
|
1079
|
+
var opProperties = userProperties[operation];
|
|
1080
|
+
switch (operation) {
|
|
1081
|
+
case IdentifyOperation.CLEAR_ALL:
|
|
1082
|
+
Object.keys(updatedProperties).forEach(function(prop) {
|
|
1083
|
+
delete updatedProperties[prop];
|
|
1084
|
+
});
|
|
1085
|
+
break;
|
|
1086
|
+
case IdentifyOperation.UNSET:
|
|
1087
|
+
Object.keys(opProperties).forEach(function(prop) {
|
|
1088
|
+
delete updatedProperties[prop];
|
|
1089
|
+
});
|
|
1090
|
+
break;
|
|
1091
|
+
case IdentifyOperation.SET:
|
|
1092
|
+
Object.assign(updatedProperties, opProperties);
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
Object.assign(updatedProperties, nonOpProperties);
|
|
1097
|
+
return updatedProperties;
|
|
1098
|
+
};
|
|
1099
|
+
AmplitudeCore2.prototype.process = function(event) {
|
|
1100
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1101
|
+
var userProperties, result, e_2, message, result;
|
|
1102
|
+
return __generator(this, function(_a) {
|
|
1103
|
+
switch (_a.label) {
|
|
1104
|
+
case 0:
|
|
1105
|
+
_a.trys.push([0, 2, , 3]);
|
|
1106
|
+
if (this.config.optOut) {
|
|
1107
|
+
return [2, buildResult(event, 0, OPT_OUT_MESSAGE)];
|
|
1108
|
+
}
|
|
1109
|
+
if (event.event_type === SpecialEventType.IDENTIFY) {
|
|
1110
|
+
userProperties = this.getOperationAppliedUserProperties(event.user_properties);
|
|
1111
|
+
this.timeline.onIdentityChanged({ userProperties });
|
|
1112
|
+
}
|
|
1113
|
+
return [4, this.timeline.push(event)];
|
|
1114
|
+
case 1:
|
|
1115
|
+
result = _a.sent();
|
|
1116
|
+
result.code === 200 ? this.config.loggerProvider.log(result.message) : result.code === 100 ? this.config.loggerProvider.warn(result.message) : this.config.loggerProvider.error(result.message);
|
|
1117
|
+
return [2, result];
|
|
1118
|
+
case 2:
|
|
1119
|
+
e_2 = _a.sent();
|
|
1120
|
+
message = String(e_2);
|
|
1121
|
+
this.config.loggerProvider.error(message);
|
|
1122
|
+
result = buildResult(event, 0, message);
|
|
1123
|
+
return [2, result];
|
|
1124
|
+
case 3:
|
|
1125
|
+
return [
|
|
1126
|
+
2
|
|
1127
|
+
/*return*/
|
|
1128
|
+
];
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
});
|
|
1132
|
+
};
|
|
1133
|
+
AmplitudeCore2.prototype.setOptOut = function(optOut) {
|
|
1134
|
+
if (!this.isReady) {
|
|
1135
|
+
this.q.push(this._setOptOut.bind(this, Boolean(optOut)));
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
this._setOptOut(optOut);
|
|
1139
|
+
};
|
|
1140
|
+
AmplitudeCore2.prototype._setOptOut = function(optOut) {
|
|
1141
|
+
if (this.config.optOut !== optOut) {
|
|
1142
|
+
this.timeline.onOptOutChanged(optOut);
|
|
1143
|
+
this.config.optOut = Boolean(optOut);
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
AmplitudeCore2.prototype.flush = function() {
|
|
1147
|
+
return returnWrapper(this.timeline.flush());
|
|
1148
|
+
};
|
|
1149
|
+
AmplitudeCore2.prototype.plugin = function(name) {
|
|
1150
|
+
var plugin = this.timeline.plugins.find(function(plugin2) {
|
|
1151
|
+
return plugin2.name === name;
|
|
1152
|
+
});
|
|
1153
|
+
if (plugin === void 0) {
|
|
1154
|
+
this.config.loggerProvider.debug("Cannot find plugin with name ".concat(name));
|
|
1155
|
+
return void 0;
|
|
1156
|
+
}
|
|
1157
|
+
return plugin;
|
|
1158
|
+
};
|
|
1159
|
+
AmplitudeCore2.prototype.plugins = function(pluginClass) {
|
|
1160
|
+
return this.timeline.plugins.filter(function(plugin) {
|
|
1161
|
+
return plugin instanceof pluginClass;
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
return AmplitudeCore2;
|
|
1165
|
+
})();
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/revenue.js
|
|
1170
|
+
var Revenue, RevenueProperty;
|
|
1171
|
+
var init_revenue = __esm({
|
|
1172
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/revenue.js"() {
|
|
1173
|
+
init_tslib_es6();
|
|
1174
|
+
init_valid_properties();
|
|
1175
|
+
Revenue = /** @class */
|
|
1176
|
+
(function() {
|
|
1177
|
+
function Revenue2() {
|
|
1178
|
+
this.productId = "";
|
|
1179
|
+
this.quantity = 1;
|
|
1180
|
+
this.price = 0;
|
|
1181
|
+
}
|
|
1182
|
+
Revenue2.prototype.setProductId = function(productId) {
|
|
1183
|
+
this.productId = productId;
|
|
1184
|
+
return this;
|
|
1185
|
+
};
|
|
1186
|
+
Revenue2.prototype.setQuantity = function(quantity) {
|
|
1187
|
+
if (quantity > 0) {
|
|
1188
|
+
this.quantity = quantity;
|
|
1189
|
+
}
|
|
1190
|
+
return this;
|
|
1191
|
+
};
|
|
1192
|
+
Revenue2.prototype.setPrice = function(price) {
|
|
1193
|
+
this.price = price;
|
|
1194
|
+
return this;
|
|
1195
|
+
};
|
|
1196
|
+
Revenue2.prototype.setRevenueType = function(revenueType) {
|
|
1197
|
+
this.revenueType = revenueType;
|
|
1198
|
+
return this;
|
|
1199
|
+
};
|
|
1200
|
+
Revenue2.prototype.setCurrency = function(currency) {
|
|
1201
|
+
this.currency = currency;
|
|
1202
|
+
return this;
|
|
1203
|
+
};
|
|
1204
|
+
Revenue2.prototype.setRevenue = function(revenue2) {
|
|
1205
|
+
this.revenue = revenue2;
|
|
1206
|
+
return this;
|
|
1207
|
+
};
|
|
1208
|
+
Revenue2.prototype.setReceipt = function(receipt) {
|
|
1209
|
+
this.receipt = receipt;
|
|
1210
|
+
return this;
|
|
1211
|
+
};
|
|
1212
|
+
Revenue2.prototype.setReceiptSig = function(receiptSig) {
|
|
1213
|
+
this.receiptSig = receiptSig;
|
|
1214
|
+
return this;
|
|
1215
|
+
};
|
|
1216
|
+
Revenue2.prototype.setEventProperties = function(properties) {
|
|
1217
|
+
if (isValidObject(properties)) {
|
|
1218
|
+
this.properties = properties;
|
|
1219
|
+
}
|
|
1220
|
+
return this;
|
|
1221
|
+
};
|
|
1222
|
+
Revenue2.prototype.getEventProperties = function() {
|
|
1223
|
+
var eventProperties = this.properties ? __assign({}, this.properties) : {};
|
|
1224
|
+
eventProperties[RevenueProperty.REVENUE_PRODUCT_ID] = this.productId;
|
|
1225
|
+
eventProperties[RevenueProperty.REVENUE_QUANTITY] = this.quantity;
|
|
1226
|
+
eventProperties[RevenueProperty.REVENUE_PRICE] = this.price;
|
|
1227
|
+
eventProperties[RevenueProperty.REVENUE_TYPE] = this.revenueType;
|
|
1228
|
+
eventProperties[RevenueProperty.REVENUE_CURRENCY] = this.currency;
|
|
1229
|
+
eventProperties[RevenueProperty.REVENUE] = this.revenue;
|
|
1230
|
+
eventProperties[RevenueProperty.RECEIPT] = this.receipt;
|
|
1231
|
+
eventProperties[RevenueProperty.RECEIPT_SIG] = this.receiptSig;
|
|
1232
|
+
return eventProperties;
|
|
1233
|
+
};
|
|
1234
|
+
return Revenue2;
|
|
1235
|
+
})();
|
|
1236
|
+
(function(RevenueProperty2) {
|
|
1237
|
+
RevenueProperty2["REVENUE_PRODUCT_ID"] = "$productId";
|
|
1238
|
+
RevenueProperty2["REVENUE_QUANTITY"] = "$quantity";
|
|
1239
|
+
RevenueProperty2["REVENUE_PRICE"] = "$price";
|
|
1240
|
+
RevenueProperty2["REVENUE_TYPE"] = "$revenueType";
|
|
1241
|
+
RevenueProperty2["REVENUE_CURRENCY"] = "$currency";
|
|
1242
|
+
RevenueProperty2["REVENUE"] = "$revenue";
|
|
1243
|
+
RevenueProperty2["RECEIPT"] = "$receipt";
|
|
1244
|
+
RevenueProperty2["RECEIPT_SIG"] = "$receiptSig";
|
|
1245
|
+
})(RevenueProperty || (RevenueProperty = {}));
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/chunk.js
|
|
1250
|
+
var chunk;
|
|
1251
|
+
var init_chunk = __esm({
|
|
1252
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/chunk.js"() {
|
|
1253
|
+
chunk = function(arr, size) {
|
|
1254
|
+
var chunkSize = Math.max(size, 1);
|
|
1255
|
+
return arr.reduce(function(chunks, element, index) {
|
|
1256
|
+
var chunkIndex = Math.floor(index / chunkSize);
|
|
1257
|
+
if (!chunks[chunkIndex]) {
|
|
1258
|
+
chunks[chunkIndex] = [];
|
|
1259
|
+
}
|
|
1260
|
+
chunks[chunkIndex].push(element);
|
|
1261
|
+
return chunks;
|
|
1262
|
+
}, []);
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
|
|
1267
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/loglevel.js
|
|
1268
|
+
var LogLevel;
|
|
1269
|
+
var init_loglevel = __esm({
|
|
1270
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/loglevel.js"() {
|
|
1271
|
+
(function(LogLevel2) {
|
|
1272
|
+
LogLevel2[LogLevel2["None"] = 0] = "None";
|
|
1273
|
+
LogLevel2[LogLevel2["Error"] = 1] = "Error";
|
|
1274
|
+
LogLevel2[LogLevel2["Warn"] = 2] = "Warn";
|
|
1275
|
+
LogLevel2[LogLevel2["Verbose"] = 3] = "Verbose";
|
|
1276
|
+
LogLevel2[LogLevel2["Debug"] = 4] = "Debug";
|
|
1277
|
+
})(LogLevel || (LogLevel = {}));
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/logger.js
|
|
1282
|
+
var PREFIX, Logger;
|
|
1283
|
+
var init_logger = __esm({
|
|
1284
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/logger.js"() {
|
|
1285
|
+
init_loglevel();
|
|
1286
|
+
PREFIX = "Amplitude Logger ";
|
|
1287
|
+
Logger = /** @class */
|
|
1288
|
+
(function() {
|
|
1289
|
+
function Logger2() {
|
|
1290
|
+
this.logLevel = LogLevel.None;
|
|
1291
|
+
}
|
|
1292
|
+
Logger2.prototype.disable = function() {
|
|
1293
|
+
this.logLevel = LogLevel.None;
|
|
1294
|
+
};
|
|
1295
|
+
Logger2.prototype.enable = function(logLevel) {
|
|
1296
|
+
if (logLevel === void 0) {
|
|
1297
|
+
logLevel = LogLevel.Warn;
|
|
1298
|
+
}
|
|
1299
|
+
this.logLevel = logLevel;
|
|
1300
|
+
};
|
|
1301
|
+
Logger2.prototype.log = function() {
|
|
1302
|
+
var args = [];
|
|
1303
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1304
|
+
args[_i] = arguments[_i];
|
|
1305
|
+
}
|
|
1306
|
+
if (this.logLevel < LogLevel.Verbose) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
console.log("".concat(PREFIX, "[Log]: ").concat(args.join(" ")));
|
|
1310
|
+
};
|
|
1311
|
+
Logger2.prototype.warn = function() {
|
|
1312
|
+
var args = [];
|
|
1313
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1314
|
+
args[_i] = arguments[_i];
|
|
1315
|
+
}
|
|
1316
|
+
if (this.logLevel < LogLevel.Warn) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
console.warn("".concat(PREFIX, "[Warn]: ").concat(args.join(" ")));
|
|
1320
|
+
};
|
|
1321
|
+
Logger2.prototype.error = function() {
|
|
1322
|
+
var args = [];
|
|
1323
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1324
|
+
args[_i] = arguments[_i];
|
|
1325
|
+
}
|
|
1326
|
+
if (this.logLevel < LogLevel.Error) {
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1329
|
+
console.error("".concat(PREFIX, "[Error]: ").concat(args.join(" ")));
|
|
1330
|
+
};
|
|
1331
|
+
Logger2.prototype.debug = function() {
|
|
1332
|
+
var args = [];
|
|
1333
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1334
|
+
args[_i] = arguments[_i];
|
|
1335
|
+
}
|
|
1336
|
+
if (this.logLevel < LogLevel.Debug) {
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
console.log("".concat(PREFIX, "[Debug]: ").concat(args.join(" ")));
|
|
1340
|
+
};
|
|
1341
|
+
return Logger2;
|
|
1342
|
+
})();
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/config.js
|
|
1347
|
+
var getDefaultConfig, Config, getServerUrl, createServerConfig, RequestMetadata;
|
|
1348
|
+
var init_config = __esm({
|
|
1349
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/config.js"() {
|
|
1350
|
+
init_constants();
|
|
1351
|
+
init_logger();
|
|
1352
|
+
init_loglevel();
|
|
1353
|
+
getDefaultConfig = function() {
|
|
1354
|
+
return {
|
|
1355
|
+
flushMaxRetries: 12,
|
|
1356
|
+
flushQueueSize: 200,
|
|
1357
|
+
flushIntervalMillis: 1e4,
|
|
1358
|
+
instanceName: DEFAULT_INSTANCE_NAME,
|
|
1359
|
+
logLevel: LogLevel.Warn,
|
|
1360
|
+
loggerProvider: new Logger(),
|
|
1361
|
+
offline: false,
|
|
1362
|
+
optOut: false,
|
|
1363
|
+
serverUrl: AMPLITUDE_SERVER_URL,
|
|
1364
|
+
serverZone: "US",
|
|
1365
|
+
useBatch: false
|
|
1366
|
+
};
|
|
1367
|
+
};
|
|
1368
|
+
Config = /** @class */
|
|
1369
|
+
(function() {
|
|
1370
|
+
function Config2(options) {
|
|
1371
|
+
var _a, _b, _c, _d;
|
|
1372
|
+
this._optOut = false;
|
|
1373
|
+
var defaultConfig = getDefaultConfig();
|
|
1374
|
+
this.apiKey = options.apiKey;
|
|
1375
|
+
this.flushIntervalMillis = (_a = options.flushIntervalMillis) !== null && _a !== void 0 ? _a : defaultConfig.flushIntervalMillis;
|
|
1376
|
+
this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;
|
|
1377
|
+
this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;
|
|
1378
|
+
this.instanceName = options.instanceName || defaultConfig.instanceName;
|
|
1379
|
+
this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;
|
|
1380
|
+
this.logLevel = (_b = options.logLevel) !== null && _b !== void 0 ? _b : defaultConfig.logLevel;
|
|
1381
|
+
this.minIdLength = options.minIdLength;
|
|
1382
|
+
this.plan = options.plan;
|
|
1383
|
+
this.ingestionMetadata = options.ingestionMetadata;
|
|
1384
|
+
this.offline = options.offline !== void 0 ? options.offline : defaultConfig.offline;
|
|
1385
|
+
this.optOut = (_c = options.optOut) !== null && _c !== void 0 ? _c : defaultConfig.optOut;
|
|
1386
|
+
this.serverUrl = options.serverUrl;
|
|
1387
|
+
this.serverZone = options.serverZone || defaultConfig.serverZone;
|
|
1388
|
+
this.storageProvider = options.storageProvider;
|
|
1389
|
+
this.transportProvider = options.transportProvider;
|
|
1390
|
+
this.useBatch = (_d = options.useBatch) !== null && _d !== void 0 ? _d : defaultConfig.useBatch;
|
|
1391
|
+
this.loggerProvider.enable(this.logLevel);
|
|
1392
|
+
var serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);
|
|
1393
|
+
this.serverZone = serverConfig.serverZone;
|
|
1394
|
+
this.serverUrl = serverConfig.serverUrl;
|
|
1395
|
+
}
|
|
1396
|
+
Object.defineProperty(Config2.prototype, "optOut", {
|
|
1397
|
+
get: function() {
|
|
1398
|
+
return this._optOut;
|
|
1399
|
+
},
|
|
1400
|
+
set: function(optOut) {
|
|
1401
|
+
this._optOut = optOut;
|
|
1402
|
+
},
|
|
1403
|
+
enumerable: false,
|
|
1404
|
+
configurable: true
|
|
1405
|
+
});
|
|
1406
|
+
return Config2;
|
|
1407
|
+
})();
|
|
1408
|
+
getServerUrl = function(serverZone, useBatch) {
|
|
1409
|
+
if (serverZone === "EU") {
|
|
1410
|
+
return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;
|
|
1411
|
+
}
|
|
1412
|
+
return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;
|
|
1413
|
+
};
|
|
1414
|
+
createServerConfig = function(serverUrl, serverZone, useBatch) {
|
|
1415
|
+
if (serverUrl === void 0) {
|
|
1416
|
+
serverUrl = "";
|
|
1417
|
+
}
|
|
1418
|
+
if (serverZone === void 0) {
|
|
1419
|
+
serverZone = getDefaultConfig().serverZone;
|
|
1420
|
+
}
|
|
1421
|
+
if (useBatch === void 0) {
|
|
1422
|
+
useBatch = getDefaultConfig().useBatch;
|
|
1423
|
+
}
|
|
1424
|
+
if (serverUrl) {
|
|
1425
|
+
return { serverUrl, serverZone: void 0 };
|
|
1426
|
+
}
|
|
1427
|
+
var _serverZone = ["US", "EU"].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;
|
|
1428
|
+
return {
|
|
1429
|
+
serverZone: _serverZone,
|
|
1430
|
+
serverUrl: getServerUrl(_serverZone, useBatch)
|
|
1431
|
+
};
|
|
1432
|
+
};
|
|
1433
|
+
RequestMetadata = /** @class */
|
|
1434
|
+
(function() {
|
|
1435
|
+
function RequestMetadata2() {
|
|
1436
|
+
this.sdk = {
|
|
1437
|
+
metrics: {
|
|
1438
|
+
histogram: {}
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
RequestMetadata2.prototype.recordHistogram = function(key, value) {
|
|
1443
|
+
this.sdk.metrics.histogram[key] = value;
|
|
1444
|
+
};
|
|
1445
|
+
return RequestMetadata2;
|
|
1446
|
+
})();
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
|
|
1450
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/status-code.js
|
|
1451
|
+
function isSuccessStatusCode(code) {
|
|
1452
|
+
return code >= 200 && code < 300;
|
|
1453
|
+
}
|
|
1454
|
+
var init_status_code = __esm({
|
|
1455
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/status-code.js"() {
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
|
|
1459
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/debug.js
|
|
1460
|
+
var getStacktrace, getClientLogConfig, getValueByStringPath, getClientStates, debugWrapper;
|
|
1461
|
+
var init_debug = __esm({
|
|
1462
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/utils/debug.js"() {
|
|
1463
|
+
init_tslib_es6();
|
|
1464
|
+
init_loglevel();
|
|
1465
|
+
getStacktrace = function(ignoreDepth) {
|
|
1466
|
+
if (ignoreDepth === void 0) {
|
|
1467
|
+
ignoreDepth = 0;
|
|
1468
|
+
}
|
|
1469
|
+
var trace = new Error().stack || "";
|
|
1470
|
+
return trace.split("\n").slice(2 + ignoreDepth).map(function(text) {
|
|
1471
|
+
return text.trim();
|
|
1472
|
+
});
|
|
1473
|
+
};
|
|
1474
|
+
getClientLogConfig = function(client) {
|
|
1475
|
+
return function() {
|
|
1476
|
+
var _a = __assign({}, client.config), logger = _a.loggerProvider, logLevel = _a.logLevel;
|
|
1477
|
+
return {
|
|
1478
|
+
logger,
|
|
1479
|
+
logLevel
|
|
1480
|
+
};
|
|
1481
|
+
};
|
|
1482
|
+
};
|
|
1483
|
+
getValueByStringPath = function(obj, path) {
|
|
1484
|
+
var e_1, _a;
|
|
1485
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
1486
|
+
path = path.replace(/^\./, "");
|
|
1487
|
+
try {
|
|
1488
|
+
for (var _b = __values(path.split(".")), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1489
|
+
var attr = _c.value;
|
|
1490
|
+
if (attr in obj) {
|
|
1491
|
+
obj = obj[attr];
|
|
1492
|
+
} else {
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
} catch (e_1_1) {
|
|
1497
|
+
e_1 = { error: e_1_1 };
|
|
1498
|
+
} finally {
|
|
1499
|
+
try {
|
|
1500
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1501
|
+
} finally {
|
|
1502
|
+
if (e_1) throw e_1.error;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return obj;
|
|
1506
|
+
};
|
|
1507
|
+
getClientStates = function(client, paths) {
|
|
1508
|
+
return function() {
|
|
1509
|
+
var e_2, _a;
|
|
1510
|
+
var res = {};
|
|
1511
|
+
try {
|
|
1512
|
+
for (var paths_1 = __values(paths), paths_1_1 = paths_1.next(); !paths_1_1.done; paths_1_1 = paths_1.next()) {
|
|
1513
|
+
var path = paths_1_1.value;
|
|
1514
|
+
res[path] = getValueByStringPath(client, path);
|
|
1515
|
+
}
|
|
1516
|
+
} catch (e_2_1) {
|
|
1517
|
+
e_2 = { error: e_2_1 };
|
|
1518
|
+
} finally {
|
|
1519
|
+
try {
|
|
1520
|
+
if (paths_1_1 && !paths_1_1.done && (_a = paths_1.return)) _a.call(paths_1);
|
|
1521
|
+
} finally {
|
|
1522
|
+
if (e_2) throw e_2.error;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
return res;
|
|
1526
|
+
};
|
|
1527
|
+
};
|
|
1528
|
+
debugWrapper = function(fn, fnName, getLogConfig, getStates, fnContext) {
|
|
1529
|
+
if (fnContext === void 0) {
|
|
1530
|
+
fnContext = null;
|
|
1531
|
+
}
|
|
1532
|
+
return function() {
|
|
1533
|
+
var args = [];
|
|
1534
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1535
|
+
args[_i] = arguments[_i];
|
|
1536
|
+
}
|
|
1537
|
+
var _a = getLogConfig(), logger = _a.logger, logLevel = _a.logLevel;
|
|
1538
|
+
if (logLevel && logLevel < LogLevel.Debug || !logLevel || !logger) {
|
|
1539
|
+
return fn.apply(fnContext, args);
|
|
1540
|
+
}
|
|
1541
|
+
var debugContext = {
|
|
1542
|
+
type: "invoke public method",
|
|
1543
|
+
name: fnName,
|
|
1544
|
+
args,
|
|
1545
|
+
stacktrace: getStacktrace(1),
|
|
1546
|
+
time: {
|
|
1547
|
+
start: (/* @__PURE__ */ new Date()).toISOString()
|
|
1548
|
+
},
|
|
1549
|
+
states: {}
|
|
1550
|
+
};
|
|
1551
|
+
if (getStates && debugContext.states) {
|
|
1552
|
+
debugContext.states.before = getStates();
|
|
1553
|
+
}
|
|
1554
|
+
var result = fn.apply(fnContext, args);
|
|
1555
|
+
if (result && result.promise) {
|
|
1556
|
+
result.promise.then(function() {
|
|
1557
|
+
if (getStates && debugContext.states) {
|
|
1558
|
+
debugContext.states.after = getStates();
|
|
1559
|
+
}
|
|
1560
|
+
if (debugContext.time) {
|
|
1561
|
+
debugContext.time.end = (/* @__PURE__ */ new Date()).toISOString();
|
|
1562
|
+
}
|
|
1563
|
+
logger.debug(JSON.stringify(debugContext, null, 2));
|
|
1564
|
+
});
|
|
1565
|
+
} else {
|
|
1566
|
+
if (getStates && debugContext.states) {
|
|
1567
|
+
debugContext.states.after = getStates();
|
|
1568
|
+
}
|
|
1569
|
+
if (debugContext.time) {
|
|
1570
|
+
debugContext.time.end = (/* @__PURE__ */ new Date()).toISOString();
|
|
1571
|
+
}
|
|
1572
|
+
logger.debug(JSON.stringify(debugContext, null, 2));
|
|
1573
|
+
}
|
|
1574
|
+
return result;
|
|
1575
|
+
};
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.js
|
|
1581
|
+
function getErrorMessage(error) {
|
|
1582
|
+
if (error instanceof Error)
|
|
1583
|
+
return error.message;
|
|
1584
|
+
return String(error);
|
|
1585
|
+
}
|
|
1586
|
+
function getResponseBodyString(res) {
|
|
1587
|
+
var responseBodyString = "";
|
|
1588
|
+
try {
|
|
1589
|
+
if ("body" in res) {
|
|
1590
|
+
responseBodyString = JSON.stringify(res.body, null, 2);
|
|
1591
|
+
}
|
|
1592
|
+
} catch (_a) {
|
|
1593
|
+
}
|
|
1594
|
+
return responseBodyString;
|
|
1595
|
+
}
|
|
1596
|
+
var Destination;
|
|
1597
|
+
var init_destination = __esm({
|
|
1598
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/plugins/destination.js"() {
|
|
1599
|
+
init_tslib_es6();
|
|
1600
|
+
init_status();
|
|
1601
|
+
init_messages();
|
|
1602
|
+
init_constants();
|
|
1603
|
+
init_chunk();
|
|
1604
|
+
init_result_builder();
|
|
1605
|
+
init_config();
|
|
1606
|
+
init_uuid();
|
|
1607
|
+
init_status_code();
|
|
1608
|
+
init_debug();
|
|
1609
|
+
Destination = /** @class */
|
|
1610
|
+
(function() {
|
|
1611
|
+
function Destination2(context) {
|
|
1612
|
+
this.name = "amplitude";
|
|
1613
|
+
this.type = "destination";
|
|
1614
|
+
this.retryTimeout = 1e3;
|
|
1615
|
+
this.throttleTimeout = 3e4;
|
|
1616
|
+
this.storageKey = "";
|
|
1617
|
+
this.scheduleId = null;
|
|
1618
|
+
this.scheduledTimeout = 0;
|
|
1619
|
+
this.flushId = null;
|
|
1620
|
+
this.queue = [];
|
|
1621
|
+
this.diagnosticsClient = context === null || context === void 0 ? void 0 : context.diagnosticsClient;
|
|
1622
|
+
}
|
|
1623
|
+
Destination2.prototype.setup = function(config) {
|
|
1624
|
+
var _a;
|
|
1625
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1626
|
+
var unsent;
|
|
1627
|
+
var _this = this;
|
|
1628
|
+
return __generator(this, function(_b) {
|
|
1629
|
+
switch (_b.label) {
|
|
1630
|
+
case 0:
|
|
1631
|
+
this.config = config;
|
|
1632
|
+
this.storageKey = "".concat(STORAGE_PREFIX, "_").concat(this.config.apiKey.substring(0, 10));
|
|
1633
|
+
return [4, (_a = this.config.storageProvider) === null || _a === void 0 ? void 0 : _a.get(this.storageKey)];
|
|
1634
|
+
case 1:
|
|
1635
|
+
unsent = _b.sent();
|
|
1636
|
+
if (unsent && unsent.length > 0) {
|
|
1637
|
+
void Promise.all(unsent.map(function(event) {
|
|
1638
|
+
return _this.execute(event);
|
|
1639
|
+
})).catch();
|
|
1640
|
+
}
|
|
1641
|
+
return [2, Promise.resolve(void 0)];
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
});
|
|
1645
|
+
};
|
|
1646
|
+
Destination2.prototype.execute = function(event) {
|
|
1647
|
+
var _this = this;
|
|
1648
|
+
if (!event.insert_id) {
|
|
1649
|
+
event.insert_id = UUID();
|
|
1650
|
+
}
|
|
1651
|
+
return new Promise(function(resolve) {
|
|
1652
|
+
var context = {
|
|
1653
|
+
event,
|
|
1654
|
+
attempts: 0,
|
|
1655
|
+
callback: function(result) {
|
|
1656
|
+
return resolve(result);
|
|
1657
|
+
},
|
|
1658
|
+
timeout: 0
|
|
1659
|
+
};
|
|
1660
|
+
_this.queue.push(context);
|
|
1661
|
+
_this.schedule(_this.config.flushIntervalMillis);
|
|
1662
|
+
_this.saveEvents();
|
|
1663
|
+
});
|
|
1664
|
+
};
|
|
1665
|
+
Destination2.prototype.removeEventsExceedFlushMaxRetries = function(list) {
|
|
1666
|
+
var _this = this;
|
|
1667
|
+
return list.filter(function(context) {
|
|
1668
|
+
context.attempts += 1;
|
|
1669
|
+
if (context.attempts < _this.config.flushMaxRetries) {
|
|
1670
|
+
return true;
|
|
1671
|
+
}
|
|
1672
|
+
void _this.fulfillRequest([context], 500, MAX_RETRIES_EXCEEDED_MESSAGE);
|
|
1673
|
+
return false;
|
|
1674
|
+
});
|
|
1675
|
+
};
|
|
1676
|
+
Destination2.prototype.scheduleEvents = function(list) {
|
|
1677
|
+
var _this = this;
|
|
1678
|
+
list.forEach(function(context) {
|
|
1679
|
+
_this.schedule(context.timeout === 0 ? _this.config.flushIntervalMillis : context.timeout);
|
|
1680
|
+
});
|
|
1681
|
+
};
|
|
1682
|
+
Destination2.prototype.schedule = function(timeout) {
|
|
1683
|
+
var _this = this;
|
|
1684
|
+
if (this.config.offline) {
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
if (this.scheduleId === null || this.scheduleId && timeout > this.scheduledTimeout) {
|
|
1688
|
+
if (this.scheduleId) {
|
|
1689
|
+
clearTimeout(this.scheduleId);
|
|
1690
|
+
}
|
|
1691
|
+
this.scheduledTimeout = timeout;
|
|
1692
|
+
this.scheduleId = setTimeout(function() {
|
|
1693
|
+
_this.queue = _this.queue.map(function(context) {
|
|
1694
|
+
context.timeout = 0;
|
|
1695
|
+
return context;
|
|
1696
|
+
});
|
|
1697
|
+
void _this.flush(true);
|
|
1698
|
+
}, timeout);
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
Destination2.prototype.resetSchedule = function() {
|
|
1703
|
+
this.scheduleId = null;
|
|
1704
|
+
this.scheduledTimeout = 0;
|
|
1705
|
+
};
|
|
1706
|
+
Destination2.prototype.flush = function(useRetry) {
|
|
1707
|
+
if (useRetry === void 0) {
|
|
1708
|
+
useRetry = false;
|
|
1709
|
+
}
|
|
1710
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1711
|
+
var list, later, batches;
|
|
1712
|
+
var _this = this;
|
|
1713
|
+
return __generator(this, function(_a) {
|
|
1714
|
+
switch (_a.label) {
|
|
1715
|
+
case 0:
|
|
1716
|
+
if (this.config.offline) {
|
|
1717
|
+
this.resetSchedule();
|
|
1718
|
+
this.config.loggerProvider.debug("Skipping flush while offline.");
|
|
1719
|
+
return [
|
|
1720
|
+
2
|
|
1721
|
+
/*return*/
|
|
1722
|
+
];
|
|
1723
|
+
}
|
|
1724
|
+
if (this.flushId) {
|
|
1725
|
+
this.resetSchedule();
|
|
1726
|
+
this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved.");
|
|
1727
|
+
return [
|
|
1728
|
+
2
|
|
1729
|
+
/*return*/
|
|
1730
|
+
];
|
|
1731
|
+
}
|
|
1732
|
+
this.flushId = this.scheduleId;
|
|
1733
|
+
this.resetSchedule();
|
|
1734
|
+
list = [];
|
|
1735
|
+
later = [];
|
|
1736
|
+
this.queue.forEach(function(context) {
|
|
1737
|
+
return context.timeout === 0 ? list.push(context) : later.push(context);
|
|
1738
|
+
});
|
|
1739
|
+
batches = chunk(list, this.config.flushQueueSize);
|
|
1740
|
+
return [4, batches.reduce(function(promise, batch) {
|
|
1741
|
+
return __awaiter(_this, void 0, void 0, function() {
|
|
1742
|
+
return __generator(this, function(_a2) {
|
|
1743
|
+
switch (_a2.label) {
|
|
1744
|
+
case 0:
|
|
1745
|
+
return [4, promise];
|
|
1746
|
+
case 1:
|
|
1747
|
+
_a2.sent();
|
|
1748
|
+
return [4, this.send(batch, useRetry)];
|
|
1749
|
+
case 2:
|
|
1750
|
+
return [2, _a2.sent()];
|
|
1751
|
+
}
|
|
1752
|
+
});
|
|
1753
|
+
});
|
|
1754
|
+
}, Promise.resolve())];
|
|
1755
|
+
case 1:
|
|
1756
|
+
_a.sent();
|
|
1757
|
+
this.flushId = null;
|
|
1758
|
+
this.scheduleEvents(this.queue);
|
|
1759
|
+
return [
|
|
1760
|
+
2
|
|
1761
|
+
/*return*/
|
|
1762
|
+
];
|
|
1763
|
+
}
|
|
1764
|
+
});
|
|
1765
|
+
});
|
|
1766
|
+
};
|
|
1767
|
+
Destination2.prototype.send = function(list, useRetry) {
|
|
1768
|
+
var _a;
|
|
1769
|
+
if (useRetry === void 0) {
|
|
1770
|
+
useRetry = true;
|
|
1771
|
+
}
|
|
1772
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1773
|
+
var payload, serverUrl, res, e_1, errorMessage;
|
|
1774
|
+
return __generator(this, function(_b) {
|
|
1775
|
+
switch (_b.label) {
|
|
1776
|
+
case 0:
|
|
1777
|
+
if (!this.config.apiKey) {
|
|
1778
|
+
return [2, this.fulfillRequest(list, 400, MISSING_API_KEY_MESSAGE)];
|
|
1779
|
+
}
|
|
1780
|
+
payload = {
|
|
1781
|
+
api_key: this.config.apiKey,
|
|
1782
|
+
events: list.map(function(context) {
|
|
1783
|
+
var _a2 = context.event; _a2.extra; var eventWithoutExtra = __rest(_a2, ["extra"]);
|
|
1784
|
+
return eventWithoutExtra;
|
|
1785
|
+
}),
|
|
1786
|
+
options: {
|
|
1787
|
+
min_id_length: this.config.minIdLength
|
|
1788
|
+
},
|
|
1789
|
+
client_upload_time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1790
|
+
request_metadata: this.config.requestMetadata
|
|
1791
|
+
};
|
|
1792
|
+
this.config.requestMetadata = new RequestMetadata();
|
|
1793
|
+
_b.label = 1;
|
|
1794
|
+
case 1:
|
|
1795
|
+
_b.trys.push([1, 3, , 4]);
|
|
1796
|
+
serverUrl = createServerConfig(this.config.serverUrl, this.config.serverZone, this.config.useBatch).serverUrl;
|
|
1797
|
+
return [4, this.config.transportProvider.send(serverUrl, payload)];
|
|
1798
|
+
case 2:
|
|
1799
|
+
res = _b.sent();
|
|
1800
|
+
if (res === null) {
|
|
1801
|
+
this.fulfillRequest(list, 0, UNEXPECTED_ERROR_MESSAGE);
|
|
1802
|
+
return [
|
|
1803
|
+
2
|
|
1804
|
+
/*return*/
|
|
1805
|
+
];
|
|
1806
|
+
}
|
|
1807
|
+
if (!useRetry) {
|
|
1808
|
+
if ("body" in res) {
|
|
1809
|
+
this.fulfillRequest(list, res.statusCode, "".concat(res.status, ": ").concat(getResponseBodyString(res)));
|
|
1810
|
+
} else {
|
|
1811
|
+
this.fulfillRequest(list, res.statusCode, res.status);
|
|
1812
|
+
}
|
|
1813
|
+
return [
|
|
1814
|
+
2
|
|
1815
|
+
/*return*/
|
|
1816
|
+
];
|
|
1817
|
+
}
|
|
1818
|
+
this.handleResponse(res, list);
|
|
1819
|
+
return [3, 4];
|
|
1820
|
+
case 3:
|
|
1821
|
+
e_1 = _b.sent();
|
|
1822
|
+
errorMessage = getErrorMessage(e_1);
|
|
1823
|
+
this.config.loggerProvider.error(errorMessage);
|
|
1824
|
+
(_a = this.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.recordEvent("analytics.events.unsuccessful.from.catch.error", {
|
|
1825
|
+
events: list.map(function(context) {
|
|
1826
|
+
return context.event.event_type;
|
|
1827
|
+
}),
|
|
1828
|
+
message: errorMessage,
|
|
1829
|
+
stack_trace: getStacktrace()
|
|
1830
|
+
});
|
|
1831
|
+
this.handleResponse({ status: Status.Failed, statusCode: 0 }, list);
|
|
1832
|
+
return [3, 4];
|
|
1833
|
+
case 4:
|
|
1834
|
+
return [
|
|
1835
|
+
2
|
|
1836
|
+
/*return*/
|
|
1837
|
+
];
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
});
|
|
1841
|
+
};
|
|
1842
|
+
Destination2.prototype.handleResponse = function(res, list) {
|
|
1843
|
+
var _a;
|
|
1844
|
+
if (!isSuccessStatusCode(res.statusCode)) {
|
|
1845
|
+
(_a = this.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.recordEvent("analytics.events.unsuccessful", {
|
|
1846
|
+
events: list.map(function(context) {
|
|
1847
|
+
return context.event.event_type;
|
|
1848
|
+
}),
|
|
1849
|
+
code: res.statusCode,
|
|
1850
|
+
status: res.status,
|
|
1851
|
+
body: getResponseBodyString(res),
|
|
1852
|
+
stack_trace: getStacktrace()
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
var status = res.status;
|
|
1856
|
+
switch (status) {
|
|
1857
|
+
case Status.Success: {
|
|
1858
|
+
this.handleSuccessResponse(res, list);
|
|
1859
|
+
break;
|
|
1860
|
+
}
|
|
1861
|
+
case Status.Invalid: {
|
|
1862
|
+
this.handleInvalidResponse(res, list);
|
|
1863
|
+
break;
|
|
1864
|
+
}
|
|
1865
|
+
case Status.PayloadTooLarge: {
|
|
1866
|
+
this.handlePayloadTooLargeResponse(res, list);
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
case Status.RateLimit: {
|
|
1870
|
+
this.handleRateLimitResponse(res, list);
|
|
1871
|
+
break;
|
|
1872
|
+
}
|
|
1873
|
+
default: {
|
|
1874
|
+
this.config.loggerProvider.warn(`{code: 0, error: "Status '`.concat(status, "' provided for ").concat(list.length, ' events"}'));
|
|
1875
|
+
this.handleOtherResponse(list);
|
|
1876
|
+
break;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
Destination2.prototype.handleSuccessResponse = function(res, list) {
|
|
1881
|
+
this.fulfillRequest(list, res.statusCode, SUCCESS_MESSAGE);
|
|
1882
|
+
};
|
|
1883
|
+
Destination2.prototype.handleInvalidResponse = function(res, list) {
|
|
1884
|
+
var _this = this;
|
|
1885
|
+
if (res.body.missingField || res.body.error.startsWith(INVALID_API_KEY)) {
|
|
1886
|
+
this.fulfillRequest(list, res.statusCode, res.body.error);
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
var dropIndex = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(Object.values(res.body.eventsWithInvalidFields)), false), __read(Object.values(res.body.eventsWithMissingFields)), false), __read(Object.values(res.body.eventsWithInvalidIdLengths)), false), __read(res.body.silencedEvents), false).flat();
|
|
1890
|
+
var dropIndexSet = new Set(dropIndex);
|
|
1891
|
+
var retry = list.filter(function(context, index) {
|
|
1892
|
+
if (dropIndexSet.has(index)) {
|
|
1893
|
+
_this.fulfillRequest([context], res.statusCode, res.body.error);
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
return true;
|
|
1897
|
+
});
|
|
1898
|
+
if (retry.length > 0) {
|
|
1899
|
+
this.config.loggerProvider.warn(getResponseBodyString(res));
|
|
1900
|
+
}
|
|
1901
|
+
var tryable = this.removeEventsExceedFlushMaxRetries(retry);
|
|
1902
|
+
this.scheduleEvents(tryable);
|
|
1903
|
+
};
|
|
1904
|
+
Destination2.prototype.handlePayloadTooLargeResponse = function(res, list) {
|
|
1905
|
+
if (list.length === 1) {
|
|
1906
|
+
this.fulfillRequest(list, res.statusCode, res.body.error);
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
this.config.loggerProvider.warn(getResponseBodyString(res));
|
|
1910
|
+
this.config.flushQueueSize /= 2;
|
|
1911
|
+
var tryable = this.removeEventsExceedFlushMaxRetries(list);
|
|
1912
|
+
this.scheduleEvents(tryable);
|
|
1913
|
+
};
|
|
1914
|
+
Destination2.prototype.handleRateLimitResponse = function(res, list) {
|
|
1915
|
+
var _this = this;
|
|
1916
|
+
var dropUserIds = Object.keys(res.body.exceededDailyQuotaUsers);
|
|
1917
|
+
var dropDeviceIds = Object.keys(res.body.exceededDailyQuotaDevices);
|
|
1918
|
+
var throttledIndex = res.body.throttledEvents;
|
|
1919
|
+
var dropUserIdsSet = new Set(dropUserIds);
|
|
1920
|
+
var dropDeviceIdsSet = new Set(dropDeviceIds);
|
|
1921
|
+
var throttledIndexSet = new Set(throttledIndex);
|
|
1922
|
+
var retry = list.filter(function(context, index) {
|
|
1923
|
+
if (context.event.user_id && dropUserIdsSet.has(context.event.user_id) || context.event.device_id && dropDeviceIdsSet.has(context.event.device_id)) {
|
|
1924
|
+
_this.fulfillRequest([context], res.statusCode, res.body.error);
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
if (throttledIndexSet.has(index)) {
|
|
1928
|
+
context.timeout = _this.throttleTimeout;
|
|
1929
|
+
}
|
|
1930
|
+
return true;
|
|
1931
|
+
});
|
|
1932
|
+
if (retry.length > 0) {
|
|
1933
|
+
this.config.loggerProvider.warn(getResponseBodyString(res));
|
|
1934
|
+
}
|
|
1935
|
+
var tryable = this.removeEventsExceedFlushMaxRetries(retry);
|
|
1936
|
+
this.scheduleEvents(tryable);
|
|
1937
|
+
};
|
|
1938
|
+
Destination2.prototype.handleOtherResponse = function(list) {
|
|
1939
|
+
var _this = this;
|
|
1940
|
+
var later = list.map(function(context) {
|
|
1941
|
+
context.timeout = context.attempts * _this.retryTimeout;
|
|
1942
|
+
return context;
|
|
1943
|
+
});
|
|
1944
|
+
var tryable = this.removeEventsExceedFlushMaxRetries(later);
|
|
1945
|
+
this.scheduleEvents(tryable);
|
|
1946
|
+
};
|
|
1947
|
+
Destination2.prototype.fulfillRequest = function(list, code, message) {
|
|
1948
|
+
var _a, _b, _c;
|
|
1949
|
+
if (!isSuccessStatusCode(code)) {
|
|
1950
|
+
(_a = this.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.increment("analytics.events.dropped", list.length);
|
|
1951
|
+
(_b = this.diagnosticsClient) === null || _b === void 0 ? void 0 : _b.recordEvent("analytics.events.dropped", {
|
|
1952
|
+
events: list.map(function(context) {
|
|
1953
|
+
return context.event.event_type;
|
|
1954
|
+
}),
|
|
1955
|
+
code,
|
|
1956
|
+
message,
|
|
1957
|
+
stack_trace: getStacktrace()
|
|
1958
|
+
});
|
|
1959
|
+
} else {
|
|
1960
|
+
(_c = this.diagnosticsClient) === null || _c === void 0 ? void 0 : _c.increment("analytics.events.sent", list.length);
|
|
1961
|
+
}
|
|
1962
|
+
this.removeEvents(list);
|
|
1963
|
+
list.forEach(function(context) {
|
|
1964
|
+
return context.callback(buildResult(context.event, code, message));
|
|
1965
|
+
});
|
|
1966
|
+
};
|
|
1967
|
+
Destination2.prototype.saveEvents = function() {
|
|
1968
|
+
if (!this.config.storageProvider) {
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
var updatedEvents = this.queue.map(function(context) {
|
|
1972
|
+
return context.event;
|
|
1973
|
+
});
|
|
1974
|
+
void this.config.storageProvider.set(this.storageKey, updatedEvents);
|
|
1975
|
+
};
|
|
1976
|
+
Destination2.prototype.removeEvents = function(eventsToRemove) {
|
|
1977
|
+
this.queue = this.queue.filter(function(queuedContext) {
|
|
1978
|
+
return !eventsToRemove.some(function(context) {
|
|
1979
|
+
return context.event.insert_id === queuedContext.event.insert_id;
|
|
1980
|
+
});
|
|
1981
|
+
});
|
|
1982
|
+
this.saveEvents();
|
|
1983
|
+
};
|
|
1984
|
+
return Destination2;
|
|
1985
|
+
})();
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
|
|
1989
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/transports/base.js
|
|
1990
|
+
var BaseTransport;
|
|
1991
|
+
var init_base = __esm({
|
|
1992
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/transports/base.js"() {
|
|
1993
|
+
init_status();
|
|
1994
|
+
init_status_code();
|
|
1995
|
+
BaseTransport = /** @class */
|
|
1996
|
+
(function() {
|
|
1997
|
+
function BaseTransport2() {
|
|
1998
|
+
}
|
|
1999
|
+
BaseTransport2.prototype.send = function(_serverUrl, _payload) {
|
|
2000
|
+
return Promise.resolve(null);
|
|
2001
|
+
};
|
|
2002
|
+
BaseTransport2.prototype.buildResponse = function(responseJSON) {
|
|
2003
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2004
|
+
if (typeof responseJSON !== "object") {
|
|
2005
|
+
return null;
|
|
2006
|
+
}
|
|
2007
|
+
var statusCode = responseJSON.code || 0;
|
|
2008
|
+
var status = this.buildStatus(statusCode);
|
|
2009
|
+
switch (status) {
|
|
2010
|
+
case Status.Success:
|
|
2011
|
+
return {
|
|
2012
|
+
status,
|
|
2013
|
+
statusCode,
|
|
2014
|
+
body: {
|
|
2015
|
+
eventsIngested: (_a = responseJSON.events_ingested) !== null && _a !== void 0 ? _a : 0,
|
|
2016
|
+
payloadSizeBytes: (_b = responseJSON.payload_size_bytes) !== null && _b !== void 0 ? _b : 0,
|
|
2017
|
+
serverUploadTime: (_c = responseJSON.server_upload_time) !== null && _c !== void 0 ? _c : 0
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
case Status.Invalid:
|
|
2021
|
+
return {
|
|
2022
|
+
status,
|
|
2023
|
+
statusCode,
|
|
2024
|
+
body: {
|
|
2025
|
+
error: (_d = responseJSON.error) !== null && _d !== void 0 ? _d : "",
|
|
2026
|
+
missingField: (_e = responseJSON.missing_field) !== null && _e !== void 0 ? _e : "",
|
|
2027
|
+
eventsWithInvalidFields: (_f = responseJSON.events_with_invalid_fields) !== null && _f !== void 0 ? _f : {},
|
|
2028
|
+
eventsWithMissingFields: (_g = responseJSON.events_with_missing_fields) !== null && _g !== void 0 ? _g : {},
|
|
2029
|
+
eventsWithInvalidIdLengths: (_h = responseJSON.events_with_invalid_id_lengths) !== null && _h !== void 0 ? _h : {},
|
|
2030
|
+
epsThreshold: (_j = responseJSON.eps_threshold) !== null && _j !== void 0 ? _j : 0,
|
|
2031
|
+
exceededDailyQuotaDevices: (_k = responseJSON.exceeded_daily_quota_devices) !== null && _k !== void 0 ? _k : {},
|
|
2032
|
+
silencedDevices: (_l = responseJSON.silenced_devices) !== null && _l !== void 0 ? _l : [],
|
|
2033
|
+
silencedEvents: (_m = responseJSON.silenced_events) !== null && _m !== void 0 ? _m : [],
|
|
2034
|
+
throttledDevices: (_o = responseJSON.throttled_devices) !== null && _o !== void 0 ? _o : {},
|
|
2035
|
+
throttledEvents: (_p = responseJSON.throttled_events) !== null && _p !== void 0 ? _p : []
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
case Status.PayloadTooLarge:
|
|
2039
|
+
return {
|
|
2040
|
+
status,
|
|
2041
|
+
statusCode,
|
|
2042
|
+
body: {
|
|
2043
|
+
error: (_q = responseJSON.error) !== null && _q !== void 0 ? _q : ""
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
case Status.RateLimit:
|
|
2047
|
+
return {
|
|
2048
|
+
status,
|
|
2049
|
+
statusCode,
|
|
2050
|
+
body: {
|
|
2051
|
+
error: (_r = responseJSON.error) !== null && _r !== void 0 ? _r : "",
|
|
2052
|
+
epsThreshold: (_s = responseJSON.eps_threshold) !== null && _s !== void 0 ? _s : 0,
|
|
2053
|
+
throttledDevices: (_t = responseJSON.throttled_devices) !== null && _t !== void 0 ? _t : {},
|
|
2054
|
+
throttledUsers: (_u = responseJSON.throttled_users) !== null && _u !== void 0 ? _u : {},
|
|
2055
|
+
exceededDailyQuotaDevices: (_v = responseJSON.exceeded_daily_quota_devices) !== null && _v !== void 0 ? _v : {},
|
|
2056
|
+
exceededDailyQuotaUsers: (_w = responseJSON.exceeded_daily_quota_users) !== null && _w !== void 0 ? _w : {},
|
|
2057
|
+
throttledEvents: (_x = responseJSON.throttled_events) !== null && _x !== void 0 ? _x : []
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
case Status.Timeout:
|
|
2061
|
+
default:
|
|
2062
|
+
return {
|
|
2063
|
+
status,
|
|
2064
|
+
statusCode
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
BaseTransport2.prototype.buildStatus = function(code) {
|
|
2069
|
+
if (isSuccessStatusCode(code)) {
|
|
2070
|
+
return Status.Success;
|
|
2071
|
+
}
|
|
2072
|
+
if (code === 429) {
|
|
2073
|
+
return Status.RateLimit;
|
|
2074
|
+
}
|
|
2075
|
+
if (code === 413) {
|
|
2076
|
+
return Status.PayloadTooLarge;
|
|
2077
|
+
}
|
|
2078
|
+
if (code === 408) {
|
|
2079
|
+
return Status.Timeout;
|
|
2080
|
+
}
|
|
2081
|
+
if (code >= 400 && code < 500) {
|
|
2082
|
+
return Status.Invalid;
|
|
2083
|
+
}
|
|
2084
|
+
if (code >= 500) {
|
|
2085
|
+
return Status.Failed;
|
|
2086
|
+
}
|
|
2087
|
+
return Status.Unknown;
|
|
2088
|
+
};
|
|
2089
|
+
return BaseTransport2;
|
|
2090
|
+
})();
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
|
|
2094
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/server-zone.js
|
|
2095
|
+
var ServerZone;
|
|
2096
|
+
var init_server_zone = __esm({
|
|
2097
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/server-zone.js"() {
|
|
2098
|
+
(function(ServerZone2) {
|
|
2099
|
+
ServerZone2["US"] = "US";
|
|
2100
|
+
ServerZone2["EU"] = "EU";
|
|
2101
|
+
ServerZone2["STAGING"] = "STAGING";
|
|
2102
|
+
})(ServerZone || (ServerZone = {}));
|
|
2103
|
+
}
|
|
2104
|
+
});
|
|
2105
|
+
|
|
2106
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/offline.js
|
|
2107
|
+
var OfflineDisabled;
|
|
2108
|
+
var init_offline = __esm({
|
|
2109
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/types/offline.js"() {
|
|
2110
|
+
OfflineDisabled = null;
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
|
|
2114
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/index.js
|
|
2115
|
+
var init_esm = __esm({
|
|
2116
|
+
"../../node_modules/.pnpm/@amplitude+analytics-core@2.33.0/node_modules/@amplitude/analytics-core/lib/esm/index.js"() {
|
|
2117
|
+
init_core_client();
|
|
2118
|
+
init_identify();
|
|
2119
|
+
init_revenue();
|
|
2120
|
+
init_destination();
|
|
2121
|
+
init_config();
|
|
2122
|
+
init_return_wrapper();
|
|
2123
|
+
init_debug();
|
|
2124
|
+
init_uuid();
|
|
2125
|
+
init_base();
|
|
2126
|
+
init_loglevel();
|
|
2127
|
+
init_event();
|
|
2128
|
+
init_server_zone();
|
|
2129
|
+
init_offline();
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2132
|
+
|
|
2133
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/version.js
|
|
2134
|
+
var VERSION;
|
|
2135
|
+
var init_version = __esm({
|
|
2136
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/version.js"() {
|
|
2137
|
+
VERSION = "1.5.26";
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
|
|
2141
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/plugins/context.js
|
|
2142
|
+
var Context;
|
|
2143
|
+
var init_context = __esm({
|
|
2144
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/plugins/context.js"() {
|
|
2145
|
+
init_tslib_es6();
|
|
2146
|
+
init_esm();
|
|
2147
|
+
init_version();
|
|
2148
|
+
Context = /** @class */
|
|
2149
|
+
(function() {
|
|
2150
|
+
function Context2() {
|
|
2151
|
+
this.name = "context";
|
|
2152
|
+
this.type = "before";
|
|
2153
|
+
this.eventId = 0;
|
|
2154
|
+
this.library = "amplitude-node-ts/".concat(VERSION);
|
|
2155
|
+
}
|
|
2156
|
+
Context2.prototype.setup = function(config) {
|
|
2157
|
+
this.config = config;
|
|
2158
|
+
return Promise.resolve(void 0);
|
|
2159
|
+
};
|
|
2160
|
+
Context2.prototype.execute = function(context) {
|
|
2161
|
+
var _this = this;
|
|
2162
|
+
return new Promise(function(resolve) {
|
|
2163
|
+
var time = (/* @__PURE__ */ new Date()).getTime();
|
|
2164
|
+
var contextEvent = __assign(__assign(__assign({ time, insert_id: UUID(), plan: _this.config.plan }, _this.config.ingestionMetadata && {
|
|
2165
|
+
ingestion_metadata: {
|
|
2166
|
+
source_name: _this.config.ingestionMetadata.sourceName,
|
|
2167
|
+
source_version: _this.config.ingestionMetadata.sourceVersion
|
|
2168
|
+
}
|
|
2169
|
+
}), context), { event_id: _this.eventId++, library: _this.library });
|
|
2170
|
+
return resolve(contextEvent);
|
|
2171
|
+
});
|
|
2172
|
+
};
|
|
2173
|
+
return Context2;
|
|
2174
|
+
})();
|
|
2175
|
+
}
|
|
2176
|
+
});
|
|
2177
|
+
var Http;
|
|
2178
|
+
var init_http = __esm({
|
|
2179
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/transports/http.js"() {
|
|
2180
|
+
init_tslib_es6();
|
|
2181
|
+
init_esm();
|
|
2182
|
+
Http = /** @class */
|
|
2183
|
+
(function(_super) {
|
|
2184
|
+
__extends(Http2, _super);
|
|
2185
|
+
function Http2() {
|
|
2186
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2187
|
+
}
|
|
2188
|
+
Http2.prototype.send = function(serverUrl, payload) {
|
|
2189
|
+
var _this = this;
|
|
2190
|
+
var protocol;
|
|
2191
|
+
if (serverUrl.startsWith("http://")) {
|
|
2192
|
+
protocol = http__namespace;
|
|
2193
|
+
} else if (serverUrl.startsWith("https://")) {
|
|
2194
|
+
protocol = https__namespace;
|
|
2195
|
+
} else {
|
|
2196
|
+
throw new Error("Invalid server url");
|
|
2197
|
+
}
|
|
2198
|
+
var url = new URL(serverUrl);
|
|
2199
|
+
var requestPayload = JSON.stringify(payload);
|
|
2200
|
+
var options = {
|
|
2201
|
+
headers: {
|
|
2202
|
+
"Content-Type": "application/json",
|
|
2203
|
+
"Content-Length": Buffer.byteLength(requestPayload)
|
|
2204
|
+
},
|
|
2205
|
+
hostname: url.hostname,
|
|
2206
|
+
method: "POST",
|
|
2207
|
+
path: url.pathname,
|
|
2208
|
+
port: url.port,
|
|
2209
|
+
protocol: url.protocol
|
|
2210
|
+
};
|
|
2211
|
+
return new Promise(function(resolve) {
|
|
2212
|
+
var req = protocol.request(options, function(res) {
|
|
2213
|
+
res.setEncoding("utf8");
|
|
2214
|
+
var responsePayload = "";
|
|
2215
|
+
res.on("data", function(chunk2) {
|
|
2216
|
+
responsePayload += chunk2;
|
|
2217
|
+
});
|
|
2218
|
+
res.on("end", function() {
|
|
2219
|
+
if (res.complete && responsePayload.length > 0) {
|
|
2220
|
+
try {
|
|
2221
|
+
var parsedResponsePayload = JSON.parse(responsePayload);
|
|
2222
|
+
var result = _this.buildResponse(parsedResponsePayload);
|
|
2223
|
+
resolve(result);
|
|
2224
|
+
} catch (_a) {
|
|
2225
|
+
resolve(_this.buildResponse({ code: res.statusCode }));
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
});
|
|
2230
|
+
req.on("error", function() {
|
|
2231
|
+
return resolve(null);
|
|
2232
|
+
});
|
|
2233
|
+
req.end(requestPayload);
|
|
2234
|
+
});
|
|
2235
|
+
};
|
|
2236
|
+
return Http2;
|
|
2237
|
+
})(BaseTransport);
|
|
2238
|
+
}
|
|
2239
|
+
});
|
|
2240
|
+
|
|
2241
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/config.js
|
|
2242
|
+
var NodeConfig, useNodeConfig;
|
|
2243
|
+
var init_config2 = __esm({
|
|
2244
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/config.js"() {
|
|
2245
|
+
init_tslib_es6();
|
|
2246
|
+
init_esm();
|
|
2247
|
+
init_http();
|
|
2248
|
+
NodeConfig = /** @class */
|
|
2249
|
+
(function(_super) {
|
|
2250
|
+
__extends(NodeConfig2, _super);
|
|
2251
|
+
function NodeConfig2(apiKey, options) {
|
|
2252
|
+
return _super.call(this, __assign(__assign({ transportProvider: new Http() }, options), { apiKey })) || this;
|
|
2253
|
+
}
|
|
2254
|
+
return NodeConfig2;
|
|
2255
|
+
})(Config);
|
|
2256
|
+
useNodeConfig = function(apiKey, overrides) {
|
|
2257
|
+
return new NodeConfig(apiKey, overrides);
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
|
|
2262
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/node-client.js
|
|
2263
|
+
var AmplitudeNode, createInstance, node_client_default;
|
|
2264
|
+
var init_node_client = __esm({
|
|
2265
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/node-client.js"() {
|
|
2266
|
+
init_tslib_es6();
|
|
2267
|
+
init_esm();
|
|
2268
|
+
init_context();
|
|
2269
|
+
init_config2();
|
|
2270
|
+
AmplitudeNode = /** @class */
|
|
2271
|
+
(function(_super) {
|
|
2272
|
+
__extends(AmplitudeNode2, _super);
|
|
2273
|
+
function AmplitudeNode2() {
|
|
2274
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2275
|
+
}
|
|
2276
|
+
AmplitudeNode2.prototype.init = function(apiKey, options) {
|
|
2277
|
+
if (apiKey === void 0) {
|
|
2278
|
+
apiKey = "";
|
|
2279
|
+
}
|
|
2280
|
+
return returnWrapper(this._init(__assign(__assign({}, options), { apiKey })));
|
|
2281
|
+
};
|
|
2282
|
+
AmplitudeNode2.prototype._init = function(options) {
|
|
2283
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
2284
|
+
var nodeOptions;
|
|
2285
|
+
return __generator(this, function(_a) {
|
|
2286
|
+
switch (_a.label) {
|
|
2287
|
+
case 0:
|
|
2288
|
+
if (this.initializing) {
|
|
2289
|
+
return [
|
|
2290
|
+
2
|
|
2291
|
+
/*return*/
|
|
2292
|
+
];
|
|
2293
|
+
}
|
|
2294
|
+
this.initializing = true;
|
|
2295
|
+
nodeOptions = useNodeConfig(options.apiKey, __assign({}, options));
|
|
2296
|
+
return [4, _super.prototype._init.call(this, nodeOptions)];
|
|
2297
|
+
case 1:
|
|
2298
|
+
_a.sent();
|
|
2299
|
+
return [4, this.add(new Destination()).promise];
|
|
2300
|
+
case 2:
|
|
2301
|
+
_a.sent();
|
|
2302
|
+
return [4, this.add(new Context()).promise];
|
|
2303
|
+
case 3:
|
|
2304
|
+
_a.sent();
|
|
2305
|
+
this.initializing = false;
|
|
2306
|
+
return [4, this.runQueuedFunctions("dispatchQ")];
|
|
2307
|
+
case 4:
|
|
2308
|
+
_a.sent();
|
|
2309
|
+
return [
|
|
2310
|
+
2
|
|
2311
|
+
/*return*/
|
|
2312
|
+
];
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
});
|
|
2316
|
+
};
|
|
2317
|
+
return AmplitudeNode2;
|
|
2318
|
+
})(AmplitudeCore);
|
|
2319
|
+
createInstance = function() {
|
|
2320
|
+
var client = new AmplitudeNode();
|
|
2321
|
+
return {
|
|
2322
|
+
init: debugWrapper(client.init.bind(client), "init", getClientLogConfig(client), getClientStates(client, ["config"])),
|
|
2323
|
+
add: debugWrapper(client.add.bind(client), "add", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.plugins"])),
|
|
2324
|
+
remove: debugWrapper(client.remove.bind(client), "remove", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.plugins"])),
|
|
2325
|
+
track: debugWrapper(client.track.bind(client), "track", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2326
|
+
logEvent: debugWrapper(client.logEvent.bind(client), "logEvent", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2327
|
+
identify: debugWrapper(client.identify.bind(client), "identify", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2328
|
+
groupIdentify: debugWrapper(client.groupIdentify.bind(client), "groupIdentify", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2329
|
+
setGroup: debugWrapper(client.setGroup.bind(client), "setGroup", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2330
|
+
revenue: debugWrapper(client.revenue.bind(client), "revenue", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2331
|
+
flush: debugWrapper(client.flush.bind(client), "flush", getClientLogConfig(client), getClientStates(client, ["config.apiKey", "timeline.queue.length"])),
|
|
2332
|
+
setOptOut: debugWrapper(client.setOptOut.bind(client), "setOptOut", getClientLogConfig(client), getClientStates(client, ["config"]))
|
|
2333
|
+
};
|
|
2334
|
+
};
|
|
2335
|
+
node_client_default = createInstance();
|
|
2336
|
+
}
|
|
2337
|
+
});
|
|
2338
|
+
|
|
2339
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/types.js
|
|
2340
|
+
var types_exports = {};
|
|
2341
|
+
__export(types_exports, {
|
|
2342
|
+
IdentifyOperation: () => IdentifyOperation,
|
|
2343
|
+
LogLevel: () => LogLevel,
|
|
2344
|
+
OfflineDisabled: () => OfflineDisabled,
|
|
2345
|
+
RevenueProperty: () => RevenueProperty,
|
|
2346
|
+
ServerZone: () => ServerZone,
|
|
2347
|
+
SpecialEventType: () => SpecialEventType
|
|
2348
|
+
});
|
|
2349
|
+
var init_types = __esm({
|
|
2350
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/types.js"() {
|
|
2351
|
+
init_esm();
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
|
|
2355
|
+
// ../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/index.js
|
|
2356
|
+
var esm_exports = {};
|
|
2357
|
+
__export(esm_exports, {
|
|
2358
|
+
Identify: () => Identify,
|
|
2359
|
+
Revenue: () => Revenue,
|
|
2360
|
+
Types: () => types_exports,
|
|
2361
|
+
add: () => add,
|
|
2362
|
+
createInstance: () => createInstance,
|
|
2363
|
+
flush: () => flush,
|
|
2364
|
+
groupIdentify: () => groupIdentify,
|
|
2365
|
+
identify: () => identify,
|
|
2366
|
+
init: () => init,
|
|
2367
|
+
logEvent: () => logEvent,
|
|
2368
|
+
remove: () => remove,
|
|
2369
|
+
revenue: () => revenue,
|
|
2370
|
+
setGroup: () => setGroup,
|
|
2371
|
+
setOptOut: () => setOptOut,
|
|
2372
|
+
track: () => track
|
|
2373
|
+
});
|
|
2374
|
+
var add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush;
|
|
2375
|
+
var init_esm2 = __esm({
|
|
2376
|
+
"../../node_modules/.pnpm/@amplitude+analytics-node@1.5.26/node_modules/@amplitude/analytics-node/lib/esm/index.js"() {
|
|
2377
|
+
init_node_client();
|
|
2378
|
+
init_node_client();
|
|
2379
|
+
init_esm();
|
|
2380
|
+
init_types();
|
|
2381
|
+
add = node_client_default.add;
|
|
2382
|
+
groupIdentify = node_client_default.groupIdentify;
|
|
2383
|
+
identify = node_client_default.identify;
|
|
2384
|
+
init = node_client_default.init;
|
|
2385
|
+
logEvent = node_client_default.logEvent;
|
|
2386
|
+
remove = node_client_default.remove;
|
|
2387
|
+
revenue = node_client_default.revenue;
|
|
2388
|
+
setGroup = node_client_default.setGroup;
|
|
2389
|
+
setOptOut = node_client_default.setOptOut;
|
|
2390
|
+
track = node_client_default.track;
|
|
2391
|
+
flush = node_client_default.flush;
|
|
2392
|
+
}
|
|
2393
|
+
});
|
|
2394
|
+
|
|
2395
|
+
// src/amplitude.ts
|
|
2396
|
+
var AmplitudeSubscriber = class {
|
|
2397
|
+
name = "AmplitudeSubscriber";
|
|
2398
|
+
version = "1.0.0";
|
|
2399
|
+
amplitude;
|
|
2400
|
+
enabled;
|
|
2401
|
+
config;
|
|
2402
|
+
initPromise = null;
|
|
2403
|
+
constructor(config) {
|
|
2404
|
+
this.enabled = config.enabled ?? true;
|
|
2405
|
+
this.config = config;
|
|
2406
|
+
if (this.enabled) {
|
|
2407
|
+
this.initPromise = this.initialize();
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
async initialize() {
|
|
2411
|
+
try {
|
|
2412
|
+
const { init: init2 } = await Promise.resolve().then(() => (init_esm2(), esm_exports));
|
|
2413
|
+
this.amplitude = init2(this.config.apiKey);
|
|
2414
|
+
} catch (error) {
|
|
2415
|
+
console.error(
|
|
2416
|
+
"Amplitude subscriber failed to initialize. Install @amplitude/events-node: pnpm add @amplitude/events-node",
|
|
2417
|
+
error
|
|
2418
|
+
);
|
|
2419
|
+
this.enabled = false;
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
async ensureInitialized() {
|
|
2423
|
+
if (this.initPromise) {
|
|
2424
|
+
await this.initPromise;
|
|
2425
|
+
this.initPromise = null;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
async trackEvent(name, attributes) {
|
|
2429
|
+
if (!this.enabled) return;
|
|
2430
|
+
await this.ensureInitialized();
|
|
2431
|
+
this.amplitude?.track({
|
|
2432
|
+
event_type: name,
|
|
2433
|
+
user_id: attributes?.userId || attributes?.user_id || "anonymous",
|
|
2434
|
+
event_properties: attributes
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
async trackFunnelStep(funnelName, step, attributes) {
|
|
2438
|
+
if (!this.enabled) return;
|
|
2439
|
+
await this.ensureInitialized();
|
|
2440
|
+
this.amplitude?.trackEvent({
|
|
2441
|
+
event_type: `${funnelName}.${step}`,
|
|
2442
|
+
user_id: attributes?.userId || attributes?.user_id || "anonymous",
|
|
2443
|
+
event_properties: {
|
|
2444
|
+
funnel: funnelName,
|
|
2445
|
+
step,
|
|
2446
|
+
...attributes
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
async trackOutcome(operationName, outcome, attributes) {
|
|
2451
|
+
if (!this.enabled) return;
|
|
2452
|
+
await this.ensureInitialized();
|
|
2453
|
+
this.amplitude?.trackEvent({
|
|
2454
|
+
event_type: `${operationName}.${outcome}`,
|
|
2455
|
+
user_id: attributes?.userId || attributes?.user_id || "anonymous",
|
|
2456
|
+
event_properties: {
|
|
2457
|
+
operation: operationName,
|
|
2458
|
+
outcome,
|
|
2459
|
+
...attributes
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
async trackValue(name, value, attributes) {
|
|
2464
|
+
if (!this.enabled) return;
|
|
2465
|
+
await this.ensureInitialized();
|
|
2466
|
+
this.amplitude?.trackEvent({
|
|
2467
|
+
event_type: name,
|
|
2468
|
+
user_id: attributes?.userId || attributes?.user_id || "anonymous",
|
|
2469
|
+
event_properties: {
|
|
2470
|
+
value,
|
|
2471
|
+
...attributes
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
/** Flush pending events before shutdown */
|
|
2476
|
+
async shutdown() {
|
|
2477
|
+
await this.ensureInitialized();
|
|
2478
|
+
if (this.amplitude) {
|
|
2479
|
+
await this.amplitude.flush();
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
exports.AmplitudeSubscriber = AmplitudeSubscriber;
|
|
2485
|
+
//# sourceMappingURL=amplitude.cjs.map
|
|
2486
|
+
//# sourceMappingURL=amplitude.cjs.map
|