Skip to content

Commit

Permalink
Merge branch 'main' into test/deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-zimerman authored Sep 18, 2024
2 parents 99e74cf + 27188a0 commit 1bb5c4d
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 95 deletions.
49 changes: 46 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Changelog

## Unreleased
## 5.33.0

### Features

- Add an option to disable native (iOS and Android) profiling for the `HermesProfiling` integration ([#4094](https://github.com/getsentry/sentry-react-native/pull/4094))

To disable native profilers add the `hermesProfilingIntegration`.

```js
import * as Sentry from '@sentry/react-native';

Sentry.init({
integrations: [
Sentry.hermesProfilingIntegration({ platformProfilers: false }),
],
});
```

## 5.32.0

### Features

Expand All @@ -20,14 +38,21 @@

### Changes

- Add Android Logger when new frame event is not emitted ([#4081](https://github.com/getsentry/sentry-react-native/pull/4081))
- React Native Tracing Deprecations ([#4073](https://github.com/getsentry/sentry-react-native/pull/4073))
- `new ReactNativeTracing` to `reactNativeTracingIntegration()`
- `new ReactNavigationInstrumentation` to `reactNativeTracingIntegration()`.
- `new ReactNativeNavigationInstrumentation` to `reactNativeTracingIntegration()`.
- `new ReactNavigationInstrumentation` to `reactNavigationIntegration()`.
- `new ReactNativeNavigationInstrumentation` to `reactNativeNavigationIntegration()`.
- `ReactNavigationV4Instrumentation` won't be supported in the next major SDK version, upgrade to `react-navigation@5` or newer.
- `RoutingInstrumentation` and `RoutingInstrumentationInstance` replace by `Integration` interface from `@sentry/types`.
- `enableAppStartTracking`, `enableNativeFramesTracking`, `enableStallTracking`, `enableUserInteractionTracing` moved to `Sentry.init({})` root options.
### Dependencies
- Bump CLI from v2.34.0 to v2.36.1 ([#4055](https://github.com/getsentry/sentry-react-native/pull/4055))
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2361)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.34.0...2.36.1)
## 5.31.1
### Fixes
Expand Down Expand Up @@ -238,6 +263,24 @@

Access to Mobile Replay is limited to early access orgs on Sentry. If you're interested, [sign up for the waitlist](https://sentry.io/lp/mobile-replay-beta/)
## 5.24.2
### Features
- Add an option to disable native (iOS and Android) profiling for the `HermesProfiling` integration ([#4094](https://github.com/getsentry/sentry-react-native/pull/4094))
To disable native profilers add the `hermesProfilingIntegration`.
```js
import * as Sentry from '@sentry/react-native';
Sentry.init({
integrations: [
Sentry.hermesProfilingIntegration({ platformProfilers: false }),
],
});
```
## 5.24.1
### Fixes
Expand Down
29 changes: 18 additions & 11 deletions android/src/main/java/io/sentry/react/RNSentryModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,17 @@ private void initializeAndroidProfiler() {
);
}

public WritableMap startProfiling() {
public WritableMap startProfiling(boolean platformProfilers) {
final WritableMap result = new WritableNativeMap();
if (androidProfiler == null) {
if (androidProfiler == null && platformProfilers) {
initializeAndroidProfiler();
}

try {
HermesSamplingProfiler.enable();
androidProfiler.start();
if (androidProfiler != null) {
androidProfiler.start();
}

result.putBoolean("started", true);
} catch (Throwable e) {
Expand All @@ -741,7 +743,10 @@ public WritableMap stopProfiling() {
final WritableMap result = new WritableNativeMap();
File output = null;
try {
AndroidProfiler.ProfileEndData end = androidProfiler.endAndCollect(false, null);
AndroidProfiler.ProfileEndData end = null;
if (androidProfiler != null) {
end = androidProfiler.endAndCollect(false, null);
}
HermesSamplingProfiler.disable();

output = File.createTempFile(
Expand All @@ -753,14 +758,16 @@ public WritableMap stopProfiling() {
HermesSamplingProfiler.dumpSampledTraceToFile(output.getPath());
result.putString("profile", readStringFromFile(output));

WritableMap androidProfile = new WritableNativeMap();
byte[] androidProfileBytes = FileUtils.readBytesFromFile(end.traceFile.getPath(), maxTraceFileSize);
String base64AndroidProfile = Base64.encodeToString(androidProfileBytes, NO_WRAP | NO_PADDING);
if (end != null) {
WritableMap androidProfile = new WritableNativeMap();
byte[] androidProfileBytes = FileUtils.readBytesFromFile(end.traceFile.getPath(), maxTraceFileSize);
String base64AndroidProfile = Base64.encodeToString(androidProfileBytes, NO_WRAP | NO_PADDING);

androidProfile.putString("sampled_profile", base64AndroidProfile);
androidProfile.putInt("android_api_level", buildInfo.getSdkInfoVersion());
androidProfile.putString("build_id", getProguardUuid());
result.putMap("androidProfile", androidProfile);
androidProfile.putString("sampled_profile", base64AndroidProfile);
androidProfile.putInt("android_api_level", buildInfo.getSdkInfoVersion());
androidProfile.putString("build_id", getProguardUuid());
result.putMap("androidProfile", androidProfile);
}
} catch (Throwable e) {
result.putString("error", e.toString());
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import java.util.Map;

import io.sentry.ILogger;
import io.sentry.SentryDate;
import io.sentry.SentryDateProvider;
import io.sentry.SentryLevel;
import io.sentry.android.core.AndroidLogger;
import io.sentry.android.core.BuildInfoProvider;
import io.sentry.android.core.SentryAndroidDateProvider;
Expand Down Expand Up @@ -68,6 +70,8 @@ public Map getExportedCustomBubblingEventTypeConstants() {

public static class RNSentryOnDrawReporterView extends View {

private static final ILogger logger = new AndroidLogger("RNSentryOnDrawReporterView");

private final @Nullable ReactApplicationContext reactContext;
private final @NotNull SentryDateProvider dateProvider = new SentryAndroidDateProvider();
private final @Nullable Runnable emitInitialDisplayEvent;
Expand Down Expand Up @@ -96,6 +100,7 @@ public void setFullDisplay(boolean fullDisplay) {
return;
}

logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register full display event emitter.");
registerForNextDraw(emitFullDisplayEvent);
}

Expand All @@ -104,16 +109,27 @@ public void setInitialDisplay(boolean initialDisplay) {
return;
}

logger.log(SentryLevel.DEBUG, "[TimeToDisplay] Register initial display event emitter.");
registerForNextDraw(emitInitialDisplayEvent);
}

private void registerForNextDraw(@Nullable Runnable emitter) {
if (emitter == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, emitter is null.");
return;
}
if (buildInfo == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, buildInfo is null.");
return;
}
if (reactContext == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
return;
}

@Nullable Activity activity = reactContext.getCurrentActivity();
if (activity == null || emitter == null || buildInfo == null) {
if (activity == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Won't emit next frame drawn event, reactContext is null.");
return;
}

Expand All @@ -129,6 +145,7 @@ private void emitDisplayEvent(String type) {
event.putDouble("newFrameTimestampInSeconds", endDate.nanoTimestamp() / 1e9);

if (reactContext == null) {
logger.log(SentryLevel.ERROR, "[TimeToDisplay] Recorded next frame draw but can't emit the event, reactContext is null.");
return;
}
reactContext
Expand Down
4 changes: 2 additions & 2 deletions android/src/newarch/java/io/sentry/react/RNSentryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public void fetchNativeSdkInfo(Promise promise) {
}

@Override
public WritableMap startProfiling() {
return this.impl.startProfiling();
public WritableMap startProfiling(boolean platformProfilers) {
return this.impl.startProfiling(platformProfilers);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions android/src/oldarch/java/io/sentry/react/RNSentryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public void fetchNativeSdkInfo(Promise promise) {
}

@ReactMethod(isBlockingSynchronousMethod = true)
public WritableMap startProfiling() {
return this.impl.startProfiling();
public WritableMap startProfiling(boolean platformProfilers) {
return this.impl.startProfiling(platformProfilers);
}

@ReactMethod(isBlockingSynchronousMethod = true)
Expand Down
10 changes: 7 additions & 3 deletions ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -649,18 +649,22 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd
static SentryId* nativeProfileTraceId = nil;
static uint64_t nativeProfileStartTime = 0;

RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, startProfiling)
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, startProfiling: (BOOL)platformProfilers)
{
#if SENTRY_PROFILING_ENABLED
try {
facebook::hermes::HermesRuntime::enableSamplingProfiler();
if (nativeProfileTraceId == nil && nativeProfileStartTime == 0) {
if (nativeProfileTraceId == nil && nativeProfileStartTime == 0 && platformProfilers) {
#if SENTRY_TARGET_PROFILING_SUPPORTED
nativeProfileTraceId = [RNSentryId newId];
nativeProfileStartTime = [PrivateSentrySDKOnly startProfilerForTrace: nativeProfileTraceId];
#endif
} else {
NSLog(@"Native profiling already in progress. Currently existing trace: %@", nativeProfileTraceId);
if (!platformProfilers) {
NSLog(@"Native profiling is disabled. Only starting Hermes profiling.");
} else {
NSLog(@"Native profiling already in progress. Currently existing trace: %@", nativeProfileTraceId);
}
}
return @{ @"started": @YES };
} catch (const std::exception& ex) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sentry/react-native",
"homepage": "https://github.com/getsentry/sentry-react-native",
"repository": "https://github.com/getsentry/sentry-react-native",
"version": "5.31.1",
"version": "5.33.0",
"description": "Official Sentry SDK for react-native",
"typings": "dist/js/index.d.ts",
"types": "dist/js/index.d.ts",
Expand Down Expand Up @@ -69,7 +69,7 @@
"dependencies": {
"@sentry/babel-plugin-component-annotate": "2.20.1",
"@sentry/browser": "7.119.0",
"@sentry/cli": "2.34.0",
"@sentry/cli": "2.36.1",
"@sentry/core": "7.119.0",
"@sentry/hub": "7.119.0",
"@sentry/integrations": "7.119.0",
Expand Down
6 changes: 3 additions & 3 deletions samples/expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"slug": "sentry-react-native-expo-sample",
"jsEngine": "hermes",
"scheme": "sentry-expo-sample",
"version": "5.31.1",
"version": "5.33.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
Expand All @@ -19,15 +19,15 @@
"ios": {
"supportsTablet": true,
"bundleIdentifier": "io.sentry.expo.sample",
"buildNumber": "20"
"buildNumber": "22"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "io.sentry.expo.sample",
"versionCode": 20
"versionCode": 22
},
"web": {
"bundler": "metro",
Expand Down
2 changes: 1 addition & 1 deletion samples/expo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sentry-react-native-expo-sample",
"version": "5.31.1",
"version": "5.33.0",
"main": "expo-router/entry",
"scripts": {
"start": "expo start",
Expand Down
4 changes: 2 additions & 2 deletions samples/react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ android {
applicationId "io.sentry.reactnative.sample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 23
versionName "5.31.1"
versionCode 25
versionName "5.33.0"
}

signingConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,14 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"$(inherited)",
" ",
"-DRN_FABRIC_ENABLED",
);
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
Expand Down Expand Up @@ -714,13 +715,14 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = (
"$(inherited)",
" ",
"-DRN_FABRIC_ENABLED",
);
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = "$(inherited)";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
Expand Down
4 changes: 2 additions & 2 deletions samples/react-native/ios/sentryreactnativesample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>5.31.1</string>
<string>5.33.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>27</string>
<string>29</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>5.31.1</string>
<string>5.33.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>27</string>
<string>29</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion samples/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sentry-react-native-sample",
"version": "5.31.1",
"version": "5.33.0",
"private": true,
"scripts": {
"postinstall": "patch-package",
Expand Down
2 changes: 1 addition & 1 deletion src/js/NativeRNSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface Spec extends TurboModule {
enableNativeFramesTracking(): void;
fetchModules(): Promise<string | undefined | null>;
fetchViewHierarchy(): Promise<number[] | undefined | null>;
startProfiling(): { started?: boolean; error?: string };
startProfiling(platformProfilers: boolean): { started?: boolean; error?: string };
stopProfiling(): {
profile?: string;
nativeProfile?: UnsafeObject;
Expand Down
Loading

0 comments on commit 1bb5c4d

Please sign in to comment.