@coralogix/react-native-plugin 0.1.3 → 0.1.5

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,16 @@
1
+ ## 0.1.5 (2025-10-13)
2
+
3
+ ### 🩹 Fixes
4
+ - fixed build issue in iOS
5
+ - fixed beforeSend to actually be optional in iOS
6
+ - handle hot reload appropriately to shutdown our native sdk, the sdk is initialized anew keeping context fresh in the native layer
7
+
8
+ ## 0.1.4 (2025-10-09)
9
+
10
+ ### 🩹 Fixes
11
+ - beforeSend is now optional
12
+ - `CoralogixRum.init` is now async
13
+
1
14
  ## 0.1.3 (2025-09-02)
2
15
 
3
16
  ### Patch
package/README.md CHANGED
@@ -12,11 +12,12 @@ This package replaces the old `@coralogix/react-native-sdk` package.
12
12
 
13
13
  To use Coralogix SDK, call `CoralogixRum.init(options)` at the soonest available moment after the app loads.
14
14
  This will initialize the SDK based on the options you provided.
15
+ Please note that `init` is an `async` function.
15
16
 
16
17
  ```javascript
17
18
  import { CoralogixRum } from '@coralogix/react-native-plugin'
18
19
 
19
- CoralogixRum.init({
20
+ await CoralogixRum.init({
20
21
  application: 'app-name',
21
22
  environment: 'production',
22
23
  public_key: 'abc-123-456',
@@ -97,7 +98,7 @@ Turn on/off specific instrumentation; defaults to true for all.
97
98
  Each instrumentation is responsible for which data the SDK will track and collect for you.
98
99
 
99
100
  ```javascript
