Skip to content

Commit

Permalink
fix(android): Load Android context in JS like on iOS (#3170)
Browse files Browse the repository at this point in the history
This enables users to interact/modify the context in the `beforeSend` callback like on iOS and also ensures there are no modifications to the event after leaving the callback.
  • Loading branch information
krystofwoldrich authored Jul 26, 2023
1 parent 94c1854 commit b0855ef
Show file tree
Hide file tree
Showing 36 changed files with 1,150 additions and 154 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ jobs:
echo "SENTRY_RELEASE=$SENTRY_RELEASE"
echo "SENTRY_DIST=$SENTRY_DIST"
- uses: actions/setup-node@v3
if: ${{ matrix.rn-version == '0.65.3' }}
with:
node-version: 16

- uses: actions/setup-node@v3
if: ${{ matrix.rn-version != '0.65.3' }}
with:
node-version: 18

- uses: actions/setup-java@v3
with:
java-version: '11'
Expand Down Expand Up @@ -376,6 +386,16 @@ jobs:
working-directory: test/e2e
run: tar -xvf *.tar

- uses: actions/setup-node@v3
if: ${{ matrix.rn-version == '0.65.3' }}
with:
node-version: 16

- uses: actions/setup-node@v3
if: ${{ matrix.rn-version != '0.65.3' }}
with:
node-version: 18

- uses: actions/setup-java@v3
with:
java-version: '11'
Expand Down
74 changes: 70 additions & 4 deletions .github/workflows/native-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
access_token: ${{ github.token }}

test:
test-ios:
name: ios
runs-on: macos-latest
steps:
Expand All @@ -32,13 +32,13 @@ jobs:
run: yarn install

- name: Install App Pods
working-directory: RNSentryTester
working-directory: RNSentryCocoaTester
run: pod install

- name: Run iOS Tests
working-directory: RNSentryTester
working-directory: RNSentryCocoaTester
env:
SCHEME: RNSentryTester
SCHEME: RNSentryCocoaTester
CONFIGURATION: Release
DESTINATION: 'platform=iOS Simulator,OS=latest,name=iPhone 14'
run: |
Expand All @@ -47,3 +47,69 @@ jobs:
-scheme $SCHEME -configuration $CONFIGURATION \
-destination "$DESTINATION" \
test
test-android:
name: android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-21

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
with:
api-level: 21
emulator-options: >
-accel on
-no-window
-gpu swiftshader_indirect
-noaudio
-no-boot-anim
-camera-back none
-camera-front none
-timezone US/Pacific
force-avd-creation: false
disable-animations: true
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."

- name: Run connected tests
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
with:
working-directory: RNSentryAndroidTester
api-level: 21
emulator-options: >
-no-snapshot-save
-accel on
-no-window
-gpu swiftshader_indirect
-noaudio
-no-boot-anim
-camera-back none
-camera-front none
-timezone US/Pacific
force-avd-creation: false
disable-animations: true
arch: x86_64
profile: Nexus 6
script: |
./gradlew uninstallDebug uninstallDebugAndroidTest
./gradlew connectedCheck
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

- Warn users about multiple versions of `promise` package which can cause unexpected behavior like undefined `Promise.allSettled` ([#3162](https://github.com/getsentry/sentry-react-native/pull/3162))
- Event is enriched with all the Android context on the JS layer and you can filter/modify all the data in the `beforeSend` callback similarly to iOS. ([#3170](https://github.com/getsentry/sentry-react-native/pull/3170))

### Dependencies

Expand All @@ -14,6 +15,9 @@
- Bump Cocoa SDK from v8.8.0 to v8.9.3 ([#3188](https://github.com/getsentry/sentry-react-native/pull/3188), [#3206](https://github.com/getsentry/sentry-react-native/pull/3206))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#893)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.8.0...8.9.3)
- Bump Android SDK from v6.25.1 to v6.27.0 ([#3170](https://github.com/getsentry/sentry-react-native/pull/3170))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6270)
- [diff](https://github.com/getsentry/sentry-java/compare/6.25.1...6.27.0)

## 5.7.1

Expand Down
15 changes: 15 additions & 0 deletions RNSentryAndroidTester/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions RNSentryAndroidTester/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions RNSentryAndroidTester/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'io.sentry.rnsentryandroidtester'
compileSdk 33

defaultConfig {
applicationId "io.sentry.rnsentryandroidtester"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}

testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}

dependencies {
implementation project(':RNSentry')
implementation 'com.facebook.react:react-android:0.72.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Loading

0 comments on commit b0855ef

Please sign in to comment.