@coralogix/browser 3.23.0 → 3.23.3

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,22 @@
1
+ ## 3.23.3 (2026-08-30)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - Stop the INP (Interaction to Next Paint) reporter throwing an uncaught `TypeError` after a back/forward navigation followed by a tab switch
6
+
7
+ ## 3.23.2 (2026-08-20)
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - Stop reporting `resolved_name` for dead clicks
12
+ - Add an optional `fullData` flag to `CoralogixRum.getResolvedName()`, used by Coralogix's own tooling
13
+
14
+ ## 3.23.1 (2026-08-19)
15
+
16
+ ### 🩹 Fixes
17
+
18
+ - Stop the public types from pulling `@types/node` into browser TypeScript builds
19
+
1
20
  ## 3.23.0 (2026-08-17)
2
21
 
3
22
  ### 🚀 Features
package/README.md CHANGED
@@ -151,6 +151,7 @@ CoralogixRum.setApplicationContext({
151
151
  });
152
152
  ```
153
153
 
154
+ <!-- split title="Sampling" path="configuration/sampling.md" -->
154
155
  ### Sampling
155
156
 
156
157
  #### 1. Basic Sampling - sample % of all sessions
@@ -221,6 +222,8 @@ CoralogixRum.init({
221
222
  });
222
223
  ```
223
224
 
225
+ <!-- /split -->
226
+ <!-- split title="Logs and errors" path="features/logs-and-errors.md" -->
224
227
  ### Sending Custom Logs
225
228
 
226
229
  ```javascript
@@ -252,6 +255,23 @@ CoralogixRum.log(CoralogixLogSeverity.Info, 'this is a custom log message with i
252
255
  });
253
256
  ```
254
257
 
258
+ #### Stringifying custom log data
259
+
260
+ By default the `data` you pass to a custom log is sent as a nested structure. Set
261
+ `stringifyCustomLogData` at initialization to send it as a string instead, which is
262
+ useful when `data` holds nested objects or arrays. Circular references are handled
263
+ rather than throwing.
264
+
265
+ ```javascript
266
+ CoralogixRum.init({
267
+ // ...
268
+ stringifyCustomLogData: true,
269
+ });
270
+ ```
271
+
272
+ The SDK reads this option once, when it initializes, so it applies to every custom
273
+ log from that point on and cannot be changed per call.
274
+
255
275
  ### Instrumentation's
256
276
 
257
277
  Turn on/off specific instrumentation, default to all trues.
@@ -273,6 +293,11 @@ CoralogixRum.init({
273
293
  });
274
294
  ```
275
295
 
296
+ > [!NOTE]
297
+ > The `fetch` and `xhr` instrumentations also add the trace context headers to outgoing requests.
298
+ > Turning both off stops trace context propagation as well, even when `traceParentInHeader` is
299
+ > enabled.
300
+
276
301
  ##### Web Vitals: TBT metric
277
302
 
278
303
  By default, the **TBT** (Total Blocking Time) metric is disabled.
@@ -308,6 +333,8 @@ try {
308
333
  }
309
334
  ```
310
335
 
336
+ <!-- /split -->
337
+ <!-- split title="Session recording" path="features/session-recording.md" -->
311
338
  ### Session Recording
312
339
 
313
340
  Session Recording enhances your user experience monitoring by enabling you to record and visually replay the web browsing activities of your users.
@@ -454,6 +481,8 @@ CoralogixRum.init({
454
481
  });
455
482
  ```
456
483
 
484
+ <!-- /split -->
485
+ <!-- split title="Configuration options" path="configuration/options.md" -->
457
486
  ### Manually Create a New Session
458
487
 
459
488
  By default the SDK rotates the session automatically — after 15 minutes of inactivity, or once a session reaches 1 hour. Starting with version `3.19.0`, you can also rotate it on demand by calling `CoralogixRum.createNewSession()`, for example when a user logs out, so that subsequent events are attributed to a fresh session.
@@ -686,6 +715,11 @@ CoralogixRum.init({
686
715
  });
687
716
  ```
688
717
 
718
+ > [!NOTE]
719
+ > Trace headers are added by the `fetch` and `xhr` instrumentations, so this feature depends on them.
720
+ > If you set both `instrumentations.fetch` and `instrumentations.xhr` to `false`, no trace headers are
721
+ > sent even with `enabled: true`.
722
+
689
723
  #### propagateTraceHeaderCorsUrls
690
724
 
691
725
  When the backend domain is different from the app domain, specifying backend domains is necessary. <br>
