@coralogix/react-native-plugin 0.1.2 → 0.1.4
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 +12 -0
- package/README.md +7 -20
- package/android/build.gradle +1 -3
- package/android/src/main/java/com/cxsdk/CxSdkModule.kt +9 -5
- package/android/src/main/java/com/cxsdk/ICxSdkModule.kt +3 -3
- package/index.cjs.js +7 -6
- package/index.esm.js +7 -6
- package/ios/CxSdk.swift +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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,27 +170,13 @@ 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',
|
|
176
177
|
});
|
|
177
178
|
```
|
|
178
179
|
|
|
179
|
-
### Android integration
|
|
180
|
-
Our Android native SDK uses java 8 features that requires desugaring to be enabled, on your native android project add this to your app module build.gradle:
|
|
181
|
-
```groovy
|
|
182
|
-
android {
|
|
183
|
-
compileOptions {
|
|
184
|
-
coreLibraryDesugaringEnabled true
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
dependencies {
|
|
189
|
-
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.5"
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
180
|
### Troubleshooting
|
|
194
181
|
|
|
195
182
|
#### URL.origin is not implemented
|
package/android/build.gradle
CHANGED
|
@@ -50,7 +50,6 @@ android {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
compileOptions {
|
|
53
|
-
setCoreLibraryDesugaringEnabled(true)
|
|
54
53
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
55
54
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
56
55
|
}
|
|
@@ -76,8 +75,7 @@ dependencies {
|
|
|
76
75
|
implementation "com.facebook.react:react-android"
|
|
77
76
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
78
77
|
|
|
79
|
-
implementation "com.coralogix:android-sdk:2.4.
|
|
80
|
-
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.5"
|
|
78
|
+
implementation "com.coralogix:android-sdk:2.4.6"
|
|
81
79
|
}
|
|
82
80
|
|
|
83
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
|
|
|
@@ -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.
|
|
222
|
+
var version = "0.1.4";
|
|
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.
|
|
220
|
+
var version = "0.1.4";
|
|
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.swift
CHANGED