@coralogix/react-native-plugin 0.2.1 → 0.2.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,16 @@
1
+ ## 0.2.3 (2025-12-04)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ Properly handle the is_crash flag
6
+ Patch: Bump iOS native version to 1.5.0
7
+
8
+ ## 0.2.2 (2025-11-20)
9
+
10
+ ### 🩹 Patch
11
+
12
+ - chore: updated the android native sdk to version 2.6.1
13
+
1
14
  ## 0.2.1 (2025-11-18)
2
15
 
3
16
  ### 🚀 Features
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.4.0'
20
- s.dependency 'CoralogixInternal','1.4.0'
21
- s.dependency 'SessionReplay','1.4.0'
19
+ s.dependency 'Coralogix','1.5.0'
20
+ s.dependency 'CoralogixInternal','1.5.0'
21
+ s.dependency 'SessionReplay','1.5.0'
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.
@@ -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.0"
78
+ implementation "com.coralogix:android-sdk:2.6.1"
79
79
  }
80
80
 
81
81
  react {
package/index.cjs.js CHANGED
@@ -25,12 +25,6 @@ let CoralogixLogSeverity = /*#__PURE__*/function (CoralogixLogSeverity) {
25
25
  return CoralogixLogSeverity;
26
26
  }({});
27
27
 
28
- let ErrorSource = /*#__PURE__*/function (ErrorSource) {
29
- ErrorSource["CONSOLE"] = "console";
30
- ErrorSource["GLOBAL"] = "global";
31
- return ErrorSource;
32
- }({});
33
-
34
28
  const ERROR_INSTRUMENTATION_NAME = 'errors';
35
29
  const ERROR_INSTRUMENTATION_VERSION = '1';
36
30
 
@@ -60,40 +54,46 @@ class CoralogixErrorInstrumentation extends instrumentation.InstrumentationBase
60
54
  listenToConsoleError() {
61
55
  const onConsoleError = (...params) => {
62
56
  defaultConsoleError.apply(console, params);
63
- this.report(ErrorSource.CONSOLE, params);
57
+ this.report(params, false);
64
58
  };
65
59
  defaultConsoleError = console.error;
66
60
  console.error = onConsoleError;
67
61
  }
68
- report(source, arg) {
62
+ report(arg, isFatal) {
69
63
  if (Array.isArray(arg)) {
70
64
  if (arg.length === 0) {
71
65
  return;
72
66
  }
73
67
  }
74
68
  if (arg instanceof Error) {
75
- this.reportError(arg);
69
+ this.reportError(arg, isFatal);
76
70
  } else if (typeof arg === 'string') {
77
- this.reportString(arg);
71
+ this.reportString(arg, isFatal);
78
72
  } else if (Array.isArray(arg)) {
79
73
  // if any arguments are Errors then add the stack trace even though the message is handled differently
80
74
  const firstError = arg.find(x => x instanceof Error);
81
75
  const message = arg.map(msg => typeof msg === 'string' ? msg : this.parseErrorObject(msg)).join(' ');
82
- this.reportString(message, firstError);
76
+ this.reportString(message, isFatal, firstError);
83
77
  } else {
84
- this.reportString(typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg));
78
+ this.reportString(typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg), isFatal);
85
79
  }
86
80
  }
