@coralogix/browser 2.4.0 → 2.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __generator, __assign } from 'tslib';
2
- import { C as CxGlobal, r as reportInternalEvent, g as getSdkConfig, S as SESSION_RECORDER_SEGMENTS_MAP, a as getNowTime, b as SESSION_RECORDING_NETWORK_ERR0R_MESSAGE, M as MAX_BATCH_TIME_MS, R as Request, c as SESSION_RECORDING_POSTFIX_URL, d as SESSION_RECORDING_DEFAULT_HEADERS, B as BATCH_TIME_DELAY, e as SESSION_RECORDER_KEY, f as MAX_MUTATIONS_FOR_SESSION_RECORDING, h as SESSION_RECORDING_DEFAULT_ERROR_MESSAGE } from './index.esm2.js';
2
+ import { C as CxGlobal, r as reportInternalEvent, g as getSdkConfig, S as SESSION_RECORDER_SEGMENTS_MAP, a as getNowTime, b as SESSION_RECORDING_NETWORK_ERR0R_MESSAGE, M as MAX_BATCH_TIME_MS, R as Request, c as SESSION_RECORDING_DEFAULT_HEADERS, d as SESSION_RECORDING_POSTFIX_URL, B as BATCH_TIME_DELAY, e as SESSION_RECORDER_KEY, f as MAX_MUTATIONS_FOR_SESSION_RECORDING, h as SESSION_RECORDING_DEFAULT_ERROR_MESSAGE } from './index.esm2.js';
3
3
  import { record } from 'rrweb';
4
4
  import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
5
5
  import '@opentelemetry/sdk-trace-base';
@@ -43,8 +43,8 @@ function isElement(n) {
43
43
  return n.nodeType === n.ELEMENT_NODE;
44
44
  }
45
45
  function isShadowRoot(n) {
46
- const host = n == null ? undefined : n.host;
47
- return Boolean((host == null ? undefined : host.shadowRoot) === n);
46
+ const host = n == null ? void 0 : n.host;
47
+ return Boolean((host == null ? void 0 : host.shadowRoot) === n);
48
48
  }
