@@ -832,7 +832,15 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
832832{
833833#if SENTRY_PROFILING_ENABLED
834834 try {
835+ # ifdef NEW_HERMES_RUNTIME
836+ auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
837+ facebook::hermes::makeHermesRootAPI ());
838+ if (hermesAPI) {
839+ hermesAPI->enableSamplingProfiler ();
840+ }
841+ # else
835842 facebook::hermes::HermesRuntime::enableSamplingProfiler ();
843+ # endif
836844 if (nativeProfileTraceId == nil && nativeProfileStartTime == 0 && platformProfilers) {
837845# if SENTRY_TARGET_PROFILING_SUPPORTED
838846 nativeProfileTraceId = [RNSentryId newId ];
@@ -892,10 +900,19 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
892900 nativeProfileTraceId = nil ;
893901 nativeProfileStartTime = 0 ;
894902
895- facebook::hermes::HermesRuntime::disableSamplingProfiler ();
896903 std::stringstream ss;
904+ # ifdef NEW_HERMES_RUNTIME
905+ auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
906+ facebook::hermes::makeHermesRootAPI ());
907+ if (hermesAPI) {
908+ hermesAPI->disableSamplingProfiler ();
909+ hermesAPI->dumpSampledTraceToStream (ss);
910+ }
911+ # else
912+ facebook::hermes::HermesRuntime::disableSamplingProfiler ();
897913 // Before RN 0.69 Hermes used llvh::raw_ostream (profiling is supported for 0.69 and newer)
898914 facebook::hermes::HermesRuntime::dumpSampledTraceToStream (ss);
915+ # endif
899916
900917 std::string s = ss.str ();
901918 NSString *data = [NSString stringWithCString: s.c_str ()
0 commit comments