-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
2,659 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,59 @@ | |
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. | ||
<!-- prettier-ignore-end --> | ||
## Unreleased | ||
## 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)) | ||
### Dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/core/RNSentryAndroidTester/app/src/androidTest/assets/invalid.options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"dsn": "invalid-dsn" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/core/RNSentryAndroidTester/app/src/androidTest/assets/invalid.options.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invalid-options |
5 changes: 5 additions & 0 deletions
5
packages/core/RNSentryAndroidTester/app/src/androidTest/assets/sentry.options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dsn": "https://[email protected]/123456", | ||
"enableTracing": true, | ||
"tracesSampleRate": 1.0 | ||
} |
103 changes: 103 additions & 0 deletions
103
...SentryAndroidTester/app/src/androidTest/java/io/sentry/react/RNSentryJsonConverterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} | ||
} |
Oops, something went wrong.