Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

### Features

- Support for React Native 0.81 ([#5051](https://github.com/getsentry/sentry-react-native/pull/5051))

- Support New Hermes Runtime Access Pattern ([#5051](https://github.com/getsentry/sentry-react-native/pull/5051))

- Support Metro 0.83 ([#5035](https://github.com/getsentry/sentry-react-native/pull/5035))

### Dependencies
Expand Down
4 changes: 3 additions & 1 deletion packages/core/RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rn_package = parse_rn_package_json()
rn_version = get_rn_version(rn_package)
is_hermes_default = is_hermes_default(rn_version)
is_profiling_supported = is_profiling_supported(rn_version)
is_new_hermes_runtime = is_new_hermes_runtime(rn_version)

# Use different Folly configuration for RN 0.80.0+
if should_use_folly_flags(rn_version)
Expand All @@ -21,7 +22,8 @@ is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] == "1"
is_using_hermes = (ENV['USE_HERMES'] == nil && is_hermes_default) || ENV['USE_HERMES'] == '1'
new_arch_enabled_flag = (is_new_arch_enabled ? folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED" : "")
sentry_profiling_supported_flag = (is_profiling_supported ? " -DSENTRY_PROFILING_SUPPORTED=1" : "")
other_cflags = "$(inherited)" + new_arch_enabled_flag + sentry_profiling_supported_flag
new_hermes_runtime_flag = (is_new_hermes_runtime ? " -DNEW_HERMES_RUNTIME" : "")
other_cflags = "$(inherited)" + new_arch_enabled_flag + sentry_profiling_supported_flag + new_hermes_runtime_flag

Pod::Spec.new do |s|
s.name = 'RNSentry'
Expand Down
19 changes: 18 additions & 1 deletion packages/core/ios/RNSentry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,15 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
{
#if SENTRY_PROFILING_ENABLED
try {
# ifdef NEW_HERMES_RUNTIME
auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
facebook::hermes::makeHermesRootAPI());
if (hermesAPI) {
hermesAPI->enableSamplingProfiler();
}
# else
facebook::hermes::HermesRuntime::enableSamplingProfiler();
# endif
if (nativeProfileTraceId == nil && nativeProfileStartTime == 0 && platformProfilers) {
# if SENTRY_TARGET_PROFILING_SUPPORTED
nativeProfileTraceId = [RNSentryId newId];
Expand Down Expand Up @@ -892,10 +900,19 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
nativeProfileTraceId = nil;
nativeProfileStartTime = 0;

facebook::hermes::HermesRuntime::disableSamplingProfiler();
std::stringstream ss;
# ifdef NEW_HERMES_RUNTIME
auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
facebook::hermes::makeHermesRootAPI());
if (hermesAPI) {
hermesAPI->disableSamplingProfiler();
hermesAPI->dumpSampledTraceToStream(ss);
}
# else
facebook::hermes::HermesRuntime::disableSamplingProfiler();
// Before RN 0.69 Hermes used llvh::raw_ostream (profiling is supported for 0.69 and newer)
facebook::hermes::HermesRuntime::dumpSampledTraceToStream(ss);
# endif

std::string s = ss.str();
NSString *data = [NSString stringWithCString:s.c_str()
Expand Down
4 changes: 4 additions & 0 deletions packages/core/scripts/sentry_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ def is_profiling_supported(rn_version)
def should_use_folly_flags(rn_version)
return (rn_version[:major] == 0 && rn_version[:minor] < 80)
end

def is_new_hermes_runtime(rn_version)
return (rn_version[:major] >= 1 || (rn_version[:major] == 0 && rn_version[:minor] >= 81))
end
Loading