@barrysolomon/mobile-react-native 0.1.0-alpha → 0.2.0-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 +27 -0
- 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/NativeDash0Mobile.d.ts.map +1 -0
- package/lib/bridge/NativeBridge.d.ts.map +1 -0
- package/lib/{src/bridge → bridge}/types.d.ts +35 -0
- package/lib/bridge/types.d.ts.map +1 -0
- package/lib/{src/index.d.ts → index.d.ts} +1 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/{src/index.js → index.js} +41 -1
- package/lib/instrumentation/errors.d.ts.map +1 -0
- package/lib/{src/instrumentation → instrumentation}/errors.js +13 -2
- package/lib/instrumentation/fetch.d.ts.map +1 -0
- package/lib/instrumentation/fetch.js +111 -0
- package/lib/instrumentation/navigation.d.ts.map +1 -0
- package/lib/instrumentation/navigation.js +63 -0
- package/lib/instrumentation/touch.d.ts.map +1 -0
- package/lib/instrumentation/unhandledRejection.d.ts.map +1 -0
- package/lib/{src/instrumentation → instrumentation}/unhandledRejection.js +13 -3
- package/lib/instrumentation/xhr.d.ts.map +1 -0
- package/lib/instrumentation/xhr.js +115 -0
- package/lib/otel-compat.d.ts.map +1 -0
- package/lib/redact.d.ts +30 -0
- package/lib/redact.d.ts.map +1 -0
- package/lib/redact.js +67 -0
- package/package.json +4 -4
- package/src/bridge/types.ts +36 -0
- package/src/index.ts +43 -2
- 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/lib/src/NativeDash0Mobile.d.ts.map +0 -1
- package/lib/src/bridge/NativeBridge.d.ts.map +0 -1
- package/lib/src/bridge/types.d.ts.map +0 -1
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/instrumentation/errors.d.ts.map +0 -1
- package/lib/src/instrumentation/fetch.d.ts.map +0 -1
- package/lib/src/instrumentation/fetch.js +0 -75
- package/lib/src/instrumentation/navigation.d.ts.map +0 -1
- package/lib/src/instrumentation/navigation.js +0 -39
- package/lib/src/instrumentation/touch.d.ts.map +0 -1
- package/lib/src/instrumentation/unhandledRejection.d.ts.map +0 -1
- package/lib/src/instrumentation/xhr.d.ts.map +0 -1
- package/lib/src/instrumentation/xhr.js +0 -88
- package/lib/src/otel-compat.d.ts.map +0 -1
- /package/lib/{src/NativeDash0Mobile.d.ts → NativeDash0Mobile.d.ts} +0 -0
- /package/lib/{src/NativeDash0Mobile.js → NativeDash0Mobile.js} +0 -0
- /package/lib/{src/bridge → bridge}/NativeBridge.d.ts +0 -0
- /package/lib/{src/bridge → bridge}/NativeBridge.js +0 -0
- /package/lib/{src/bridge → bridge}/types.js +0 -0
- /package/lib/{src/instrumentation → instrumentation}/errors.d.ts +0 -0
- /package/lib/{src/instrumentation → instrumentation}/fetch.d.ts +0 -0
- /package/lib/{src/instrumentation → instrumentation}/navigation.d.ts +0 -0
- /package/lib/{src/instrumentation → instrumentation}/touch.d.ts +0 -0
- /package/lib/{src/instrumentation → instrumentation}/touch.js +0 -0
- /package/lib/{src/instrumentation → instrumentation}/unhandledRejection.d.ts +0 -0
- /package/lib/{src/instrumentation → instrumentation}/xhr.d.ts +0 -0
- /package/lib/{src/otel-compat.d.ts → otel-compat.d.ts} +0 -0
- /package/lib/{src/otel-compat.js → otel-compat.js} +0 -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
|
@@ -81,6 +81,33 @@ await Dash0Mobile.start({
|
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
## Sampling
|
|
85
|
+
|
|
86
|
+
**The RN bridge defaults to `always_on` (100% of spans)** — unlike the native
|
|
87
|
+
Android/iOS SDKs, which default to `dynamic(0.1)` (10% baseline). RN manual
|
|
88
|
+
spans (`Dash0Mobile.startSpan()` / `Dash0Mobile.span()`) are root spans with
|
|
89
|
+
arbitrary names, so a 10% baseline would silently drop ~90% of a user's very
|
|
90
|
+
first span — a terrible first-run experience (and on iOS a dropped span is a
|
|
91
|
+
non-recording span whose `.end()` is a silent no-op). For RN architectures,
|
|
92
|
+
sampling and rate-limiting belong in the collector, not the on-device SDK.
|
|
93
|
+
|
|
94
|
+
Opt into on-device sampling explicitly:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await Dash0Mobile.start({
|
|
98
|
+
// ...
|
|
99
|
+
// 100% (RN default — may be omitted):
|
|
100
|
+
sampling: { strategy: 'always_on' },
|
|
101
|
+
// Disable tracing entirely:
|
|
102
|
+
// sampling: { strategy: 'always_off' },
|
|
103
|
+
// Native-style dynamic sampling (10% baseline, 100% for high-priority spans):
|
|
104
|
+
// sampling: { strategy: 'dynamic', normalRate: 0.1, highPriorityRate: 1.0 },
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The native-only Android/iOS SDKs keep their `dynamic(0.1)` default — only the
|
|
109
|
+
RN-bridged default changes.
|
|
110
|
+
|
|
84
111
|
## Architecture
|
|
85
112
|
|
|
86
113
|
The JS layer is a thin marshaller with a 50 ms batching window. All buffering,
|
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.0-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.0-alpha).
|
|
15
|
+
# Single source of truth, read by build.gradle's dash0SdkVersion.
|
|
16
|
+
Dash0Mobile_sdkVersion=0.2.0-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" "$@"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@rem
|
|
2
|
+
@rem Copyright 2015 the original author or authors.
|
|
3
|
+
@rem
|
|
4
|
+
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
@rem you may not use this file except in compliance with the License.
|
|
6
|
+
@rem You may obtain a copy of the License at
|
|
7
|
+
@rem
|
|
8
|
+
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
@rem
|
|
10
|
+
@rem Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
@rem See the License for the specific language governing permissions and
|
|
14
|
+
@rem limitations under the License.
|
|
15
|
+
@rem
|
|
16
|
+
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
@rem
|
|
18
|
+
|
|
19
|
+
@if "%DEBUG%"=="" @echo off
|
|
20
|
+
@rem ##########################################################################
|
|
21
|
+
@rem
|
|
22
|
+
@rem Gradle startup script for Windows
|
|
23
|
+
@rem
|
|
24
|
+
@rem ##########################################################################
|
|
25
|
+
|
|
26
|
+
@rem Set local scope for the variables with windows NT shell
|
|
27
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
28
|
+
|
|
29
|
+
set DIRNAME=%~dp0
|
|
30
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
+
@rem This is normally unused
|
|
32
|
+
set APP_BASE_NAME=%~n0
|
|
33
|
+
set APP_HOME=%DIRNAME%
|
|
34
|
+
|
|
35
|
+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
36
|
+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
37
|
+
|
|
38
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
39
|
+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
40
|
+
|
|
41
|
+
@rem Find java.exe
|
|
42
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
43
|
+
|
|
44
|
+
set JAVA_EXE=java.exe
|
|
45
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
46
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
47
|
+
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
+
echo. 1>&2
|
|
51
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
+
echo location of your Java installation. 1>&2
|
|
53
|
+
|
|
54
|
+
goto fail
|
|
55
|
+
|
|
56
|
+
:findJavaFromJavaHome
|
|
57
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
58
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
59
|
+
|
|
60
|
+
if exist "%JAVA_EXE%" goto execute
|
|
61
|
+
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
+
echo. 1>&2
|
|
65
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
+
echo location of your Java installation. 1>&2
|
|
67
|
+
|
|
68
|
+
goto fail
|
|
69
|
+
|
|
70
|
+
:execute
|
|
71
|
+
@rem Setup the command line
|
|
72
|
+
|
|
73
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@rem Execute Gradle
|
|
77
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
78
|
+
|
|
79
|
+
:end
|
|
80
|
+
@rem End local scope for the variables with windows NT shell
|
|
81
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
82
|
+
|
|
83
|
+
:fail
|
|
84
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
85
|
+
rem the _cmd.exe /c_ return code!
|
|
86
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
87
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
88
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
89
|
+
exit /b %EXIT_CODE%
|
|
90
|
+
|
|
91
|
+
:mainEnd
|
|
92
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
93
|
+
|
|
94
|
+
:omega
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Standalone Gradle settings for the @dash0/mobile-react-native Android module.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS:
|
|
5
|
+
* When consumed by a host React Native app, this module is wired into the
|
|
6
|
+
* host's Gradle build via RN autolinking — the host buildscript supplies the
|
|
7
|
+
* Android Gradle Plugin + Kotlin plugin versions and the repositories. That
|
|
8
|
+
* means the module's Kotlin unit tests (src/test/**) ran NOWHERE in isolation;
|
|
9
|
+
* CI's react-native job was jest-only and the native interceptor that wraps
|
|
10
|
+
* the host's entire OkHttp pipeline shipped without a runnable test.
|
|
11
|
+
*
|
|
12
|
+
* This file makes the module a self-contained Gradle build so
|
|
13
|
+
* `./gradlew :testDebugUnitTest` runs the src/test Kotlin on a pure JVM with
|
|
14
|
+
* no emulator. It supplies exactly what autolinking would otherwise inject:
|
|
15
|
+
* the plugin versions (pluginManagement) and the dependency repositories,
|
|
16
|
+
* including Maven Central where React Native publishes `react-android` and
|
|
17
|
+
* where the OkHttp / OpenTelemetry artifacts live.
|
|
18
|
+
*
|
|
19
|
+
* The shipping `build.gradle` is unchanged in spirit — it still applies the
|
|
20
|
+
* AGP + Kotlin plugins by id without hardcoding classpath versions, exactly
|
|
21
|
+
* as a host-autolinked build expects. The versions are pinned HERE so they
|
|
22
|
+
* only affect the standalone test build, never a host consumer.
|
|
23
|
+
*/
|
|
24
|
+
pluginManagement {
|
|
25
|
+
repositories {
|
|
26
|
+
google()
|
|
27
|
+
mavenCentral()
|
|
28
|
+
gradlePluginPortal()
|
|
29
|
+
}
|
|
30
|
+
plugins {
|
|
31
|
+
// AGP 8.11.x runs on the demo-app's Gradle 9.1.0 (and thus JDK 25)
|
|
32
|
+
// while still using the standalone kotlin-android plugin. AGP 9.x was
|
|
33
|
+
// rejected here: its built-in Kotlin integration registers its own
|
|
34
|
+
// `kotlin` extension and clashes with org.jetbrains.kotlin.android
|
|
35
|
+
// ("extension already registered with name 'kotlin'").
|
|
36
|
+
id 'com.android.library' version '8.11.1'
|
|
37
|
+
id 'org.jetbrains.kotlin.android' version '2.1.20'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
dependencyResolutionManagement {
|
|
42
|
+
// The module's own build.gradle declares google()/mavenCentral() in a
|
|
43
|
+
// `repositories {}` block (it must, to stay autolinking-friendly), so do
|
|
44
|
+
// NOT fail on project repos here.
|
|
45
|
+
repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
|
|
46
|
+
repositories {
|
|
47
|
+
google()
|
|
48
|
+
mavenCentral()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
rootProject.name = 'dash0-mobile-react-native-android'
|
|
53
|
+
|
|
54
|
+
// react-android 0.76 + the OTel SDK pull androidx.core 1.17.x transitively,
|
|
55
|
+
// which requires compiling against android-36. The shipping build.gradle reads
|
|
56
|
+
// the compileSdk/targetSdk from rootProject.ext (defaulting to 34 for old host
|
|
57
|
+
// consumers); set them here for the standalone test build only, without
|
|
58
|
+
// touching that host-facing default.
|
|
59
|
+
gradle.rootProject {
|
|
60
|
+
ext.compileSdkVersion = 36
|
|
61
|
+
ext.targetSdkVersion = 36
|
|
62
|
+
}
|
|
@@ -64,4 +64,46 @@ data class StartConfig(
|
|
|
64
64
|
* sink will translate them the same way the iOS sink does today.
|
|
65
65
|
*/
|
|
66
66
|
val nativeAutoCapture: List<String> = emptyList(),
|
|
67
|
+
/**
|
|
68
|
+
* Trace sampling strategy from the JS caller, mapped onto the native
|
|
69
|
+
* [io.opentelemetry.android.mobile.sampling.SamplingConfig].
|
|
70
|
+
*
|
|
71
|
+
* The RN bridge defaults this to [SamplingStrategy.ALWAYS_ON] when the
|
|
72
|
+
* JS caller omits `sampling`, rather than inheriting the native SDK's
|
|
73
|
+
* `dynamic(0.1)` default. RN manual spans are root spans with arbitrary
|
|
74
|
+
* names, so a 10% baseline silently drops ~90% of a user's first span
|
|
75
|
+
* (Loper finding #4). Null here means "caller said nothing" — the sink
|
|
76
|
+
* leaves the native default untouched, but in practice the JS bridge
|
|
77
|
+
* always sends a value.
|
|
78
|
+
*/
|
|
79
|
+
val sampling: BridgeSamplingConfig? = null,
|
|
67
80
|
)
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Bridge-side mirror of the JS `SamplingConfig`. Decoded from the RN
|
|
84
|
+
* `start()` payload and translated to the native SDK's `SamplingConfig` in
|
|
85
|
+
* [OTelMobileCallSink.start].
|
|
86
|
+
*/
|
|
87
|
+
data class BridgeSamplingConfig(
|
|
88
|
+
val strategy: SamplingStrategy,
|
|
89
|
+
/** Baseline rate for [SamplingStrategy.DYNAMIC]. Null = native default. */
|
|
90
|
+
val normalRate: Double? = null,
|
|
91
|
+
/** High-priority rate for [SamplingStrategy.DYNAMIC]. Null = native default. */
|
|
92
|
+
val highPriorityRate: Double? = null,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
enum class SamplingStrategy {
|
|
96
|
+
ALWAYS_ON,
|
|
97
|
+
ALWAYS_OFF,
|
|
98
|
+
DYNAMIC,
|
|
99
|
+
;
|
|
100
|
+
|
|
101
|
+
companion object {
|
|
102
|
+
/** Maps the JS `strategy` string; unknown values fall back to ALWAYS_ON (RN default). */
|
|
103
|
+
fun fromToken(raw: String?): SamplingStrategy = when (raw) {
|
|
104
|
+
"always_off" -> ALWAYS_OFF
|
|
105
|
+
"dynamic" -> DYNAMIC
|
|
106
|
+
else -> ALWAYS_ON
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|