87
- reportError(err) {
88
- CoralogixRum.reportError(err, false);
81
+ reportError(error, isFatal) {
82
+ const errorDetails = this.buildErrorDetails(error, error.message, isFatal);
83
+ CxSdk.reportError(errorDetails);
89
84
  }
90
- reportString(message, firstError) {
91
- const truncatedMessage = (message == null ? void 0 : message.substring(0, MESSAGE_LIMIT)) || '';
92
- CoralogixRum.reportError({
93
- name: (firstError == null ? void 0 : firstError.name) || 'CONSOLE',
94
- message: truncatedMessage,
95
- stack: firstError == null ? void 0 : firstError.stack
96
- }, false);
85
+ reportString(message, isFatal, firstError) {
86
+ const truncatedMessage = message == null ? void 0 : message.substring(0, MESSAGE_LIMIT);
87
+ const errorDetails = this.buildErrorDetails(firstError, truncatedMessage, isFatal);
88
+ CxSdk.reportError(errorDetails);
89
+ }
90
+ buildErrorDetails(error, errorMessage, isCrash) {
91
+ return {
92
+ error_type: (error == null ? void 0 : error.name) || 'CONSOLE',
93
+ error_message: errorMessage || '',
94
+ stack_trace: error ? parseErrorStack(error) : [],
95
+ is_crash: isCrash != null ? isCrash : false
96
+ };
97
97
  }
98
98
  getPossibleEventMessage(event) {
99
99
  const {
@@ -113,7 +113,7 @@ class CoralogixErrorInstrumentation extends instrumentation.InstrumentationBase
113
113
  enable() {
114
114
  const defaultHandler = ErrorUtils.getGlobalHandler();
115
115
  ErrorUtils.setGlobalHandler((error, isFatal) => {
116
- this.report(ErrorSource.GLOBAL, error);
116
+ this.report(error, isFatal);
117
117
  if (defaultHandler) {
118
118
  setTimeout(() => {
119
119
  defaultHandler(error, isFatal);
@@ -219,7 +219,7 @@ function stopJsRefreshRateSampler() {
219
219
  appStateSub = null;
220
220
  }
221
221
 
222
- var version = "0.2.1";
222
+ var version = "0.2.3";
223
223
  var pkg = {
224
224
  version: version};
225
225
 
@@ -778,5 +778,7 @@ const subscription = eventEmitter.addListener('onBeforeSend', events => {
778
778
  exports.CoralogixDomain = CoralogixDomain;
779
779
  exports.CoralogixLogSeverity = CoralogixLogSeverity;
780
780
  exports.CoralogixRum = CoralogixRum;
781
+ exports.CxSdk = CxSdk;
781
782
  exports.SessionReplay = SessionReplay;
782
783
  exports.attachReactNavigationObserver = attachReactNavigationObserver;
784
+ exports.parseErrorStack = parseErrorStack;
package/index.esm.js CHANGED
@@ -23,12 +23,6 @@ let CoralogixLogSeverity = /*#__PURE__*/function (CoralogixLogSeverity) {
23
23
  return CoralogixLogSeverity;
24
24
  }({});
25
25
 
26
- let ErrorSource = /*#__PURE__*/function (ErrorSource) {
27
- ErrorSource["CONSOLE"] = "console";
28
- ErrorSource["GLOBAL"] = "global";
29
- return ErrorSource;
30
- }({});
31
-
32
26
  const ERROR_INSTRUMENTATION_NAME = 'errors';
33
27
  const ERROR_INSTRUMENTATION_VERSION = '1';
34
28
 
@@ -58,40 +52,46 @@ class CoralogixErrorInstrumentation extends InstrumentationBase {
58
52
  listenToConsoleError() {
59
53
  const onConsoleError = (...params) => {
60
54
  defaultConsoleError.apply(console, params);
61
- this.report(ErrorSource.CONSOLE, params);
55
+ this.report(params, false);
62
56
  };
63
57
  defaultConsoleError = console.error;
64
58
  console.error = onConsoleError;
65
59
  }
66
- report(source, arg) {
60
+ report(arg, isFatal) {
67
61
  if (Array.isArray(arg)) {
68
62
  if (arg.length === 0) {
69
63
  return;
70
64
  }
71
65
  }
72
66
  if (arg instanceof Error) {
73
- this.reportError(arg);
67
+ this.reportError(arg, isFatal);
74
68
  } else if (typeof arg === 'string') {
75
- this.reportString(arg);
69
+ this.reportString(arg, isFatal);
76
70
  } else if (Array.isArray(arg)) {
77
71
  // if any arguments are Errors then add the stack trace even though the message is handled differently
78
72
  const firstError = arg.find(x => x instanceof Error);
79
73
  const message = arg.map(msg => typeof msg === 'string' ? msg : this.parseErrorObject(msg)).join(' ');
80
- this.reportString(message, firstError);
74
+ this.reportString(message, isFatal, firstError);
81
75
  } else {
82
- this.reportString(typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg));
76
+ this.reportString(typeof arg === 'string' ? arg : this.getPossibleEventMessage(arg), isFatal);
83
77
  }
84
78
  }
85
- reportError(err) {
86
- CoralogixRum.reportError(err, false);
79
+ reportError(error, isFatal) {
80
+ const errorDetails = this.buildErrorDetails(error, error.message, isFatal);
81
+ CxSdk.reportError(errorDetails);
87
82
  }
88
- reportString(message, firstError) {
89
- const truncatedMessage = (message == null ? void 0 : message.substring(0, MESSAGE_LIMIT)) || '';
90
- CoralogixRum.reportError({
91
- name: (firstError == null ? void 0 : firstError.name) || 'CONSOLE',
92
- message: truncatedMessage,
93
- stack: firstError == null ? void 0 : firstError.stack
94
- }, false);
83
+ reportString(message, isFatal, firstError) {
84
+ const truncatedMessage = message == null ? void 0 : message.substring(0, MESSAGE_LIMIT);
85
+ const errorDetails = this.buildErrorDetails(firstError, truncatedMessage, isFatal);
86
+ CxSdk.reportError(errorDetails);
87
+ }
88
+ buildErrorDetails(error, errorMessage, isCrash) {
89
+ return {
90
+ error_type: (error == null ? void 0 : error.name) || 'CONSOLE',
91
+ error_message: errorMessage || '',
92
+ stack_trace: error ? parseErrorStack(error) : [],
93
+ is_crash: isCrash != null ? isCrash : false
94
+ };
95
95
  }
96
96
  getPossibleEventMessage(event) {
97
97
  const {
@@ -111,7 +111,7 @@ class CoralogixErrorInstrumentation extends InstrumentationBase {
111
111
  enable() {
112
112
  const defaultHandler = ErrorUtils.getGlobalHandler();
113
113
  ErrorUtils.setGlobalHandler((error, isFatal) => {
114
- this.report(ErrorSource.GLOBAL, error);
114
+ this.report(error, isFatal);
115
115
  if (defaultHandler) {
116
116
  setTimeout(() => {
117
117
  defaultHandler(error, isFatal);
@@ -217,7 +217,7 @@ function stopJsRefreshRateSampler() {
217
217
  appStateSub = null;
218
218
  }
219
219
 
220
- var version = "0.2.1";
220
+ var version = "0.2.3";
221
221
  var pkg = {
222
222
  version: version};
223
223
 
@@ -773,4 +773,4 @@ const subscription = eventEmitter.addListener('onBeforeSend', events => {
773
773
  }
774
774
  });
775
775
 
776
- export { CoralogixDomain, CoralogixLogSeverity, CoralogixRum, SessionReplay, attachReactNavigationObserver };
776
+ export { CoralogixDomain, CoralogixLogSeverity, CoralogixRum, CxSdk, SessionReplay, attachReactNavigationObserver, parseErrorStack };
package/ios/CxSdk.swift CHANGED
@@ -185,10 +185,12 @@ class CxSdk: RCTEventEmitter {
185
185
  let stackTrace = (dictionary[Keys.keyStackTrace.rawValue] as? [[String: Any]]) ?? []
186
186
  let message = dictionary[Keys.errorMessage.rawValue] as? String ?? ""
187
187
  let errorType = dictionary[Keys.errorType.rawValue] as? String ?? "5"
188
-
188
+ let isCrash = dictionary[Keys.isCrash.rawValue] as? Bool ?? false
189
+
189
190
  coralogixRum?.reportError(message: message,
190
191
  stackTrace: stackTrace,
191
- errorType: errorType)
192
+ errorType: errorType,
193
+ isCrash: isCrash)
192
194
  resolve("reportError success")
193
195
  }
194
196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/react-native-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Official Coralogix React Native plugin",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
package/src/index.d.ts CHANGED
@@ -1,7 +1,46 @@
1
+ import type { UserContextConfig } from './model/UserContextConfig';
2
+ import type { ApplicationContextConfig } from './model/ApplicationContextConfig';
1
3
  import type { CoralogixOtelWebType } from './model/CoralogixOtelWebType';
2
- import { SessionReplayType } from './model/SessionReplayType';
4
+ import type { CoralogixBrowserSdkConfig, CoralogixStackFrame, CxSpan, HybridMetric } from './model/Types';
5
+ import { CoralogixLogSeverity } from './model/Types';
6
+ import type { NetworkRequestDetails } from './model/NetworkRequestDetails';
7
+ import type { CustomMeasurement } from './model/CustomMeasurement';
8
+ import { SessionReplayOptions, SessionReplayType } from './model/SessionReplayType';
9
+ interface CxSdkClient {
10
+ initialize(options: CoralogixBrowserSdkConfig & {
11
+ frameworkVersion?: string;
12
+ }): Promise<boolean>;
13
+ setUserContext(userContext: UserContextConfig): void;
14
+ getUserContext(): Promise<UserContextConfig>;
15
+ setApplicationContext(appContext: ApplicationContextConfig): void;
16
+ getSessionId(): Promise<string>;
17
+ setLabels(labels: Record<string, string>): void;
18
+ getLabels(): Promise<Record<string, string>>;
19
+ setViewContext(viewContext: string): void;
20
+ log(severity: CoralogixLogSeverity, message: string, data: Record<string, any> | undefined | null, labels: Record<string, any> | undefined | null): void;
21
+ sendCustomMeasurement(measurement: CustomMeasurement): void;
22
+ reportError(details: Record<string, string>): void;
23
+ reportNetworkRequest(details: NetworkRequestDetails): void;
24
+ shutdown(): Promise<boolean>;
25
+ sendCxSpanData(results: CxSpan[]): void;
26
+ reportMobileVitalsMeasurement(type: string, value: number, units: string): void;
27
+ reportMobileVitalsMeasurementSet(type: string, metrics: HybridMetric[]): void;
28
+ isCoralogixGradlePluginApplied(): Promise<boolean>;
29
+ addListener(): void;
30
+ removeListeners(): void;
31
+ initializeSessionReplay(options: SessionReplayOptions): Promise<boolean>;
32
+ shutdownSessionReplay(): Promise<boolean>;
33
+ isSessionReplayInitialized(): Promise<boolean>;
34
+ isRecording(): Promise<boolean>;
35
+ startSessionRecording(): void;
36
+ stopSessionRecording(): void;
37
+ captureScreenshot(): void;
38
+ maskViewByTag(viewTag: number): void;
39
+ }
40
+ export declare const CxSdk: CxSdkClient;
3
41
  export declare const CoralogixRum: CoralogixOtelWebType;
4
42
  export declare const SessionReplay: SessionReplayType;
43
+ export declare const parseErrorStack: (error: Error) => CoralogixStackFrame[];
5
44
  export { type ApplicationContextConfig } from './model/ApplicationContextConfig';
6
45
  export { type ViewContextConfig } from './model/ViewContextConfig';
7
46
  export { CoralogixDomain } from './model/CoralogixDomain';
@@ -1,5 +1,4 @@
1
1
  import { InstrumentationBase, InstrumentationConfig } from '@opentelemetry/instrumentation';
2
- import { ErrorSource } from './error.enums';
3
2
  export declare const getCircularReplacer: () => ((key: any, value: any) => undefined | any);
4
3
  export interface CoralogixErrorInstrumentationConfig extends InstrumentationConfig {
5
4
  ignoreErrors?: Array<string | RegExp>;
@@ -8,10 +7,11 @@ export declare class CoralogixErrorInstrumentation extends InstrumentationBase {
8
7
  constructor(config: CoralogixErrorInstrumentationConfig);
9
8
  init(): void;
10
9
  private listenToConsoleError;
11
- report(source: ErrorSource, arg: string | Error | Event | Array<any>): void;
10
+ protected report(arg: string | Error | Event | Array<any>, isFatal?: boolean): void;
12
11
  parseErrorObject: (obj: any) => string;
13
- protected reportError(err: Error): void;
14
- protected reportString(message: string, firstError?: Error): void;
12
+ protected reportError(error: Error, isFatal?: boolean): void;
13
+ protected reportString(message: string, isFatal?: boolean, firstError?: Error): void;
14
+ private buildErrorDetails;
15
15
  protected getPossibleEventMessage(event: any): string;
16
16
  enable(): void;
17
17
  disable(): void;