@coralogix/browser 2.8.9 → 2.10.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,15 @@
1
+ ## 2.10.0 (2025-09-14)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **ignoreProxyUrlParams:** Added ignoreProxyUrlParams, which provides the ability to skip appending the Coralogix endpoint to the proxy URL.
6
+
7
+ ## 2.9.0 (2025-08-18)
8
+
9
+ ### 🚀 Features
10
+
11
+ - **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.
12
+
1
13
  ## 2.8.9 (2025-07-24)
2
14
 
3
15
  ### 🩹 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.
@@ -690,6 +696,18 @@ CoralogixRum.init({
690
696
  });
691
697
  ```
692
698
 
699
+ #### ignoreProxyUrlParams
700
+ If you want the SDK to ignore the cxforward parameter and always send data to the proxy URL directly, you can use the ignoreProxyUrlParams option.
701
+ By default, this option is disabled.
702
+ ```javascript
703
+ CoralogixRum.init({
704
+ // ...
705
+ coralogixDomain: 'EU1',
706
+ proxyUrl: 'https://proxy.mycompany.com/rum',
707
+ ignoreProxyUrlParams: true,
708
+ });
709
+ ```
710
+
693
711
  ### Collect IP Data
694
712
 
695
713
  Determines whether the SDK should collect the user's IP address and corresponding geolocation data. Defaults to true.
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),
@@ -3261,13 +3262,23 @@ var Request = (function () {
3261
3262
  this.resolvedHeaders = {};
3262
3263
  this.init();
3263
3264
  }
3265
+ Request.prototype.getResolvedUrl = function (config) {
3266
+ var coralogixDomain = config.coralogixDomain, proxyUrl = config.proxyUrl, ignoreProxyUrlParams = config.ignoreProxyUrlParams;
3267
+ var cxEndpoint = "".concat(CoralogixDomainsApiUrlMap[coralogixDomain]).concat(this.requestConfig.suffix);
3268
+ if (!proxyUrl)
3269
+ return cxEndpoint;
3270
+ if (ignoreProxyUrlParams)
3271
+ return proxyUrl;
3272
+ return "".concat(proxyUrl, "?").concat(PROXY_CX_FORWARD_PARAMETER, "=").concat(encodeURIComponent(cxEndpoint));
3273
+ };
3264
3274
  Request.prototype.init = function () {
3265
- var _a = getSdkConfig(), proxyUrl = _a.proxyUrl, coralogixDomain = _a.coralogixDomain, public_key = _a.public_key;
3266
- var _b = this.requestConfig, suffix = _b.suffix, headers = _b.headers;
3267
- var cxEndpoint = "".concat(CoralogixDomainsApiUrlMap[coralogixDomain]).concat(suffix);
3268
- this.resolvedUrl = proxyUrl
3269
- ? "".concat(proxyUrl, "?").concat(PROXY_CX_FORWARD_PARAMETER, "=").concat(encodeURIComponent(cxEndpoint))
3270
- : cxEndpoint;
3275
+ var _a = getSdkConfig(), proxyUrl = _a.proxyUrl, ignoreProxyUrlParams = _a.ignoreProxyUrlParams, coralogixDomain = _a.coralogixDomain, public_key = _a.public_key;
3276
+ var headers = this.requestConfig.headers;
3277
+ this.resolvedUrl = this.getResolvedUrl({
3278
+ proxyUrl: proxyUrl,
3279
+ ignoreProxyUrlParams: ignoreProxyUrlParams,
3280
+ coralogixDomain: coralogixDomain,
3281
+ });
3271
3282
  if (public_key) {
3272
3283
  headers['Authorization'] = "Bearer ".concat(public_key);
3273
3284
  }
@@ -3674,6 +3685,13 @@ var SessionManager = (function (_super) {
3674
3685
  enumerable: false,
3675
3686
  configurable: true
3676
3687
  });
3688
+ Object.defineProperty(SessionManager.prototype, "fingerPrint", {
3689
+ get: function () {
3690
+ return this._fingerPrint;
3691
+ },
3692
+ enumerable: false,
3693
+ configurable: true
3694
+ });
3677
3695
  SessionManager.prototype.updateCurrentPage = function (fragment) {
3678
3696
  if (this.isIdleActive) {
3679
3697
  this._currentPageFragment = undefined;
@@ -3692,6 +3710,7 @@ var SessionManager = (function (_super) {
3692
3710
  this.startIdleListener();
3693
3711
  this.clearPrevSession();
3694
3712
  this.setSession();
3713
+ this.setFingerPrint();
3695
3714
  };
3696
3715
  SessionManager.prototype.stop = function () {
3697
3716
  this.stopIdleListener();
@@ -3779,6 +3798,17 @@ var SessionManager = (function (_super) {
3779
3798
  sessionExpirationDate: now + SESSION_EXPIRATION_TIME,
3780
3799
  };
3781
3800
  };
3801
+ SessionManager.prototype.setFingerPrint = function () {
3802
+ var generateFingerPrint = function () { return generateUUID(); };
3803
+ var storedFingerPrint = CxGlobal.localStorage.getItem(FINGER_PRINT_KEY);
3804
+ if (storedFingerPrint) {
3805
+ this._fingerPrint = storedFingerPrint;
3806
+ return;
3807
+ }
3808
+ var newFingerPrint = generateFingerPrint();
3809
+ CxGlobal.localStorage.setItem(FINGER_PRINT_KEY, newFingerPrint);
3810
+ this._fingerPrint = newFingerPrint;
3811
+ };
3782
3812
  return SessionManager;
3783
3813
  }(SessionIdle));
3784
3814
 
@@ -3935,7 +3965,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
3935
3965
  return resolvedUrlBlueprinters;
3936
3966
  }
3937
3967
 
3938
- var SDK_VERSION = '2.8.9';
3968
+ var SDK_VERSION = '2.10.0';
3939
3969
 
3940
3970
  function shouldDropEvent(cxRumEvent, options) {
3941
3971
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -4050,6 +4080,7 @@ var CoralogixSpanMapProcessor = (function () {
4050
4080
  var eventTypeContext = this._getEventTypeContext(attributes, eventType, span);
4051
4081
  var _e = span.spanContext(), spanId = _e.spanId, traceId = _e.traceId;
4052
4082
  var resourceAttributes = __assign(__assign({}, (_a = span.resource) === null || _a === void 0 ? void 0 : _a.attributes), { 'service.name': application });
4083
+ var fingerPrint = getSessionManager().fingerPrint;
4053
4084
  var labels = JSON.parse(attributes[CoralogixAttributes.CUSTOM_LABELS]);
4054
4085
  var isErrorWithStacktrace = !!((_b = eventTypeContext === null || eventTypeContext === void 0 ? void 0 : eventTypeContext.error_context) === null || _b === void 0 ? void 0 : _b.original_stacktrace);
4055
4086
  var version_metadata = {
@@ -4070,7 +4101,7 @@ var CoralogixSpanMapProcessor = (function () {
4070
4101
  severity: severity,
4071
4102
  timestamp: timestamp,
4072
4103
  text: {
4073
- cx_rum: __assign(__assign({ platform: 'browser', timestamp: timestamp }, eventTypeContext), { browser_sdk: {
4104
+ cx_rum: __assign(__assign({ fingerPrint: fingerPrint, platform: 'browser', timestamp: timestamp }, eventTypeContext), { browser_sdk: {
4074
4105
  version: SDK_VERSION,
4075
4106
  }, version_metadata: version_metadata, session_context: __assign(__assign(__assign(__assign({}, user_context), { session_id: sessionId, session_creation_date: sessionCreationDate, prev_session: prevSessionId
4076
4107
  ? {
@@ -4453,8 +4484,10 @@ var CoralogixRum = {
4453
4484
  var _a, _b;
4454
4485
  var _this = this;
4455
4486
  try {
4456
- if (isInited && (options === null || options === void 0 ? void 0 : options.debug)) {
4457
- console.debug('CoralogixRum already initialized, skipping init');
4487
+ if (isInited) {
4488
+ if (options === null || options === void 0 ? void 0 : options.debug) {
4489
+ console.debug('CoralogixRum already initialized, skipping init');
4490
+ }
4458
4491
  return;
4459
4492
  }
4460
4493
  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.10.0",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
package/src/Request.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class Request {
7
7
  private resolvedUrl;
8
8
  private resolvedHeaders;
9
9
  constructor(requestConfig: RequestConfig);
10
+ private getResolvedUrl;
10
11
  private init;
11
12
  send(body: BodyInit): Promise<Response>;
12
13
  }
@@ -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
@@ -149,6 +149,7 @@ export interface CoralogixBrowserSdkConfig {
149
149
  maskClass?: string | RegExp;
150
150
  beforeSend?: (event: EditableCxRumEvent) => BeforeSendResult;
151
151
  proxyUrl?: string;
152
+ ignoreProxyUrlParams?: boolean;
152
153
  collectIPData?: boolean;
153
154
  trackSoftNavigations?: boolean;
154
155
  memoryUsageConfig?: MemoryUsageConfig;
@@ -324,6 +325,7 @@ export interface CxRumEvent extends EventTypeContext {
324
325
  isSnapshotEvent?: boolean;
325
326
  screenshot_context?: ScreenshotContext;
326
327
  screenshotId?: string;
328
+ fingerPrint: string;
327
329
  }
328
330
  export interface CxSpan {
329
331
  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.10.0";