49
49
  function isNativeShadowDom(shadowRoot) {
50
50
  return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
@@ -120,7 +120,7 @@ class Mirror {
120
120
  var _a;
121
121
  if (!n)
122
122
  return -1;
123
- const id = (_a = this.getMeta(n)) == null ? undefined : _a.id;
123
+ const id = (_a = this.getMeta(n)) == null ? void 0 : _a.id;
124
124
  return id ?? -1;
125
125
  }
126
126
  getNode(id) {
@@ -232,7 +232,7 @@ function extractFileExtension(path, baseURL) {
232
232
  }
233
233
  const regex = /\.([0-9a-z]+)(?:$)/i;
234
234
  const match = url.pathname.match(regex);
235
- return (match == null ? undefined : match[1]) ?? null;
235
+ return (match == null ? void 0 : match[1]) ?? null;
236
236
  }
237
237
  let _id = 1;
238
238
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
@@ -607,17 +607,17 @@ function serializeNode(n, options) {
607
607
  }
608
608
  function getRootId(doc, mirror) {
609
609
  if (!mirror.hasNode(doc))
610
- return undefined;
610
+ return void 0;
611
611
  const docId = mirror.getId(doc);
612
- return docId === 1 ? undefined : docId;
612
+ return docId === 1 ? void 0 : docId;
613
613
  }
614
614
  function serializeTextNode(n, options) {
615
615
  var _a;
616
616
  const { needsMask, maskTextFn, rootId } = options;
617
617
  const parentTagName = n.parentNode && n.parentNode.tagName;
618
618
  let textContent = n.textContent;
619
- const isStyle = parentTagName === "STYLE" ? true : undefined;
620
- const isScript = parentTagName === "SCRIPT" ? true : undefined;
619
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
620
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
621
621
  if (isStyle && textContent) {
622
622
  try {
623
623
  if (n.nextSibling || n.previousSibling) {
@@ -831,14 +831,14 @@ function serializeElementNode(n, options) {
831
831
  tagName,
832
832
  attributes: attributes2,
833
833
  childNodes: [],
834
- isSVG: isSVGElement(n) || undefined,
834
+ isSVG: isSVGElement(n) || void 0,
835
835
  needBlock,
836
836
  rootId,
837
837
  isCustom: isCustomElement
838
838
  };
839
839
  }
840
840
  function lowerIfExists(maybeAttr) {
841
- if (maybeAttr === undefined || maybeAttr === null) {
841
+ if (maybeAttr === void 0 || maybeAttr === null) {
842
842
  return "";
843
843
  } else {
844
844
  return maybeAttr.toLowerCase();
@@ -865,7 +865,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
865
865
  return true;
866
866
  } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
867
867
  return true;
868
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== undefined) {
868
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
869
869
  return true;
870
870
  } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
871
871
  return true;
@@ -904,7 +904,7 @@ function serializeNodeWithId(n, options) {
904
904
  let { needsMask } = options;
905
905
  let { preserveWhiteSpace = true } = options;
906
906
  if (!needsMask && n.childNodes) {
907
- const checkAncestors = needsMask === undefined;
907
+ const checkAncestors = needsMask === void 0;
908
908
  needsMask = needMaskingText(
909
909
  n,
910
910
  maskTextClass,
@@ -985,7 +985,7 @@ function serializeNodeWithId(n, options) {
985
985
  stylesheetLoadTimeout,
986
986
  keepIframeSrcFn
987
987
  };
988
- if (serializedNode2.type === NodeType.Element && serializedNode2.tagName === "textarea" && serializedNode2.attributes.value !== undefined)
988
+ if (serializedNode2.type === NodeType.Element && serializedNode2.tagName === "textarea" && serializedNode2.attributes.value !== void 0)
989
989
  ;
990
990
  else {
991
991
  for (const childN of Array.from(n.childNodes)) {
@@ -1243,7 +1243,7 @@ function getWorkerString() {
1243
1243
  }
1244
1244
  }
1245
1245
  function createBlobAndSend(sessionId, sessionCreationDate, gzipData, chunkIndex, totalChunks, screenshotId, event) {
1246
- if (event === undefined) { event = 'sendRecordData'; }
1246
+ if (event === void 0) { event = 'sendRecordData'; }
1247
1247
  var blob = new Blob([gzipData], {
1248
1248
  type: 'application/octet-stream',
1249
1249
  });
@@ -1263,7 +1263,7 @@ var WorkerManager = /** @class */ (function () {
1263
1263
  function WorkerManager() {
1264
1264
  }
1265
1265
  WorkerManager.prototype.loadAndCreateWorker = function (workerUrl) {
1266
- return __awaiter(this, undefined, undefined, function () {
1266
+ return __awaiter(this, void 0, void 0, function () {
1267
1267
  var workerCode, _a, workerBlob, blobUrl, error_1;
1268
1268
  return __generator(this, function (_b) {
1269
1269
  switch (_b.label) {
@@ -1294,7 +1294,7 @@ var WorkerManager = /** @class */ (function () {
1294
1294
  });
1295
1295
  };
1296
1296
  WorkerManager.prototype.loadWorkerScript = function (url) {
1297
- return __awaiter(this, undefined, undefined, function () {
1297
+ return __awaiter(this, void 0, void 0, function () {
1298
1298
  var response;
1299
1299
  return __generator(this, function (_a) {
1300
1300
  switch (_a.label) {
@@ -1341,7 +1341,7 @@ var SessionRecorder = /** @class */ (function () {
1341
1341
  this.recordingStopped = false;
1342
1342
  this.batchTimeDelay = BATCH_TIME_DELAY;
1343
1343
  this.isErrorOccurred = false;
1344
- this.debugMode = !!((_a = getSdkConfig()) === null || _a === undefined ? undefined : _a.debug);
1344
+ this.debugMode = !!((_a = getSdkConfig()) === null || _a === void 0 ? void 0 : _a.debug);
1345
1345
  this._recordingStopDueToTimeout = false;
1346
1346
  this.handleRecordEvent = function (event, isCheckout) {
1347
1347
  if (!_this.recordingStopped) {
@@ -1370,7 +1370,7 @@ var SessionRecorder = /** @class */ (function () {
1370
1370
  var metaData = _this.getMetadata(workerData, shouldSplit);
1371
1371
  formData.append('chunk', workerData.gzipBlob);
1372
1372
  formData.append('metaData', JSON.stringify(metaData));
1373
- var sendRecordRequest = function () { return __awaiter(_this, undefined, undefined, function () {
1373
+ var sendRecordRequest = function () { return __awaiter(_this, void 0, void 0, function () {
1374
1374
  var response, _a;
1375
1375
  var _b;
1376
1376
  return __generator(this, function (_c) {
@@ -1378,7 +1378,7 @@ var SessionRecorder = /** @class */ (function () {
1378
1378
  case 0:
1379
1379
  _c.trys.push([0, 4, , 5]);
1380
1380
  if (!!this.isErrorOccurred) return [3 /*break*/, 2];
1381
- return [4 /*yield*/, ((_b = this.request) === null || _b === undefined ? undefined : _b.send(formData))];
1381
+ return [4 /*yield*/, ((_b = this.request) === null || _b === void 0 ? void 0 : _b.send(formData))];
1382
1382
  case 1:
1383
1383
  _a = _c.sent();
1384
1384
  return [3 /*break*/, 3];
@@ -1391,7 +1391,7 @@ var SessionRecorder = /** @class */ (function () {
1391
1391
  return [3 /*break*/, 5];
1392
1392
  case 4:
1393
1393
  _c.sent();
1394
- this.handleSessionRecordingResponse(undefined);
1394
+ this.handleSessionRecordingResponse();
1395
1395
  return [3 /*break*/, 5];
1396
1396
  case 5: return [2 /*return*/];
1397
1397
  }
@@ -1413,7 +1413,7 @@ var SessionRecorder = /** @class */ (function () {
1413
1413
  this.onlySessionWithErrorMode = onlySessionWithErrorMode;
1414
1414
  this.maxRecordTimeForSessionWithError = maxRecordTimeForSessionWithError;
1415
1415
  this.isAutoStartRecording = autoStartSessionRecording;
1416
- this.maxMutations = maxMutations !== null && maxMutations !== undefined ? maxMutations : MAX_MUTATIONS_FOR_SESSION_RECORDING;
1416
+ this.maxMutations = maxMutations !== null && maxMutations !== void 0 ? maxMutations : MAX_MUTATIONS_FOR_SESSION_RECORDING;
1417
1417
  this.recordConfig = this.prepareRecordConfig(recordConfig);
1418
1418
  if (CxGlobal.Worker) {
1419
1419
  this.workerManager = new WorkerManager();
@@ -1431,7 +1431,7 @@ var SessionRecorder = /** @class */ (function () {
1431
1431
  SessionRecorder.prototype.getSessionHasRecording = function () {
1432
1432
  var _a;
1433
1433
  return (this.hasRecording &&
1434
- !!this.segmentIndexCounter[(_a = this.sessionManager.getActiveSession()) === null || _a === undefined ? undefined : _a.sessionId]);
1434
+ !!this.segmentIndexCounter[(_a = this.sessionManager.getActiveSession()) === null || _a === void 0 ? void 0 : _a.sessionId]);
1435
1435
  };
1436
1436
  SessionRecorder.prototype.updateSegmentIndexCounter = function (segmentIndexCounter) {
1437
1437
  this.segmentIndexCounter = segmentIndexCounter;
@@ -1444,13 +1444,16 @@ var SessionRecorder = /** @class */ (function () {
1444
1444
  return this._recordingStopDueToTimeout;
1445
1445
  },
1446
1446
  set: function (value) {
1447
+ if (this.debugMode && value) {
1448
+ console.debug('Coralogix Browser SDK - Session recording stopped due to timeout');
1449
+ }
1447
1450
  this._recordingStopDueToTimeout = value;
1448
1451
  },
1449
1452
  enumerable: false,
1450
1453
  configurable: true
1451
1454
  });
1452
1455
  SessionRecorder.prototype.startRecording = function () {
1453
- return __awaiter(this, undefined, undefined, function () {
1456
+ return __awaiter(this, void 0, void 0, function () {
1454
1457
  return __generator(this, function (_a) {
1455
1458
  switch (_a.label) {
1456
1459
  case 0: return [4 /*yield*/, this.isWorkerReady];
@@ -1464,7 +1467,6 @@ var SessionRecorder = /** @class */ (function () {
1464
1467
  }
1465
1468
  this.startMutationObserver();
1466
1469
  this.resetBatching();
1467
- this.hasRecording = true;
1468
1470
  this.recordingStopped = false;
1469
1471
  this.isErrorOccurred = false;
1470
1472
  this.recordingStopDueToTimeout = false;
@@ -1506,7 +1508,7 @@ var SessionRecorder = /** @class */ (function () {
1506
1508
  };
1507
1509
  SessionRecorder.prototype.stopMutationObserver = function () {
1508
1510
  var _a;
1509
- (_a = this.mutationObserver) === null || _a === undefined ? undefined : _a.disconnect();
1511
+ (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1510
1512
  };
1511
1513
  SessionRecorder.prototype.startMutationObserver = function () {
1512
1514
  var _this = this;
@@ -1539,7 +1541,7 @@ var SessionRecorder = /** @class */ (function () {
1539
1541
  // @ts-ignore
1540
1542
  this.recordConfig = __assign(__assign({}, recordConfig), { emit: this.handleRecordEvent, checkoutEveryNms: this.onlySessionWithErrorMode
1541
1543
  ? this.maxRecordTimeForSessionWithError
1542
- : undefined, slimDOMOptions: __assign(__assign({}, excludeDOMOptions), { script: (_a = excludeDOMOptions === null || excludeDOMOptions === undefined ? undefined : excludeDOMOptions.script) !== null && _a !== undefined ? _a : true }), plugins: recordConsoleEvents ? [getRecordConsolePlugin()] : [] });
1544
+ : undefined, slimDOMOptions: __assign(__assign({}, excludeDOMOptions), { script: (_a = excludeDOMOptions === null || excludeDOMOptions === void 0 ? void 0 : excludeDOMOptions.script) !== null && _a !== void 0 ? _a : true }), plugins: recordConsoleEvents ? [getRecordConsolePlugin()] : [] });
1543
1545
  return this.recordConfig;
1544
1546
  };
1545
1547
  SessionRecorder.prototype.handleRecordEventForSessionWithError = function (event, isCheckout) {
@@ -1634,12 +1636,17 @@ var SessionRecorder = /** @class */ (function () {
1634
1636
  sessionId: sessionId,
1635
1637
  snapshotId: screenshotId,
1636
1638
  application: application,
1637
- subIndex: chunkIndex !== null && chunkIndex !== undefined ? chunkIndex : -1,
1639
+ subIndex: chunkIndex !== null && chunkIndex !== void 0 ? chunkIndex : -1,
1638
1640
  };
1639
1641
  return metaData;
1640
1642
  };
1641
1643
  SessionRecorder.prototype.handleSessionRecordingResponse = function (response) {
1642
- if (!(response === null || response === undefined ? undefined : response.ok) && !this.isErrorOccurred) {
1644
+ if (response === null || response === void 0 ? void 0 : response.ok) {
1645
+ // If the response is ok, we can assume that the recording was successful and no error occurred
1646
+ this.hasRecording = true;
1647
+ this.isErrorOccurred = false;
1648
+ }
1649
+ else if (!(response === null || response === void 0 ? void 0 : response.ok) && !this.isErrorOccurred) {
1643
1650
  console.warn(SESSION_RECORDING_NETWORK_ERR0R_MESSAGE);
1644
1651
  this.isErrorOccurred = true;
1645
1652
  this.stopRecording();
@@ -1647,9 +1654,6 @@ var SessionRecorder = /** @class */ (function () {
1647
1654
  clearTimeout(this.batchTimeout);
1648
1655
  }
1649
1656
  }
1650
- else {
1651
- this.isErrorOccurred = false;
1652
- }
1653
1657
  };
1654
1658
  SessionRecorder.prototype.startBatchingRecords = function () {
1655
1659
  this.batchingTimeInterval = setInterval(this.prepareRecordEventsBeforeSend, MAX_BATCH_TIME_MS);
@@ -10,6 +10,7 @@ export declare class SessionManager extends SessionIdle {
10
10
  private _cachedLogsSent;
11
11
  private _currentPageFragment;
12
12
  private _currentPageTimestamp;
13
+ private debugMode;
13
14
  constructor(recordConfig?: SessionRecordingConfig);
14
15
  get currentPageTimestamp(): number;
15
16
  get currentPageFragment(): string | undefined;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.4.0";
1
+ export declare const SDK_VERSION = "2.4.1";