app-tracker 3.1.0 → 3.1.1
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/app-tracker.service.d.ts +1 -1
- package/app-tracker.service.js +14 -6
- package/log.d.ts +1 -0
- package/log.js +1 -0
- package/package.json +1 -1
- package/version.js +1 -1
package/app-tracker.service.d.ts
CHANGED
package/app-tracker.service.js
CHANGED
|
@@ -57,7 +57,7 @@ class AppTrackerService {
|
|
|
57
57
|
}
|
|
58
58
|
this.setRunningSystem(config);
|
|
59
59
|
if (!this.isNode && !this.correlationId) {
|
|
60
|
-
this.correlationId = this.
|
|
60
|
+
this.correlationId = this.createId();
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
addEventListener(apiKey) {
|
|
@@ -79,7 +79,7 @@ class AppTrackerService {
|
|
|
79
79
|
if (this.logs.length === 0)
|
|
80
80
|
return;
|
|
81
81
|
const logsToSend = this.logs.splice(0);
|
|
82
|
-
const body = this.serializePayload(logsToSend, true);
|
|
82
|
+
const body = this.serializePayload(logsToSend, true, this.createId());
|
|
83
83
|
const url = this.getLogsEndpoint();
|
|
84
84
|
// sendBeacon is specifically designed to survive page termination. The API
|
|
85
85
|
// key is also accepted in the request body by the server's ApiKeyGuard.
|
|
@@ -174,7 +174,13 @@ class AppTrackerService {
|
|
|
174
174
|
}
|
|
175
175
|
sendLogsToServer(type, message, ...optionalParams) {
|
|
176
176
|
var _a, _b;
|
|
177
|
-
const log = {
|
|
177
|
+
const log = {
|
|
178
|
+
eventId: this.createId(),
|
|
179
|
+
logType: type,
|
|
180
|
+
message: typeof message === 'string' ? log_privacy_1.sanitizeLogText(message) : message,
|
|
181
|
+
optionalParams: [],
|
|
182
|
+
createdAt: new Date()
|
|
183
|
+
};
|
|
178
184
|
optionalParams.forEach((op) => {
|
|
179
185
|
if (Array.isArray(op))
|
|
180
186
|
op.forEach(o => log.optionalParams.push(log_privacy_1.sanitizeLogValue(o)));
|
|
@@ -232,11 +238,12 @@ class AppTrackerService {
|
|
|
232
238
|
sendLogsToServerCore(logsToSend) {
|
|
233
239
|
var _a;
|
|
234
240
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const batchId = this.createId();
|
|
235
242
|
for (let sendTry = 1; sendTry <= this.maxSendTries; sendTry++) {
|
|
236
243
|
const abortController = typeof AbortController !== 'undefined' ? new AbortController() : undefined;
|
|
237
244
|
const timeout = abortController ? setTimeout(() => abortController.abort(), this.requestTimeoutMs) : undefined;
|
|
238
245
|
try {
|
|
239
|
-
const body = this.serializePayload(logsToSend);
|
|
246
|
+
const body = this.serializePayload(logsToSend, false, batchId);
|
|
240
247
|
const response = yield safeFetch(this.getLogsEndpoint(), {
|
|
241
248
|
method: 'POST',
|
|
242
249
|
headers: {
|
|
@@ -271,10 +278,11 @@ class AppTrackerService {
|
|
|
271
278
|
const last = this.endpointUrl.charAt(this.endpointUrl.length - 1);
|
|
272
279
|
return `${this.endpointUrl}${last === '/' ? 'logs/createLog' : '/logs/createLog'}`;
|
|
273
280
|
}
|
|
274
|
-
serializePayload(logsToSend, includeApiKey = false) {
|
|
281
|
+
serializePayload(logsToSend, includeApiKey = false, batchId = this.createId()) {
|
|
275
282
|
const seen = new WeakSet();
|
|
276
283
|
const payload = {
|
|
277
284
|
logs: logsToSend,
|
|
285
|
+
batchId: batchId,
|
|
278
286
|
osType: this.isNode ? 'node' : 'web',
|
|
279
287
|
packageVersion: version_1.APP_TRACKER_VERSION,
|
|
280
288
|
clientInfo: this.clientInfo
|
|
@@ -341,7 +349,7 @@ class AppTrackerService {
|
|
|
341
349
|
const match = typeof value === 'string' ? value.match(/\d+/) : null;
|
|
342
350
|
return match ? match[0] : '';
|
|
343
351
|
}
|
|
344
|
-
|
|
352
|
+
createId() {
|
|
345
353
|
var _a, _b;
|
|
346
354
|
const browserCrypto = typeof globalThis !== 'undefined' ? globalThis.crypto : undefined;
|
|
347
355
|
if (typeof ((_a = browserCrypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === 'function')
|
package/log.d.ts
CHANGED
package/log.js
CHANGED
package/package.json
CHANGED
package/version.js
CHANGED