@@ -810,7 +810,15 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
810810{
811811#if SENTRY_PROFILING_ENABLED
812812 try {
813+ # ifdef NEW_HERMES_RUNTIME
814+ auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
815+ facebook::hermes::makeHermesRootAPI ());
816+ if (hermesAPI) {
817+ hermesAPI->enableSamplingProfiler ();
818+ }
819+ # else
813820 facebook::hermes::HermesRuntime::enableSamplingProfiler ();
821+ # endif
814822 if (nativeProfileTraceId == nil && nativeProfileStartTime == 0 && platformProfilers) {
815823# if SENTRY_TARGET_PROFILING_SUPPORTED
816824 nativeProfileTraceId = [RNSentryId newId ];
@@ -870,10 +878,19 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
870878 nativeProfileTraceId = nil ;
871879 nativeProfileStartTime = 0 ;
872880
873- facebook::hermes::HermesRuntime::disableSamplingProfiler ();
874881 std::stringstream ss;
882+ # ifdef NEW_HERMES_RUNTIME
883+ auto *hermesAPI = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(
884+ facebook::hermes::makeHermesRootAPI ());
885+ if (hermesAPI) {
886+ hermesAPI->disableSamplingProfiler ();
887+ hermesAPI->dumpSampledTraceToStream (ss);
888+ }
889+ # else
890+ facebook::hermes::HermesRuntime::disableSamplingProfiler ();
875891 // Before RN 0.69 Hermes used llvh::raw_ostream (profiling is supported for 0.69 and newer)
876892 facebook::hermes::HermesRuntime::dumpSampledTraceToStream (ss);
893+ # endif
877894
878895 std::string s = ss.str ();
879896 NSString *data = [NSString stringWithCString: s.c_str ()
0 commit comments