@coralogix/react-native-plugin 0.2.5 → 0.2.7

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,25 @@
1
+ ## 0.2.7 (2026-01-29)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - changed name for traceParentInHeader options object
6
+ - simplify traceParentInHeader mapping and rename allowedTracingUrls
7
+ - when traceParentInHeader is disabled, don't inject any headers at all
8
+ - map traceParentInHeader keys from RN to native iOS SDK format
9
+ - change documentation for View Tracking
10
+
11
+ ### 🩹 Patch
12
+
13
+ - updated the android native sdk to version 2.6.4
14
+ - updated the ios native sdk to version 1.5.3
15
+
16
+ ## 0.2.6 (2026-01-05)
17
+
18
+ ### 🚀 Features
19
+
20
+ - Implement React Native SDK E2E Test
21
+ - Bump iOS native version to 1.5.2
22
+
1
23
  ## 0.2.5 (2025-12-08)
2
24
 
3
25
  Fix: Resolved an issue where severity mapping bug by treating the value as Double instead of Int.
package/CxSdk.podspec CHANGED
@@ -16,9 +16,9 @@ Pod::Spec.new do |s|
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
- s.dependency 'Coralogix','1.5.0'
20
- s.dependency 'CoralogixInternal','1.5.0'
21
- s.dependency 'SessionReplay','1.5.0'
19
+ s.dependency 'Coralogix','1.5.3'
20
+ s.dependency 'CoralogixInternal','1.5.3'
21
+ s.dependency 'SessionReplay','1.5.3'
22
22
 
