Skip to content

Commit ee0b201

Browse files
Merge branch 'main' (4.10.0-candidate) into 5.0.0
2 parents d5a5308 + 98946b2 commit ee0b201

File tree

30 files changed

+532
-194
lines changed

30 files changed

+532
-194
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
!/ios/**/*
1212
!/android/**/*
1313
!src/js/NativeRNSentry.ts
14+
!scripts/collect-modules.sh

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66

77
- Add missing source Spec for RNSentry Codegen. ([#2639](https://github.com/getsentry/sentry-react-native/pull/2639))
88

9+
### Features
10+
11+
- JS Runtime dependencies are sent in Events ([#2606](https://github.com/getsentry/sentry-react-native/pull/2606))
12+
- To collect JS dependencies on iOS add `../node_modules/@sentry/react-native/scripts/collect-modules.sh` at the end of the `Bundle React Native code and images` build phase. The collection only works on Release builds. Android builds have a new step in `sentry.gradle` plugin. More in [the migration documentation](https://docs.sentry.io/platforms/react-native/migration#from-48x-to-49x).
13+
14+
### Dependencies
15+
16+
- Bump JavaScript SDK from v7.20.1 to v7.21.1 ([#2636](https://github.com/getsentry/sentry-react-native/pull/2636))
17+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7211)
18+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.20.1...7.21.1)
19+
920
## 5.0.0-alpha.8
1021

1122
- Latest changes from 4.9.0

android/src/main/java/io/sentry/react/RNSentryModuleImpl.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Context;
55
import android.content.pm.PackageInfo;
66
import android.content.pm.PackageManager;
7+
import android.content.res.AssetManager;
78
import android.util.SparseIntArray;
89

910
import androidx.annotation.Nullable;
@@ -17,8 +18,12 @@
1718
import com.facebook.react.bridge.ReadableMapKeySetIterator;
1819
import com.facebook.react.bridge.WritableMap;
1920

21+
import java.io.BufferedInputStream;
2022
import java.io.File;
23+
import java.io.FileNotFoundException;
2124
import java.io.FileOutputStream;
25+
import java.io.InputStream;
26+
import java.nio.charset.Charset;
2227
import java.util.Date;
2328
import java.util.HashMap;
2429
import java.util.List;
@@ -48,6 +53,8 @@ public class RNSentryModuleImpl {
4853
public static final String NAME = "RNSentry";
4954

5055
private static final Logger logger = Logger.getLogger("react-native-sentry");
56+
private static final String modulesPath = "modules.json";
57+
private static final Charset UTF_8 = Charset.forName("UTF-8");
5158

5259
private final ReactApplicationContext reactApplicationContext;
5360
private final PackageInfo packageInfo;
@@ -173,6 +180,24 @@ public void crash() {
173180
throw new RuntimeException("TEST - Sentry Client Crash (only works in release mode)");
174181
}
175182

183+
public void fetchModules(Promise promise) {
184+
final AssetManager assets = this.getReactApplicationContext().getResources().getAssets();
185+
try (final InputStream stream =
186+
new BufferedInputStream(assets.open(RNSentryModuleImpl.modulesPath))) {
187+
int size = stream.available();
188+
byte[] buffer = new byte[size];
189+
stream.read(buffer);
190+
stream.close();
191+
String modulesJson = new String(buffer, RNSentryModuleImpl.UTF_8);
192+
promise.resolve(modulesJson);
193+
} catch (FileNotFoundException e) {
194+
promise.resolve(null);
195+
} catch (Throwable e) {
196+
logger.warning("Fetching JS Modules failed.");
197+
promise.resolve(null);
198+
}
199+
}
200+
176201
public void fetchNativeRelease(Promise promise) {
177202
WritableMap release = Arguments.createMap();
178203
release.putString("id", packageInfo.packageName);

android/src/newarch/java/io/sentry/react/RNSentryModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public void crash() {
3232
this.impl.crash();
3333
}
3434

35+
@Override
36+
public void fetchModules(Promise promise) {
37+
this.impl.fetchModules(promise);
38+
}
39+
3540
@Override
3641
public void fetchNativeRelease(Promise promise) {
3742
this.impl.fetchNativeRelease(promise);

android/src/oldarch/java/io/sentry/react/RNSentryModule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public void crash() {
3232
this.impl.crash();
3333
}
3434

35+
@ReactMethod
36+
public void fetchModules(Promise promise) {
37+
this.impl.fetchModules(promise);
38+
}
39+
3540
@ReactMethod
3641
public void fetchNativeRelease(Promise promise) {
3742
this.impl.fetchNativeRelease(promise);

ios/RNSentry.mm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ - (void)setEventEnvironmentTag:(SentryEvent *)event
161161
});
162162
}
163163

164+
RCT_EXPORT_METHOD(fetchModules:(RCTPromiseResolveBlock)resolve
165+
rejecter:(RCTPromiseRejectBlock)reject)
166+
{
167+
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"modules" ofType:@"json"];
168+
NSString* modulesString = [NSString stringWithContentsOfFile:filePath
169+
encoding:NSUTF8StringEncoding
170+
error:nil];
171+
resolve(modulesString);
172+
}
173+
164174
RCT_EXPORT_METHOD(fetchNativeDeviceContexts:(RCTPromiseResolveBlock)resolve
165175
rejecter:(RCTPromiseRejectBlock)reject)
166176
{

package.json

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
},
1212
"main": "dist/js/index.js",
1313
"scripts": {
14-
"build": "tsc -p tsconfig.build.json",
15-
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
14+
"build": "yarn build:sdk && yarn build:tools",
15+
"build:sdk": "tsc -p tsconfig.build.json",
16+
"build:sdk:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
17+
"build:tools": "tsc -p tsconfig.build.tools.json",
1618
"clean": "rimraf dist coverage",
1719
"test": "jest",
1820
"lint": "eslint .",
@@ -40,19 +42,19 @@
4042
"react-native": ">=0.70.0"
4143
},
4244
"dependencies": {
43-
"@sentry/browser": "7.20.1",
45+
"@sentry/browser": "7.21.1",
4446
"@sentry/cli": "2.7.0",
45-
"@sentry/core": "7.20.1",
46-
"@sentry/hub": "7.20.1",
47-
"@sentry/integrations": "7.20.1",
48-
"@sentry/react": "7.20.1",
49-
"@sentry/tracing": "7.20.1",
50-
"@sentry/types": "7.20.1",
51-
"@sentry/utils": "7.20.1"
47+
"@sentry/core": "7.21.1",
48+
"@sentry/hub": "7.21.1",
49+
"@sentry/integrations": "7.21.1",
50+
"@sentry/react": "7.21.1",
51+
"@sentry/tracing": "7.21.1",
52+
"@sentry/types": "7.21.1",
53+
"@sentry/utils": "7.21.1"
5254
},
5355
"devDependencies": {
54-
"@sentry-internal/eslint-config-sdk": "7.20.1",
55-
"@sentry-internal/eslint-plugin-sdk": "7.20.1",
56+
"@sentry-internal/eslint-config-sdk": "7.21.1",
57+
"@sentry-internal/eslint-plugin-sdk": "7.21.1",
5658
"@sentry/typescript": "^5.20.1",
5759
"@sentry/wizard": "2.2.0",
5860
"@types/jest": "^26.0.15",

sample-new-architecture/android/app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ project.ext.react = [
8282
enableHermes: true, // clean and rebuild if changing
8383
]
8484

85+
project.ext.sentryCli = [
86+
collectModulesScript: "../../../dist/js/tools/collectModules.js",
87+
modulesPaths: [
88+
"node_modules",
89+
"../..",
90+
],
91+
skipCollectModules: false,
92+
]
93+
8594
apply from: "../../node_modules/react-native/react.gradle"
8695
apply from: "../../../sentry.gradle"
8796

sample-new-architecture/ios/sampleNewArchitecture.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
);
266266
runOnlyForDeploymentPostprocessing = 0;
267267
shellPath = /bin/sh;
268-
shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"../../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\"\"\n";
268+
shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"../../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\"\"\n\nexport MODULES_PATHS=\"$PWD/../node_modules,$PWD/../../..\"\n/bin/sh ../../scripts/collect-modules.sh\n";
269269
};
270270
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
271271
isa = PBXShellScriptBuildPhase;

sample/android/app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ project.ext.react = [
8181
enableHermes: true, // clean and rebuild if changing
8282
]
8383

84+
project.ext.sentryCli = [
85+
collectModulesScript: "../../../dist/js/tools/collectModules.js",
86+
modulesPaths: [
87+
"node_modules",
88+
"../..",
89+
],
90+
skipCollectModules: false,
91+
]
92+
8493
apply from: "../../node_modules/react-native/react.gradle"
8594
apply from: "../../../sentry.gradle"
8695

0 commit comments

Comments
 (0)