From df9b2cef7ee8f336807e059fa77845a7e30e076a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 22 Jul 2024 05:00:31 -0700 Subject: [PATCH] Prefix custom tracks for markers coming from JS with Web Performance (#45564) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45564 Changelog: [internal] (this is internal because the integration hasn't been enabled in OSS yet) In our current React integration for Perfetto we're currently creating multiple custom tracks that are spread throughout the process section and it can be hard to identify the source of the information. This adds a "Web Performance: " prefix to all custom tracks coming from JS to achieve 2 purposes: * Group them together (in terms of order in the process) * Clarify the source of the data Reviewed By: sammy-SC Differential Revision: D60010695 fbshipit-source-id: 081f5b6417d676c61005114337530a089142e7c6 --- .../nativemodule/webperformance/NativePerformance.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp b/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp index 91b2cac1a09..4fecf7c8810 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp @@ -37,6 +37,7 @@ namespace { const std::string TRACK_PREFIX = "Track:"; const std::string DEFAULT_TRACK_NAME = "Web Performance"; +const std::string CUSTOM_TRACK_NAME_PREFIX = "Web Performance: "; std::tuple parsePerfettoTrack( const std::string& name) { @@ -48,8 +49,10 @@ std::tuple parsePerfettoTrack( if (name.starts_with(TRACK_PREFIX)) { const auto trackNameDelimiter = name.find(':', TRACK_PREFIX.length()); if (trackNameDelimiter != std::string::npos) { - trackName = name.substr( - TRACK_PREFIX.length(), trackNameDelimiter - TRACK_PREFIX.length()); + trackName = CUSTOM_TRACK_NAME_PREFIX + + name.substr( + TRACK_PREFIX.length(), + trackNameDelimiter - TRACK_PREFIX.length()); eventName = std::string_view(name).substr(trackNameDelimiter + 1); } }