@coralogix/browser 2.8.9 → 2.9.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.9.0 (2025-08-18)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **fingerprint:** Added user fingerprint. The fingerprint is generated and stored on each user’s machine for reuse, and will be used to calculate the unique users count.
6
+
1
7
  ## 2.8.9 (2025-07-24)
2
8
 
3
9
  ### 🩹 Fixes
package/README.md CHANGED
@@ -420,6 +420,12 @@ CoralogixRum.init({
420
420
  });
421
421
  ```
422
422
 
423
+ ### Unique Users
424
+
425
+ Starting with version `2.9.0`, the SDK calculates unique users based on the user’s `fingerprint`.<br>
426
+ The fingerprint is generated and stored on each user’s machine for reuse.<br>
427
+ In earlier versions, the SDK used user_id to calculate unique users, which is still supported for backward compatibility.<br>
428
+
423
429
  ### Network Extra Configuration
424
430
 
425
431
  The `networkExtraConfig` property is an array of configuration objects, each specifying custom rules for capturing network requests and responses. This feature collects data from `Fetch` and `XMLHttpRequest` calls, attaching specified request and response information, headers, and payloads to each network event.
package/index.esm2.js CHANGED
@@ -2457,6 +2457,7 @@ var MASK_INPUT_TYPES_DEFAULT = [
2457
2457
  'email',
2458
2458
  'tel',
2459
2459
  ];
2460
+ var FINGER_PRINT_KEY = 'cx-fingerprint';
2460
2461
  var idPatterns = [
2461
2462
  {
2462
2463
  pattern: new RegExp(UUID_REGEX),
@@ -3674,6 +3675,13 @@ var SessionManager = (function (_super) {
3674
3675
  enumerable: false,
3675
3676
  configurable: true
3676
3677
  });
3678
+ Object.defineProperty(SessionManager.prototype, "fingerPrint", {
3679
+ get: function () {
3680
+ return this._fingerPrint;
3681
+ },
3682
+ enumerable: false,
3683
+ configurable: true
3684
+ });
3677
3685
  SessionManager.prototype.updateCurrentPage = function (fragment) {
3678
3686
  if (this.isIdleActive) {
3679
3687
  this._currentPageFragment = undefined;
@@ -3692,6 +3700,7 @@ var SessionManager = (function (_super) {
3692
3700
  this.startIdleListener();
3693
3701
  this.clearPrevSession();
3694
3702
  this.setSession();
3703
+ this.setFingerPrint();
3695
3704
  };
3696
3705
  SessionManager.prototype.stop = function () {
3697
3706
  this.stopIdleListener();
@@ -3779,6 +3788,17 @@ var SessionManager = (function (_super) {
3779
3788
  sessionExpirationDate: now + SESSION_EXPIRATION_TIME,
3780
3789
  };
3781
3790
  };
3791
+ SessionManager.prototype.setFingerPrint = function () {
3792
+ var generateFingerPrint = function () { return generateUUID(); };
3793
+ var storedFingerPrint = CxGlobal.localStorage.getItem(FINGER_PRINT_KEY);
3794
+ if (storedFingerPrint) {
3795
+ this._fingerPrint = storedFingerPrint;
3796
+ return;
3797
+ }
3798
+ var newFingerPrint = generateFingerPrint();
3799
+ CxGlobal.localStorage.setItem(FINGER_PRINT_KEY, newFingerPrint);
3800
+ this._fingerPrint = newFingerPrint;
3801
+ };
3782
3802
  return SessionManager;
3783
3803
  }(SessionIdle));
3784
3804
 
@@ -3935,7 +3955,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
3935
3955
  return resolvedUrlBlueprinters;
3936
3956
  }
3937
3957
 
3938
- var SDK_VERSION = '2.8.9';
3958
+ var SDK_VERSION = '2.9.0';
3939
3959
 
3940
3960
  function shouldDropEvent(cxRumEvent, options) {
3941
3961
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -4050,6 +4070,7 @@ var CoralogixSpanMapProcessor = (function () {
4050
4070
  var eventTypeContext = this._getEventTypeContext(attributes, eventType, span);
4051
4071
  var _e = span.spanContext(), spanId = _e.spanId, traceId = _e.traceId;
4052
4072
  var resourceAttributes = __assign(__assign({}, (_a = span.resource) === null || _a === void 0 ? void 0 : _a.attributes), { 'service.name': application });
4073
+ var fingerPrint = getSessionManager().fingerPrint;
4053
4074
  var labels = JSON.parse(attributes[CoralogixAttributes.CUSTOM_LABELS]);
4054
4075
  var isErrorWithStacktrace = !!((_b = eventTypeContext === null || eventTypeContext === void 0 ? void 0 : eventTypeContext.error_context) === null || _b === void 0 ? void 0 : _b.original_stacktrace);
4055
4076
  var version_metadata = {
@@ -4070,7 +4091,7 @@ var CoralogixSpanMapProcessor = (function () {
4070
4091
  severity: severity,
4071
4092
  timestamp: timestamp,
4072
4093
  text: {
4073
- cx_rum: __assign(__assign({ platform: 'browser', timestamp: timestamp }, eventTypeContext), { browser_sdk: {
4094
+ cx_rum: __assign(__assign({ fingerPrint: fingerPrint, platform: 'browser', timestamp: timestamp }, eventTypeContext), { browser_sdk: {
4074
4095
  version: SDK_VERSION,
4075
4096
  }, version_metadata: version_metadata, session_context: __assign(__assign(__assign(__assign({}, user_context), { session_id: sessionId, session_creation_date: sessionCreationDate, prev_session: prevSessionId
4076
4097
  ? {
@@ -4453,8 +4474,10 @@ var CoralogixRum = {
4453
4474
  var _a, _b;
4454
4475
  var _this = this;
4455
4476
  try {
4456
- if (isInited && (options === null || options === void 0 ? void 0 : options.debug)) {
4457
- console.debug('CoralogixRum already initialized, skipping init');
4477
+ if (isInited) {
4478
+ if (options === null || options === void 0 ? void 0 : options.debug) {
4479
+ console.debug('CoralogixRum already initialized, skipping init');
4480
+ }
4458
4481
  return;
4459
4482
  }
4460
4483
  if (!CxGlobal.sessionStorage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "2.8.9",
3
+ "version": "2.9.0",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -18,6 +18,7 @@ export declare const RUM_INTERNAL_DATA_KEY = "rumInternalData";
18
18
  export declare const MASKED_TEXT = "***";
19
19
  export declare const MASK_CLASS_DEFAULT = "cx-mask";
20
20
  export declare const MASK_INPUT_TYPES_DEFAULT: InputType[];
21
+ export declare const FINGER_PRINT_KEY = "cx-fingerprint";
21
22
  export declare const OPTIONS_DEFAULTS: Partial<CoralogixBrowserSdkConfig>;
22
23
  export declare const INSTRUMENTATIONS: readonly InternalInstrumentationConfig[];
23
24
  export declare const CoralogixAttributes: {
@@ -10,6 +10,7 @@ export declare class SessionManager extends SessionIdle {
10
10
  private _cachedLogsSent;
11
11
  private _currentPageFragment;
12
12
  private _currentPageTimestamp;
13
+ private _fingerPrint;
13
14
  private debugMode;
14
15
  constructor(recordConfig?: SessionRecordingConfig);
15
16
  get currentPageTimestamp(): number;
@@ -21,6 +22,7 @@ export declare class SessionManager extends SessionIdle {
21
22
  get instrumentationsToSend(): Partial<Record<CoralogixEventType, boolean>> | undefined;
22
23
  get cachedLogsSent(): boolean;
23
24
  get sessionHasError(): boolean;
25
+ get fingerPrint(): string | undefined;
24
26
  set sessionHasError(value: boolean);
25
27
  set cachedLogsSent(val: boolean);
26
28
  updateCurrentPage(fragment: string): void;
@@ -38,5 +40,6 @@ export declare class SessionManager extends SessionIdle {
38
40
  private clearSessionWithErrorMode;
39
41
  private handleRefreshedSessions;
40
42
  private createNewSession;
43
+ private setFingerPrint;
41
44
  setSession: (afterIdle?: boolean) => Session;
42
45
  }
package/src/types.d.ts CHANGED
@@ -324,6 +324,7 @@ export interface CxRumEvent extends EventTypeContext {
324
324
  isSnapshotEvent?: boolean;
325
325
  screenshot_context?: ScreenshotContext;
326
326
  screenshotId?: string;
327
+ fingerPrint: string;
327
328
  }
328
329
  export interface CxSpan {
329
330
  version_metadata: VersionMetaData;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.8.9";
1
+ export declare const SDK_VERSION = "2.9.0";