23
23
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
24
24
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/README.md CHANGED
@@ -103,18 +103,18 @@ CoralogixRum.setViewContext({
103
103
  ```
104
104
 
105
105
  You can automatically track view changes by using [react-navigation](https://reactnavigation.org/docs/navigation-container/#onstatechange).
106
- Wrap your navigation ref with our `attachReactNavigationObserver` hook like so:
106
+ Use the NavigationContainer onStateChange callback to track route changes and update the view context manually, as shown below:
107
107
 
108
108
  ```javascript
109
- const navigationRef = createNavigationContainerRef();
110
- const navHooks = attachReactNavigationObserver(navigationRef);
111
-
112
109
  <NavigationContainer
113
110
  ref={navigationRef}
114
- onReady={navHooks.onReady}
115
- onStateChange={navHooks.onStateChange}
111
+ onStateChange={() => {
112
+ const currentRouteName = navigationRef.current.getCurrentRoute().name;
113
+
114
+ CoralogixRum.setViewContext({ view: currentRouteName });
115
+ }}
116
116
  >
117
- >{/* ... */}
117
+ {/* ... */}
118
118
  </NavigationContainer>
119
119
  ```
120
120
 
@@ -75,7 +75,7 @@ dependencies {
75
75
  implementation "com.facebook.react:react-android"
76
76
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
77
 
78
- implementation "com.coralogix:android-sdk:2.6.2"
78
+ implementation "com.coralogix:android-sdk:2.6.4"
79
79
  }
80
80
 
81
81
  react {
@@ -309,7 +309,7 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
309
309
 
310
310
  val traceParentInHeaderMap = getMap("traceParentInHeader")
311
311
  val isTraceParentInHeaderEnabled = traceParentInHeaderMap?.let {
312
- it.hasKey("enable") && it.getBoolean("enable")
312
+ it.hasKey("enabled") && it.getBoolean("enabled")
313
313
  } ?: false
314
314
  val collectIpData = if (hasKey("collectIPData")) getBoolean("collectIPData") else true
315
315
 
package/index.cjs.js CHANGED
@@ -4,6 +4,7 @@ var reactNative = require('react-native');
4
4
  var instrumentationFetch = require('@opentelemetry/instrumentation-fetch');
5
5
  var instrumentation = require('@opentelemetry/instrumentation');
6
6
  var sdkTraceWeb = require('@opentelemetry/sdk-trace-web');
7
+ var core = require('@opentelemetry/core');
7
8
 
8
9
  function _extends() {
9
10
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -219,7 +220,7 @@ function stopJsRefreshRateSampler() {
219
220
  appStateSub = null;
220
221
  }
221
222
 
222
- var version = "0.2.5";
223
+ var version = "0.2.7";
223
224
  var pkg = {
224
225
  version: version};
225
226
 
@@ -257,17 +258,6 @@ class Logger {
257
258
  }
258
259
  const logger = new Logger();
259
260
 
260
- const propagateTraceHeaderCorsUrls = config => {
261
- var _traceParentInHeader$;
262
- const {
263
- traceParentInHeader
264
- } = config;
265
- const propagateCorsUrls = traceParentInHeader == null || (_traceParentInHeader$ = traceParentInHeader.options) == null ? void 0 : _traceParentInHeader$.propagateTraceHeaderCorsUrls;
266
- if (traceParentInHeader != null && traceParentInHeader.enabled && propagateCorsUrls) {
267
- config.propagateTraceHeaderCorsUrls = propagateCorsUrls;
268
- }
269
- };
270
-
271
261
  const CORALOGIX_LOGS_URL_SUFFIX = '/browser/v1beta/logs';
272
262
  const CORALOGIX_RECORDING_URL_SUFFIX = '/sessionrecording';
273
263
  const OPTIONS_DEFAULTS = {
@@ -331,8 +321,18 @@ let OtelNetworkAttrs = /*#__PURE__*/function (OtelNetworkAttrs) {
331
321
 
332
322
  class CoralogixFetchInstrumentation extends instrumentationFetch.FetchInstrumentation {
333
323
  constructor(config) {
334
- propagateTraceHeaderCorsUrls(config);
335
- config.applyCustomAttributesOnSpan = (span, request, result) => {
324
+ var _traceParentInHeader$;
325
+ const {
326
+ traceParentInHeader
327
+ } = config;
328
+ const enabled = (traceParentInHeader == null ? void 0 : traceParentInHeader.enabled) === true;
329
+ const urls = traceParentInHeader == null || (_traceParentInHeader$ = traceParentInHeader.options) == null ? void 0 : _traceParentInHeader$.allowedTracingUrls;
330
+ const fetchConfig = {
331
+ // If disabled -> match nothing -> no traceparent injection
332
+ // If enabled and user didn't provide urls -> match all
333
+ propagateTraceHeaderCorsUrls: enabled ? urls != null ? urls : /.*/ : allowNone()
334
+ };
335
+ fetchConfig.applyCustomAttributesOnSpan = (span, request, result) => {
336
336
  span.end();
337
337
  const readableSpan = span;
338
338
  const attrs = readableSpan.attributes;
@@ -366,12 +366,16 @@ class CoralogixFetchInstrumentation extends instrumentationFetch.FetchInstrument
366
366
  };
367
367
  CoralogixRum.reportNetworkRequest(details);
368
368
  };
369
- super(config);
369
+ super(fetchConfig);
370
370
  }
371
371
  enable() {
372
372
  super.enable();
373
373
  }
374
374
  }
375
+ function allowNone() {
376
+ // matches nothing
377
+ return /^$/;
378
+ }
375
379
 
376
380
  function isSessionReplayOptionsValid(options) {
377
381
  const scaleValid = options.captureScale > 0 && options.captureScale <= 1;
@@ -672,6 +676,9 @@ async function registerCoralogixInstrumentations(options) {
672
676
  beforeSendCallback = options.beforeSend;
673
677
  }
674
678
  const tracerProvider = new sdkTraceWeb.WebTracerProvider();
679
+ tracerProvider.register({
680
+ propagator: new core.W3CTraceContextPropagator()
681
+ });
675
682
  const instrumentations = [];
676
683
  const instrumentationsOptions = options.instrumentations;
677
684
 
@@ -681,12 +688,12 @@ async function registerCoralogixInstrumentations(options) {
681
688
  if (isAndroid) {
682
689
  pluginApplied = await CxSdk.isCoralogixGradlePluginApplied();
683
690
  }
684
- const shouldInterceptNetowrk = isAndroid && !pluginApplied && (!instrumentationsOptions || instrumentationsOptions.network !== false);
691
+ const shouldInterceptNetwork = isAndroid && !pluginApplied && (!instrumentationsOptions || instrumentationsOptions.network !== false);
685
692
  const shouldInterceptErrors = !instrumentationsOptions || instrumentationsOptions.errors !== false;
686
693
  const shouldInterceptMobileVitals = !instrumentationsOptions || instrumentationsOptions.mobile_vitals !== false;
687
-
694
+ logger.debug("activating fetch instrumentation: ", shouldInterceptNetwork);
688
695
  // Fetch instrumentation
689
- if (shouldInterceptNetowrk) {
696
+ if (shouldInterceptNetwork) {
690
697
  fetchInstrumentation = new CoralogixFetchInstrumentation(options);
691
698
  instrumentations.push(fetchInstrumentation);
692
699
  }
package/index.esm.js CHANGED
@@ -2,6 +2,7 @@ import { AppState, Platform, NativeModules, NativeEventEmitter, findNodeHandle }
2
2
  import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch';
3
3
  import { InstrumentationBase, registerInstrumentations } from '@opentelemetry/instrumentation';
4
4
  import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
5
+ import { W3CTraceContextPropagator } from '@opentelemetry/core';
5
6
 
6
7
  function _extends() {
7
8
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -217,7 +218,7 @@ function stopJsRefreshRateSampler() {
217
218
  appStateSub = null;
218
219
  }
219
220
 
220
- var version = "0.2.5";
221
+ var version = "0.2.7";
221
222
  var pkg = {
222
223
  version: version};
223
224
 
@@ -255,17 +256,6 @@ class Logger {
255
256
  }
256
257
  const logger = new Logger();
257
258
 
258
- const propagateTraceHeaderCorsUrls = config => {
259
- var _traceParentInHeader$;
260
- const {
261
- traceParentInHeader
262
- } = config;
263
- const propagateCorsUrls = traceParentInHeader == null || (_traceParentInHeader$ = traceParentInHeader.options) == null ? void 0 : _traceParentInHeader$.propagateTraceHeaderCorsUrls;
264
- if (traceParentInHeader != null && traceParentInHeader.enabled && propagateCorsUrls) {
265
- config.propagateTraceHeaderCorsUrls = propagateCorsUrls;
266
- }
267
- };
268
-
269
259
  const CORALOGIX_LOGS_URL_SUFFIX = '/browser/v1beta/logs';
270
260
  const CORALOGIX_RECORDING_URL_SUFFIX = '/sessionrecording';
271
261
  const OPTIONS_DEFAULTS = {
@@ -329,8 +319,18 @@ let OtelNetworkAttrs = /*#__PURE__*/function (OtelNetworkAttrs) {
329
319
 
330
320
  class CoralogixFetchInstrumentation extends FetchInstrumentation {
331
321
  constructor(config) {
332
- propagateTraceHeaderCorsUrls(config);
333
- config.applyCustomAttributesOnSpan = (span, request, result) => {
322
+ var _traceParentInHeader$;
323
+ const {
324
+ traceParentInHeader
325
+ } = config;
326
+ const enabled = (traceParentInHeader == null ? void 0 : traceParentInHeader.enabled) === true;
327
+ const urls = traceParentInHeader == null || (_traceParentInHeader$ = traceParentInHeader.options) == null ? void 0 : _traceParentInHeader$.allowedTracingUrls;
328
+ const fetchConfig = {
329
+ // If disabled -> match nothing -> no traceparent injection
330
+ // If enabled and user didn't provide urls -> match all
331
+ propagateTraceHeaderCorsUrls: enabled ? urls != null ? urls : /.*/ : allowNone()
332
+ };
333
+ fetchConfig.applyCustomAttributesOnSpan = (span, request, result) => {
334
334
  span.end();
335
335
  const readableSpan = span;
336
336
  const attrs = readableSpan.attributes;
@@ -364,12 +364,16 @@ class CoralogixFetchInstrumentation extends FetchInstrumentation {
364
364
  };
365
365
  CoralogixRum.reportNetworkRequest(details);
366
366
  };
367
- super(config);
367
+ super(fetchConfig);
368
368
  }
369
369
  enable() {
370
370
  super.enable();
371
371
  }
372
372
  }
373
+ function allowNone() {
374
+ // matches nothing
375
+ return /^$/;
376
+ }
373
377
 
374
378
  function isSessionReplayOptionsValid(options) {
375
379
  const scaleValid = options.captureScale > 0 && options.captureScale <= 1;
@@ -670,6 +674,9 @@ async function registerCoralogixInstrumentations(options) {
670
674
  beforeSendCallback = options.beforeSend;
671
675
  }
672
676
  const tracerProvider = new WebTracerProvider();
677
+ tracerProvider.register({
678
+ propagator: new W3CTraceContextPropagator()
679
+ });
673
680
  const instrumentations = [];
674
681
  const instrumentationsOptions = options.instrumentations;
675
682
 
@@ -679,12 +686,12 @@ async function registerCoralogixInstrumentations(options) {
679
686
  if (isAndroid) {
680
687
  pluginApplied = await CxSdk.isCoralogixGradlePluginApplied();
681
688
  }
682
- const shouldInterceptNetowrk = isAndroid && !pluginApplied && (!instrumentationsOptions || instrumentationsOptions.network !== false);
689
+ const shouldInterceptNetwork = isAndroid && !pluginApplied && (!instrumentationsOptions || instrumentationsOptions.network !== false);
683
690
  const shouldInterceptErrors = !instrumentationsOptions || instrumentationsOptions.errors !== false;
684
691
  const shouldInterceptMobileVitals = !instrumentationsOptions || instrumentationsOptions.mobile_vitals !== false;
685
-
692
+ logger.debug("activating fetch instrumentation: ", shouldInterceptNetwork);
686
693
  // Fetch instrumentation
687
- if (shouldInterceptNetowrk) {
694
+ if (shouldInterceptNetwork) {
688
695
  fetchInstrumentation = new CoralogixFetchInstrumentation(options);
689
696
  instrumentations.push(fetchInstrumentation);
690
697
  }
package/ios/CxSdk.swift CHANGED
@@ -128,7 +128,8 @@ class CxSdk: RCTEventEmitter {
128
128
  return
129
129
  }
130
130
  let data = data as? [String: Any] ?? [String: Any]()
131
- coralogixRum?.log(severity:cxLogSeverity, message: message, data: data)
131
+ let labels = labels as? [String: Any] ?? [String: Any]()
132
+ coralogixRum?.log(severity:cxLogSeverity, message: message, data: data, labels: labels)
132
133
  resolve("log success")
133
134
  }
134
135
 
@@ -402,8 +403,8 @@ class CxSdk: RCTEventEmitter {
402
403
  fpsSampleRate: parameter["fpsSamplingSeconds"] as? TimeInterval ?? 300,
403
404
  instrumentations: instrumentationDict,
404
405
  collectIPData: parameter["collectIPData"] as? Bool ?? true,
405
- proxyUrl: parameter["proxyUrl"] as? String ?? nil,
406
- traceParentInHeader: parameter["traceParentInHeader"] as? [String: Any] ?? nil,
406
+ proxyUrl: parameter["proxyUrl"] as? String ?? nil,
407
+ traceParentInHeader: mapTraceParentInHeader(parameter["traceParentInHeader"] as? [String: Any]),
407
408
  mobileVitals: mobileVitalsDict,
408
409
  debug: parameter["debug"] as? Bool ?? true)
409
410
 
@@ -446,6 +447,23 @@ class CxSdk: RCTEventEmitter {
446
447
  return sessionReplayOptions
447
448
  }
448
449
 
450
+ private func mapTraceParentInHeader(_ rnConfig: [String: Any]?) -> [String: Any]? {
451
+ guard let rnConfig = rnConfig else { return nil }
452
+
453
+ var nativeConfig: [String: Any] = [:]
454
+
455
+ // Copy all keys, but rename "enabled" to "enable"
456
+ for (key, value) in rnConfig {
457
+ if key == "enabled" {
458
+ nativeConfig["enable"] = value
459
+ } else {
460
+ nativeConfig[key] = value
461
+ }
462
+ }
463
+
464
+ return nativeConfig.isEmpty ? nil : nativeConfig
465
+ }
466
+
449
467
  private func convertToJSCompatibleEvent(event: [String: Any]) -> [String: Any] {
450
468
  var jsEvent: [String: Any] = [:]
451
469
  for (key, value) in event {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/react-native-plugin",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Official Coralogix React Native plugin",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -25,6 +25,8 @@
25
25
  },
26
26
  "main": "./index.cjs.js",
27
27
  "dependencies": {
28
+ "@opentelemetry/context-zone": "^2.5.0",
29
+ "@opentelemetry/core": "^2.5.0",
28
30
  "@opentelemetry/instrumentation": "0.48.0",
29
31
  "@opentelemetry/instrumentation-fetch": "0.203.0",
30
32
  "@opentelemetry/sdk-trace-web": "1.30.1"
@@ -141,7 +141,7 @@ export interface TraceParentInHeader {
141
141
  enabled: boolean;
142
142
  options?: {
143
143
  /** urls outside of origin that should also add Traceparent to header */
144
- propagateTraceHeaderCorsUrls?: Array<string | RegExp>;
144
+ allowedTracingUrls?: Array<string | RegExp>;
145
145
  };
146
146
  }
147
147
  export interface CoralogixStackFrame {
@@ -1,2 +0,0 @@
1
- import { FetchInstrumentationConfig } from '@opentelemetry/instrumentation-fetch';
2
- export declare const propagateTraceHeaderCorsUrls: (config: FetchInstrumentationConfig) => void;