Skip to content

chore(sample-e2e): Migrate from Detox to Maestro #4914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: capture-app-start-errors
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 35 additions & 47 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,62 +98,39 @@ jobs:
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
working-directory: samples
run: |
[[ "${{ matrix.platform }}" == "ios" ]] && cd react-native/ios
[[ "${{ matrix.platform }}" == "macos" ]] && cd react-native-macos/macos
[[ "${{ matrix.platform }}" == "ios" ]] && cd react-native
[[ "${{ matrix.platform }}" == "macos" ]] && cd react-native-macos

[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
[[ "${{ matrix.rn-architecture }}" == "new" ]] && ENABLE_NEW_ARCH=1 || ENABLE_NEW_ARCH=0
[[ "${{ matrix.build-type }}" == "production" ]] && export ENABLE_PROD=1 || export ENABLE_PROD=0
[[ "${{ matrix.rn-architecture }}" == "new" ]] && export ENABLE_NEW_ARCH=1 || export ENABLE_NEW_ARCH=0
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic-frameworks" ]] && export USE_FRAMEWORKS=dynamic
echo "ENABLE_PROD=$ENABLE_PROD"
echo "ENABLE_NEW_ARCH=$ENABLE_NEW_ARCH"
PRODUCTION=$ENABLE_PROD RCT_NEW_ARCH_ENABLED=$ENABLE_NEW_ARCH bundle exec pod install
cat Podfile.lock | grep $RN_SENTRY_POD_NAME

./scripts/pod-install.sh

- name: Build Android App
if: ${{ matrix.platform == 'android' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: |
if [[ ${{ matrix.rn-architecture }} == 'new' ]]; then
perl -i -pe's/newArchEnabled=false/newArchEnabled=true/g' gradle.properties
echo 'New Architecture enabled'
elif [[ ${{ matrix.rn-architecture }} == 'legacy' ]]; then
perl -i -pe's/newArchEnabled=true/newArchEnabled=false/g' gradle.properties
echo 'Legacy Architecture enabled'
else
echo 'No changes for architecture: ${{ matrix.rn-architecture }}'
fi
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
[[ "${{ matrix.build-type }}" == "production" ]] && TEST_TYPE='release' || TEST_TYPE='debug'
echo "Building $TEST_TYPE"
export RN_ARCHITECTURE="${{ matrix.rn-architecture }}"
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='release' || export CONFIG='debug'

./gradlew ":app:assemble$CONFIG" -PreactNativeArchitectures=x86
./scripts/set-dsn-aos.mjs
./scripts/build-android.sh -PreactNativeArchitectures=x86

- name: Build iOS App
if: ${{ matrix.platform == 'ios' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: |
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
echo "Building $CONFIG"
mkdir -p "DerivedData"
derivedData="$(cd "DerivedData" ; pwd -P)"
set -o pipefail && xcodebuild \
-workspace sentryreactnativesample.xcworkspace \
-configuration "$CONFIG" \
-scheme sentryreactnativesample \
-sdk 'iphonesimulator' \
-destination 'generic/platform=iOS Simulator' \
ONLY_ACTIVE_ARCH=yes \
-derivedDataPath "$derivedData" \
build \
| tee xcodebuild.log \
| xcbeautify --quieter --is-ci --disable-colored-output
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='Release' || export CONFIG='Debug'

./scripts/set-dsn-ios.mjs
./scripts/build-ios.sh

- name: Build macOS App
if: ${{ matrix.platform == 'macos' }}
working-directory: samples/react-native-macos/macos
run: |
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
[[ "${{ matrix.build-type }}" == "production" ]] && export CONFIG='Release' || export CONFIG='Debug'
echo "Building $CONFIG"
mkdir -p "DerivedData"
derivedData="$(cd "DerivedData" ; pwd -P)"
Expand All @@ -170,19 +147,19 @@ jobs:

- name: Archive iOS App
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: |
cd ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/DerivedData/Build/Products/Release-iphonesimulator
zip -r \
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \
sentryreactnativesample.app

- name: Archive Android App
if: ${{ matrix.platform == 'android' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' }}
run: |
mv ${{ env.REACT_NATIVE_SAMPLE_PATH }}/android/app/build/outputs/apk/release/app-release.apk app.apk
zip -j \
${{ env.ANDROID_APP_ARCHIVE_PATH }} \
app.apk
${{ env.REACT_NATIVE_SAMPLE_PATH }}/app.apk \
${{ env.REACT_NATIVE_SAMPLE_PATH }}/app-androidTest.apk

- name: Upload iOS APP
if: ${{ matrix.platform == 'ios' && matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
Expand All @@ -208,7 +185,7 @@ jobs:
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/${{ matrix.platform }}/*.log

test:
name: Test ${{ matrix.platform }} ${{ matrix.build-type }} REV2
name: Test ${{ matrix.platform }} ${{ matrix.build-type }} ${{ matrix.init-type }} REV2
runs-on: ${{ matrix.runs-on }}
needs: [diff_check, build]
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
Expand All @@ -222,11 +199,20 @@ jobs:
rn-architecture: 'new'
ios-use-frameworks: 'no-frameworks'
build-type: 'production'
init-type: 'auto'

- platform: ios
runs-on: macos-15
rn-architecture: 'new'
ios-use-frameworks: 'no-frameworks'
build-type: 'production'
init-type: 'manual'

- platform: android
runs-on: ubuntu-latest
rn-architecture: 'new'
build-type: 'production'
init-type: 'manual'

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -258,7 +244,9 @@ jobs:
- name: Unzip Android APK
if: ${{ matrix.platform == 'android' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: unzip ${{ env.ANDROID_APP_ARCHIVE_PATH }}
run: |
unzip ${{ env.ANDROID_APP_ARCHIVE_PATH }}
rm app-androidTest.apk

- name: Enable Corepack
run: npm i -g corepack
Expand Down Expand Up @@ -293,7 +281,7 @@ jobs:
- name: Run iOS Tests
if: ${{ matrix.platform == 'ios' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: yarn test-ios
run: yarn test-ios-${{ matrix.init-type }}

- name: Run Android Tests on API ${{ env.ANDROID_API_LEVEL }}
if: ${{ matrix.platform == 'android' }}
Expand All @@ -315,4 +303,4 @@ jobs:
-camera-front none
-timezone US/Pacific
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
script: yarn test-android
script: yarn test-android-${{ matrix.init-type }}
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,61 @@
- [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#320)
- [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.1.2...3.2.0)


## 6.7.0-alpha.0

### Features

- Capture App Start errors and crashes by initializing Sentry from `sentry.options.json` ([#4472](https://github.com/getsentry/sentry-react-native/pull/4472))

Create `sentry.options.json` in the React Native project root and set options the same as you currently have in `Sentry.init` in JS.

```json
{
"dsn": "https://[email protected]/value",
}
```

Initialize Sentry on the native layers by newly provided native methods.

```kotlin
import io.sentry.react.RNSentrySDK

class MainApplication : Application(), ReactApplication {
override fun onCreate() {
super.onCreate()
RNSentrySDK.init(this)
}
}
```

```obj-c
#import <RNSentry/RNSentry.h>

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RNSentrySDK start];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
```

### Changes

- Load `optionsFile` into the JS bundle during Metro bundle process ([#4476](https://github.com/getsentry/sentry-react-native/pull/4476))
- Add experimental version of `startWithConfigureOptions` for Apple platforms ([#4444](https://github.com/getsentry/sentry-react-native/pull/4444))
- Add experimental version of `init` with optional `OptionsConfiguration<SentryAndroidOptions>` for Android ([#4451](https://github.com/getsentry/sentry-react-native/pull/4451))
- Add initialization using `sentry.options.json` for Apple platforms ([#4447](https://github.com/getsentry/sentry-react-native/pull/4447))
- Add initialization using `sentry.options.json` for Android ([#4451](https://github.com/getsentry/sentry-react-native/pull/4451))
- Merge options from file with `Sentry.init` options in JS ([#4510](https://github.com/getsentry/sentry-react-native/pull/4510))

### Internal

- Extract iOS native initialization to standalone structures ([#4442](https://github.com/getsentry/sentry-react-native/pull/4442))
- Extract Android native initialization to standalone structures ([#4445](https://github.com/getsentry/sentry-react-native/pull/4445))

## 6.7.0

> [!WARNING]
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"performance-tests/*"
],
"npmClient": "yarn"
}
}
2 changes: 1 addition & 1 deletion packages/core/RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |s|
s.preserve_paths = '*.js'

s.source_files = 'ios/**/*.{h,m,mm}'
s.public_header_files = 'ios/RNSentry.h'
s.public_header_files = 'ios/RNSentry.h', 'ios/RNSentrySDK.h'

s.compiler_flags = other_cflags

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dsn": "invalid-dsn"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dsn": "https://[email protected]/123456",
"enableTracing": true,
"tracesSampleRate": 1.0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package io.sentry.react

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import io.sentry.react.RNSentryJsonConverter.convertToWritable
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class RNSentryJsonConverterTest {
@Test
fun testConvertToWritableWithSimpleJsonObject() {
val jsonObject =
JSONObject().apply {
put("floatKey", 12.3f)
put("doubleKey", 12.3)
put("intKey", 123)
put("stringKey", "test")
put("nullKey", JSONObject.NULL)
}

val result: WritableMap? = convertToWritable(jsonObject)

assertNotNull(result)
assertEquals(12.3, result!!.getDouble("floatKey"), 0.0001)
assertEquals(12.3, result.getDouble("doubleKey"), 0.0)
assertEquals(123, result.getInt("intKey"))
assertEquals("test", result.getString("stringKey"))
assertNull(result.getString("nullKey"))
}

@Test
fun testConvertToWritableWithNestedJsonObject() {
val jsonObject =
JSONObject().apply {
put(
"nested",
JSONObject().apply {
put("key", "value")
},
)
}

val result: WritableMap? = convertToWritable(jsonObject)

assertNotNull(result)
val nestedMap = result!!.getMap("nested")
assertNotNull(nestedMap)
assertEquals("value", nestedMap!!.getString("key"))
}

@Test
fun testConvertToWritableWithJsonArray() {
val jsonArray =
JSONArray().apply {
put(1)
put(2.5)
put("string")
put(JSONObject.NULL)
}

val result: WritableArray = convertToWritable(jsonArray)

assertEquals(1, result.getInt(0))
assertEquals(2.5, result.getDouble(1), 0.0)
assertEquals("string", result.getString(2))
assertNull(result.getString(3))
}

@Test
fun testConvertToWritableWithNestedJsonArray() {
val jsonObject =
JSONObject().apply {
put(
"array",
JSONArray().apply {
put(
JSONObject().apply {
put("key1", "value1")
},
)
put(
JSONObject().apply {
put("key2", "value2")
},
)
},
)
}

val result: WritableMap? = convertToWritable(jsonObject)

val array = result?.getArray("array")
assertEquals("value1", array?.getMap(0)?.getString("key1"))
assertEquals("value2", array?.getMap(1)?.getString("key2"))
}
}
Loading
Loading