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.
@@ -46,5 +46,5 @@ export declare class AppTrackerService {
46
46
  private getBrowserClientInfo;
47
47
  private getNodeClientInfo;
48
48
  private majorVersion;
49
- private createCorrelationId;
49
+ private createId;
50
50
  }
@@ -57,7 +57,7 @@ class AppTrackerService {
57
57
  }
58
58
  this.setRunningSystem(config);
59
59
  if (!this.isNode && !this.correlationId) {
60
- this.correlationId = this.createCorrelationId();
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 = { logType: type, message: typeof message === 'string' ? log_privacy_1.sanitizeLogText(message) : message, optionalParams: [], createdAt: new Date() };
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
- createCorrelationId() {
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
@@ -16,6 +16,7 @@ export declare class AppTrackerConfig {
16
16
  userAgentOrOs?: any;
17
17
  }
18
18
  export declare class Log {
19
+ eventId: string;
19
20
  logType: LogType;
20
21
  message: any;
21
22
  optionalParams: any[];
package/log.js CHANGED
@@ -13,6 +13,7 @@ class AppTrackerConfig {
13
13
  exports.AppTrackerConfig = AppTrackerConfig;
14
14
  class Log {
15
15
  constructor() {
16
+ this.eventId = '';
16
17
  this.logType = LogType.log;
17
18
  this.optionalParams = [];
18
19
  this.createdAt = new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-tracker",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "App Tracker for Web-Applications",
5
5
  "main": "index.js",
6
6
  "repository": {
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /** Replaced with the package.json version by the build script. */
4
- exports.APP_TRACKER_VERSION = '3.1.0';
4
+ exports.APP_TRACKER_VERSION = '3.1.1';