100
- CoralogixRum.init({
101
+ await CoralogixRum.init({
101
102
  // ...
102
103
  instrumentations: {
103
104
  errors: true,
@@ -120,7 +121,7 @@ Use regular expressions for exact matching as strings remove partial matches.
120
121
  ```javascript
121
122
  import { CoralogixRum } from '@coralogix/react-native-plugin';
122
123
 
123
- CoralogixRum.init({
124
+ await CoralogixRum.init({
124
125
  // ...
125
126
  ignoreErrors: [/Exact Match Error Message/, 'partial/match'],
126
127
  });
@@ -131,7 +132,7 @@ CoralogixRum.init({
131
132
  Add trace context propagation in headers across service boundaries
132
133
 
133
134
  ```javascript
134
- CoralogixRum.init({
135
+ await CoralogixRum.init({
135
136
  // ...
136
137
  traceParentInHeader: {
137
138
  enabled: true
@@ -144,7 +145,7 @@ CoralogixRum.init({
144
145
  Enable event access and modification before sending to Coralogix, supporting content modification, and event discarding.
145
146
 
146
147
  ```javascript
147
- CoralogixRum.init({
148
+ await CoralogixRum.init({
148
149
  // ...
149
150
  beforeSend: (event) => {
150
151
  // Discard events from @company.com users.
@@ -169,7 +170,7 @@ The Coralogix route for each request that is sent to the proxy is available in t
169
170
  (for example, https://www.your-proxy.com/endpoint?cxforward=https%3A%2F%2Fingress.eu1.rum-ingress-coralogix.com%2Fbrowser%2Fv1beta%2Flogs).
170
171
 
171
172
  ```javascript
172
- CoralogixRum.init({
173
+ await CoralogixRum.init({
173
174
  // ...
174
175
  coralogixDomain: 'EU1',
175
176
  proxyUrl: 'https://www.your-proxy.com/endpoint',
@@ -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.4.6"
78
+ implementation "com.coralogix:android-sdk:2.5.2"
79
79
  }
80
80
 
81
81
  react {
@@ -38,7 +38,7 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
38
38
  }
39
39
 
40
40
  @ReactMethod
41
- override fun initialize(config: ReadableMap) {
41
+ override fun initialize(config: ReadableMap, promise: Promise) {
42
42
  val application = reactApplicationContext.applicationContext as Application
43
43
  val options = config.toCoralogixOptions()
44
44
 
@@ -50,7 +50,10 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
50
50
  CoralogixRum.initialize(
51
51
  application = application,
52
52
  options = options,
53
- framework = Framework.HybridFramework.ReactNative(rnPluginVersion))
53
+ framework = Framework.HybridFramework.ReactNative(rnPluginVersion)
54
+ )
55
+
56
+ promise.resolve(true)
54
57
  }
55
58
  }
56
59
 
@@ -97,8 +100,8 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
97
100
  }
98
101
 
99
102
  @ReactMethod
100
- override fun log(severity: Int, message: String, data: ReadableMap) {
101
- CoralogixRum.log(severity.toCoralogixLogSeverity(), message, data.toStringMap())
103
+ override fun log(severity: Int, message: String, data: ReadableMap, labels: ReadableMap) {
104
+ CoralogixRum.log(severity.toCoralogixLogSeverity(), message, data.toStringMap(), labels.toStringMap())
102
105
  }
103
106
 
104
107
  @ReactMethod
@@ -169,9 +172,10 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
169
172
  }
170
173
 
171
174
  @ReactMethod
172
- override fun shutdown() {
175
+ override fun shutdown(promise: Promise) {
173
176
  Handler(Looper.getMainLooper()).post {
174
177
  CoralogixRum.shutdown()
178
+ promise.resolve(true)
175
179
  }
176
180
  }
177
181
 
@@ -185,6 +189,15 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
185
189
  Log.d("CxSdkModule", "removeListeners: $count")
186
190
  }
187
191
 
192
+ override fun invalidate() {
193
+ super.invalidate()
194
+
195
+ Handler(Looper.getMainLooper()).post {
196
+ Log.d("CxSdkModule", "Bridge destroyed — shutting down CoralogixRum")
197
+ CoralogixRum.shutdown()
198
+ }
199
+ }
200
+
188
201
  private fun ReadableMap.toCoralogixOptions(): CoralogixOptions {
189
202
  val applicationName = getString("application")
190
203
  ?: throw IllegalArgumentException("Missing required parameter: application")
@@ -223,6 +236,8 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
223
236
 
224
237
  private fun beforeSendCallback(data: List<Map<String, Any?>>) {
225
238
  val args = convertAnyListToWritableArray(data)
239
+ if (!reactApplicationContext.hasActiveReactInstance()) return
240
+
226
241
  reactApplicationContext
227
242
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
228
243
  .emit("onBeforeSend", args)
@@ -5,7 +5,7 @@ import com.facebook.react.bridge.ReadableArray
5
5
  import com.facebook.react.bridge.ReadableMap
6
6
 
7
7
  interface ICxSdkModule {
8
- fun initialize(config: ReadableMap)
8
+ fun initialize(config: ReadableMap, promise: Promise)
9
9
  fun setUserContext(userContextMap: ReadableMap)
10
10
  fun getUserContext(promise: Promise)
11
11
  fun setApplicationContext(appContextMap: ReadableMap)
@@ -13,12 +13,12 @@ interface ICxSdkModule {
13
13
  fun setLabels(labelsMap: ReadableMap)
14
14
  fun getLabels(promise: Promise)
15
15
  fun setViewContext(viewContext: String)
16
- fun log(severity: Int, message: String, data: ReadableMap)
16
+ fun log(severity: Int, message: String, data: ReadableMap, labels: ReadableMap)
17
17
  fun reportNetworkRequest(requestDetails: ReadableMap)
18
18
  fun sendCustomMeasurement(measurement: ReadableMap)
19
19
  fun reportError(details: ReadableMap)
20
20
  fun sendCxSpanData(results: ReadableArray)
21
21
  fun reportMobileVitalsMeasurement(type: String, value: Double, units: String)
22
22
  fun reportMobileVitalsMeasurementSet(type: String, metrics: ReadableArray)
23
- fun shutdown()
23
+ fun shutdown(promise: Promise)
24
24
  }
package/index.cjs.js CHANGED
@@ -219,7 +219,7 @@ function stopJsRefreshRateSampler() {
219
219
  appStateSub = null;
220
220
  }
221
221
 
222
- var version = "0.1.3";
222
+ var version = "0.1.5";
223
223
  var pkg = {
224
224
  version: version};
225
225
 
@@ -405,7 +405,7 @@ const CoralogixRum = {
405
405
  get isInited() {
406
406
  return isInited;
407
407
  },
408
- init: function (options) {
408
+ init: async function (options) {
409
409
  var _resolvedOptions$debu;
410
410
  if (isInited) {
411
411
  console.warn('[Coralogix React Native SDK] - already initialized');
@@ -418,7 +418,7 @@ const CoralogixRum = {
418
418
  return;
419
419
  }
420
420
  registerCoralogixInstrumentations(resolvedOptions);
421
- CxSdk.initialize(_extends({}, resolvedOptions, {
421
+ await CxSdk.initialize(_extends({}, resolvedOptions, {
422
422
  frameworkVersion: pkg.version
423
423
  }));
424
424
  isInited = true;
@@ -494,12 +494,12 @@ const CoralogixRum = {
494
494
  }
495
495
  return CxSdk.getSessionId();
496
496
  },
497
- log: (severity, message, data) => {
497
+ log: (severity, message, data, labels) => {
498
498
  if (!isInited) {
499
499
  logger.debug('CoralogixRum must be initiated before using log');
500
500
  return;
501
501
  }
502
- CxSdk.log(severity, message, data != null ? data : {});
502
+ CxSdk.log(severity, message, data != null ? data : {}, labels != null ? labels : {});
503
503
  },
504
504
  debug(message, data) {
505
505
  this.log(CoralogixLogSeverity.Debug, message, data);
@@ -673,7 +673,8 @@ const subscription = eventEmitter.addListener('onBeforeSend', events => {
673
673
  logger.debug('❌ Error in beforeSend callback:', error);
674
674
  }
675
675
  } else {
676
- logger.debug('⚠️ No beforeSendCallback available');
676
+ logger.debug('⚠️ No beforeSendCallback available - sending raw events');
677
+ CxSdk.sendCxSpanData(events);
677
678
  }
678
679
  });
679
680
 
package/index.esm.js CHANGED
@@ -217,7 +217,7 @@ function stopJsRefreshRateSampler() {
217
217
  appStateSub = null;
218
218
  }
219
219
 
220
- var version = "0.1.3";
220
+ var version = "0.1.5";
221
221
  var pkg = {
222
222
  version: version};
223
223
 
@@ -403,7 +403,7 @@ const CoralogixRum = {
403
403
  get isInited() {
404
404
  return isInited;
405
405
  },
406
- init: function (options) {
406
+ init: async function (options) {
407
407
  var _resolvedOptions$debu;
408
408
  if (isInited) {
409
409
  console.warn('[Coralogix React Native SDK] - already initialized');
@@ -416,7 +416,7 @@ const CoralogixRum = {
416
416
  return;
417
417
  }
418
418
  registerCoralogixInstrumentations(resolvedOptions);
419
- CxSdk.initialize(_extends({}, resolvedOptions, {
419
+ await CxSdk.initialize(_extends({}, resolvedOptions, {
420
420
  frameworkVersion: pkg.version
421
421
  }));
422
422
  isInited = true;
@@ -492,12 +492,12 @@ const CoralogixRum = {
492
492
  }
493
493
  return CxSdk.getSessionId();
494
494
  },
495
- log: (severity, message, data) => {
495
+ log: (severity, message, data, labels) => {
496
496
  if (!isInited) {
497
497
  logger.debug('CoralogixRum must be initiated before using log');
498
498
  return;
499
499
  }
500
- CxSdk.log(severity, message, data != null ? data : {});
500
+ CxSdk.log(severity, message, data != null ? data : {}, labels != null ? labels : {});
501
501
  },
502
502
  debug(message, data) {
503
503
  this.log(CoralogixLogSeverity.Debug, message, data);
@@ -671,7 +671,8 @@ const subscription = eventEmitter.addListener('onBeforeSend', events => {
671
671
  logger.debug('❌ Error in beforeSend callback:', error);
672
672
  }
673
673
  } else {
674
- logger.debug('⚠️ No beforeSendCallback available');
674
+ logger.debug('⚠️ No beforeSendCallback available - sending raw events');
675
+ CxSdk.sendCxSpanData(events);
675
676
  }
676
677
  });
677
678
 
package/ios/CxSdk.mm CHANGED
@@ -51,6 +51,7 @@ RCT_EXTERN_METHOD(reportError:(NSDictionary *)errorDictionary
51
51
  RCT_EXTERN_METHOD(log:(int)severity
52
52
  message:(NSString *)message
53
53
  data:(NSDictionary *)data
54
+ labels:(NSDictionary *)labels
54
55
  withResolver:(RCTPromiseResolveBlock)resolve
55
56
  withRejecter:(RCTPromiseRejectBlock)reject)
56
57
 
package/ios/CxSdk.swift CHANGED
@@ -29,7 +29,7 @@ class CxSdk: RCTEventEmitter {
29
29
  reject:RCTPromiseRejectBlock) -> Void {
30
30
  do {
31
31
  // Create beforeSendCallback only if parameter["beforeSend"] is not null
32
- let beforeSendCallBack: (([[String: Any]]) -> Void)? = parameter["beforeSend"] != nil ? { [weak self] (event: [[String: Any]]) -> Void in
32
+ let beforeSendCallBack: (([[String: Any]]) -> Void)? = { [weak self] (event: [[String: Any]]) -> Void in
33
33
  // Convert the event dictionary to a format that
34
34
  // can be safely passed to JavaScript
35
35
  let jsEvent = event.map { (element) in
@@ -37,7 +37,7 @@ class CxSdk: RCTEventEmitter {
37
37
  }
38
38
 
39
39
  self?.sendEvent(withName: "onBeforeSend", body: jsEvent)
40
- } : nil
40
+ }
41
41
 
42
42
  var options = try self.toCoralogixOptions(parameter: parameter)
43
43
  options.beforeSendCallBack = beforeSendCallBack
@@ -115,10 +115,11 @@ class CxSdk: RCTEventEmitter {
115
115
  resolve("setViewContext success")
116
116
  }
117
117
 
118
- @objc(log:message:data:withResolver:withRejecter:)
118
+ @objc(log:message:data:labels:withResolver:withRejecter:)
119
119
  func log(severity: Int,
120
120
  message: String,
121
121
  data: NSDictionary,
122
+ labels: NSDictionary,
122
123
  resolve:RCTPromiseResolveBlock,
123
124
  reject:RCTPromiseRejectBlock) -> Void {
124
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/react-native-plugin",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Official Coralogix React Native plugin",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",