@@ -822,6 +856,8 @@ export class CustomPropagator implements TextMapPropagator {
822
856
 
823
857
  ```
824
858
 
859
+ <!-- /split -->
860
+ <!-- split title="Before send and transport" path="configuration/before-send-and-transport.md" -->
825
861
  ### Before Send
826
862
 
827
863
  Enable event access and modification before sending to Coralogix, supporting content modification, and event discarding.
@@ -923,6 +959,8 @@ CoralogixRum.init({
923
959
  > [!NOTE]
924
960
  > The `priority` hint only works in Chromium browsers (Chrome/Edge 101+) and is a no-op elsewhere. We type this option with our own `SdkFetchPriority` alias instead of the DOM `RequestPriority` type, so it still compiles on older TypeScript versions (the SDK supports `>= 4.4.2`).
925
961
 
962
+ <!-- /split -->
963
+ <!-- split title="Custom instrumentation" path="features/custom-instrumentation.md" -->
926
964
  ### Custom Measurement
927
965
 
928
966
  Custom measurement allows you to send numeric data to Coralogix for precise monitoring and analysis.
@@ -972,6 +1010,13 @@ CoralogixRum.startTimeMeasure('login', {
972
1010
  CoralogixRum.endTimeMeasure('login');
973
1011
  ```
974
1012
 
1013
+ A few behaviours worth knowing:
1014
+
1015
+ - Starting a key while a measurement for it is still in progress does nothing, and neither does a blank key: `startTimeMeasure` returns and the running timer is left alone.
1016
+ - `endTimeMeasure` takes only the key, so there is no way to pass labels at the end. The object handed to `startTimeMeasure` is held by reference, and at the end it is merged over the SDK's global labels as they stand then - so a later `CoralogixRum.setLabels()` does affect the result.
1017
+ - Ending a measurement releases its key, so the same key can be measured again afterwards.
1018
+ - Open measurements are dropped the next time you start or end one while the session is idle. The check runs on those calls rather than on a timer, and activity clears the idle flag, so a measurement spanning a short idle gap may still report.
1019
+
975
1020
  ### Microfrontend support
976
1021
 
977
1022
  This feature allows you to track multiple applications on the same page.<br>
@@ -1028,15 +1073,57 @@ const customTracer = CoralogixRum.getCustomTracer({
1028
1073
  // ... your code
1029
1074
  ```
1030
1075
 
1076
+ #### When getCustomTracer returns nothing
1077
+
1078
+ `getCustomTracer` returns `undefined` rather than throwing, so a missing prerequisite
1079
+ shows up as a `TypeError` on the next line instead. It returns nothing when:
1080
+
1081
+ - the SDK has not been initialized yet
1082
+ - `traceParentInHeader` is not enabled - custom spans need it, and only a debug-level
1083
+ message says so
1084
+ - a custom tracer already exists, which logs `Custom tracer already exists`
1085
+
1086
+ `startGlobalSpan` behaves the same way: with a global span already open it warns
1087
+ `Global span already exists` and returns `undefined`, rather than replacing it.
1088
+
1089
+ A few more things worth knowing:
1090
+
1091
+ - Every span must be ended explicitly. `endSpan` ends the span and releases it, so a
1092
+ new global span can be started afterwards.
1093
+ - Labels are applied to the span they are passed with. A child span created by
1094
+ `startCustomSpan` does not inherit the global span's labels.
1095
+ - Open global spans are ended for you when the session resets, which happens after an
1096
+ hour of session time or 15 minutes of inactivity.
1097
+
1031
1098
  ### Traces Exporter
1032
1099
 
1033
1100
  The `tracesExporter` callback gives you full control over how collected trace events are handled.
1034
1101
  It receives a `TraceExporterData` object containing all trace data that the SDK has collected.
1035
1102
 
1103
+ Setting it redirects your traces rather than copying them. The span data is removed from
1104
+ what the SDK sends to Coralogix and delivered to your callback instead, so Coralogix stops
1105
+ receiving traces until you forward them yourself from inside the callback.
1106
+
1107
+ This happens per batch, and only for batches that carry OpenTelemetry span data. When
1108
+ one does, the strip applies to every log in it, not only to custom spans: views, errors
1109
+ and network events still reach Coralogix as RUM events, but without their
1110
+ `instrumentation_data`, the field holding request and response span detail. A batch with
1111
+ no span data at all is sent unchanged and your callback is not called for it.
1112
+
1113
+ Treat the payload as a subset rather than a mirror. A span missing its trace id, span id,
1114
+ name or timestamps is dropped from the conversion, as is one whose timestamps fall
1115
+ outside the accepted window - more than an hour ahead or a day behind. Those spans can
1116
+ still reach Coralogix inside the RUM payload without a matching entry in what your
1117
+ callback receives, so `resource_spans` can be shorter than you expect, or empty.
1118
+
1119
+ > [!WARNING]
1120
+ > The callback runs inline on the path that sends the RUM payload, and it is not wrapped.
1121
+ > An exception escaping your callback also stops that batch reaching Coralogix, so keep
1122
+ > your own work inside a `try`/`catch`.
1123
+
1036
1124
  ```ts
1037
1125
  CoralogixRum.init({
1038
1126
  tracesExporter: (data: TraceExporterData) => {
1039
- // Example: forward traces to your own backend endpoint
1040
1127
  fetch('https://api.mycompany.com/rum-traces', {
1041
1128
  method: 'POST',
1042
1129
  headers: {
@@ -1104,6 +1191,7 @@ You can also manually trigger memory usage data collection.
1104
1191
  CoralogixRum.measureUserAgentSpecificMemory();
1105
1192
  ```
1106
1193
 
1194
+ <!-- /split -->
1107
1195
  ## Web Worker Support
1108
1196
 
1109
1197
  Web Worker support enables the capture of events originating from Web Workers, including unhandled errors, custom logs, and other functionalities provided by the SDK.
@@ -1126,8 +1214,14 @@ CoralogixRum.init({
1126
1214
  const worker = new Worker('my-worker.js');
1127
1215
  ```
1128
1216
 
1217
+ The SDK also attaches a `CoralogixRum` handle to the worker object it returns, as a
1218
+ convenience for logging next to the code that created the worker. It is an alias to the
1219
+ same SDK instance, not a per-worker one, so it adds no worker attribution of its own -
1220
+ `worker.CoralogixRum.log(...)` and `CoralogixRum.log(...)` do the same thing. Pass a
1221
+ label yourself if you need to tell workers apart.
1222
+
1129
1223
  ```javascript
1130
- // Worker code
1224
+ // App code, on the main thread
1131
1225
 
1132
1226
  // Log a basic info log
1133
1227
  worker.CoralogixRum.log(CoralogixLogSeverity.Info, 'Test log from worker');
@@ -1139,12 +1233,17 @@ try {
1139
1233
  worker.CoralogixRum.captureError(error, { worker: 'analytics-worker' }, { label1: 'value1' });
1140
1234
  }
1141
1235
 
1142
- // Log messages received in the worker
1143
- self.onmessage = (message) => {
1144
- worker.CoralogixRum.log(CoralogixLogSeverity.Info, message);
1236
+ // Log messages the worker sends back
1237
+ worker.onmessage = (message) => {
1238
+ worker.CoralogixRum.log(CoralogixLogSeverity.Info, 'worker message', { data: message.data });
1145
1239
  };
1146
1240
  ```
1147
1241
 
1242
+ > [!NOTE]
1243
+ > `worker.CoralogixRum` lives on the worker object in the page, not inside the worker
1244
+ > script. Worker scope has no Coralogix global, so these calls only work on the main
1245
+ > thread.
1246
+
1148
1247
  ## Angular Zone.js Configuration
1149
1248
 
1150
1249
  By default, the SDK runs its internal timers outside Angular's Zone.js to prevent unnecessary change detection cycles. This improves performance by avoiding redundant UI updates triggered by the SDK's background operations.
@@ -1182,7 +1281,8 @@ If you are targeting legacy environments, make sure to use the ES5-compatible ve
1182
1281
 
1183
1282
  https://cdn.rum-ingress-coralogix.com/coralogix/browser/[version]/coralogix-browser-sdk.es5.js
1184
1283
 
1185
- > _**Note: CDN latest has no longer maintained, please use an explicit version instead.**_
1284
+ > [!NOTE]
1285
+ > The CDN `latest` tag is no longer maintained. Use an explicit version instead.
1186
1286
 
1187
1287
  ### Add the CDN script to your application
1188
1288
 
package/index.esm.js CHANGED
@@ -7,6 +7,7 @@ import 'error-stack-parser';
7
7
  import '@opentelemetry/instrumentation-fetch';
8
8
  import '@opentelemetry/instrumentation-xml-http-request';
9
9
  import 'web-vitals/attribution';
10
+ import 'web-vitals';
10
11
  import '@opentelemetry/api';
11
12
  import '@opentelemetry/propagator-b3';
12
13
  import '@opentelemetry/propagator-aws-xray';
package/index.esm2.js CHANGED
@@ -5,7 +5,8 @@ import { InstrumentationBase, registerInstrumentations } from '@opentelemetry/in
5
5
  import ErrorStackParser from 'error-stack-parser';
6
6
  import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
7
7
  import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
8
- import { onFID, onCLS, onLCP, onFCP, onINP, onTTFB } from 'web-vitals/attribution';
8
+ import { onFID, onCLS, onLCP, onFCP, onTTFB } from 'web-vitals/attribution';
9
+ import { onINP } from 'web-vitals';
9
10
  import { createContextKey, baggageEntryMetadataFromString, propagation, diag, trace, isSpanContextValid, TraceFlags, context } from '@opentelemetry/api';
10
11
  import { B3Propagator, B3InjectEncoding } from '@opentelemetry/propagator-b3';
11
12
  import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
@@ -389,6 +390,37 @@ function getCustomMergedLabels(labels) {
389
390
  return __assign(__assign({}, globalLabels), labels);
390
391
  }
391
392
 
393
+ var ResourceInitiatorTypes;
394
+ (function (ResourceInitiatorTypes) {
395
+ ResourceInitiatorTypes["Media"] = "media";
396
+ ResourceInitiatorTypes["Script"] = "script";
397
+ ResourceInitiatorTypes["Css"] = "css";
398
+ ResourceInitiatorTypes["Beacon"] = "beacon";
399
+ ResourceInitiatorTypes["Img"] = "img";
400
+ ResourceInitiatorTypes["Font"] = "font";
401
+ ResourceInitiatorTypes["Doc"] = "doc";
402
+ ResourceInitiatorTypes["Xhr"] = "xmlhttprequest";
403
+ ResourceInitiatorTypes["Fetch"] = "fetch";
404
+ ResourceInitiatorTypes["Iframe"] = "iframe";
405
+ ResourceInitiatorTypes["Video"] = "video";
406
+ ResourceInitiatorTypes["Audio"] = "audio";
407
+ ResourceInitiatorTypes["Track"] = "track";
408
+ ResourceInitiatorTypes["Other"] = "other";
409
+ })(ResourceInitiatorTypes || (ResourceInitiatorTypes = {}));
410
+ var ErrorSource;
411
+ (function (ErrorSource) {
412
+ ErrorSource["CONSOLE"] = "console";
413
+ ErrorSource["WINDOW"] = "window";
414
+ ErrorSource["UNHANDLED_REJECTION"] = "unhandledrejection";
415
+ ErrorSource["DOCUMENT"] = "document";
416
+ ErrorSource["CAPTURED"] = "captured";
417
+ ErrorSource["WEB_WORKER"] = "web_worker";
418
+ })(ErrorSource || (ErrorSource = {}));
419
+ var LogSource;
420
+ (function (LogSource) {
421
+ LogSource["CODE"] = "code";
422
+ })(LogSource || (LogSource = {}));
423
+
392
424
  var CACHED_METADATA_KEY = '__cx_metadata__';
393
425
  var ERROR_INSTRUMENTATION_VERSION = '1';
394
426
  var STACK_FRAME_LIMIT = 50;
@@ -424,15 +456,6 @@ var ErrorAttributes = {
424
456
  MESSAGE: 'error_message',
425
457
  DATA: 'error_custom_data',
426
458
  };
427
- var ErrorSource;
428
- (function (ErrorSource) {
429
- ErrorSource["CONSOLE"] = "console";
430
- ErrorSource["WINDOW"] = "window";
431
- ErrorSource["UNHANDLED_REJECTION"] = "unhandledrejection";
432
- ErrorSource["DOCUMENT"] = "document";
433
- ErrorSource["CAPTURED"] = "captured";
434
- ErrorSource["WEB_WORKER"] = "web_worker";
435
- })(ErrorSource || (ErrorSource = {}));
436
459
  function parseStackFrames(err) {
437
460
  var stack = err.stack, message = err.message, name = err.name;
438
461
  if (!stack) {
@@ -996,6 +1019,14 @@ var NetworkInstrumentationAttributes = {
996
1019
  RESPONSE_PAYLOAD: 'response_payload',
997
1020
  REQUEST_PAYLOAD: 'request_payload',
998
1021
  };
1022
+ var FetchSource;
1023
+ (function (FetchSource) {
1024
+ FetchSource["FETCH"] = "fetch";
1025
+ })(FetchSource || (FetchSource = {}));
1026
+ var XHRSource;
1027
+ (function (XHRSource) {
1028
+ XHRSource["XHR"] = "xhr";
1029
+ })(XHRSource || (XHRSource = {}));
999
1030
 
1000
1031
  function checkAttachingNetworkSpanToGlobalSpan(span) {
1001
1032
  var activeGlobalSpan = getGlobalSpanByTraceId(span.spanContext().traceId);
@@ -1007,10 +1038,6 @@ function checkAttachingNetworkSpanToGlobalSpan(span) {
1007
1038
  }
1008
1039
  }
1009
1040
 
1010
- var FetchSource;
1011
- (function (FetchSource) {
1012
- FetchSource["FETCH"] = "fetch";
1013
- })(FetchSource || (FetchSource = {}));
1014
1041
  var CoralogixFetchInstrumentation = (function (_super) {
1015
1042
  __extends(CoralogixFetchInstrumentation, _super);
1016
1043
  function CoralogixFetchInstrumentation(config) {
@@ -1151,10 +1178,6 @@ var CoralogixFetchInstrumentation = (function (_super) {
1151
1178
  return CoralogixFetchInstrumentation;
1152
1179
  }(FetchInstrumentation));
1153
1180
 
1154
- var XHRSource;
1155
- (function (XHRSource) {
1156
- XHRSource["XHR"] = "xhr";
1157
- })(XHRSource || (XHRSource = {}));
1158
1181
  var CoralogixXhrInstrumentation = (function (_super) {
1159
1182
  __extends(CoralogixXhrInstrumentation, _super);
1160
1183
  function CoralogixXhrInstrumentation(config) {
@@ -1210,10 +1233,6 @@ var CoralogixXhrInstrumentation = (function (_super) {
1210
1233
  }(XMLHttpRequestInstrumentation));
1211
1234
 
1212
1235
  var CUSTOM_INSTRUMENTATION_VERSION = '1';
1213
- var LogSource;
1214
- (function (LogSource) {
1215
- LogSource["CODE"] = "code";
1216
- })(LogSource || (LogSource = {}));
1217
1236
  var CoralogixCustomLogInstrumentation = (function (_super) {
1218
1237
  __extends(CoralogixCustomLogInstrumentation, _super);
1219
1238
  function CoralogixCustomLogInstrumentation(config) {
@@ -1424,7 +1443,7 @@ var attributionSanitizers = {
1424
1443
  return __assign(__assign({}, rest), { attribution: sanitizedAttribution });
1425
1444
  },
1426
1445
  INP: function (metric) {
1427
- metric.entries; metric.attribution; var rest = __rest(metric, ["entries", "attribution"]);
1446
+ metric.entries; var rest = __rest(metric, ["entries"]);
1428
1447
  return rest;
1429
1448
  },
1430
1449
  };
@@ -1813,6 +1832,9 @@ function isPerformanceObserverSupported() {
1813
1832
  }
1814
1833
 
1815
1834
  function sanitizeAttribution(metric) {
1835
+ if (metric.name === 'INP') {
1836
+ return attributionSanitizers.INP(metric);
1837
+ }
1816
1838
  if (!('attribution' in metric)) {
1817
1839
  metric.entries; var rest = __rest(metric, ["entries"]);
1818
1840
  return rest;
@@ -1828,8 +1850,6 @@ function sanitizeAttribution(metric) {
1828
1850
  return attributionSanitizers.FID(metric);
1829
1851
  case 'TTFB':
1830
1852
  return attributionSanitizers.TTFB(metric);
1831
- case 'INP':
1832
- return attributionSanitizers.INP(metric);
1833
1853
  }
1834
1854
  }
1835
1855
  var CoralogixWebVitalsInstrumentation = (function (_super) {
@@ -1838,6 +1858,13 @@ var CoralogixWebVitalsInstrumentation = (function (_super) {
1838
1858
  var _this = _super.call(this, WEB_VITALS_INSTRUMENTATION_NAME, WEB_VITALS_INSTRUMENTATION_VERSION, config) || this;
1839
1859
  _this.observers = [];
1840
1860
  _this.isSoftNavsEnabled = getSdkConfig().trackSoftNavigations;
1861
+ _this.onReportInp = function (metric) {
1862
+ var _a;
1863
+ if (!((_a = metric === null || metric === void 0 ? void 0 : metric.entries) === null || _a === void 0 ? void 0 : _a.length)) {
1864
+ return;
1865
+ }
1866
+ _this.onReport(metric);
1867
+ };
1841
1868
  _this.onReport = function (metric) {
1842
1869
  if (!metric) {
1843
1870
  return;
@@ -1882,7 +1909,7 @@ var CoralogixWebVitalsInstrumentation = (function (_super) {
1882
1909
  onFCP(this.onReport, { reportSoftNavs: shouldReportSoftNavs });
1883
1910
  }
1884
1911
  if (this.metrics.inp) {
1885
- onINP(this.onReport, { reportSoftNavs: shouldReportSoftNavs });
1912
+ onINP(this.onReportInp, { reportSoftNavs: shouldReportSoftNavs });
1886
1913
  }
1887
1914
  if (this.metrics.ttfb) {
1888
1915
  onTTFB(this.onReport, { reportSoftNavs: shouldReportSoftNavs });
@@ -2036,24 +2063,6 @@ function resourceInitiatorTypeIs(value, types) {
2036
2063
  return types.some(function (type) { return type === value; });
2037
2064
  }
2038
2065
 
2039
- var ResourceInitiatorTypes;
2040
- (function (ResourceInitiatorTypes) {
2041
- ResourceInitiatorTypes["Media"] = "media";
2042
- ResourceInitiatorTypes["Script"] = "script";
2043
- ResourceInitiatorTypes["Css"] = "css";
2044
- ResourceInitiatorTypes["Beacon"] = "beacon";
2045
- ResourceInitiatorTypes["Img"] = "img";
2046
- ResourceInitiatorTypes["Font"] = "font";
2047
- ResourceInitiatorTypes["Doc"] = "doc";
2048
- ResourceInitiatorTypes["Xhr"] = "xmlhttprequest";
2049
- ResourceInitiatorTypes["Fetch"] = "fetch";
2050
- ResourceInitiatorTypes["Iframe"] = "iframe";
2051
- ResourceInitiatorTypes["Video"] = "video";
2052
- ResourceInitiatorTypes["Audio"] = "audio";
2053
- ResourceInitiatorTypes["Track"] = "track";
2054
- ResourceInitiatorTypes["Other"] = "other";
2055
- })(ResourceInitiatorTypes || (ResourceInitiatorTypes = {}));
2056
-
2057
2066
  function isPatternMatch(str, arr, warnKey) {
2058
2067
  return arr.some(function (item) {
2059
2068
  if (item instanceof RegExp) {
@@ -2279,9 +2288,11 @@ function extractTestId(el) {
2279
2288
  return (el === null || el === void 0 ? void 0 : el.getAttribute(DATA_TEST_ATTRIBUTE)) || '';
2280
2289
  }
2281
2290
  function extractResolvedName(_a) {
2282
- var element = _a.element, config = _a.config, actionName = _a.actionName, ariaLabel = _a.ariaLabel;
2291
+ var isDeadClick = _a.isDeadClick, element = _a.element, config = _a.config, actionName = _a.actionName, ariaLabel = _a.ariaLabel;
2283
2292
  if (!element)
2284
2293
  return '';
2294
+ if (isDeadClick)
2295
+ return '';
2285
2296
  var resolveName = actionName ||
2286
2297
  maskedTextIfMasked(element, config) ||
2287
2298
  resolveFallbackName(element, ariaLabel, ANCESTOR_SEARCH_DEPTH);
@@ -2687,17 +2698,19 @@ var CoralogixUserInteractionInstrumentation = (function (_super) {
2687
2698
  }
2688
2699
  if (eventTarget instanceof Element) {
2689
2700
  var clickableElement = findClickableElement(eventTarget);
2701
+ var isDeadClick = clickableElement === null;
2690
2702
  var elementText = extractMaskedOrTextContent(eventTarget, config);
2691
2703
  var cxActionName = extractActionName(eventTarget);
2692
2704
  var ariaLabel = extractAriaLabel(eventTarget);
2693
2705
  var testId = extractTestId(eventTarget);
2694
2706
  var resolvedName = extractResolvedName({
2707
+ isDeadClick: isDeadClick,
2695
2708
  element: eventTarget,
2696
2709
  config: config,
2697
2710
  actionName: cxActionName,
2698
2711
  ariaLabel: ariaLabel,
2699
2712
  });
2700
- span.setAttribute(CoralogixAttributes.IS_DEAD_CLICK, clickableElement === null);
2713
+ span.setAttribute(CoralogixAttributes.IS_DEAD_CLICK, isDeadClick);
2701
2714
  var _b = eventTarget.getBoundingClientRect(), width = _b.width, height = _b.height;
2702
2715
  span.setAttribute(CoralogixAttributes.ELEMENT_WIDTH, width);
2703
2716
  span.setAttribute(CoralogixAttributes.ELEMENT_HEIGHT, height);
@@ -2709,19 +2722,25 @@ var CoralogixUserInteractionInstrumentation = (function (_super) {
2709
2722
  : false;
2710
2723
  span.setAttribute(CoralogixAttributes.IS_RAGE_CLICK, isRageClick);
2711
2724
  }
2712
- [
2725
+ var spanAttributes = [
2713
2726
  [CoralogixAttributes.ELEMENT_ID, id],
2714
2727
  [CoralogixAttributes.ELEMENT_CLASSES, getClassName(eventTarget)],
2715
2728
  [CoralogixAttributes.TARGET_ELEMENT_TYPE, type],
2716
2729
  [CoralogixAttributes.ELEMENT_INNER_TEXT, elementText],
2717
2730
  [CoralogixAttributes.TARGET_ELEMENT, nodeName],
2718
- [CoralogixAttributes.RESOLVED_NAME, resolvedName],
2731
+ [
2732
+ CoralogixAttributes.RESOLVED_NAME,
2733
+ isDeadClick ? undefined : resolvedName,
2734
+ ],
2719
2735
  [CoralogixAttributes.CX_ACTION_NAME, cxActionName],
2720
2736
  [CoralogixAttributes.ARIA_LABEL, ariaLabel],
2721
2737
  [CoralogixAttributes.TEST_ID, testId],
2722
- ].forEach(function (_a) {
2738
+ ];
2739
+ spanAttributes.forEach(function (_a) {
2723
2740
  var _b = __read$1(_a, 2), key = _b[0], value = _b[1];
2724
- span.setAttribute(key, value);
2741
+ if (value !== undefined) {
2742
+ span.setAttribute(key, value);
2743
+ }
2725
2744
  });
2726
2745
  }
2727
2746
  span.end();
@@ -5196,7 +5215,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
5196
5215
  return resolvedUrlBlueprinters;
5197
5216
  }
5198
5217
 
5199
- var SDK_VERSION = '3.23.0';
5218
+ var SDK_VERSION = '3.23.3';
5200
5219
 
5201
5220
  function shouldDropEvent(cxRumEvent, options) {
5202
5221
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
@@ -5820,6 +5839,31 @@ var spanMapProcessor;
5820
5839
  var navigationProcessor;
5821
5840
  var exporter;
5822
5841
  var timeMeasurementTracker;
5842
+ function getResolvedName(element, fullData) {
5843
+ if (fullData === void 0) { fullData = false; }
5844
+ if (!isInited) {
5845
+ console.debug('CoralogixRum must be initiated before resolving element names');
5846
+ return;
5847
+ }
5848
+ try {
5849
+ var isDeadClick = findClickableElement(element) === null;
5850
+ var actionName = extractActionName(element);
5851
+ var ariaLabel = extractAriaLabel(element);
5852
+ var resolvedName = extractResolvedName({
5853
+ isDeadClick: isDeadClick,
5854
+ element: element,
5855
+ config: getSdkConfig(),
5856
+ actionName: actionName,
5857
+ ariaLabel: ariaLabel,
5858
+ });
5859
+ return fullData
5860
+ ? { resolvedName: resolvedName, isDeadClick: isDeadClick, actionName: actionName, ariaLabel: ariaLabel }
5861
+ : resolvedName;
5862
+ }
5863
+ catch (err) {
5864
+ return;
5865
+ }
5866
+ }
5823
5867
  var CoralogixRum = {
5824
5868
  get isInited() {
5825
5869
  return isInited;
@@ -6153,23 +6197,7 @@ var CoralogixRum = {
6153
6197
  var _a, _b;
6154
6198
  return (_b = (_a = getSessionManager()) === null || _a === void 0 ? void 0 : _a.getSession()) === null || _b === void 0 ? void 0 : _b.sessionId;
6155
6199
  },
6156
- getResolvedName: function (element) {
6157
- if (!isInited) {
6158
- console.debug('CoralogixRum must be initiated before resolving element names');
6159
- return;
6160
- }
6161
- try {
6162
- return extractResolvedName({
6163
- element: element,
6164
- config: getSdkConfig(),
6165
- actionName: extractActionName(element),
6166
- ariaLabel: extractAriaLabel(element),
6167
- });
6168
- }
6169
- catch (err) {
6170
- return;
6171
- }
6172
- },
6200
+ getResolvedName: getResolvedName,
6173
6201
  getViewName: function () {
6174
6202
  var _a;
6175
6203
  if (!isInited) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "3.23.0",
3
+ "version": "3.23.3",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -7,6 +7,7 @@ import 'error-stack-parser';
7
7
  import '@opentelemetry/instrumentation-fetch';
8
8
  import '@opentelemetry/instrumentation-xml-http-request';
9
9
  import 'web-vitals/attribution';
10
+ import 'web-vitals';
10
11
  import '@opentelemetry/api';
11
12
  import '@opentelemetry/propagator-b3';
12
13
  import '@opentelemetry/propagator-aws-xray';
@@ -1,5 +1,5 @@
1
1
  import { CoralogixOtelWebType, CoralogixWindow, CxSpan } from './types';
2
- import { MemoryUsageContext } from './instrumentations/memory-usage';
2
+ import { MemoryUsageContext } from './instrumentations/memory-usage/memory-usage.types';
3
3
  declare global {
4
4
  interface Worker {
5
5
  CoralogixRum: CoralogixOtelWebType;
@@ -2,9 +2,6 @@ import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instr
2
2
  import { CoralogixLogSeverity } from '../types-external';
3
3
  import { CoralogixRumLabels } from '../types';
4
4
  export declare const CUSTOM_INSTRUMENTATION_VERSION = "1";
5
- export declare enum LogSource {
6
- CODE = "code"
7
- }
8
5
  interface CustomLogParams {
9
6
  severity: CoralogixLogSeverity;
10
7
  message: string;
@@ -1,5 +1,6 @@
1
1
  import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
2
  import { CoralogixRumLabels, CxStackFrame } from '../types';
3
+ import { ErrorSource } from './instrumentation.model';
3
4
  export declare const STACK_FRAME_LIMIT = 50;
4
5
  export declare const STACK_LINE_LIMIT = 1024;
5
6
  export declare function sanitizeConsoleErrorStack(stack: string | undefined): string | undefined;
@@ -11,14 +12,6 @@ export declare const ErrorAttributes: {
11
12
  MESSAGE: string;
12
13
  DATA: string;
13
14
  };
14
- export declare enum ErrorSource {
15
- CONSOLE = "console",
16
- WINDOW = "window",
17
- UNHANDLED_REJECTION = "unhandledrejection",
18
- DOCUMENT = "document",
19
- CAPTURED = "captured",
20
- WEB_WORKER = "web_worker"
21
- }
22
15
  interface CoralogixErrorInstrumentationConfig extends InstrumentationConfig {
23
16
  ignoreErrors?: Array<string | RegExp>;
24
17
  }
@@ -1,6 +1,6 @@
1
1
  import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
+ import { CoralogixInternalEvent } from './instrumentation.model';
2
3
  export declare const INTERNAL_INSTRUMENTATION_VERSION = "1";
3
- export type CoralogixInternalEvent = 'init' | 'recording-start' | 'recording-stop' | 'session-end' | 'error';
4
4
  export declare class CoralogixInternalInstrumentation extends InstrumentationBase {
5
5
  constructor(config: InstrumentationConfig);
6
6
  protected init(): void;
@@ -20,3 +20,15 @@ export type InternalInstrumentationConfig = {
20
20
  confKey: keyof CoralogixOtelWebOptionsInstrumentations | CoralogixEventType;
21
21
  disable: boolean;
22
22
  };
23
+ export declare enum ErrorSource {
24
+ CONSOLE = "console",
25
+ WINDOW = "window",
26
+ UNHANDLED_REJECTION = "unhandledrejection",
27
+ DOCUMENT = "document",
28
+ CAPTURED = "captured",
29
+ WEB_WORKER = "web_worker"
30
+ }
31
+ export declare enum LogSource {
32
+ CODE = "code"
33
+ }
34
+ export type CoralogixInternalEvent = 'init' | 'recording-start' | 'recording-stop' | 'session-end' | 'error';
@@ -1,7 +1,4 @@
1
1
  import { FetchInstrumentation, FetchInstrumentationConfig } from '@opentelemetry/instrumentation-fetch';
2
- export declare enum FetchSource {
3
- FETCH = "fetch"
4
- }
5
2
  export declare class CoralogixFetchInstrumentation extends FetchInstrumentation {
6
3
  private networkDataManager;
7
4
  private headersManager;
@@ -1,7 +1,4 @@
1
1
  import { XMLHttpRequestInstrumentation, XMLHttpRequestInstrumentationConfig } from '@opentelemetry/instrumentation-xml-http-request';
2
- export declare enum XHRSource {
3
- XHR = "xhr"
4
- }
5
2
  export declare class CoralogixXhrInstrumentation extends XMLHttpRequestInstrumentation {
6
3
  private networkDataManager;
7
4
  private headersManager;
@@ -4,3 +4,9 @@ export declare const NetworkInstrumentationAttributes: {
4
4
  RESPONSE_PAYLOAD: string;
5
5
  REQUEST_PAYLOAD: string;
6
6
  };
7
+ export declare enum FetchSource {
8
+ FETCH = "fetch"
9
+ }
10
+ export declare enum XHRSource {
11
+ XHR = "xhr"
12
+ }
@@ -1,11 +1,7 @@
1
- import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
- import { EventName } from '../../types';
1
+ import { InstrumentationBase } from '@opentelemetry/instrumentation';
2
+ import { CoralogixUserInteractionInstrumentationConfig, UserInteractionEventsConfig } from './user-interaction.types';
3
3
  export declare const USER_INTERACTION_INSTRUMENTATION_NAME = "interactions";
4
4
  export declare const USER_INTERACTION_INSTRUMENTATION_VERSION = "1";
5
- export type UserInteractionEventsConfig = Partial<Record<EventName, boolean>>;
6
- export interface CoralogixUserInteractionInstrumentationConfig extends InstrumentationConfig {
7
- events?: UserInteractionEventsConfig;
8
- }
9
5
  export declare const DEFAULT_INSTRUMENTED_EVENTS: UserInteractionEventsConfig;
10
6
  export declare class CoralogixUserInteractionInstrumentation extends InstrumentationBase<CoralogixUserInteractionInstrumentationConfig> {
11
7
  private readonly rageClicksTracker;
@@ -0,0 +1,6 @@
1
+ import { EventName } from '../../types';
2
+ export type UserInteractionEventsConfig = Partial<Record<EventName, boolean>>;
3
+ export interface CoralogixUserInteractionInstrumentationConfig {
4
+ enabled?: boolean;
5
+ events?: UserInteractionEventsConfig;
6
+ }
@@ -2,7 +2,8 @@ import { CoralogixBrowserSdkConfig } from '../../types';
2
2
  export declare function extractActionName(el: Element | HTMLElement | null): string;
3
3
  export declare function extractAriaLabel(el: Element | HTMLElement | null): string;
4
4
  export declare function extractTestId(el: Element | HTMLElement | null): string;
5
- export declare function extractResolvedName({ element, config, actionName, ariaLabel, }: {
5
+ export declare function extractResolvedName({ isDeadClick, element, config, actionName, ariaLabel, }: {
6
+ isDeadClick: boolean;
6
7
  element: Element | HTMLElement | null;
7
8
  config: CoralogixBrowserSdkConfig;
8
9
  actionName: string;
@@ -8,6 +8,7 @@ export declare class CoralogixWebVitalsInstrumentation extends InstrumentationBa
8
8
  private registerToCoreWebVitalMetrics;
9
9
  private registerToSoftNavigations;
10
10
  private registerToCalculatedWebVitalMetrics;
11
+ private onReportInp;
11
12
  private onReport;
12
13
  private registerToTBTMetric;
13
14
  private calculateLoadingPageTime;
@@ -1,6 +1,6 @@
1
- import { CLSMetricWithAttribution, FCPMetricWithAttribution, FIDMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution, Metric, TTFBMetricWithAttribution } from 'web-vitals/attribution';
1
+ import { CLSMetricWithAttribution, FCPMetricWithAttribution, FIDMetricWithAttribution, INPMetricWithAttribution, LCPMetricWithAttribution, Metric, MetricWithAttribution, TTFBMetricWithAttribution } from 'web-vitals/attribution';
2
+ import { INPMetric } from 'web-vitals';
2
3
  import { WebVitalsRating } from '../../types';
3
- import { InstrumentationConfig } from '@opentelemetry/instrumentation';
4
4
  export type CustomMetric = {
5
5
  name: 'SN' | 'LT' | 'TBT' | 'TTI';
6
6
  id: string;
@@ -37,7 +37,7 @@ type SanitizedFIDMetric = Omit<FIDMetricWithAttribution, 'entries' | 'attributio
37
37
  export type SanitizedTTFBMetric = Omit<TTFBMetricWithAttribution, 'entries' | 'attribution'> & {
38
38
  attribution: Omit<TTFBAttribution, 'navigationEntry'>;
39
39
  };
40
- type SanitizedINPMetric = Omit<INPMetricWithAttribution, 'entries' | 'attribution'>;
40
+ type SanitizedINPMetric = Omit<INPMetric, 'entries'>;
41
41
  export type SanitizedMetric = SanitizedLCPMetric | SanitizedFCPMetric | SanitizedCLSMetric | SanitizedFIDMetric | SanitizedTTFBMetric | SanitizedINPMetric | CustomMetric;
42
42
  export type SanitizerMap = {
43
43
  LCP: (m: LCPMetricWithAttribution) => SanitizedLCPMetric;
@@ -45,8 +45,9 @@ export type SanitizerMap = {
45
45
  CLS: (m: CLSMetricWithAttribution) => SanitizedCLSMetric;
46
46
  FID: (m: FIDMetricWithAttribution) => SanitizedFIDMetric;
47
47
  TTFB: (m: TTFBMetricWithAttribution) => SanitizedTTFBMetric;
48
- INP: (m: INPMetricWithAttribution) => SanitizedINPMetric;
48
+ INP: (m: INPMetric) => SanitizedINPMetric;
49
49
  };
50
+ export type ReportedMetric = Exclude<MetricWithAttribution, INPMetricWithAttribution> | INPMetric | CustomMetric;
50
51
  export interface CoralogixWebVitalsMetrics {
51
52
  lcp: boolean;
52
53
  fid: boolean;
@@ -57,7 +58,8 @@ export interface CoralogixWebVitalsMetrics {
57
58
  tbt: boolean;
58
59
  lt: boolean;
59
60
  }
60
- export interface CoralogixWebVitalsInstrumentationConfig extends InstrumentationConfig {
61
+ export interface CoralogixWebVitalsInstrumentationConfig {
62
+ enabled?: boolean;
61
63
  metrics: Partial<CoralogixWebVitalsMetrics>;
62
64
  }
63
65
  export declare const ALL_WEB_VITALS_METRICS: CoralogixWebVitalsMetrics;
@@ -1,2 +1,2 @@
1
- import { CoralogixInternalEvent } from './instrumentations/CoralogixInternalInstrumentation';
1
+ import { CoralogixInternalEvent } from './instrumentations/instrumentation.model';
2
2
  export declare const reportInternalEvent: (event: CoralogixInternalEvent, message?: string) => void;
package/src/types.d.ts CHANGED
@@ -1,22 +1,18 @@
1
- import { Attributes, TextMapPropagator } from '@opentelemetry/api';
1
+ import { Attributes, HrTime, SpanKind, SpanStatusCode, TextMapPropagator } from '@opentelemetry/api';
2
2
  import { CoralogixDomainsApiUrlMap } from './constants';
3
3
  import { CoralogixLogSeverity } from './types-external';
4
- import { ErrorSource } from './instrumentations/CoralogixErrorInstrumentation';
5
- import { FetchSource } from './instrumentations/network/CoralogixFetchInstrumentation';
6
- import { XHRSource } from './instrumentations/network/CoralogixXhrInstrumentation';
7
- import { LogSource } from './instrumentations/CoralogixCustomLogInstrumentation';
8
- import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
9
- import { CoralogixUserInteractionInstrumentationConfig } from './instrumentations/user-interaction/CoralogixUserInteractionInstrumentation';
4
+ import { CoralogixInternalEvent, ErrorSource, LogSource } from './instrumentations/instrumentation.model';
5
+ import { FetchSource, XHRSource } from './instrumentations/network/constants';
6
+ import { CoralogixUserInteractionInstrumentationConfig } from './instrumentations/user-interaction/user-interaction.types';
10
7
  import { Metric } from 'web-vitals/attribution';
11
8
  import { CoralogixWebVitalsInstrumentationConfig } from './instrumentations/web-vitals/web-vitals.types';
12
9
  import { SessionConfig, SessionRecordingConfig } from './session/session.model';
13
- import { CoralogixInternalEvent } from './instrumentations/CoralogixInternalInstrumentation';
14
10
  import { SnapshotContext } from './snapshot/snapshot.model';
15
11
  import { MetricWithAttribution } from 'web-vitals';
16
- import { MemoryUsageContext } from './instrumentations/memory-usage';
12
+ import { MemoryUsageContext } from './instrumentations/memory-usage/memory-usage.types';
17
13
  import { MFEMetadata } from './mfe/mfe.types';
18
14
  import { UrlBasedLabelProvider } from './label-providers/url-based-label-provider';
19
- import { CustomTracer, CustomTracerIgnoredInstruments } from './custom-spans';
15
+ import { CustomTracer, CustomTracerIgnoredInstruments } from './custom-spans/custom-spans.types';
20
16
  import { TraceExporterData } from './traces-exporter/traces-exporter.types';
21
17
  export interface CxStackFrame extends Partial<MFEMetadata> {
22
18
  fileName?: string;
@@ -176,6 +172,12 @@ export interface CoralogixBrowserSdkConfig {
176
172
  runOutsideAngularZone?: boolean;
177
173
  sdkFetchPriority?: SdkFetchPriority;
178
174
  }
175
+ export interface ResolvedNameDetails {
176
+ resolvedName: string;
177
+ isDeadClick: boolean;
178
+ actionName: string;
179
+ ariaLabel: string;
180
+ }
179
181
  export interface CoralogixOtelWebType extends SendLog {
180
182
  init: (options: CoralogixBrowserSdkConfig) => void;
181
183
  shutdown: () => void;
@@ -189,7 +191,11 @@ export interface CoralogixOtelWebType extends SendLog {
189
191
  measureUserAgentSpecificMemory: () => void;
190
192
  getUserContext: () => UserContextConfig | undefined;
191
193
  getSessionId: () => string | undefined;
192
- getResolvedName: (element: Element) => string | undefined;
194
+ getResolvedName: {
195
+ (element: Element, fullData?: false): string | undefined;
196
+ (element: Element, fullData: true): ResolvedNameDetails | undefined;
197
+ (element: Element, fullData: boolean): string | ResolvedNameDetails | undefined;
198
+ };
193
199
  getViewName: () => string | undefined;
194
200
  getSdkVersion: () => string;
195
201
  createNewSession: () => void;
@@ -343,8 +349,21 @@ interface SpanContext {
343
349
  interface OtelResource {
344
350
  attributes: Attributes;
345
351
  }
352
+ interface OtelSpanData extends SpanContext {
353
+ parentSpanId?: string;
354
+ name?: string;
355
+ kind?: SpanKind;
356
+ attributes?: Attributes;
357
+ startTime?: HrTime;
358
+ endTime?: HrTime;
359
+ duration?: HrTime;
360
+ status?: {
361
+ code: SpanStatusCode | number;
362
+ message?: string;
363
+ };
364
+ }
346
365
  interface InstrumentationData {
347
- otelSpan: Partial<ReadableSpan> & SpanContext;
366
+ otelSpan: OtelSpanData;
348
367
  otelResource: OtelResource;
349
368
  }
350
369
  interface VersionMetaData {
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.23.0";
1
+ export declare const SDK_VERSION = "3.23.3";