@barrysolomon/mobile-react-native 0.1.1-alpha → 0.2.1-alpha
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/Dash0Mobile.podspec +4 -0
- package/README.md +113 -28
- package/android/build.gradle +73 -6
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +27 -0
- package/android/gradlew +251 -0
- package/android/gradlew.bat +94 -0
- package/android/settings.gradle +62 -0
- package/android/src/main/java/com/dash0/mobile/reactnative/BridgeCallSink.kt +42 -0
- package/android/src/main/java/com/dash0/mobile/reactnative/Dash0MobileModule.kt +35 -7
- package/android/src/main/java/com/dash0/mobile/reactnative/Dash0MobilePackage.kt +71 -2
- package/android/src/main/java/com/dash0/mobile/reactnative/NetworkInstrumentation.kt +28 -0
- package/android/src/main/java/com/dash0/mobile/reactnative/OTelMobileCallSink.kt +61 -1
- package/android/src/main/java/com/dash0/mobile/reactnative/OTelNetworkInterceptor.kt +206 -0
- package/android/src/test/java/com/dash0/mobile/reactnative/Dash0MobileModuleTest.kt +81 -6
- package/android/src/test/java/com/dash0/mobile/reactnative/OTelNetworkInterceptorTest.kt +381 -0
- package/ios/BoundedLiveSpanStore.swift +138 -0
- package/ios/BridgeCallSink.swift +49 -1
- package/ios/Dash0MobileBridgeDispatcher.swift +23 -1
- package/ios/OTelMobileCallSink.swift +205 -34
- package/ios/RCTDash0MobileModule.swift +10 -2
- package/ios/Tests/BoundedLiveSpanStoreTests.swift +143 -0
- package/ios/Tests/Dash0MobileBridgeDispatcherTests.swift +63 -0
- package/ios/Tests/OTelMobileCallSinkTests.swift +243 -0
- package/lib/bridge/types.d.ts +35 -0
- package/lib/bridge/types.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +42 -2
- package/lib/instrumentation/errors.d.ts.map +1 -1
- package/lib/instrumentation/errors.js +13 -2
- package/lib/instrumentation/fetch.d.ts.map +1 -1
- package/lib/instrumentation/fetch.js +58 -22
- package/lib/instrumentation/navigation.d.ts.map +1 -1
- package/lib/instrumentation/navigation.js +32 -8
- package/lib/instrumentation/unhandledRejection.d.ts.map +1 -1
- package/lib/instrumentation/unhandledRejection.js +13 -3
- package/lib/instrumentation/xhr.d.ts.map +1 -1
- package/lib/instrumentation/xhr.js +63 -36
- package/lib/redact.d.ts +30 -0
- package/lib/redact.d.ts.map +1 -0
- package/lib/redact.js +67 -0
- package/package.json +1 -1
- package/src/bridge/types.ts +36 -0
- package/src/index.ts +44 -3
- package/src/instrumentation/errors.ts +12 -2
- package/src/instrumentation/fetch.ts +60 -27
- package/src/instrumentation/navigation.ts +40 -8
- package/src/instrumentation/unhandledRejection.ts +12 -3
- package/src/instrumentation/xhr.ts +65 -40
- package/src/redact.ts +71 -0
package/Dash0Mobile.podspec
CHANGED
|
@@ -22,6 +22,10 @@ Pod::Spec.new do |s|
|
|
|
22
22
|
s.exclude_files = [
|
|
23
23
|
"ios/Tests/**/*",
|
|
24
24
|
"ios/OTelMobileCallSink.swift",
|
|
25
|
+
# BoundedLiveSpanStore is used only by OTelMobileCallSink. Both are copied
|
|
26
|
+
# together into the consumer's app target (same module → internal access),
|
|
27
|
+
# so it is excluded from the pod alongside the call sink.
|
|
28
|
+
"ios/BoundedLiveSpanStore.swift",
|
|
25
29
|
]
|
|
26
30
|
s.swift_version = "5.9"
|
|
27
31
|
|
package/README.md
CHANGED
|
@@ -1,23 +1,52 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @barrysolomon/mobile-react-native
|
|
2
2
|
|
|
3
3
|
Dash0 Mobile Observability SDK for React Native. Bridges JS/TS into the
|
|
4
4
|
existing native Android (`otel-android-mobile`) and iOS (`otel-ios-mobile`)
|
|
5
5
|
SDKs — native owns buffering, policy evaluation, OTLP export, and crash
|
|
6
6
|
recovery. JS stays thin.
|
|
7
7
|
|
|
8
|
-
**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
RN iOS) have a UAT matrix of 12/12 cells green.
|
|
8
|
+
**Version:** `0.2.1-alpha`, published under the `alpha` dist-tag.
|
|
9
|
+
|
|
10
|
+
**Status:** Validated end-to-end in Dash0. All 4 platforms (Android native,
|
|
11
|
+
iOS native, RN Android, RN iOS) have a UAT matrix of 12/12 cells green.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Install the alpha (a bare `npm install @barrysolomon/mobile-react-native`
|
|
17
|
+
# resolves the OLD 0.1.0-alpha — always pin the dist-tag or version):
|
|
18
|
+
npm install @barrysolomon/mobile-react-native@alpha
|
|
19
|
+
# or pin the exact version:
|
|
20
|
+
# npm install @barrysolomon/mobile-react-native@0.2.1-alpha
|
|
21
|
+
|
|
22
|
+
cd ios && pod install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This JS package wraps the native SDKs; install those too:
|
|
26
|
+
|
|
27
|
+
- **iOS** — add the Swift Package `https://github.com/barrysolomon/mobile-otel`
|
|
28
|
+
at tag `v0.2.1-alpha` to your app target, then copy
|
|
29
|
+
`OTelMobileCallSink.swift` (+ `BoundedLiveSpanStore.swift`) from this package
|
|
30
|
+
into your app target and call
|
|
31
|
+
`Dash0MobileModule.installSink { OTelMobileCallSink() }`. The pod intentionally
|
|
32
|
+
excludes the sink because it depends on the SwiftPM SDK delivered on the app
|
|
33
|
+
side.
|
|
34
|
+
- **Android** — `io.opentelemetry.android:mobile:0.2.1-alpha` from GitHub
|
|
35
|
+
Packages (`https://maven.pkg.github.com/barrysolomon/mobile-otel`). As of
|
|
36
|
+
0.2.0-alpha the full module set (`mobile-core` + all
|
|
37
|
+
`mobile-instrumentation-*` modules) publishes there, so the dependency tree
|
|
38
|
+
resolves.
|
|
12
39
|
|
|
13
40
|
## Quickstart
|
|
14
41
|
|
|
15
42
|
```ts
|
|
16
|
-
import { Dash0Mobile } from '@
|
|
43
|
+
import { Dash0Mobile } from '@barrysolomon/mobile-react-native';
|
|
17
44
|
|
|
18
45
|
await Dash0Mobile.start({
|
|
19
46
|
serviceName: 'my-rn-app',
|
|
20
|
-
|
|
47
|
+
// Base ingress host — per-signal URLs are built as
|
|
48
|
+
// `<endpoint>/v1/{logs,traces,metrics}`; do NOT append `/v1/...` yourself.
|
|
49
|
+
endpoint: 'https://ingress.us-west-2.aws.dash0.com',
|
|
21
50
|
authToken: process.env.DASH0_AUTH_TOKEN,
|
|
22
51
|
dataset: 'otel-mobile',
|
|
23
52
|
});
|
|
@@ -35,7 +64,7 @@ await Dash0Mobile.span('checkout', async () => {
|
|
|
35
64
|
# Install dependencies (first time)
|
|
36
65
|
npm install
|
|
37
66
|
|
|
38
|
-
# Jest — bridge contract + auto-instrumentation
|
|
67
|
+
# Jest — bridge contract + auto-instrumentation
|
|
39
68
|
npm test
|
|
40
69
|
|
|
41
70
|
# Type-check
|
|
@@ -53,34 +82,83 @@ src/
|
|
|
53
82
|
types.ts # cross-repo seam — DO NOT change without coordinating
|
|
54
83
|
NativeBridge.ts # debounced batching marshaller (50 ms batch window)
|
|
55
84
|
instrumentation/
|
|
56
|
-
fetch.ts # fetch
|
|
57
|
-
xhr.ts # XHR span
|
|
85
|
+
fetch.ts # fetch span shim (non-RN/web; off on RN — fetch is XHR-backed)
|
|
86
|
+
xhr.ts # XHR span shim (authoritative JS layer; gated off on Android)
|
|
58
87
|
errors.ts # JS error log auto-capture
|
|
59
88
|
unhandledRejection.ts # unhandled promise rejection capture
|
|
60
|
-
navigation.ts # React Navigation screen-view auto-capture
|
|
61
|
-
touch.ts # tap event auto-capture
|
|
89
|
+
navigation.ts # React Navigation screen-view auto-capture (opt-in)
|
|
90
|
+
touch.ts # tap event auto-capture (opt-in via withTapTelemetry)
|
|
62
91
|
otel-compat.ts # OTel-API shim (third-party JS libs flow through bridge)
|
|
63
92
|
index.ts # public API
|
|
64
|
-
android/ # Kotlin ReactContextBaseJavaModule +
|
|
65
|
-
ios/ # Swift RCTDash0MobileModule +
|
|
66
|
-
__tests__/ # Jest —
|
|
93
|
+
android/ # Kotlin ReactContextBaseJavaModule + OkHttp net interceptor
|
|
94
|
+
ios/ # Swift RCTDash0MobileModule + OTelMobileCallSink
|
|
95
|
+
__tests__/ # Jest — bridge contract + instrumentation suites
|
|
67
96
|
```
|
|
68
97
|
|
|
69
98
|
## Auto-instrumentation
|
|
70
99
|
|
|
71
|
-
|
|
100
|
+
`network` and `errors` are enabled by default when `Dash0Mobile.start()` is
|
|
101
|
+
called. Opt out per signal:
|
|
72
102
|
|
|
73
103
|
```ts
|
|
74
104
|
await Dash0Mobile.start({
|
|
75
105
|
// ...
|
|
76
106
|
autoCapture: {
|
|
77
|
-
network: false, // disable fetch/XHR
|
|
78
|
-
errors: false, // disable JS error + rejection logs
|
|
79
|
-
lifecycle: false, // disable AppState fg/bg
|
|
107
|
+
network: false, // disable HTTP capture (JS fetch/XHR shims + native net)
|
|
108
|
+
errors: false, // disable JS error + unhandled-rejection logs
|
|
80
109
|
},
|
|
81
110
|
});
|
|
82
111
|
```
|
|
83
112
|
|
|
113
|
+
App lifecycle (`app.foreground` / `app.background` / `app.start`) is **always
|
|
114
|
+
on via native instrumentation** (Android `ProcessLifecycleOwner`, iOS
|
|
115
|
+
`NotificationCenter`) — there is no JS or per-flag knob for it. The other
|
|
116
|
+
`autoCapture` flags (`tap`, `scroll`, `textInput`, `screen`, `freeze`,
|
|
117
|
+
`vitals`, `deviceStats`, `screenshot`, `wireframe`) toggle native-only capture
|
|
118
|
+
suites and default **off** on RN.
|
|
119
|
+
|
|
120
|
+
### HTTP capture on Android is native (Expo SDK 52+)
|
|
121
|
+
|
|
122
|
+
On Android, network capture is owned by a native OkHttp interceptor
|
|
123
|
+
(`OTelNetworkInterceptor`) installed before JS runs. It records native CLIENT
|
|
124
|
+
spans and injects a W3C `traceparent` from the real native span context, so
|
|
125
|
+
Android mobile→backend traces stitch. The JS `XMLHttpRequest` shim is
|
|
126
|
+
auto-gated **off** on Android to avoid double-counting.
|
|
127
|
+
|
|
128
|
+
This matters because **Expo SDK 52+ replaced the global `fetch` with
|
|
129
|
+
`expo/fetch`, a non-XHR-backed client.** The JS `fetch`/XHR shims wrap the JS
|
|
130
|
+
globals and see nothing there — only the native interceptor (which sits under
|
|
131
|
+
OkHttp) captures `expo/fetch` traffic. On iOS the JS XHR shim is kept (RN iOS
|
|
132
|
+
`fetch` is XHR-backed and the native `URLProtocol` swizzle is opt-in/off by
|
|
133
|
+
default for RN).
|
|
134
|
+
|
|
135
|
+
## Sampling
|
|
136
|
+
|
|
137
|
+
**The RN bridge defaults to `always_on` (100% of spans)** — unlike the native
|
|
138
|
+
Android/iOS SDKs, which default to `dynamic(0.1)` (10% baseline). RN manual
|
|
139
|
+
spans (`Dash0Mobile.startSpan()` / `Dash0Mobile.span()`) are root spans with
|
|
140
|
+
arbitrary names, so a 10% baseline would silently drop ~90% of a user's very
|
|
141
|
+
first span — a terrible first-run experience (and on iOS a dropped span is a
|
|
142
|
+
non-recording span whose `.end()` is a silent no-op). For RN architectures,
|
|
143
|
+
sampling and rate-limiting belong in the collector, not the on-device SDK.
|
|
144
|
+
|
|
145
|
+
Opt into on-device sampling explicitly:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
await Dash0Mobile.start({
|
|
149
|
+
// ...
|
|
150
|
+
// 100% (RN default — may be omitted):
|
|
151
|
+
sampling: { strategy: 'always_on' },
|
|
152
|
+
// Disable tracing entirely:
|
|
153
|
+
// sampling: { strategy: 'always_off' },
|
|
154
|
+
// Native-style dynamic sampling (10% baseline, 100% for high-priority spans):
|
|
155
|
+
// sampling: { strategy: 'dynamic', normalRate: 0.1, highPriorityRate: 1.0 },
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The native-only Android/iOS SDKs keep their `dynamic(0.1)` default — only the
|
|
160
|
+
RN-bridged default changes.
|
|
161
|
+
|
|
84
162
|
## Architecture
|
|
85
163
|
|
|
86
164
|
The JS layer is a thin marshaller with a 50 ms batching window. All buffering,
|
|
@@ -90,15 +168,18 @@ native SDK on each platform:
|
|
|
90
168
|
```text
|
|
91
169
|
JS (fetch/XHR/errors/nav/tap)
|
|
92
170
|
↓ 50 ms batch window
|
|
93
|
-
NativeBridge.ts → NativeDash0Mobile → Android: OTelMobile (
|
|
94
|
-
→ iOS: OTelMobile (HTTP
|
|
171
|
+
NativeBridge.ts → NativeDash0Mobile → Android: OTelMobile (OTLP/HTTP)
|
|
172
|
+
→ iOS: OTelMobile (OTLP/HTTP)
|
|
95
173
|
↓
|
|
96
174
|
OTLP Collector → Dash0
|
|
97
175
|
```
|
|
98
176
|
|
|
99
|
-
**Transport note:**
|
|
100
|
-
|
|
101
|
-
|
|
177
|
+
**Transport note:** As of 0.2.0-alpha both platforms default to OTLP/HTTP
|
|
178
|
+
(protobuf) against a single endpoint, with per-signal URLs built as
|
|
179
|
+
`<endpoint>/v1/{logs,traces,metrics}`. Android changed from gRPC to HTTP so
|
|
180
|
+
exports traverse HTTPS-terminating proxies / managed ingress that can't forward
|
|
181
|
+
HTTP/2 gRPC. gRPC-only collector? Restore it on Android with
|
|
182
|
+
`MobileConfig.protocol = OtlpProtocol.GRPC`.
|
|
102
183
|
|
|
103
184
|
## Test strategy
|
|
104
185
|
|
|
@@ -106,12 +187,16 @@ Three layers, all must pass on every PR:
|
|
|
106
187
|
|
|
107
188
|
1. **Jest** — `npm test` in this directory; contract + bridge + instrumentation
|
|
108
189
|
2. **Native unit** — `./gradlew :android:test` (Android) + `swift test` (iOS)
|
|
109
|
-
3. **Real-app E2E** — `scripts/test/validate-rn-end-to-end.sh`
|
|
110
|
-
|
|
190
|
+
3. **Real-app E2E** — `scripts/test/validate-rn-end-to-end.sh` (use `--mode=jest`
|
|
191
|
+
for the package + AstronomyShopRN demo tests; `--mode=device` boots
|
|
192
|
+
AstronomyShopRN on iOS Simulator + Android emulator and queries Dash0)
|
|
111
193
|
|
|
112
194
|
## Known limitations
|
|
113
195
|
|
|
114
|
-
- **Expo** —
|
|
115
|
-
|
|
196
|
+
- **Expo** — works in the bare/dev-client workflow (native modules required).
|
|
197
|
+
0.2.0-alpha was hardened against a real Expo SDK 56 / RN 0.85 integration,
|
|
198
|
+
including the Expo SDK 52+ `expo/fetch` capture via native Android
|
|
199
|
+
instrumentation (see above). A managed-workflow config plugin (no prebuild)
|
|
200
|
+
is tracked as a follow-up (EXPO-001).
|
|
116
201
|
- **Realm / Amplify DataStore** — scoped in a separate epic.
|
|
117
202
|
- **Web / desktop RN targets** — not supported.
|
package/android/build.gradle
CHANGED
|
@@ -4,6 +4,17 @@
|
|
|
4
4
|
// Kotlin plugin versions. We apply the plugins here but let the host provide
|
|
5
5
|
// them — hardcoding classpath versions here forced an old AGP/Kotlin combo
|
|
6
6
|
// that conflicted with host-provided stdlib.
|
|
7
|
+
//
|
|
8
|
+
// Plugins are applied WITHOUT versions: in a host-autolinked build the host's
|
|
9
|
+
// settings `pluginManagement` resolves them; in the standalone test build the
|
|
10
|
+
// module's own settings.gradle `pluginManagement` does. Using the `plugins {}`
|
|
11
|
+
// DSL (rather than legacy `apply plugin:`) is what lets the standalone build
|
|
12
|
+
// resolve the plugin from `pluginManagement` with no buildscript classpath.
|
|
13
|
+
|
|
14
|
+
plugins {
|
|
15
|
+
id 'com.android.library'
|
|
16
|
+
id 'org.jetbrains.kotlin.android'
|
|
17
|
+
}
|
|
7
18
|
|
|
8
19
|
// Default matches RN 0.85's Kotlin (2.1.20). Older RN consumers can override
|
|
9
20
|
// via -PDash0Mobile_kotlinVersion.
|
|
@@ -12,8 +23,15 @@ ext.safeExtGet = { prop, fallback ->
|
|
|
12
23
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
13
24
|
}
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
// The standalone unit-test harness sets this. It excludes Dash0MobilePackage.kt
|
|
27
|
+
// from compilation because that file is the ONLY source touching RN's
|
|
28
|
+
// OkHttpClientProvider factory API, whose `getOkHttpClientFactory()` getter is
|
|
29
|
+
// absent in the pinned react-android 0.76.0 (verified via javap on the AAR).
|
|
30
|
+
// The package is pure provider-swap wiring with no pure-JVM-testable logic; the
|
|
31
|
+
// interceptor it installs (OTelNetworkInterceptor) is React-free and IS tested
|
|
32
|
+
// here. A host-autolinked build (no this flag) compiles the full module
|
|
33
|
+
// against the host's own RN version as before.
|
|
34
|
+
ext.standaloneTestBuild = project.hasProperty('Dash0Mobile_standaloneTestBuild')
|
|
17
35
|
|
|
18
36
|
android {
|
|
19
37
|
namespace 'com.dash0.mobile.reactnative'
|
|
@@ -23,6 +41,7 @@ android {
|
|
|
23
41
|
minSdk safeExtGet('minSdkVersion', 26)
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
|
|
26
45
|
compileOptions {
|
|
27
46
|
sourceCompatibility JavaVersion.VERSION_17
|
|
28
47
|
targetCompatibility JavaVersion.VERSION_17
|
|
@@ -36,6 +55,11 @@ android {
|
|
|
36
55
|
targetSdk safeExtGet('targetSdkVersion', 34)
|
|
37
56
|
unitTests {
|
|
38
57
|
includeAndroidResources = true
|
|
58
|
+
// The bridge tests exercise pure decode/forward logic with
|
|
59
|
+
// JavaOnlyMap/JavaOnlyArray fakes and a mocked ReactApplicationContext;
|
|
60
|
+
// they never touch a real Android runtime. Return defaults for any
|
|
61
|
+
// incidental android.* call instead of throwing "not mocked".
|
|
62
|
+
returnDefaultValues = true
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
65
|
|
|
@@ -44,25 +68,68 @@ android {
|
|
|
44
68
|
}
|
|
45
69
|
}
|
|
46
70
|
|
|
71
|
+
// (Dash0MobilePackage.kt is no longer excluded from the standalone build: it now
|
|
72
|
+
// uses only react-android 0.76-stable OkHttpClientProvider APIs — createClientBuilder()
|
|
73
|
+
// + setOkHttpClientFactory — so it compiles against the declared RN peer and is
|
|
74
|
+
// covered by the standalone harness like the rest of the module.)
|
|
75
|
+
|
|
47
76
|
repositories {
|
|
48
77
|
google()
|
|
49
78
|
mavenCentral()
|
|
79
|
+
// The native Android SDK (io.opentelemetry.android:mobile) is this repo's
|
|
80
|
+
// own artifact, published to the local Maven cache by the demo-app build
|
|
81
|
+
// (examples/demo-app publishes :otel-android-mobile* to mavenLocal). It is
|
|
82
|
+
// not on a public repo, so resolve it from mavenLocal for the standalone
|
|
83
|
+
// test build. Listed last so public deps still come from google()/central.
|
|
84
|
+
mavenLocal()
|
|
50
85
|
}
|
|
51
86
|
|
|
87
|
+
// react-android version. Host-autolinked builds leave this as `+` (the host
|
|
88
|
+
// app pins the RN version); the standalone test harness sets
|
|
89
|
+
// -PDash0Mobile_reactAndroidVersion (see gradle.properties) for a reproducible
|
|
90
|
+
// build against the version this package's package.json devDepends on.
|
|
91
|
+
ext.reactAndroidVersion = project.findProperty('Dash0Mobile_reactAndroidVersion') ?: '+'
|
|
92
|
+
|
|
93
|
+
// Version of the native Android SDK (io.opentelemetry.android:mobile) this RN
|
|
94
|
+
// module depends on. Single source of truth — MUST track the published SDK
|
|
95
|
+
// version (see the publishing convention in examples/demo-app/build.gradle.kts).
|
|
96
|
+
// Kept as a property so a version bump updates one place, not N hardcoded
|
|
97
|
+
// dependency strings (which silently drifted to 0.1.0-alpha vs the published
|
|
98
|
+
// 0.2.0-alpha and broke clean-.m2 CI while passing on caches that still had the
|
|
99
|
+
// old artifact).
|
|
100
|
+
ext.dash0SdkVersion = project.findProperty('Dash0Mobile_sdkVersion') ?: '0.2.1-alpha'
|
|
101
|
+
|
|
52
102
|
dependencies {
|
|
53
|
-
implementation "com.facebook.react:react-android
|
|
103
|
+
implementation "com.facebook.react:react-android:$reactAndroidVersion"
|
|
54
104
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
55
105
|
|
|
106
|
+
// react-android bundles OkHttp and exposes OkHttpClientProvider /
|
|
107
|
+
// OkHttpClientFactory (com.facebook.react.modules.network). We compile
|
|
108
|
+
// against okhttp3 directly for the network interceptor; declare it
|
|
109
|
+
// `compileOnly` so we don't pin a version that conflicts with the one
|
|
110
|
+
// react-android already puts on the host runtime classpath.
|
|
111
|
+
compileOnly 'com.squareup.okhttp3:okhttp:4.12.0'
|
|
112
|
+
|
|
56
113
|
// Depend on the existing native Android SDK. Must be `implementation`
|
|
57
114
|
// (not `compileOnly`) so Kotlin can resolve transitive config classes
|
|
58
115
|
// (TextInputConfig, BreadcrumbConfig, VitalsConfig, etc.) referenced
|
|
59
116
|
// through MobileConfig's constructor signature.
|
|
60
|
-
implementation
|
|
117
|
+
implementation "io.opentelemetry.android:mobile:${dash0SdkVersion}"
|
|
61
118
|
implementation 'io.opentelemetry:opentelemetry-api:1.58.0'
|
|
62
119
|
|
|
63
120
|
testImplementation 'junit:junit:4.13.2'
|
|
64
|
-
|
|
121
|
+
// Mockito 5.18 (and its bundled ByteBuddy) supports the JDK 25 bytecode the
|
|
122
|
+
// standalone harness runs on; 5.12's ByteBuddy could not instrument classes
|
|
123
|
+
// on Java 25 ("Could not modify all classes ... ReactApplicationContext").
|
|
124
|
+
testImplementation 'org.mockito:mockito-core:5.18.0'
|
|
65
125
|
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.4.0'
|
|
66
|
-
testImplementation
|
|
126
|
+
testImplementation "io.opentelemetry.android:mobile:${dash0SdkVersion}"
|
|
67
127
|
testImplementation 'io.opentelemetry:opentelemetry-api:1.58.0'
|
|
128
|
+
|
|
129
|
+
// Network-interceptor unit tests: real OkHttp + the OTel SDK in-memory
|
|
130
|
+
// span exporter so we can assert the span the interceptor produced and the
|
|
131
|
+
// traceparent it injected, all on a pure JVM (no emulator).
|
|
132
|
+
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
|
133
|
+
testImplementation 'io.opentelemetry:opentelemetry-sdk:1.58.0'
|
|
134
|
+
testImplementation 'io.opentelemetry:opentelemetry-sdk-testing:1.58.0'
|
|
68
135
|
}
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#Thu May 28 10:16:37 MDT 2026
|
|
2
|
+
distributionBase=GRADLE_USER_HOME
|
|
3
|
+
distributionPath=wrapper/dists
|
|
4
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
|
5
|
+
networkTimeout=10000
|
|
6
|
+
validateDistributionUrl=true
|
|
7
|
+
zipStoreBase=GRADLE_USER_HOME
|
|
8
|
+
zipStorePath=wrapper/dists
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Standalone test-build properties for the @dash0/mobile-react-native Android
|
|
2
|
+
# module. These only apply when building this module on its own (the harness
|
|
3
|
+
# that runs the Kotlin unit tests); a host-autolinked consumer supplies its own.
|
|
4
|
+
android.useAndroidX=true
|
|
5
|
+
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
|
6
|
+
|
|
7
|
+
# Marks this as the standalone unit-test build (vs a host-autolinked consumer).
|
|
8
|
+
# Used to set standalone-only build params (compileSdk/targetSdk) in settings.gradle.
|
|
9
|
+
# (Dash0MobilePackage.kt is no longer excluded — it now uses only react-android
|
|
10
|
+
# 0.76-stable OkHttpClientProvider APIs and compiles here.)
|
|
11
|
+
Dash0Mobile_standaloneTestBuild=true
|
|
12
|
+
|
|
13
|
+
# Version of the native Android SDK (io.opentelemetry.android:mobile) this module
|
|
14
|
+
# depends on. MUST match the version the repo publishes (currently 0.2.1-alpha).
|
|
15
|
+
# Single source of truth, read by build.gradle's dash0SdkVersion.
|
|
16
|
+
Dash0Mobile_sdkVersion=0.2.1-alpha
|
|
17
|
+
|
|
18
|
+
# Pin the Kotlin version the module's build.gradle reads (it defaults to
|
|
19
|
+
# 2.1.20 and honors this property) so stdlib matches the compiler the
|
|
20
|
+
# pluginManagement block applies.
|
|
21
|
+
Dash0Mobile_kotlinVersion=2.1.20
|
|
22
|
+
|
|
23
|
+
# Pin react-android to the version this package's package.json devDepends on
|
|
24
|
+
# (react-native 0.76.0). The shipping build.gradle uses `react-android:+` for
|
|
25
|
+
# host-autolinked builds (the host pins it); standalone we pin it for a
|
|
26
|
+
# reproducible test build via this property, honored by build.gradle.
|
|
27
|
+
Dash0Mobile_reactAndroidVersion=0.76.0
|
package/android/gradlew
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Copyright © 2015-2021 the original authors.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
##############################################################################
|
|
22
|
+
#
|
|
23
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
+
#
|
|
25
|
+
# Important for running:
|
|
26
|
+
#
|
|
27
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
+
# bash, then to run this script, type that shell name before the whole
|
|
30
|
+
# command line, like:
|
|
31
|
+
#
|
|
32
|
+
# ksh Gradle
|
|
33
|
+
#
|
|
34
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
+
# requires all of these POSIX shell features:
|
|
36
|
+
# * functions;
|
|
37
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
+
#
|
|
42
|
+
# Important for patching:
|
|
43
|
+
#
|
|
44
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
+
#
|
|
47
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
+
# space-separated string is a well documented source of bugs and security
|
|
49
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
+
# options in "$@", and eventually passing that to Java.
|
|
51
|
+
#
|
|
52
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
+
# see the in-line comments for details.
|
|
55
|
+
#
|
|
56
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
+
# Darwin, MinGW, and NonStop.
|
|
58
|
+
#
|
|
59
|
+
# (3) This script is generated from the Groovy template
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
+
# within the Gradle project.
|
|
62
|
+
#
|
|
63
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
+
#
|
|
65
|
+
##############################################################################
|
|
66
|
+
|
|
67
|
+
# Attempt to set APP_HOME
|
|
68
|
+
|
|
69
|
+
# Resolve links: $0 may be a link
|
|
70
|
+
app_path=$0
|
|
71
|
+
|
|
72
|
+
# Need this for daisy-chained symlinks.
|
|
73
|
+
while
|
|
74
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
+
[ -h "$app_path" ]
|
|
76
|
+
do
|
|
77
|
+
ls=$( ls -ld "$app_path" )
|
|
78
|
+
link=${ls#*' -> '}
|
|
79
|
+
case $link in #(
|
|
80
|
+
/*) app_path=$link ;; #(
|
|
81
|
+
*) app_path=$APP_HOME$link ;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
87
|
+
APP_BASE_NAME=${0##*/}
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
90
|
+
|
|
91
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
92
|
+
MAX_FD=maximum
|
|
93
|
+
|
|
94
|
+
warn () {
|
|
95
|
+
echo "$*"
|
|
96
|
+
} >&2
|
|
97
|
+
|
|
98
|
+
die () {
|
|
99
|
+
echo
|
|
100
|
+
echo "$*"
|
|
101
|
+
echo
|
|
102
|
+
exit 1
|
|
103
|
+
} >&2
|
|
104
|
+
|
|
105
|
+
# OS specific support (must be 'true' or 'false').
|
|
106
|
+
cygwin=false
|
|
107
|
+
msys=false
|
|
108
|
+
darwin=false
|
|
109
|
+
nonstop=false
|
|
110
|
+
case "$( uname )" in #(
|
|
111
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
112
|
+
Darwin* ) darwin=true ;; #(
|
|
113
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
114
|
+
NONSTOP* ) nonstop=true ;;
|
|
115
|
+
esac
|
|
116
|
+
|
|
117
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# Determine the Java command to use to start the JVM.
|
|
121
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
122
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
123
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
124
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
125
|
+
else
|
|
126
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
127
|
+
fi
|
|
128
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
129
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
130
|
+
|
|
131
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
132
|
+
location of your Java installation."
|
|
133
|
+
fi
|
|
134
|
+
else
|
|
135
|
+
JAVACMD=java
|
|
136
|
+
if ! command -v java >/dev/null 2>&1
|
|
137
|
+
then
|
|
138
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
139
|
+
|
|
140
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
141
|
+
location of your Java installation."
|
|
142
|
+
fi
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
# Increase the maximum file descriptors if we can.
|
|
146
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
147
|
+
case $MAX_FD in #(
|
|
148
|
+
max*)
|
|
149
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
150
|
+
# shellcheck disable=SC2039,SC3045
|
|
151
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
152
|
+
warn "Could not query maximum file descriptor limit"
|
|
153
|
+
esac
|
|
154
|
+
case $MAX_FD in #(
|
|
155
|
+
'' | soft) :;; #(
|
|
156
|
+
*)
|
|
157
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
158
|
+
# shellcheck disable=SC2039,SC3045
|
|
159
|
+
ulimit -n "$MAX_FD" ||
|
|
160
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
161
|
+
esac
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
165
|
+
# * args from the command line
|
|
166
|
+
# * the main class name
|
|
167
|
+
# * -classpath
|
|
168
|
+
# * -D...appname settings
|
|
169
|
+
# * --module-path (only if needed)
|
|
170
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
171
|
+
|
|
172
|
+
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
173
|
+
if "$cygwin" || "$msys" ; then
|
|
174
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
175
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
176
|
+
|
|
177
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
178
|
+
|
|
179
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
180
|
+
for arg do
|
|
181
|
+
if
|
|
182
|
+
case $arg in #(
|
|
183
|
+
-*) false ;; # don't mess with options #(
|
|
184
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
185
|
+
[ -e "$t" ] ;; #(
|
|
186
|
+
*) false ;;
|
|
187
|
+
esac
|
|
188
|
+
then
|
|
189
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
190
|
+
fi
|
|
191
|
+
# Roll the args list around exactly as many times as the number of
|
|
192
|
+
# args, so each arg winds up back in the position where it started, but
|
|
193
|
+
# possibly modified.
|
|
194
|
+
#
|
|
195
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
196
|
+
# changing the positional parameters here affects neither the number of
|
|
197
|
+
# iterations, nor the values presented in `arg`.
|
|
198
|
+
shift # remove old arg
|
|
199
|
+
set -- "$@" "$arg" # push replacement arg
|
|
200
|
+
done
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
205
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
206
|
+
|
|
207
|
+
# Collect all arguments for the java command:
|
|
208
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
209
|
+
# and any embedded shellness will be escaped.
|
|
210
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
211
|
+
# treated as '${Hostname}' itself on the command line.
|
|
212
|
+
|
|
213
|
+
set -- \
|
|
214
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
215
|
+
-classpath "$CLASSPATH" \
|
|
216
|
+
org.gradle.wrapper.GradleWrapperMain \
|
|
217
|
+
"$@"
|
|
218
|
+
|
|
219
|
+
# Stop when "xargs" is not available.
|
|
220
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
221
|
+
then
|
|
222
|
+
die "xargs is not available"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# Use "xargs" to parse quoted args.
|
|
226
|
+
#
|
|
227
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
228
|
+
#
|
|
229
|
+
# In Bash we could simply go:
|
|
230
|
+
#
|
|
231
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
232
|
+
# set -- "${ARGS[@]}" "$@"
|
|
233
|
+
#
|
|
234
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
235
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
236
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
237
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
238
|
+
# the whole thing up as a single "set" statement.
|
|
239
|
+
#
|
|
240
|
+
# This will of course break if any of these variables contains a newline or
|
|
241
|
+
# an unmatched quote.
|
|
242
|
+
#
|
|
243
|
+
|
|
244
|
+
eval "set -- $(
|
|
245
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
246
|
+
xargs -n1 |
|
|
247
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
248
|
+
tr '\n' ' '
|
|
249
|
+
)" '"$@"'
|
|
250
|
+
|
|
251
|
+
exec "$JAVACMD" "$@"
|