@coralogix/react-native-plugin 0.17.0 β 0.19.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 +34 -0
- package/CxSdk.podspec +1 -1
- package/README.md +45 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/cxsdk/CxSdkModule.kt +34 -0
- package/android/src/test/kotlin/com/cxsdk/UrlMaskingOptionsBridgeTest.kt +61 -0
- package/index.cjs.js +22 -1
- package/index.esm.js +22 -1
- package/ios/CxSdk.swift +31 -0
- package/package.json +1 -1
- package/src/index.d.ts +4 -2
- package/src/model/Types.d.ts +21 -0
- package/src/urlMasking.d.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 0.19.0 (2026-11-17)
|
|
2
|
+
|
|
3
|
+
### π Features
|
|
4
|
+
|
|
5
|
+
- Sensitive URL parameters are now masked by default. In every reported URL, including network requests and the URLs inside error messages, the values of parameters such as `code`, `state`, `access_token`, `password` or `api_key`, JWTs and URL credentials are replaced with `[REDACTED]`. This changes the data you see for existing apps. Masking can't be turned off.
|
|
6
|
+
- New `urlMasking` option: `params` masks more parameter names, and `mode` (`'mask'`, `'maskAll'` or `'dropQuery'`) chooses how much of the query is masked.
|
|
7
|
+
|
|
8
|
+
### β¬οΈ Dependency Updates
|
|
9
|
+
|
|
10
|
+
- Native iOS SDK bumped to **2.24.1** and native Android SDK to **2.28.0**, which do the masking.
|
|
11
|
+
|
|
12
|
+
## 0.18.0 (2026-11-12)
|
|
13
|
+
|
|
14
|
+
### π Features
|
|
15
|
+
|
|
16
|
+
- On iOS, an uncaught C++ exception is now reported with its type and message, and an ANR now carries the stacks of every thread, main thread first.
|
|
17
|
+
- On iOS, a hang the app does not survive is now reported once: live when possible, otherwise as an ANR crash the next time the app starts.
|
|
18
|
+
|
|
19
|
+
### π©Ή Fixes
|
|
20
|
+
|
|
21
|
+
- On iOS, a crash that could not be sent before the app closed, or while the device was offline, is now delivered later in the session and screen it happened in, instead of being lost.
|
|
22
|
+
- On iOS, `ignoreErrors` now also matches the error type (for example `SIGSEGV` or `ANR`), and an ANR is no longer reported each time the app returns from the background.
|
|
23
|
+
|
|
24
|
+
### π Notes
|
|
25
|
+
|
|
26
|
+
- On iOS, crash messages now name what crashed, such as `NSInvalidArgumentException: <reason>` or `SIGSEGV (SEGV_MAPERR)`, with the signal as the error type, as on Android. Update queries that match the previous crash messages.
|
|
27
|
+
- On iOS, an ANR is now reported once the main thread has been blocked for 5 seconds, and system hang reports are no longer sent as errors.
|
|
28
|
+
- On iOS, a crash that happens before `CoralogixRum.init` has finished, including a native crash while the app starts, is no longer reported, as on Android. Initialize the plugin as early as possible in app startup.
|
|
29
|
+
- On iOS, crash events are not passed to `beforeSend`; `ignoreErrors` still applies to them.
|
|
30
|
+
|
|
31
|
+
### β¬οΈ Dependency Updates
|
|
32
|
+
|
|
33
|
+
- Native iOS SDK bumped to **2.23.0**.
|
|
34
|
+
|
|
1
35
|
## 0.17.0 (2026-11-10)
|
|
2
36
|
|
|
3
37
|
### π Features
|
package/CxSdk.podspec
CHANGED
|
@@ -26,7 +26,7 @@ Pod::Spec.new do |s|
|
|
|
26
26
|
# stay on that version while SPM moves ahead of it.
|
|
27
27
|
#
|
|
28
28
|
# scripts/check-ios-sdk-pins.sh keeps the two versions consistent.
|
|
29
|
-
cx_ios_sdk_version = '2.
|
|
29
|
+
cx_ios_sdk_version = '2.24.1'
|
|
30
30
|
cx_ios_sdk_products = ['Coralogix', 'CoralogixInternal', 'SessionReplay']
|
|
31
31
|
cx_ios_sdk_frozen_file = File.join(__dir__, 'ios', 'COCOAPODS_FROZEN_SDK_VERSION')
|
|
32
32
|
cx_ios_sdk_pod_version =
|
package/README.md
CHANGED
|
@@ -500,6 +500,8 @@ await CoralogixRum.init({
|
|
|
500
500
|
});
|
|
501
501
|
```
|
|
502
502
|
|
|
503
|
+
On iOS, crash events are sent without passing through `beforeSend`. Use `ignoreErrors` to filter them.
|
|
504
|
+
|
|
503
505
|
#### Telling excluded events apart in `beforeSend`
|
|
504
506
|
|
|
505
507
|
Every event carries `session_context.isSessionSampledIn`. `false` means the event
|
|
@@ -578,6 +580,47 @@ Everything else β `event_context` (including `severity`), `labels`,
|
|
|
578
580
|
`environment`, `device_context`, `device_state`, `version_metadata` β is editable,
|
|
579
581
|
and returning `null` still drops the event entirely.
|
|
580
582
|
|
|
583
|
+
### URL masking
|
|
584
|
+
|
|
585
|
+
From version 0.19.0, the SDK masks sensitive URL parameters before it reports a URL,
|
|
586
|
+
including network request URLs and the URLs inside error messages. The value is replaced
|
|
587
|
+
with `[REDACTED]`, and the parameter name and the rest of the URL are kept:
|
|
588
|
+
`https://app.com/callback?code=abc&page=2#access_token=xyz` is reported as
|
|
589
|
+
`https://app.com/callback?code=[REDACTED]&page=2#access_token=[REDACTED]`.
|
|
590
|
+
|
|
591
|
+
Masked by default: parameters named `code`, `state`, `key`, `sig`, `otp` and similar,
|
|
592
|
+
any parameter whose name contains `token`, `secret`, `password`, `session`, `apikey`,
|
|
593
|
+
`signature` or `jwt` and similar, JWTs anywhere in the URL, and credentials in the URL
|
|
594
|
+
(`https://user:password@host`). Names are compared ignoring case and punctuation, so
|
|
595
|
+
`api_key`, `apiKey` and `API-Key` are the same name.
|
|
596
|
+
|
|
597
|
+
Use `urlMasking` to mask more:
|
|
598
|
+
|
|
599
|
+
```javascript
|
|
600
|
+
await CoralogixRum.init({
|
|
601
|
+
// ...
|
|
602
|
+
urlMasking: {
|
|
603
|
+
params: ['tenant_id', /^customer/i], // optional, more names to mask
|
|
604
|
+
mode: 'mask', // 'mask' (default), 'maskAll' or 'dropQuery'
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
- `params`: a string matches the whole parameter name, ignoring case and punctuation. A
|
|
610
|
+
regular expression is tested against the decoded name; only its `i` flag is used. The
|
|
611
|
+
native SDKs compile it (Java on Android, ICU on iOS), so keep to syntax all three accept:
|
|
612
|
+
a pattern that does not compile there is skipped with a warning in the device log, while
|
|
613
|
+
the default masking still applies.
|
|
614
|
+
- `mode`: `'mask'` masks the sensitive parameters, `'maskAll'` masks every parameter
|
|
615
|
+
value, and `'dropQuery'` reports the URL without its query and fragment.
|
|
616
|
+
|
|
617
|
+
You cannot turn masking off or remove a default. `ignoreUrls` matches the original URL,
|
|
618
|
+
and `beforeSend` receives the masked one.
|
|
619
|
+
|
|
620
|
+
> [!WARNING]
|
|
621
|
+
> A header you list in `networkExtraConfig` (`reqHeaders` or `resHeaders`) is captured as
|
|
622
|
+
> sent, including `Authorization` and `Cookie`. Do not list a header that carries credentials.
|
|
623
|
+
|
|
581
624
|
### Proxy URL
|
|
582
625
|
|
|
583
626
|
Proxy configuration to route requests.
|
|
@@ -594,6 +637,8 @@ await CoralogixRum.init({
|
|
|
594
637
|
});
|
|
595
638
|
```
|
|
596
639
|
|
|
640
|
+
For what the proxy must do with each request, where to host it, and complete Node.js and Nginx examples, see the [Proxy URL guide](https://coralogix.com/docs/user-guides/rum/proxy-url/).
|
|
641
|
+
|
|
597
642
|
<!-- /split -->
|
|
598
643
|
<!-- split title="Session Replay" path="features/session-replay.md" -->
|
|
599
644
|
### Session Replay
|
package/android/build.gradle
CHANGED
|
@@ -91,7 +91,7 @@ dependencies {
|
|
|
91
91
|
// reportUserInteraction reads instead of reimplementing the SDK's mask rule here.
|
|
92
92
|
// 2.25.0 adds CoralogixRum.networkRequestSampling() and the traceparent echo fields on
|
|
93
93
|
// NetworkRequestDetails, which the JS traceparent flag depends on.
|
|
94
|
-
implementation "com.coralogix:android-sdk:2.
|
|
94
|
+
implementation "com.coralogix:android-sdk:2.28.0"
|
|
95
95
|
|
|
96
96
|
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
|
97
97
|
testImplementation "org.mockito:mockito-core:5.12.0"
|
|
@@ -26,6 +26,8 @@ import com.coralogix.android.sdk.model.Instrumentation
|
|
|
26
26
|
import com.coralogix.android.sdk.model.MobileVitalType
|
|
27
27
|
import com.coralogix.android.sdk.model.NetworkCaptureRule
|
|
28
28
|
import com.coralogix.android.sdk.model.TraceParentInHeaderConfig
|
|
29
|
+
import com.coralogix.android.sdk.model.UrlMaskingMode
|
|
30
|
+
import com.coralogix.android.sdk.model.UrlMaskingOptions
|
|
29
31
|
import com.coralogix.android.sdk.model.TraceParentInHeaderConfigOptions
|
|
30
32
|
import com.coralogix.android.sdk.model.UserContext
|
|
31
33
|
import com.coralogix.android.sdk.model.ViewContext
|
|
@@ -683,6 +685,7 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
|
|
|
683
685
|
beforeSendCallback = if (hasKey("hasBeforeSend") && getBoolean("hasBeforeSend")) ::beforeSendCallback else null,
|
|
684
686
|
collectIPData = collectIpData,
|
|
685
687
|
networkCaptureConfig = networkExtraConfig,
|
|
688
|
+
urlMasking = toUrlMaskingOptions(if (hasKey("urlMasking") && !isNull("urlMasking")) getMap("urlMasking")?.toHashMap() else null),
|
|
686
689
|
tracesExporter = if (hasKey("hasTracesExporter") && getBoolean("hasTracesExporter")) {
|
|
687
690
|
{ data: CoralogixTraceExporterData ->
|
|
688
691
|
if (reactApplicationContext.hasActiveReactInstance()) {
|
|
@@ -1157,6 +1160,37 @@ class CxSdkModule(reactContext: ReactApplicationContext) :
|
|
|
1157
1160
|
return known.mapNotNull { EXCLUDABLE_INSTRUMENTATIONS[it] }.distinct()
|
|
1158
1161
|
}
|
|
1159
1162
|
|
|
1163
|
+
// Spelled out because the native enum's `rawValue` is internal.
|
|
1164
|
+
private val URL_MASKING_MODES = mapOf(
|
|
1165
|
+
"mask" to UrlMaskingMode.MASK,
|
|
1166
|
+
"maskAll" to UrlMaskingMode.MASK_ALL,
|
|
1167
|
+
"dropQuery" to UrlMaskingMode.DROP_QUERY,
|
|
1168
|
+
)
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Builds the native options from the JS `serializeUrlMasking` output. Bad entries are
|
|
1172
|
+
* dropped with a warning: they must not fail init, since masking runs either way.
|
|
1173
|
+
*/
|
|
1174
|
+
internal fun toUrlMaskingOptions(raw: Map<String, Any?>?): UrlMaskingOptions {
|
|
1175
|
+
if (raw == null) return UrlMaskingOptions()
|
|
1176
|
+
val params = (raw["params"] as? List<*>)?.filterIsInstance<String>() ?: emptyList()
|
|
1177
|
+
val patterns = (raw["paramPatterns"] as? List<*>)?.mapNotNull { entry ->
|
|
1178
|
+
val source = (entry as? Map<*, *>)?.get("source") as? String ?: return@mapNotNull null
|
|
1179
|
+
val ignoreCase = ((entry["flags"] as? String) ?: "").contains('i')
|
|
1180
|
+
try {
|
|
1181
|
+
if (ignoreCase) Regex(source, RegexOption.IGNORE_CASE) else Regex(source)
|
|
1182
|
+
} catch (e: IllegalArgumentException) {
|
|
1183
|
+
Log.w(NAME, "urlMasking: ignoring a pattern that does not compile: $source")
|
|
1184
|
+
null
|
|
1185
|
+
}
|
|
1186
|
+
} ?: emptyList()
|
|
1187
|
+
val rawMode = raw["mode"] as? String
|
|
1188
|
+
val mode = URL_MASKING_MODES[rawMode] ?: UrlMaskingMode.MASK.also {
|
|
1189
|
+
if (raw["mode"] != null) Log.w(NAME, "urlMasking: unknown mode ${raw["mode"]}, using mask")
|
|
1190
|
+
}
|
|
1191
|
+
return UrlMaskingOptions(params = params, paramPatterns = patterns, mode = mode)
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1160
1194
|
internal fun toInstrumentationMap(map: ReadableMap): Map<Instrumentation, Boolean> =
|
|
1161
1195
|
INSTRUMENTATION_KEYS.entries.associate { (key, instrumentation) ->
|
|
1162
1196
|
// Only an explicit boolean switches an instrumentation; null or a wrong type keeps the default.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.cxsdk
|
|
2
|
+
|
|
3
|
+
import com.coralogix.android.sdk.model.UrlMaskingMode
|
|
4
|
+
import kotlin.test.Test
|
|
5
|
+
import kotlin.test.assertEquals
|
|
6
|
+
|
|
7
|
+
class UrlMaskingOptionsBridgeTest {
|
|
8
|
+
|
|
9
|
+
@Test
|
|
10
|
+
fun `nothing configured gives the native defaults`() {
|
|
11
|
+
val options = CxSdkModule.toUrlMaskingOptions(null)
|
|
12
|
+
|
|
13
|
+
assertEquals(emptyList(), options.params)
|
|
14
|
+
assertEquals(emptyList(), options.paramPatterns.map { it.pattern })
|
|
15
|
+
assertEquals(UrlMaskingMode.MASK, options.mode)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Test
|
|
19
|
+
fun `each JS mode maps to its native mode`() {
|
|
20
|
+
val modes = mapOf(
|
|
21
|
+
"mask" to UrlMaskingMode.MASK,
|
|
22
|
+
"maskAll" to UrlMaskingMode.MASK_ALL,
|
|
23
|
+
"dropQuery" to UrlMaskingMode.DROP_QUERY,
|
|
24
|
+
)
|
|
25
|
+
for ((js, native) in modes) {
|
|
26
|
+
assertEquals(native, CxSdkModule.toUrlMaskingOptions(mapOf("mode" to js)).mode, js)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Test
|
|
31
|
+
fun `an unknown or missing mode falls back to mask`() {
|
|
32
|
+
assertEquals(UrlMaskingMode.MASK, CxSdkModule.toUrlMaskingOptions(mapOf("mode" to "off")).mode)
|
|
33
|
+
assertEquals(UrlMaskingMode.MASK, CxSdkModule.toUrlMaskingOptions(mapOf("mode" to null)).mode)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Test
|
|
37
|
+
fun `names and patterns are passed through, with the i flag kept`() {
|
|
38
|
+
val options = CxSdkModule.toUrlMaskingOptions(
|
|
39
|
+
mapOf(
|
|
40
|
+
"params" to listOf("tenant_id", 3.0, null),
|
|
41
|
+
"paramPatterns" to listOf(
|
|
42
|
+
mapOf("source" to "^customer", "flags" to "i"),
|
|
43
|
+
mapOf("source" to "^acct", "flags" to ""),
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
assertEquals(listOf("tenant_id"), options.params)
|
|
49
|
+
assertEquals(true, options.paramPatterns[0].containsMatchIn("CUSTOMER_ID"))
|
|
50
|
+
assertEquals(false, options.paramPatterns[1].containsMatchIn("ACCT_ID"))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Test
|
|
54
|
+
fun `a pattern that does not compile is dropped, not thrown`() {
|
|
55
|
+
val options = CxSdkModule.toUrlMaskingOptions(
|
|
56
|
+
mapOf("paramPatterns" to listOf(mapOf("source" to "("), mapOf("source" to "ok")))
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
assertEquals(listOf("ok"), options.paramPatterns.map { it.pattern })
|
|
60
|
+
}
|
|
61
|
+
}
|
package/index.cjs.js
CHANGED
|
@@ -1104,7 +1104,7 @@ function stopJsRefreshRateSampler() {
|
|
|
1104
1104
|
appStateSub = null;
|
|
1105
1105
|
}
|
|
1106
1106
|
|
|
1107
|
-
var version = "0.
|
|
1107
|
+
var version = "0.19.0";
|
|
1108
1108
|
var pkg = {
|
|
1109
1109
|
version: version};
|
|
1110
1110
|
|
|
@@ -1726,6 +1726,26 @@ function headersToRecord(headers) {
|
|
|
1726
1726
|
return result;
|
|
1727
1727
|
}
|
|
1728
1728
|
|
|
1729
|
+
/** What `urlMasking` looks like on the bridge: a RegExp cannot cross it, so patterns travel as strings. */
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Converts `urlMasking` to a form that can cross the JSβnative bridge: names and
|
|
1733
|
+
* RegExps go in separate lists, each RegExp as its `source` and `flags` strings.
|
|
1734
|
+
* Entries of any other type are dropped.
|
|
1735
|
+
*/
|
|
1736
|
+
function serializeUrlMasking(options) {
|
|
1737
|
+
if (!options) return undefined;
|
|
1738
|
+
const entries = Array.isArray(options.params) ? options.params : [];
|
|
1739
|
+
return {
|
|
1740
|
+
params: entries.filter(p => typeof p === 'string'),
|
|
1741
|
+
paramPatterns: entries.filter(p => p instanceof RegExp).map(p => ({
|
|
1742
|
+
source: p.source,
|
|
1743
|
+
flags: p.flags.replace(/[gy]/g, '')
|
|
1744
|
+
})),
|
|
1745
|
+
mode: options.mode
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1729
1749
|
function isSessionReplayOptionsValid(options) {
|
|
1730
1750
|
const scaleValid = options.captureScale > 0 && options.captureScale <= 1;
|
|
1731
1751
|
const sampleRateValid = options.sessionRecordingSampleRate >= 0 && options.sessionRecordingSampleRate <= 100;
|
|
@@ -2090,6 +2110,7 @@ progress) {
|
|
|
2090
2110
|
frameworkVersion: pkg.version,
|
|
2091
2111
|
networkExtraConfig: finalOptions.networkExtraConfig ? serializeNetworkCaptureRules(finalOptions.networkExtraConfig) : undefined,
|
|
2092
2112
|
traceParentInHeader: serializeTraceParentInHeader(finalOptions.traceParentInHeader),
|
|
2113
|
+
urlMasking: serializeUrlMasking(finalOptions.urlMasking),
|
|
2093
2114
|
hasBeforeSend: !!finalOptions.beforeSend,
|
|
2094
2115
|
hasTracesExporter: !!finalOptions.tracesExporter,
|
|
2095
2116
|
reportHybridColdStart: ((_finalOptions$instrum = finalOptions.instrumentations) == null ? void 0 : _finalOptions$instrum.mobile_vitals) !== false && ((_finalOptions$mobileV = finalOptions.mobileVitals) == null ? void 0 : _finalOptions$mobileV.cold) !== false
|
package/index.esm.js
CHANGED
|
@@ -1102,7 +1102,7 @@ function stopJsRefreshRateSampler() {
|
|
|
1102
1102
|
appStateSub = null;
|
|
1103
1103
|
}
|
|
1104
1104
|
|
|
1105
|
-
var version = "0.
|
|
1105
|
+
var version = "0.19.0";
|
|
1106
1106
|
var pkg = {
|
|
1107
1107
|
version: version};
|
|
1108
1108
|
|
|
@@ -1724,6 +1724,26 @@ function headersToRecord(headers) {
|
|
|
1724
1724
|
return result;
|
|
1725
1725
|
}
|
|
1726
1726
|
|
|
1727
|
+
/** What `urlMasking` looks like on the bridge: a RegExp cannot cross it, so patterns travel as strings. */
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* Converts `urlMasking` to a form that can cross the JSβnative bridge: names and
|
|
1731
|
+
* RegExps go in separate lists, each RegExp as its `source` and `flags` strings.
|
|
1732
|
+
* Entries of any other type are dropped.
|
|
1733
|
+
*/
|
|
1734
|
+
function serializeUrlMasking(options) {
|
|
1735
|
+
if (!options) return undefined;
|
|
1736
|
+
const entries = Array.isArray(options.params) ? options.params : [];
|
|
1737
|
+
return {
|
|
1738
|
+
params: entries.filter(p => typeof p === 'string'),
|
|
1739
|
+
paramPatterns: entries.filter(p => p instanceof RegExp).map(p => ({
|
|
1740
|
+
source: p.source,
|
|
1741
|
+
flags: p.flags.replace(/[gy]/g, '')
|
|
1742
|
+
})),
|
|
1743
|
+
mode: options.mode
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1727
1747
|
function isSessionReplayOptionsValid(options) {
|
|
1728
1748
|
const scaleValid = options.captureScale > 0 && options.captureScale <= 1;
|
|
1729
1749
|
const sampleRateValid = options.sessionRecordingSampleRate >= 0 && options.sessionRecordingSampleRate <= 100;
|
|
@@ -2088,6 +2108,7 @@ progress) {
|
|
|
2088
2108
|
frameworkVersion: pkg.version,
|
|
2089
2109
|
networkExtraConfig: finalOptions.networkExtraConfig ? serializeNetworkCaptureRules(finalOptions.networkExtraConfig) : undefined,
|
|
2090
2110
|
traceParentInHeader: serializeTraceParentInHeader(finalOptions.traceParentInHeader),
|
|
2111
|
+
urlMasking: serializeUrlMasking(finalOptions.urlMasking),
|
|
2091
2112
|
hasBeforeSend: !!finalOptions.beforeSend,
|
|
2092
2113
|
hasTracesExporter: !!finalOptions.tracesExporter,
|
|
2093
2114
|
reportHybridColdStart: ((_finalOptions$instrum = finalOptions.instrumentations) == null ? void 0 : _finalOptions$instrum.mobile_vitals) !== false && ((_finalOptions$mobileV = finalOptions.mobileVitals) == null ? void 0 : _finalOptions$mobileV.cold) !== false
|
package/ios/CxSdk.swift
CHANGED
|
@@ -681,6 +681,7 @@ class CxSdk: RCTEventEmitter {
|
|
|
681
681
|
traceParentInHeader: mapTraceParentInHeader(parameter["traceParentInHeader"] as? [String: Any]),
|
|
682
682
|
mobileVitals: mobileVitalsDict,
|
|
683
683
|
networkExtraConfig: networkExtraConfig,
|
|
684
|
+
urlMasking: toUrlMasking(parameter["urlMasking"] as? [String: Any]),
|
|
684
685
|
debug: parameter["debug"] as? Bool ?? true)
|
|
685
686
|
|
|
686
687
|
return options
|
|
@@ -788,6 +789,36 @@ class CxSdk: RCTEventEmitter {
|
|
|
788
789
|
}
|
|
789
790
|
}
|
|
790
791
|
|
|
792
|
+
/// Builds the native options from the JS `serializeUrlMasking` output. Bad entries are
|
|
793
|
+
/// dropped with a warning: they must not fail init, since masking runs either way.
|
|
794
|
+
private func toUrlMasking(_ raw: [String: Any]?) -> UrlMaskingOptions {
|
|
795
|
+
guard let raw = raw else { return UrlMaskingOptions() }
|
|
796
|
+
var params: [UrlMaskingOptions.Param] = ((raw["params"] as? [Any]) ?? []).compactMap {
|
|
797
|
+
($0 as? String).map { .name($0) }
|
|
798
|
+
}
|
|
799
|
+
for entry in (raw["paramPatterns"] as? [Any]) ?? [] {
|
|
800
|
+
guard let entry = entry as? [String: Any], let source = entry["source"] as? String else { continue }
|
|
801
|
+
let flags = entry["flags"] as? String ?? ""
|
|
802
|
+
guard let regex = try? NSRegularExpression(pattern: source, options: flags.contains("i") ? [.caseInsensitive] : []) else {
|
|
803
|
+
NSLog("[CxSdk] urlMasking: ignoring a pattern that does not compile: %@", source)
|
|
804
|
+
continue
|
|
805
|
+
}
|
|
806
|
+
params.append(.regex(regex))
|
|
807
|
+
}
|
|
808
|
+
let mode: UrlMaskingOptions.Mode
|
|
809
|
+
switch raw["mode"] as? String {
|
|
810
|
+
case "maskAll": mode = .maskAll
|
|
811
|
+
case "dropQuery": mode = .dropQuery
|
|
812
|
+
case "mask": mode = .mask
|
|
813
|
+
default:
|
|
814
|
+
if let other = raw["mode"], !(other is NSNull) {
|
|
815
|
+
NSLog("[CxSdk] urlMasking: unknown mode %@, using mask", String(describing: other))
|
|
816
|
+
}
|
|
817
|
+
mode = .mask
|
|
818
|
+
}
|
|
819
|
+
return UrlMaskingOptions(params: params, mode: mode)
|
|
820
|
+
}
|
|
821
|
+
|
|
791
822
|
/// Maps the JS `excludeFromSampling` strings, warning once about any the native enum does not know.
|
|
792
823
|
private func toExcludeFromSampling(_ raw: [Any]?) -> Set<ExcludableInstrumentation> {
|
|
793
824
|
guard let raw = raw else { return [] }
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { CoralogixBrowserSdkConfig, CoralogixStackFrame, CxSpan, HybridMetr
|
|
|
5
5
|
import { CoralogixLogSeverity } from './model/Types';
|
|
6
6
|
import type { NetworkRequestDetails } from './model/NetworkRequestDetails';
|
|
7
7
|
import type { CustomMeasurement } from './model/CustomMeasurement';
|
|
8
|
+
import { UrlMaskingBridgeOptions } from './urlMasking';
|
|
8
9
|
import { SessionReplayOptions, SessionReplayType } from './model/SessionReplayType';
|
|
9
10
|
/**
|
|
10
11
|
* The bridge contract, and the source of truth for it: every method here must
|
|
@@ -13,7 +14,8 @@ import { SessionReplayOptions, SessionReplayType } from './model/SessionReplayTy
|
|
|
13
14
|
* without the declaration leaving this file.
|
|
14
15
|
*/
|
|
15
16
|
export interface CxSdkClient {
|
|
16
|
-
initialize(options: CoralogixBrowserSdkConfig & {
|
|
17
|
+
initialize(options: Omit<CoralogixBrowserSdkConfig, 'urlMasking'> & {
|
|
18
|
+
urlMasking?: UrlMaskingBridgeOptions;
|
|
17
19
|
frameworkVersion?: string;
|
|
18
20
|
hasBeforeSend?: boolean;
|
|
19
21
|
hasTracesExporter?: boolean;
|
|
@@ -93,7 +95,7 @@ export { type ApplicationContextConfig } from './model/ApplicationContextConfig'
|
|
|
93
95
|
export { type ViewContextConfig } from './model/ViewContextConfig';
|
|
94
96
|
export { CoralogixDomain } from './model/CoralogixDomain';
|
|
95
97
|
export { type UserContextConfig } from './model/UserContextConfig';
|
|
96
|
-
export { type CoralogixBrowserSdkConfig, type CoralogixIgnoredInstrument, type ExcludableInstrumentation, type NetworkCaptureRule, type TraceExporterData, type EditableCxRumEvent, type BeforeSendResult, type InteractionEventContext, CoralogixEventType, CoralogixLogSeverity, } from './model/Types';
|
|
98
|
+
export { type CoralogixBrowserSdkConfig, type CoralogixIgnoredInstrument, type ExcludableInstrumentation, type NetworkCaptureRule, type UrlMaskingOptions, type UrlMaskingMode, type TraceExporterData, type EditableCxRumEvent, type BeforeSendResult, type InteractionEventContext, CoralogixEventType, CoralogixLogSeverity, } from './model/Types';
|
|
97
99
|
export { type CoralogixOtelWebOptionsInstrumentations } from './model/CoralogixOtelWebOptionsInstrumentations';
|
|
98
100
|
export { type CustomMeasurement } from './model/CustomMeasurement';
|
|
99
101
|
export { type NetworkRequestDetails } from './model/NetworkRequestDetails';
|
package/src/model/Types.d.ts
CHANGED
|
@@ -261,6 +261,20 @@ export interface EditableCxRumEvent extends Omit<CxRumEvent, 'session_context' |
|
|
|
261
261
|
session_context: Pick<SessionContext, keyof UserMetadata | 'isSessionSampledIn'>;
|
|
262
262
|
}
|
|
263
263
|
export type BeforeSendResult = EditableCxRumEvent | null;
|
|
264
|
+
export type UrlMaskingMode = 'mask' | 'maskAll' | 'dropQuery';
|
|
265
|
+
export interface UrlMaskingOptions {
|
|
266
|
+
/**
|
|
267
|
+
* More parameter names to mask. A string matches the whole name, ignoring case and
|
|
268
|
+
* any non-alphanumeric character (`tenant_id` matches `tenantId`); a RegExp is tested
|
|
269
|
+
* against the decoded name.
|
|
270
|
+
*/
|
|
271
|
+
params?: Array<string | RegExp>;
|
|
272
|
+
/**
|
|
273
|
+
* `'mask'` (default) masks the sensitive parameters, `'maskAll'` masks every parameter
|
|
274
|
+
* value, `'dropQuery'` drops the query and the fragment.
|
|
275
|
+
*/
|
|
276
|
+
mode?: UrlMaskingMode;
|
|
277
|
+
}
|
|
264
278
|
export interface NetworkCaptureRule {
|
|
265
279
|
/** Exact-string URL match. One of `url` or `urlPattern` is required. */
|
|
266
280
|
url?: string;
|
|
@@ -350,6 +364,13 @@ export interface CoralogixBrowserSdkConfig {
|
|
|
350
364
|
proxyUrl?: string;
|
|
351
365
|
/** Rules for capturing request/response headers and payloads per URL. */
|
|
352
366
|
networkExtraConfig?: NetworkCaptureRule[];
|
|
367
|
+
/**
|
|
368
|
+
* Sensitive URL parameters (`code`, `state`, anything containing `token`, `secret`,
|
|
369
|
+
* `password`, `session` and so on) are always masked as `[REDACTED]` in every reported
|
|
370
|
+
* URL. Use this to mask more parameters or the whole query. It can't turn masking off
|
|
371
|
+
* or remove a default.
|
|
372
|
+
*/
|
|
373
|
+
urlMasking?: UrlMaskingOptions;
|
|
353
374
|
/**
|
|
354
375
|
* JS refresh rate metric collection configuration.
|
|
355
376
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UrlMaskingMode, UrlMaskingOptions } from './model/Types';
|
|
2
|
+
/** What `urlMasking` looks like on the bridge: a RegExp cannot cross it, so patterns travel as strings. */
|
|
3
|
+
export interface UrlMaskingBridgeOptions {
|
|
4
|
+
params: string[];
|
|
5
|
+
paramPatterns: Array<{
|
|
6
|
+
source: string;
|
|
7
|
+
flags: string;
|
|
8
|
+
}>;
|
|
9
|
+
mode?: UrlMaskingMode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts `urlMasking` to a form that can cross the JSβnative bridge: names and
|
|
13
|
+
* RegExps go in separate lists, each RegExp as its `source` and `flags` strings.
|
|
14
|
+
* Entries of any other type are dropped.
|
|
15
|
+
*/
|
|
16
|
+
export declare function serializeUrlMasking(options: UrlMaskingOptions | undefined): UrlMaskingBridgeOptions | undefined;
|