@coralogix/browser 2.10.0 → 2.11.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.11.0 (2025-11-23)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **trace:** allow custom propagator
6
+
7
+ ## 2.10.1 (2025-11-17)
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - **url-fragments:** Fix URL encoding of template placeholders in page_fragments. Template placeholders like `{id}`, `{lbid}` etc. added by URL blueprinters are now preserved in `page_fragments` instead of being percent-encoded to `%7Bid%7D`, `%7Blbid%7D`. This ensures consistency between `page_url_blueprint` and `page_fragments`.
12
+
1
13
  ## 2.10.0 (2025-09-14)
2
14
 
3
15
  ### 🚀 Features
package/README.md CHANGED
@@ -657,6 +657,82 @@ CoralogixRum.init({
657
657
  },
658
658
  },
659
659
  });
660
+ ```
661
+
662
+ #### Custom Propagation
663
+ ```javascript
664
+ CoralogixRum.init({
665
+ // ...
666
+ traceParentInHeader: {
667
+ enabled: true,
668
+ options: {
669
+ // ...
670
+ /* for Custom propagation */
671
+ propagateCustomTraceHeader: new CustomPropagator()
672
+ },
673
+ },
674
+ });
675
+
676
+ // Example of CustomPropagator, Converts the 128-bit OpenTelemetry trace/span IDs into 64-bit decimal IDs
677
+
678
+ import {
679
+ TextMapGetter,
680
+ TextMapSetter,
681
+ TextMapPropagator,
682
+ Context,
683
+ trace,
684
+ } from '@opentelemetry/api';
685
+
686
+ export class CustomPropagator implements TextMapPropagator {
687
+ inject(context: Context, carrier: any, setter: TextMapSetter) {
688
+ const span = trace.getSpan(context);
689
+ if (!span) return;
690
+
691
+ const spanContext = span.spanContext();
692
+ if (!spanContext) return;
693
+
694
+ // Custom trace ID = last 64 bits of OTel trace ID
695
+ const customTraceId = BigInt(
696
+ '0x' + spanContext.traceId.slice(16)
697
+ ).toString();
698
+ const customParentId = BigInt('0x' + spanContext.spanId).toString();
699
+
700
+ setter.set(carrier, 'my-custom-trace-id', customTraceId);
701
+ setter.set(carrier, 'my-custom-parent-id', customParentId);
702
+ }
703
+
704
+ extract(context: Context, carrier: any, getter: TextMapGetter): Context {
705
+ const traceIdHeader = getter.get(carrier, 'my-custom-trace-id');
706
+ const parentIdHeader = getter.get(carrier, 'my-custom-parent-id');
707
+
708
+ if (!traceIdHeader || !parentIdHeader) return context;
709
+
710
+ const traceId = BigInt(traceIdHeader as string)
711
+ .toString(16)
712
+ .padStart(32, '0');
713
+
714
+ const spanId = BigInt(parentIdHeader as string)
715
+ .toString(16)
716
+ .padStart(16, '0');
717
+
718
+ return trace.setSpan(
719
+ context,
720
+ trace.wrapSpanContext({
721
+ traceId,
722
+ spanId,
723
+ traceFlags: 1,
724
+ isRemote: true,
725
+ })
726
+ );
727
+ }
728
+
729
+ fields(): string[] {
730
+ return ['my-custom-trace-id', 'my-custom-parent-id'];
731
+ }
732
+ }
733
+
734
+
735
+
660
736
  ```
661
737
 
662
738
  ### Before Send
package/index.esm2.js CHANGED
@@ -2660,7 +2660,7 @@ var getUrlFragments = function (url) {
2660
2660
  if (url.startsWith('blob:')) {
2661
2661
  return url;
2662
2662
  }
2663
- return new URL(url).pathname.substring(1) || BASE_PATH;
2663
+ return decodeURIComponent(new URL(url).pathname.substring(1)) || BASE_PATH;
2664
2664
  }
2665
2665
  catch (err) {
2666
2666
  console.warn('Coralogix Browser SDK - Error parsing URL', err);
@@ -3819,12 +3819,12 @@ var reportInternalEvent = function (event, message) {
3819
3819
 
3820
3820
  function handlePropagators(config, tracerProvider) {
3821
3821
  return __awaiter(this, void 0, void 0, function () {
3822
- var propagators, _a, propagateB3TraceHeader, propagateAwsXrayTraceHeader, singleHeader, multiHeader;
3822
+ var propagators, _a, propagateB3TraceHeader, propagateAwsXrayTraceHeader, propagateCustomTraceHeader, singleHeader, multiHeader;
3823
3823
  var _b, _c;
3824
3824
  return __generator(this, function (_d) {
3825
3825
  if ((_b = config.traceParentInHeader) === null || _b === void 0 ? void 0 : _b.enabled) {
3826
3826
  propagators = [];
3827
- _a = ((_c = config.traceParentInHeader) === null || _c === void 0 ? void 0 : _c.options) || {}, propagateB3TraceHeader = _a.propagateB3TraceHeader, propagateAwsXrayTraceHeader = _a.propagateAwsXrayTraceHeader;
3827
+ _a = ((_c = config.traceParentInHeader) === null || _c === void 0 ? void 0 : _c.options) || {}, propagateB3TraceHeader = _a.propagateB3TraceHeader, propagateAwsXrayTraceHeader = _a.propagateAwsXrayTraceHeader, propagateCustomTraceHeader = _a.propagateCustomTraceHeader;
3828
3828
  if (!propagateAwsXrayTraceHeader && !propagateB3TraceHeader) {
3829
3829
  propagators = __spreadArray(__spreadArray([], __read$1(propagators), false), [
3830
3830
  new W3CBaggagePropagator(),
@@ -3843,6 +3843,9 @@ function handlePropagators(config, tracerProvider) {
3843
3843
  propagators.push(new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }));
3844
3844
  }
3845
3845
  }
3846
+ if (propagateCustomTraceHeader) {
3847
+ propagators.push(propagateCustomTraceHeader);
3848
+ }
3846
3849
  tracerProvider.register({
3847
3850
  propagator: new CxPropagator(config, new CompositePropagator({
3848
3851
  propagators: propagators,
@@ -3965,7 +3968,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
3965
3968
  return resolvedUrlBlueprinters;
3966
3969
  }
3967
3970
 
3968
- var SDK_VERSION = '2.10.0';
3971
+ var SDK_VERSION = '2.11.0';
3969
3972
 
3970
3973
  function shouldDropEvent(cxRumEvent, options) {
3971
3974
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
package/src/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Attributes } from '@opentelemetry/api';
1
+ import { Attributes, TextMapPropagator } from '@opentelemetry/api';
2
2
  import { CoralogixDomainsApiUrlMap } from './constants';
3
3
  import { CoralogixLogSeverity } from './types-external';
4
4
  import { ErrorSource } from './instrumentations/CoralogixErrorInstrumentation';
@@ -88,6 +88,7 @@ export interface TraceHeaderConfiguration {
88
88
  singleHeader?: boolean;
89
89
  multiHeader?: boolean;
90
90
  };
91
+ propagateCustomTraceHeader?: TextMapPropagator;
91
92
  };
92
93
  }
93
94
  export interface CoralogixOtelWebOptionsInstrumentations {
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.10.0";
1
+ export declare const SDK_VERSION = "2.11.0";