@sentry/react-native 7.0.0-rc.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNSentry.podspec +3 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +50 -5
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +5 -0
- package/dist/js/NativeRNSentry.d.ts +1 -0
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/client.d.ts +2 -2
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +8 -8
- package/dist/js/client.js.map +1 -1
- package/dist/js/feedback/FeedbackWidget.js +12 -12
- package/dist/js/feedback/FeedbackWidget.js.map +1 -1
- package/dist/js/feedback/FeedbackWidgetManager.js +2 -2
- package/dist/js/feedback/FeedbackWidgetManager.js.map +1 -1
- package/dist/js/feedback/FeedbackWidgetProvider.js +3 -3
- package/dist/js/feedback/FeedbackWidgetProvider.js.map +1 -1
- package/dist/js/integrations/appRegistry.js +2 -2
- package/dist/js/integrations/appRegistry.js.map +1 -1
- package/dist/js/integrations/debugsymbolicator.js +3 -3
- package/dist/js/integrations/debugsymbolicator.js.map +1 -1
- package/dist/js/integrations/debugsymbolicatorutils.js +3 -3
- package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -1
- package/dist/js/integrations/default.d.ts.map +1 -1
- package/dist/js/integrations/default.js +4 -1
- package/dist/js/integrations/default.js.map +1 -1
- package/dist/js/integrations/devicecontext.js +2 -2
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/integrations/expocontext.d.ts.map +1 -1
- package/dist/js/integrations/expocontext.js +2 -2
- package/dist/js/integrations/expocontext.js.map +1 -1
- package/dist/js/integrations/exports.d.ts +1 -0
- package/dist/js/integrations/exports.d.ts.map +1 -1
- package/dist/js/integrations/exports.js +1 -0
- package/dist/js/integrations/exports.js.map +1 -1
- package/dist/js/integrations/logEnricherIntegration.d.ts +3 -0
- package/dist/js/integrations/logEnricherIntegration.d.ts.map +1 -0
- package/dist/js/integrations/logEnricherIntegration.js +65 -0
- package/dist/js/integrations/logEnricherIntegration.js.map +1 -0
- package/dist/js/integrations/modulesloader.js +2 -2
- package/dist/js/integrations/modulesloader.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +12 -12
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlersutils.js +6 -6
- package/dist/js/integrations/reactnativeerrorhandlersutils.js.map +1 -1
- package/dist/js/integrations/sdkinfo.js +3 -3
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/integrations/spotlight.js +4 -4
- package/dist/js/integrations/spotlight.js.map +1 -1
- package/dist/js/integrations/viewhierarchy.js +2 -2
- package/dist/js/integrations/viewhierarchy.js.map +1 -1
- package/dist/js/options.d.ts +1 -1
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/playground/modal.js +3 -3
- package/dist/js/playground/modal.js.map +1 -1
- package/dist/js/profiling/convertHermesProfile.js +5 -5
- package/dist/js/profiling/convertHermesProfile.js.map +1 -1
- package/dist/js/profiling/debugid.d.ts.map +1 -1
- package/dist/js/profiling/debugid.js +2 -2
- package/dist/js/profiling/debugid.js.map +1 -1
- package/dist/js/profiling/integration.js +13 -13
- package/dist/js/profiling/integration.js.map +1 -1
- package/dist/js/profiling/utils.js +3 -3
- package/dist/js/profiling/utils.js.map +1 -1
- package/dist/js/replay/CustomMask.js +3 -3
- package/dist/js/replay/CustomMask.js.map +1 -1
- package/dist/js/replay/mobilereplay.js +5 -5
- package/dist/js/replay/mobilereplay.js.map +1 -1
- package/dist/js/sdk.js +7 -7
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tools/ModulesCollector.js +12 -12
- package/dist/js/tools/ModulesCollector.js.map +1 -1
- package/dist/js/tools/enableLogger.js +1 -1
- package/dist/js/tools/enableLogger.js.map +1 -1
- package/dist/js/tools/metroMiddleware.js +6 -6
- package/dist/js/tools/metroMiddleware.js.map +1 -1
- package/dist/js/tools/metroconfig.js +2 -2
- package/dist/js/tools/metroconfig.js.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.d.ts.map +1 -1
- package/dist/js/tools/sentryBabelTransformerUtils.js +6 -6
- package/dist/js/tools/sentryBabelTransformerUtils.js.map +1 -1
- package/dist/js/tools/utils.d.ts.map +1 -1
- package/dist/js/tools/utils.js +39 -10
- package/dist/js/tools/utils.js.map +1 -1
- package/dist/js/tools/vendor/metro/utils.d.ts.map +1 -1
- package/dist/js/tools/vendor/metro/utils.js +28 -6
- package/dist/js/tools/vendor/metro/utils.js.map +1 -1
- package/dist/js/touchevents.js +3 -3
- package/dist/js/touchevents.js.map +1 -1
- package/dist/js/tracing/gesturetracing.js +5 -5
- package/dist/js/tracing/gesturetracing.js.map +1 -1
- package/dist/js/tracing/integrations/appStart.js +34 -34
- package/dist/js/tracing/integrations/appStart.js.map +1 -1
- package/dist/js/tracing/integrations/nativeFrames.js +14 -14
- package/dist/js/tracing/integrations/nativeFrames.js.map +1 -1
- package/dist/js/tracing/integrations/stalltracking.js +7 -7
- package/dist/js/tracing/integrations/stalltracking.js.map +1 -1
- package/dist/js/tracing/integrations/timeToDisplayIntegration.js +11 -11
- package/dist/js/tracing/integrations/timeToDisplayIntegration.js.map +1 -1
- package/dist/js/tracing/integrations/userInteraction.js +8 -8
- package/dist/js/tracing/integrations/userInteraction.js.map +1 -1
- package/dist/js/tracing/onSpanEndUtils.js +10 -10
- package/dist/js/tracing/onSpanEndUtils.js.map +1 -1
- package/dist/js/tracing/reactnativeprofiler.js +2 -2
- package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
- package/dist/js/tracing/reactnavigation.js +14 -14
- package/dist/js/tracing/reactnavigation.js.map +1 -1
- package/dist/js/tracing/span.js +6 -6
- package/dist/js/tracing/span.js.map +1 -1
- package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
- package/dist/js/tracing/timetodisplay.js +20 -30
- package/dist/js/tracing/timetodisplay.js.map +1 -1
- package/dist/js/tracing/utils.js +2 -2
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/utils/environment.d.ts.map +1 -1
- package/dist/js/utils/environment.js +2 -1
- package/dist/js/utils/environment.js.map +1 -1
- package/dist/js/utils/safe.js +3 -3
- package/dist/js/utils/safe.js.map +1 -1
- package/dist/js/utils/worldwide.d.ts +1 -0
- package/dist/js/utils/worldwide.d.ts.map +1 -1
- package/dist/js/utils/worldwide.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts +1 -0
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +40 -26
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry+fetchNativeStack.m +101 -0
- package/ios/RNSentry.h +5 -0
- package/ios/RNSentry.mm +67 -77
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +15 -14
- package/plugin/build/withSentryAndroid.js +7 -7
- package/plugin/build/withSentryAndroidGradlePlugin.d.ts +3 -2
- package/plugin/build/withSentryAndroidGradlePlugin.js +11 -22
- package/scripts/expo-upload-sourcemaps.js +1 -1
- package/scripts/sentry_utils.rb +4 -0
- package/src/js/NativeRNSentry.ts +1 -0
- package/ts3.8/dist/js/NativeRNSentry.d.ts +1 -0
- package/ts3.8/dist/js/client.d.ts +2 -2
- package/ts3.8/dist/js/integrations/exports.d.ts +1 -0
- package/ts3.8/dist/js/integrations/logEnricherIntegration.d.ts +3 -0
- package/ts3.8/dist/js/options.d.ts +1 -1
- package/ts3.8/dist/js/utils/worldwide.d.ts +1 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/ts3.8/dist/js/wrapper.d.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tC,EACD,UAAU,oBACL,iBAAiB,CAAC,UAAU,GAEjC,mBAAmB,kCACd,iBAAiB,CAAC,UAAU,KAC/B,KAAK,EAAE,iBAAiB,KAE1B,QAAQ,kCACH,iBAAiB,CAAC,QAAQ,KAC7B,KAAK,EAAE,iBAAiB,KAE1B,YAAY,kCACP,iBAAiB,CAAC,YAAY,KACjC,WAAW,EAAE,oBAAoB,KAEnC,aAAa,kCACR,iBAAiB,CAAC,aAAa,KAClC,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,oBAAoB,KAEvC,uBAAuB,kCAClB,iBAAiB,CAAC,uBAAuB,KAC5C,eAAe,EAAE,oBAAoB,OAEvC,CAAC;AAEH,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,EAAE;QAClB,sDAAsD;QACtD,4DAA4D;QAC5D,KAAK,CAAC,GAAG,SAAS,CAAC,GAAG,UAAU,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;SAC9B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACX,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;KAC9C;AACH,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { logger } from '@sentry/core';\nimport * as React from 'react';\nimport {\n Animated,\n Image,\n Modal,\n Platform,\n Pressable,\n SafeAreaView,\n StyleSheet,\n Text,\n useColorScheme,\n View,\n} from 'react-native';\nimport { getDevServer } from '../integrations/debugsymbolicatorutils';\nimport { isExpo, isExpoGo, isWeb } from '../utils/environment';\nimport { bug as bugAnimation, hi as hiAnimation, thumbsup as thumbsupAnimation } from './animations';\nimport { nativeCrashExample, tryCatchExample, uncaughtErrorExample } from './examples';\nimport { bug as bugImage, hi as hiImage, thumbsup as thumbsupImage } from './images';\n\n/**\n * Wrapper to add Sentry Playground to your application\n * to test your Sentry React Native SDK setup.\n *\n * @example\n * ```tsx\n * import * as Sentry from '@sentry/react-native';\n * import { withSentryPlayground } from '@sentry/react-native/playground';\n *\n * function App() {\n * return <View>...</View>;\n * }\n *\n * export default withSentryPlayground(Sentry.wrap(App), {\n * projectId: '123456',\n * organizationSlug: 'my-org'\n * });\n * ```\n */\nexport const withSentryPlayground = <P extends object>(\n Component: React.ComponentType<P>,\n options: { projectId?: string; organizationSlug?: string } = {},\n): React.ComponentType<P> => {\n const Wrapper = (props: P): React.ReactElement => {\n return (\n <>\n <SentryPlayground projectId={options.projectId} organizationSlug={options.organizationSlug} />\n <Component {...props} />\n </>\n );\n };\n\n Wrapper.displayName = 'withSentryPlayground()';\n return Wrapper;\n};\n\nexport const SentryPlayground = ({\n projectId,\n organizationSlug,\n}: {\n projectId?: string;\n organizationSlug?: string;\n}): React.ReactElement => {\n const issuesStreamUrl =\n projectId && organizationSlug\n ? `https://${organizationSlug}.sentry.io/issues/?project=${projectId}&statsPeriod=1h`\n : 'https://sentry.io/';\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n const [show, setShow] = React.useState(true);\n const [animation, setAnimation] = React.useState('hi');\n\n const onAnimationPress = (): void => {\n switch (animation) {\n case 'hi':\n setAnimation('thumbsup');\n break;\n default:\n setAnimation('hi');\n }\n };\n\n const showOpenSentryButton = !isExpo();\n const isNativeCrashDisabled = isWeb() || isExpoGo() || __DEV__;\n\n const animationContainerYPosition = React.useRef(new Animated.Value(0)).current;\n\n const springAnimation = Animated.sequence([\n Animated.timing(animationContainerYPosition, {\n toValue: -50,\n duration: 300,\n useNativeDriver: true,\n }),\n Animated.spring(animationContainerYPosition, {\n toValue: 0,\n friction: 4,\n tension: 40,\n useNativeDriver: true,\n }),\n ]);\n\n const changeAnimationToBug = (func: () => void): void => {\n setAnimation('bug');\n springAnimation.start(() => {\n func();\n });\n };\n\n return (\n <Modal\n presentationStyle=\"formSheet\"\n visible={show}\n animationType=\"slide\"\n onRequestClose={() => {\n setShow(false);\n }}\n >\n <SafeAreaView style={styles.background}>\n <View style={styles.container}>\n <Text style={styles.welcomeText}>Welcome to Sentry Playground!</Text>\n <Animated.View\n style={{\n width: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n transform: [{ translateY: animationContainerYPosition }],\n }}\n onTouchEnd={() => {\n springAnimation.start();\n }}\n >\n <Pressable onPress={onAnimationPress}>\n <Animation id={animation} />\n </Pressable>\n </Animated.View>\n <View style={styles.listContainer}>\n <Row\n title={'captureException()'}\n description={'In a try-catch scenario, errors can be reported using manual APIs.'}\n actionDescription={'Try'}\n action={tryCatchExample}\n />\n <Row\n title={'throw new Error()'}\n description={'Uncaught errors are automatically reported by the React Native Global Handler.'}\n actionDescription={'Throw'}\n action={() => changeAnimationToBug(uncaughtErrorExample)}\n />\n <Row\n title={'throw RuntimeException()'}\n description={\n isNativeCrashDisabled\n ? 'For testing native crashes, build the mobile application in release mode.'\n : 'Unhandled errors in native layers such as Java, Objective-C, C, Swift, or Kotlin are automatically reported.'\n }\n actionDescription={'Crash'}\n action={nativeCrashExample}\n last\n disabled={isNativeCrashDisabled}\n />\n </View>\n <View style={{ marginTop: 40 }} />\n <View\n style={{\n width: '100%',\n flexDirection: 'row', // Arrange buttons horizontally\n justifyContent: 'space-evenly', // Space between buttons\n }}\n >\n {showOpenSentryButton && (\n <Button\n secondary\n title={'Open Sentry'}\n onPress={() => {\n openURLInBrowser(issuesStreamUrl);\n }}\n />\n )}\n <Button\n title={'Go to my App'}\n onPress={() => {\n setShow(false);\n }}\n />\n </View>\n </View>\n </SafeAreaView>\n </Modal>\n );\n};\n\nconst Animation = ({ id }: { id: string }): React.ReactElement | null => {\n const shouldFallbackToImage = Platform.OS === 'android';\n\n switch (id) {\n case 'hi':\n return (\n <Image source={{ uri: shouldFallbackToImage ? hiImage : hiAnimation }} style={{ width: 100, height: 100 }} />\n );\n case 'bug':\n return (\n <Image source={{ uri: shouldFallbackToImage ? bugImage : bugAnimation }} style={{ width: 100, height: 100 }} />\n );\n case 'thumbsup':\n return (\n <Image\n source={{ uri: shouldFallbackToImage ? thumbsupImage : thumbsupAnimation }}\n style={{ width: 100, height: 100 }}\n />\n );\n default:\n return null;\n }\n};\n\nconst Row = ({\n last = false,\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n action = () => {},\n actionDescription = '',\n title,\n description,\n disabled = false,\n}: {\n last?: boolean;\n action?: () => void;\n actionDescription?: string;\n title: string;\n description: string;\n disabled?: boolean;\n}): React.ReactElement => {\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n return (\n <View style={[styles.rowContainer, last && styles.lastRowContainer]}>\n <View style={{ flexShrink: 1, paddingRight: 12 }}>\n <Text style={styles.rowTitle}>{title}</Text>\n <Text style={{ color: 'rgb(146, 130, 170)', fontSize: 12 }}>{description}</Text>\n </View>\n <View>\n <Button disabled={disabled} secondary onPress={action} title={actionDescription} />\n </View>\n </View>\n );\n};\n\nconst Button = ({\n onPress,\n title,\n secondary,\n disabled = false,\n}: {\n onPress: () => void;\n title: string;\n secondary?: boolean;\n disabled?: boolean;\n}): React.ReactElement => {\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n return (\n <View style={[styles.buttonBottomLayer, styles.buttonCommon, secondary && styles.buttonSecondaryBottomLayer]}>\n <Pressable\n style={({ pressed }) => [\n styles.buttonMainContainer,\n pressed && styles.buttonMainContainerPressed,\n styles.buttonCommon,\n secondary && styles.buttonSecondaryContainer,\n disabled && styles.buttonDisabledContainer,\n ]}\n onPress={onPress}\n disabled={disabled}\n >\n <Text\n style={[styles.buttonText, secondary && styles.buttonSecondaryText, disabled && styles.buttonDisabledText]}\n >\n {title}\n </Text>\n </Pressable>\n </View>\n );\n};\n\nconst defaultDarkStyles = StyleSheet.create({\n welcomeText: { color: 'rgb(246, 245, 250)', fontSize: 24, fontWeight: 'bold' },\n background: {\n flex: 1,\n backgroundColor: 'rgb(26, 20, 31)',\n width: '100%',\n minHeight: '100%',\n alignItems: 'center', // Center content horizontally\n justifyContent: 'center', // Center content vertically\n },\n container: {\n flex: 1,\n flexDirection: 'column',\n padding: 12,\n marginTop: 20,\n width: '100%',\n alignItems: 'center', // Center image and button container\n justifyContent: 'space-evenly', // Center image and button container\n },\n buttonContainer: {\n flexDirection: 'row', // Arrange buttons horizontally\n marginTop: 20, // Add some space above the buttons\n },\n listContainer: {\n backgroundColor: 'rgb(39, 36, 51)',\n width: '100%',\n flexDirection: 'column',\n marginTop: 20, // Add some space above the buttons\n borderColor: 'rgb(7, 5, 15)',\n borderWidth: 1,\n borderRadius: 8,\n },\n rowTitle: {\n color: 'rgb(246, 245, 250)',\n fontSize: 14,\n fontWeight: 'bold',\n textAlign: 'left',\n fontFamily: 'Menlo',\n },\n rowContainer: {\n overflow: 'hidden',\n flexDirection: 'row',\n justifyContent: 'space-between', // Space between buttons\n paddingTop: 16,\n paddingBottom: 10,\n paddingHorizontal: 10,\n borderColor: 'rgb(7, 5, 15)',\n borderBottomWidth: 1,\n },\n lastRowContainer: {\n borderBottomWidth: 0, // Remove border for the last row\n },\n buttonCommon: {\n borderRadius: 8,\n },\n buttonBottomLayer: {\n backgroundColor: 'rgb(7, 5, 15)',\n },\n buttonMainContainer: {\n paddingVertical: 8,\n paddingHorizontal: 13,\n backgroundColor: 'rgb(117, 83, 255)',\n transform: [{ translateY: -4 }],\n borderWidth: 1,\n borderColor: 'rgb(7, 5, 15)',\n },\n buttonSecondaryContainer: {\n backgroundColor: 'rgb(39, 36, 51)',\n },\n buttonSecondaryBottomLayer: {},\n buttonSecondaryText: {},\n buttonMainContainerPressed: {\n transform: [{ translateY: 0 }],\n },\n buttonText: {\n color: 'rgb(246, 245, 250)',\n fontSize: 16,\n fontWeight: 'bold',\n textAlign: 'center',\n },\n buttonDisabledText: {\n color: 'rgb(146, 130, 170)',\n },\n buttonDisabledContainer: {\n transform: [{ translateY: -2 }],\n backgroundColor: 'rgb(39, 36, 51)',\n },\n});\n\nconst lightStyles: typeof defaultDarkStyles = StyleSheet.create({\n ...defaultDarkStyles,\n welcomeText: {\n ...defaultDarkStyles.welcomeText,\n color: 'rgb(24, 20, 35)',\n },\n background: {\n ...defaultDarkStyles.background,\n backgroundColor: 'rgb(251, 250, 255)',\n },\n buttonMainContainer: {\n ...defaultDarkStyles.buttonMainContainer,\n backgroundColor: 'rgb(117, 83, 255)',\n borderColor: 'rgb(85, 61, 184)',\n },\n buttonBottomLayer: {\n backgroundColor: 'rgb(85, 61, 184)',\n },\n buttonSecondaryContainer: {\n backgroundColor: 'rgb(255, 255, 255)',\n borderColor: 'rgb(218, 215, 229)',\n },\n buttonSecondaryBottomLayer: {\n backgroundColor: 'rgb(218, 215, 229)',\n },\n buttonText: {\n ...defaultDarkStyles.buttonText,\n },\n buttonSecondaryText: {\n ...defaultDarkStyles.buttonText,\n color: 'rgb(24, 20, 35)',\n },\n rowTitle: {\n ...defaultDarkStyles.rowTitle,\n color: 'rgb(24, 20, 35)',\n },\n rowContainer: {\n ...defaultDarkStyles.rowContainer,\n borderColor: 'rgb(218, 215, 229)',\n },\n listContainer: {\n ...defaultDarkStyles.listContainer,\n borderColor: 'rgb(218, 215, 229)',\n backgroundColor: 'rgb(255, 255, 255)',\n },\n buttonDisabledContainer: {\n ...defaultDarkStyles.buttonDisabledContainer,\n backgroundColor: 'rgb(238, 235, 249)',\n },\n});\n\nfunction openURLInBrowser(url: string): void {\n const devServer = getDevServer();\n if (devServer?.url) {\n // This doesn't work for Expo project with Web enabled\n // disable-next-line @typescript-eslint/no-floating-promises\n fetch(`${devServer.url}open-url`, {\n method: 'POST',\n body: JSON.stringify({ url }),\n }).catch(e => {\n logger.error('Error opening URL:', e);\n });\n } else {\n logger.error('Dev server URL not available');\n }\n}\n"]}
|
|
1
|
+
{"version":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jC,mBAAmB,kCACd,iBAAiB,CAAC,UAAU,KAC/B,KAAK,EAAE,iBAAiB,KAE1B,QAAQ,kCACH,iBAAiB,CAAC,QAAQ,KAC7B,KAAK,EAAE,iBAAiB,KAE1B,YAAY,kCACP,iBAAiB,CAAC,YAAY,KACjC,WAAW,EAAE,oBAAoB,KAEnC,aAAa,kCACR,iBAAiB,CAAC,aAAa,KAClC,WAAW,EAAE,oBAAoB,EACjC,eAAe,EAAE,oBAAoB,KAEvC,uBAAuB,kCAClB,iBAAiB,CAAC,uBAAuB,KAC5C,eAAe,EAAE,oBAAoB,OAEvC,CAAC;AAEH,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,EAAE;QAClB,sDAAsD;QACtD,4DAA4D;QAC5D,KAAK,CAAC,GAAG,SAAS,CAAC,GAAG,UAAU,EAAE;YAChC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;SAC9B,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACX,KAAK,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;KAC7C;AACH,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport { debug } from '@sentry/core';\nimport * as React from 'react';\nimport {\n Animated,\n Image,\n Modal,\n Platform,\n Pressable,\n SafeAreaView,\n StyleSheet,\n Text,\n useColorScheme,\n View,\n} from 'react-native';\nimport { getDevServer } from '../integrations/debugsymbolicatorutils';\nimport { isExpo, isExpoGo, isWeb } from '../utils/environment';\nimport { bug as bugAnimation, hi as hiAnimation, thumbsup as thumbsupAnimation } from './animations';\nimport { nativeCrashExample, tryCatchExample, uncaughtErrorExample } from './examples';\nimport { bug as bugImage, hi as hiImage, thumbsup as thumbsupImage } from './images';\n\n/**\n * Wrapper to add Sentry Playground to your application\n * to test your Sentry React Native SDK setup.\n *\n * @example\n * ```tsx\n * import * as Sentry from '@sentry/react-native';\n * import { withSentryPlayground } from '@sentry/react-native/playground';\n *\n * function App() {\n * return <View>...</View>;\n * }\n *\n * export default withSentryPlayground(Sentry.wrap(App), {\n * projectId: '123456',\n * organizationSlug: 'my-org'\n * });\n * ```\n */\nexport const withSentryPlayground = <P extends object>(\n Component: React.ComponentType<P>,\n options: { projectId?: string; organizationSlug?: string } = {},\n): React.ComponentType<P> => {\n const Wrapper = (props: P): React.ReactElement => {\n return (\n <>\n <SentryPlayground projectId={options.projectId} organizationSlug={options.organizationSlug} />\n <Component {...props} />\n </>\n );\n };\n\n Wrapper.displayName = 'withSentryPlayground()';\n return Wrapper;\n};\n\nexport const SentryPlayground = ({\n projectId,\n organizationSlug,\n}: {\n projectId?: string;\n organizationSlug?: string;\n}): React.ReactElement => {\n const issuesStreamUrl =\n projectId && organizationSlug\n ? `https://${organizationSlug}.sentry.io/issues/?project=${projectId}&statsPeriod=1h`\n : 'https://sentry.io/';\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n const [show, setShow] = React.useState(true);\n const [animation, setAnimation] = React.useState('hi');\n\n const onAnimationPress = (): void => {\n switch (animation) {\n case 'hi':\n setAnimation('thumbsup');\n break;\n default:\n setAnimation('hi');\n }\n };\n\n const showOpenSentryButton = !isExpo();\n const isNativeCrashDisabled = isWeb() || isExpoGo() || __DEV__;\n\n const animationContainerYPosition = React.useRef(new Animated.Value(0)).current;\n\n const springAnimation = Animated.sequence([\n Animated.timing(animationContainerYPosition, {\n toValue: -50,\n duration: 300,\n useNativeDriver: true,\n }),\n Animated.spring(animationContainerYPosition, {\n toValue: 0,\n friction: 4,\n tension: 40,\n useNativeDriver: true,\n }),\n ]);\n\n const changeAnimationToBug = (func: () => void): void => {\n setAnimation('bug');\n springAnimation.start(() => {\n func();\n });\n };\n\n return (\n <Modal\n presentationStyle=\"formSheet\"\n visible={show}\n animationType=\"slide\"\n onRequestClose={() => {\n setShow(false);\n }}\n >\n <SafeAreaView style={styles.background}>\n <View style={styles.container}>\n <Text style={styles.welcomeText}>Welcome to Sentry Playground!</Text>\n <Animated.View\n style={{\n width: '100%',\n alignItems: 'center',\n justifyContent: 'center',\n transform: [{ translateY: animationContainerYPosition }],\n }}\n onTouchEnd={() => {\n springAnimation.start();\n }}\n >\n <Pressable onPress={onAnimationPress}>\n <Animation id={animation} />\n </Pressable>\n </Animated.View>\n <View style={styles.listContainer}>\n <Row\n title={'captureException()'}\n description={'In a try-catch scenario, errors can be reported using manual APIs.'}\n actionDescription={'Try'}\n action={tryCatchExample}\n />\n <Row\n title={'throw new Error()'}\n description={'Uncaught errors are automatically reported by the React Native Global Handler.'}\n actionDescription={'Throw'}\n action={() => changeAnimationToBug(uncaughtErrorExample)}\n />\n <Row\n title={'throw RuntimeException()'}\n description={\n isNativeCrashDisabled\n ? 'For testing native crashes, build the mobile application in release mode.'\n : 'Unhandled errors in native layers such as Java, Objective-C, C, Swift, or Kotlin are automatically reported.'\n }\n actionDescription={'Crash'}\n action={nativeCrashExample}\n last\n disabled={isNativeCrashDisabled}\n />\n </View>\n <View style={{ marginTop: 40 }} />\n <View\n style={{\n width: '100%',\n flexDirection: 'row', // Arrange buttons horizontally\n justifyContent: 'space-evenly', // Space between buttons\n }}\n >\n {showOpenSentryButton && (\n <Button\n secondary\n title={'Open Sentry'}\n onPress={() => {\n openURLInBrowser(issuesStreamUrl);\n }}\n />\n )}\n <Button\n title={'Go to my App'}\n onPress={() => {\n setShow(false);\n }}\n />\n </View>\n </View>\n </SafeAreaView>\n </Modal>\n );\n};\n\nconst Animation = ({ id }: { id: string }): React.ReactElement | null => {\n const shouldFallbackToImage = Platform.OS === 'android';\n\n switch (id) {\n case 'hi':\n return (\n <Image source={{ uri: shouldFallbackToImage ? hiImage : hiAnimation }} style={{ width: 100, height: 100 }} />\n );\n case 'bug':\n return (\n <Image source={{ uri: shouldFallbackToImage ? bugImage : bugAnimation }} style={{ width: 100, height: 100 }} />\n );\n case 'thumbsup':\n return (\n <Image\n source={{ uri: shouldFallbackToImage ? thumbsupImage : thumbsupAnimation }}\n style={{ width: 100, height: 100 }}\n />\n );\n default:\n return null;\n }\n};\n\nconst Row = ({\n last = false,\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n action = () => {},\n actionDescription = '',\n title,\n description,\n disabled = false,\n}: {\n last?: boolean;\n action?: () => void;\n actionDescription?: string;\n title: string;\n description: string;\n disabled?: boolean;\n}): React.ReactElement => {\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n return (\n <View style={[styles.rowContainer, last && styles.lastRowContainer]}>\n <View style={{ flexShrink: 1, paddingRight: 12 }}>\n <Text style={styles.rowTitle}>{title}</Text>\n <Text style={{ color: 'rgb(146, 130, 170)', fontSize: 12 }}>{description}</Text>\n </View>\n <View>\n <Button disabled={disabled} secondary onPress={action} title={actionDescription} />\n </View>\n </View>\n );\n};\n\nconst Button = ({\n onPress,\n title,\n secondary,\n disabled = false,\n}: {\n onPress: () => void;\n title: string;\n secondary?: boolean;\n disabled?: boolean;\n}): React.ReactElement => {\n const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;\n\n return (\n <View style={[styles.buttonBottomLayer, styles.buttonCommon, secondary && styles.buttonSecondaryBottomLayer]}>\n <Pressable\n style={({ pressed }) => [\n styles.buttonMainContainer,\n pressed && styles.buttonMainContainerPressed,\n styles.buttonCommon,\n secondary && styles.buttonSecondaryContainer,\n disabled && styles.buttonDisabledContainer,\n ]}\n onPress={onPress}\n disabled={disabled}\n >\n <Text\n style={[styles.buttonText, secondary && styles.buttonSecondaryText, disabled && styles.buttonDisabledText]}\n >\n {title}\n </Text>\n </Pressable>\n </View>\n );\n};\n\nconst defaultDarkStyles = StyleSheet.create({\n welcomeText: { color: 'rgb(246, 245, 250)', fontSize: 24, fontWeight: 'bold' },\n background: {\n flex: 1,\n backgroundColor: 'rgb(26, 20, 31)',\n width: '100%',\n minHeight: '100%',\n alignItems: 'center', // Center content horizontally\n justifyContent: 'center', // Center content vertically\n },\n container: {\n flex: 1,\n flexDirection: 'column',\n padding: 12,\n marginTop: 20,\n width: '100%',\n alignItems: 'center', // Center image and button container\n justifyContent: 'space-evenly', // Center image and button container\n },\n buttonContainer: {\n flexDirection: 'row', // Arrange buttons horizontally\n marginTop: 20, // Add some space above the buttons\n },\n listContainer: {\n backgroundColor: 'rgb(39, 36, 51)',\n width: '100%',\n flexDirection: 'column',\n marginTop: 20, // Add some space above the buttons\n borderColor: 'rgb(7, 5, 15)',\n borderWidth: 1,\n borderRadius: 8,\n },\n rowTitle: {\n color: 'rgb(246, 245, 250)',\n fontSize: 14,\n fontWeight: 'bold',\n textAlign: 'left',\n fontFamily: 'Menlo',\n },\n rowContainer: {\n overflow: 'hidden',\n flexDirection: 'row',\n justifyContent: 'space-between', // Space between buttons\n paddingTop: 16,\n paddingBottom: 10,\n paddingHorizontal: 10,\n borderColor: 'rgb(7, 5, 15)',\n borderBottomWidth: 1,\n },\n lastRowContainer: {\n borderBottomWidth: 0, // Remove border for the last row\n },\n buttonCommon: {\n borderRadius: 8,\n },\n buttonBottomLayer: {\n backgroundColor: 'rgb(7, 5, 15)',\n },\n buttonMainContainer: {\n paddingVertical: 8,\n paddingHorizontal: 13,\n backgroundColor: 'rgb(117, 83, 255)',\n transform: [{ translateY: -4 }],\n borderWidth: 1,\n borderColor: 'rgb(7, 5, 15)',\n },\n buttonSecondaryContainer: {\n backgroundColor: 'rgb(39, 36, 51)',\n },\n buttonSecondaryBottomLayer: {},\n buttonSecondaryText: {},\n buttonMainContainerPressed: {\n transform: [{ translateY: 0 }],\n },\n buttonText: {\n color: 'rgb(246, 245, 250)',\n fontSize: 16,\n fontWeight: 'bold',\n textAlign: 'center',\n },\n buttonDisabledText: {\n color: 'rgb(146, 130, 170)',\n },\n buttonDisabledContainer: {\n transform: [{ translateY: -2 }],\n backgroundColor: 'rgb(39, 36, 51)',\n },\n});\n\nconst lightStyles: typeof defaultDarkStyles = StyleSheet.create({\n ...defaultDarkStyles,\n welcomeText: {\n ...defaultDarkStyles.welcomeText,\n color: 'rgb(24, 20, 35)',\n },\n background: {\n ...defaultDarkStyles.background,\n backgroundColor: 'rgb(251, 250, 255)',\n },\n buttonMainContainer: {\n ...defaultDarkStyles.buttonMainContainer,\n backgroundColor: 'rgb(117, 83, 255)',\n borderColor: 'rgb(85, 61, 184)',\n },\n buttonBottomLayer: {\n backgroundColor: 'rgb(85, 61, 184)',\n },\n buttonSecondaryContainer: {\n backgroundColor: 'rgb(255, 255, 255)',\n borderColor: 'rgb(218, 215, 229)',\n },\n buttonSecondaryBottomLayer: {\n backgroundColor: 'rgb(218, 215, 229)',\n },\n buttonText: {\n ...defaultDarkStyles.buttonText,\n },\n buttonSecondaryText: {\n ...defaultDarkStyles.buttonText,\n color: 'rgb(24, 20, 35)',\n },\n rowTitle: {\n ...defaultDarkStyles.rowTitle,\n color: 'rgb(24, 20, 35)',\n },\n rowContainer: {\n ...defaultDarkStyles.rowContainer,\n borderColor: 'rgb(218, 215, 229)',\n },\n listContainer: {\n ...defaultDarkStyles.listContainer,\n borderColor: 'rgb(218, 215, 229)',\n backgroundColor: 'rgb(255, 255, 255)',\n },\n buttonDisabledContainer: {\n ...defaultDarkStyles.buttonDisabledContainer,\n backgroundColor: 'rgb(238, 235, 249)',\n },\n});\n\nfunction openURLInBrowser(url: string): void {\n const devServer = getDevServer();\n if (devServer?.url) {\n // This doesn't work for Expo project with Web enabled\n // disable-next-line @typescript-eslint/no-floating-promises\n fetch(`${devServer.url}open-url`, {\n method: 'POST',\n body: JSON.stringify({ url }),\n }).catch(e => {\n debug.error('Error opening URL:', e);\n });\n } else {\n debug.error('Dev server URL not available');\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debug } from '@sentry/core';
|
|
2
2
|
import { MAX_PROFILE_DURATION_MS } from './constants';
|
|
3
3
|
import { DEFAULT_BUNDLE_NAME } from './hermes';
|
|
4
4
|
const PLACEHOLDER_THREAD_ID_STRING = '0';
|
|
@@ -20,7 +20,7 @@ const JS_THREAD_PRIORITY = 1;
|
|
|
20
20
|
*/
|
|
21
21
|
export function convertToSentryProfile(hermesProfile) {
|
|
22
22
|
if (hermesProfile.samples.length === 0) {
|
|
23
|
-
|
|
23
|
+
debug.warn('[Profiling] No samples found in profile.');
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);
|
|
@@ -29,7 +29,7 @@ export function convertToSentryProfile(hermesProfile) {
|
|
|
29
29
|
for (const sample of samples) {
|
|
30
30
|
const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);
|
|
31
31
|
if (sentryStackId === undefined) {
|
|
32
|
-
|
|
32
|
+
debug.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);
|
|
33
33
|
sample.stack_id = UNKNOWN_STACK_ID;
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
@@ -64,7 +64,7 @@ export function mapSamples(hermesSamples, maxElapsedSinceStartNs = MAX_PROFILE_D
|
|
|
64
64
|
const hermesStacks = new Set();
|
|
65
65
|
const firstSample = hermesSamples[0];
|
|
66
66
|
if (!firstSample) {
|
|
67
|
-
|
|
67
|
+
debug.warn('[Profiling] No samples found in profile.');
|
|
68
68
|
return {
|
|
69
69
|
samples,
|
|
70
70
|
hermesStacks,
|
|
@@ -77,7 +77,7 @@ export function mapSamples(hermesSamples, maxElapsedSinceStartNs = MAX_PROFILE_D
|
|
|
77
77
|
hermesStacks.add(hermesSample.sf);
|
|
78
78
|
const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;
|
|
79
79
|
if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {
|
|
80
|
-
|
|
80
|
+
debug.warn(`[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +
|
|
81
81
|
`greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`);
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA6B;IAClE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE/E,MAAM,EAAE,MAAM,EAAE,oCAAoC,EAAE,GAAG,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAE9F,MAAM,EAAE,MAAM,EAAE,2BAA2B,EAAE,GAAG,SAAS,CACvD,YAAY,EACZ,aAAa,CAAC,WAAW,EACzB,oCAAoC,CACrC,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,MAAM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AI;YACpB,QAAQ,EAAE,mBAAmB;YAC7B,mJAAmJ;YACnJ,0HAA0H;YAC1H,MAAM,EAAE,CAAC;YACT,mDAAmD;YACnD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;SAC7D,CAAC;KACH;IAED,aAAa;IACb,MAAM,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO;QACL,QAAQ,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;QACnH,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACjE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/core';\nimport { logger } from '@sentry/core';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport type * as Hermes from './hermes';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\nimport type { RawThreadCpuProfile } from './types';\n\nconst PLACEHOLDER_THREAD_ID_STRING = '0';\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n logger.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n logger.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n active_thread_id,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const samples: ThreadCpuSample[] = [];\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const firstSample = hermesSamples[0];\n if (!firstSample) {\n logger.warn('[Profiling] No samples found in profile.');\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n }\n\n const start = Number(firstSample.ts);\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n logger.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n\n const hermesStackFrame = hermesStackFrames[key];\n if (hermesStackFrame) {\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n frames.push(parseHermesJSStackFrame(hermesStackFrame));\n }\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId]?.parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n\n/**\n * Parses Hermes StackFrame to Sentry StackFrame.\n * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.\n */\nexport function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame {\n if (frame.category !== 'JavaScript') {\n // Native\n if (frame.name === '[root]') {\n return { function: frame.name, in_app: false };\n }\n return { function: frame.name };\n }\n\n if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {\n // Hermes Bytecode\n return {\n function: frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n // https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301\n // Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.\n lineno: 1,\n // Hermes colno is 0-based, while Sentry is 1-based\n colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,\n };\n }\n\n // JavaScript\n const indexOfLeftParenthesis = frame.name.indexOf('(');\n return {\n function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n lineno: frame.line !== undefined ? Number(frame.line) : undefined,\n colno: frame.column !== undefined ? Number(frame.column) : undefined,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA6B;IAClE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,KAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,C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AE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;SAChD;QACD,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;KACjC;IAED,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;QAClE,kBAAkB;QAClB,OAAO;YACL,QAAQ,EAAE,KAAK,CAAC,IAAI;YACpB,QAAQ,EAAE,mBAAmB;YAC7B,mJAAmJ;YACnJ,0HAA0H;YAC1H,MAAM,EAAE,CAAC;YACT,mDAAmD;YACnD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;SAC7D,CAAC;KACH;IAED,aAAa;IACb,MAAM,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO;QACL,QAAQ,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;QACnH,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACjE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/core';\nimport { debug } from '@sentry/core';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport type * as Hermes from './hermes';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\nimport type { RawThreadCpuProfile } from './types';\n\nconst PLACEHOLDER_THREAD_ID_STRING = '0';\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n debug.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n debug.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n active_thread_id,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const samples: ThreadCpuSample[] = [];\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const firstSample = hermesSamples[0];\n if (!firstSample) {\n debug.warn('[Profiling] No samples found in profile.');\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n }\n\n const start = Number(firstSample.ts);\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n debug.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n\n const hermesStackFrame = hermesStackFrames[key];\n if (hermesStackFrame) {\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n frames.push(parseHermesJSStackFrame(hermesStackFrame));\n }\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId]?.parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n\n/**\n * Parses Hermes StackFrame to Sentry StackFrame.\n * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.\n */\nexport function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame {\n if (frame.category !== 'JavaScript') {\n // Native\n if (frame.name === '[root]') {\n return { function: frame.name, in_app: false };\n }\n return { function: frame.name };\n }\n\n if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {\n // Hermes Bytecode\n return {\n function: frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n // https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301\n // Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.\n lineno: 1,\n // Hermes colno is 0-based, while Sentry is 1-based\n colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,\n };\n }\n\n // JavaScript\n const indexOfLeftParenthesis = frame.name.indexOf('(');\n return {\n function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n lineno: frame.line !== undefined ? Number(frame.line) : undefined,\n colno: frame.column !== undefined ? Number(frame.column) : undefined,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugid.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/debugid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"debugid.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/debugid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,EAAE,CAoC/C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debug, GLOBAL_OBJ } from '@sentry/core';
|
|
2
2
|
import { DEFAULT_BUNDLE_NAME } from './hermes';
|
|
3
3
|
/**
|
|
4
4
|
* Returns debug meta images of the loaded bundle.
|
|
@@ -16,7 +16,7 @@ export function getDebugMetadata() {
|
|
|
16
16
|
return [];
|
|
17
17
|
}
|
|
18
18
|
if (debugIdsKeys.length > 1) {
|
|
19
|
-
|
|
19
|
+
debug.warn('[Profiling] Multiple debug images found, but only one one bundle is supported. Using the first one...');
|
|
20
20
|
return [];
|
|
21
21
|
}
|
|
22
22
|
if (!debugIdsKeys[0]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugid.js","sourceRoot":"","sources":["../../../src/js/profiling/debugid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"debugid.js","sourceRoot":"","sources":["../../../src/js/profiling/debugid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,EAAE,CAAC;KACX;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACxB,OAAO,EAAE,CAAC;KACX;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,KAAK,CAAC,IAAI,CAAC,uGAAuG,CAAC,CAAC;QACpH,OAAO,EAAE,CAAC;KACX;IAED,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;QACpB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;IAED,OAAO;QACL;YACE,SAAS,EAAE,mBAAmB;YAC9B,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,WAAW;SAClB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { DebugImage } from '@sentry/core';\nimport { debug, GLOBAL_OBJ } from '@sentry/core';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\n\n/**\n * Returns debug meta images of the loaded bundle.\n */\nexport function getDebugMetadata(): DebugImage[] {\n if (!DEFAULT_BUNDLE_NAME) {\n return [];\n }\n\n const debugIdMap = GLOBAL_OBJ._sentryDebugIds;\n if (!debugIdMap) {\n return [];\n }\n\n const debugIdsKeys = Object.keys(debugIdMap);\n if (!debugIdsKeys.length) {\n return [];\n }\n\n if (debugIdsKeys.length > 1) {\n debug.warn('[Profiling] Multiple debug images found, but only one one bundle is supported. Using the first one...');\n return [];\n }\n\n if (!debugIdsKeys[0]) {\n return [];\n }\n\n const debugId = debugIdMap[debugIdsKeys[0]];\n if (!debugId) {\n return [];\n }\n\n return [\n {\n code_file: DEFAULT_BUNDLE_NAME,\n debug_id: debugId,\n type: 'sourcemap',\n },\n ];\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getActiveSpan, getClient,
|
|
1
|
+
import { debug, getActiveSpan, getClient, spanIsSampled, uuid4 } from '@sentry/core';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import { isHermesEnabled } from '../utils/environment';
|
|
4
4
|
import { isRootSpan } from '../utils/span';
|
|
@@ -29,7 +29,7 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
29
29
|
}
|
|
30
30
|
isReady = true;
|
|
31
31
|
if (!isHermesEnabled()) {
|
|
32
|
-
|
|
32
|
+
debug.log('[Profiling] Hermes is not enabled, not adding profiling integration.');
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const client = getClient();
|
|
@@ -45,7 +45,7 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
45
45
|
}
|
|
46
46
|
const profiledTransactions = findProfiledTransactionsFromEnvelope(envelope);
|
|
47
47
|
if (!profiledTransactions.length) {
|
|
48
|
-
|
|
48
|
+
debug.log('[Profiling] no profiled transactions found in envelope');
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
const profilesToAddToEnvelope = [];
|
|
@@ -80,19 +80,19 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
80
80
|
const _shouldStartProfiling = (activeSpan) => {
|
|
81
81
|
var _a;
|
|
82
82
|
if (!spanIsSampled(activeSpan)) {
|
|
83
|
-
|
|
83
|
+
debug.log('[Profiling] Transaction is not sampled, skipping profiling');
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
const client = getClient();
|
|
87
87
|
const options = (_a = client === null || client === void 0 ? void 0 : client.getOptions) === null || _a === void 0 ? void 0 : _a.call(client);
|
|
88
88
|
const profilesSampleRate = options && typeof options.profilesSampleRate === 'number' ? options.profilesSampleRate : undefined;
|
|
89
89
|
if (profilesSampleRate === undefined) {
|
|
90
|
-
|
|
90
|
+
debug.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');
|
|
91
91
|
return false;
|
|
92
92
|
}
|
|
93
93
|
// Check if we should sample this profile
|
|
94
94
|
if (Math.random() > profilesSampleRate) {
|
|
95
|
-
|
|
95
|
+
debug.log('[Profiling] Skip profiling transaction due to sampling.');
|
|
96
96
|
return false;
|
|
97
97
|
}
|
|
98
98
|
return true;
|
|
@@ -111,7 +111,7 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
111
111
|
startTimestampNs: profileStartTimestampNs,
|
|
112
112
|
};
|
|
113
113
|
activeSpan.setAttribute('profile_id', _currentProfile.profile_id);
|
|
114
|
-
|
|
114
|
+
debug.log('[Profiling] started profiling: ', _currentProfile.profile_id);
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
117
|
* Stops current profile if the ending span is the currently profiled span.
|
|
@@ -121,7 +121,7 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
if (span.spanContext().spanId !== (_currentProfile === null || _currentProfile === void 0 ? void 0 : _currentProfile.span_id)) {
|
|
124
|
-
|
|
124
|
+
debug.log(`[Profiling] Span (${span.spanContext().spanId}) ended is not the currently profiled span (${_currentProfile === null || _currentProfile === void 0 ? void 0 : _currentProfile.span_id}). Not stopping profiling.`);
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
127
|
_finishCurrentProfile();
|
|
@@ -136,19 +136,19 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
136
136
|
}
|
|
137
137
|
const profile = stopProfiling(_currentProfile.startTimestampNs);
|
|
138
138
|
if (!profile) {
|
|
139
|
-
|
|
139
|
+
debug.warn('[Profiling] Stop failed. Cleaning up...');
|
|
140
140
|
_currentProfile = undefined;
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
PROFILE_QUEUE.add(_currentProfile.profile_id, profile);
|
|
144
|
-
|
|
144
|
+
debug.log('[Profiling] finished profiling: ', _currentProfile.profile_id);
|
|
145
145
|
_currentProfile = undefined;
|
|
146
146
|
};
|
|
147
147
|
const _createProfileEventFor = (profiledTransaction) => {
|
|
148
148
|
var _a, _b, _c, _d, _e, _f;
|
|
149
149
|
const profile_id = (_c = (_b = (_a = profiledTransaction === null || profiledTransaction === void 0 ? void 0 : profiledTransaction.contexts) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.profile_id;
|
|
150
150
|
if (typeof profile_id !== 'string') {
|
|
151
|
-
|
|
151
|
+
debug.log('[Profiling] cannot find profile for a transaction without a profile context');
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
154
|
// Remove the profile from the transaction context before sending, relay will take care of the rest.
|
|
@@ -158,11 +158,11 @@ export const hermesProfilingIntegration = (initOptions = defaultOptions) => {
|
|
|
158
158
|
const profile = PROFILE_QUEUE.get(profile_id);
|
|
159
159
|
PROFILE_QUEUE.delete(profile_id);
|
|
160
160
|
if (!profile) {
|
|
161
|
-
|
|
161
|
+
debug.log(`[Profiling] cannot find profile ${profile_id} for transaction ${profiledTransaction.event_id}`);
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
164
|
const profileWithEvent = enrichCombinedProfileWithEventContext(profile_id, profile, profiledTransaction);
|
|
165
|
-
|
|
165
|
+
debug.log(`[Profiling] Created profile ${profile_id} for transaction ${profiledTransaction.event_id}`);
|
|
166
166
|
return profileWithEvent;
|
|
167
167
|
};
|
|
168
168
|
const _clearCurrentProfileTimeout = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/js/profiling/integration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,SAAS,CAAC;AAEjB,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,QAAQ,GAAW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ACV,MAAM,KACT,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,IACxC,CAAC;KACN,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Envelope, Event, Integration, Span, ThreadCpuProfile } from '@sentry/core';\nimport { getActiveSpan, getClient, logger, spanIsSampled, uuid4 } from '@sentry/core';\nimport { Platform } from 'react-native';\nimport type { ReactNativeClient } from '../client';\nimport { isHermesEnabled } from '../utils/environment';\nimport { isRootSpan } from '../utils/span';\nimport { NATIVE } from '../wrapper';\nimport { PROFILE_QUEUE } from './cache';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { NativeAndroidProfileEvent, NativeProfileEvent } from './nativeTypes';\nimport type { AndroidCombinedProfileEvent, CombinedProfileEvent, HermesProfileEvent, ProfileEvent } from './types';\nimport {\n addProfilesToEnvelope,\n createHermesProfilingEvent,\n enrichCombinedProfileWithEventContext,\n findProfiledTransactionsFromEnvelope,\n} from './utils';\n\nconst INTEGRATION_NAME = 'HermesProfiling';\n\nconst MS_TO_NS: number = 1e6;\n\nexport interface HermesProfilingOptions {\n /**\n * Enable or disable profiling of native (iOS and Android) threads\n *\n * @default true\n */\n platformProfilers?: boolean;\n}\n\nconst defaultOptions: Required<HermesProfilingOptions> = {\n platformProfilers: true,\n};\n\n/**\n * Profiling integration creates a profile for each transaction and adds it to the event envelope.\n *\n * @experimental\n */\nexport const hermesProfilingIntegration = (initOptions: HermesProfilingOptions = defaultOptions): Integration => {\n const usePlatformProfilers = initOptions.platformProfilers ?? true;\n let _currentProfile:\n | {\n span_id: string;\n profile_id: string;\n startTimestampNs: number;\n }\n | undefined;\n let _currentProfileTimeout: ReturnType<typeof setTimeout> | undefined;\n let isReady: boolean = false;\n\n const setupOnce = (): void => {\n if (isReady) {\n return;\n }\n isReady = true;\n\n if (!isHermesEnabled()) {\n logger.log('[Profiling] Hermes is not enabled, not adding profiling integration.');\n return;\n }\n\n const client = getClient();\n\n if (!client || typeof client.on !== 'function') {\n return;\n }\n\n _startCurrentProfileForActiveTransaction();\n client.on('spanStart', _startCurrentProfile);\n\n client.on('spanEnd', _finishCurrentProfileForSpan);\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (!PROFILE_QUEUE.size()) {\n return;\n }\n\n const profiledTransactions = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactions.length) {\n logger.log('[Profiling] no profiled transactions found in envelope');\n return;\n }\n\n const profilesToAddToEnvelope: ProfileEvent[] = [];\n for (const profiledTransaction of profiledTransactions) {\n const profile = _createProfileEventFor(profiledTransaction);\n if (profile) {\n profilesToAddToEnvelope.push(profile);\n }\n }\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n };\n\n const _startCurrentProfileForActiveTransaction = (): void => {\n if (_currentProfile) {\n return;\n }\n const activeSpan = getActiveSpan();\n activeSpan && _startCurrentProfile(activeSpan);\n };\n\n const _startCurrentProfile = (activeSpan: Span): void => {\n if (!isRootSpan(activeSpan)) {\n return;\n }\n\n _finishCurrentProfile();\n\n const shouldStartProfiling = _shouldStartProfiling(activeSpan);\n if (!shouldStartProfiling) {\n return;\n }\n\n _currentProfileTimeout = setTimeout(_finishCurrentProfile, MAX_PROFILE_DURATION_MS);\n _startNewProfile(activeSpan);\n };\n\n const _shouldStartProfiling = (activeSpan: Span): boolean => {\n if (!spanIsSampled(activeSpan)) {\n logger.log('[Profiling] Transaction is not sampled, skipping profiling');\n return false;\n }\n\n const client = getClient<ReactNativeClient>();\n const options = client?.getOptions?.();\n\n const profilesSampleRate =\n options && typeof options.profilesSampleRate === 'number' ? options.profilesSampleRate : undefined;\n if (profilesSampleRate === undefined) {\n logger.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');\n return false;\n }\n\n // Check if we should sample this profile\n if (Math.random() > profilesSampleRate) {\n logger.log('[Profiling] Skip profiling transaction due to sampling.');\n return false;\n }\n\n return true;\n };\n\n /**\n * Starts a new profile and links it to the transaction.\n */\n const _startNewProfile = (activeSpan: Span): void => {\n const profileStartTimestampNs = startProfiling(usePlatformProfilers);\n if (!profileStartTimestampNs) {\n return;\n }\n\n _currentProfile = {\n span_id: activeSpan.spanContext().spanId,\n profile_id: uuid4(),\n startTimestampNs: profileStartTimestampNs,\n };\n activeSpan.setAttribute('profile_id', _currentProfile.profile_id);\n logger.log('[Profiling] started profiling: ', _currentProfile.profile_id);\n };\n\n /**\n * Stops current profile if the ending span is the currently profiled span.\n */\n const _finishCurrentProfileForSpan = (span: Span): void => {\n if (!isRootSpan(span)) {\n return;\n }\n\n if (span.spanContext().spanId !== _currentProfile?.span_id) {\n logger.log(\n `[Profiling] Span (${span.spanContext().spanId}) ended is not the currently profiled span (${\n _currentProfile?.span_id\n }). Not stopping profiling.`,\n );\n return;\n }\n\n _finishCurrentProfile();\n };\n\n /**\n * Stops profiling and adds the profile to the queue to be processed on beforeEnvelope.\n */\n const _finishCurrentProfile = (): void => {\n _clearCurrentProfileTimeout();\n if (_currentProfile === undefined) {\n return;\n }\n\n const profile = stopProfiling(_currentProfile.startTimestampNs);\n if (!profile) {\n logger.warn('[Profiling] Stop failed. Cleaning up...');\n _currentProfile = undefined;\n return;\n }\n\n PROFILE_QUEUE.add(_currentProfile.profile_id, profile);\n\n logger.log('[Profiling] finished profiling: ', _currentProfile.profile_id);\n _currentProfile = undefined;\n };\n\n const _createProfileEventFor = (profiledTransaction: Event): ProfileEvent | null => {\n const profile_id = profiledTransaction?.contexts?.trace?.data?.profile_id;\n\n if (typeof profile_id !== 'string') {\n logger.log('[Profiling] cannot find profile for a transaction without a profile context');\n return null;\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profiledTransaction?.contexts?.trace?.data?.profile_id) {\n delete profiledTransaction.contexts.trace.data.profile_id;\n }\n\n const profile = PROFILE_QUEUE.get(profile_id);\n PROFILE_QUEUE.delete(profile_id);\n\n if (!profile) {\n logger.log(`[Profiling] cannot find profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n return null;\n }\n\n const profileWithEvent = enrichCombinedProfileWithEventContext(profile_id, profile, profiledTransaction);\n logger.log(`[Profiling] Created profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n\n return profileWithEvent;\n };\n\n const _clearCurrentProfileTimeout = (): void => {\n _currentProfileTimeout !== undefined && clearTimeout(_currentProfileTimeout);\n _currentProfileTimeout = undefined;\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce,\n };\n};\n\n/**\n * Starts Profilers and returns the timestamp when profiling started in nanoseconds.\n */\nexport function startProfiling(platformProfilers: boolean): number | null {\n const started = NATIVE.startProfiling(platformProfilers);\n if (!started) {\n return null;\n }\n\n return Date.now() * MS_TO_NS;\n}\n\n/**\n * Stops Profilers and returns collected combined profile.\n */\nexport function stopProfiling(\n profileStartTimestampNs: number,\n): CombinedProfileEvent | AndroidCombinedProfileEvent | null {\n const collectedProfiles = NATIVE.stopProfiling();\n if (!collectedProfiles) {\n return null;\n }\n const profileEndTimestampNs = Date.now() * MS_TO_NS;\n\n const hermesProfile = convertToSentryProfile(collectedProfiles.hermesProfile);\n if (!hermesProfile) {\n return null;\n }\n\n const hermesProfileEvent = createHermesProfilingEvent(hermesProfile);\n if (!hermesProfileEvent) {\n return null;\n }\n\n if (collectedProfiles.androidProfile) {\n const durationNs = profileEndTimestampNs - profileStartTimestampNs;\n return createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);\n } else if (collectedProfiles.nativeProfile) {\n return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);\n }\n\n return hermesProfileEvent;\n}\n\n/**\n * Creates Android profile event with attached javascript profile.\n */\nexport function createAndroidWithHermesProfile(\n hermes: HermesProfileEvent,\n nativeAndroid: NativeAndroidProfileEvent,\n durationNs: number,\n): AndroidCombinedProfileEvent {\n return {\n ...nativeAndroid,\n platform: 'android',\n js_profile: hermes.profile,\n duration_ns: durationNs.toString(10),\n active_thread_id: hermes.transaction.active_thread_id,\n };\n}\n\n/**\n * Merges Hermes and Native profile events into one.\n */\nexport function addNativeProfileToHermesProfile(\n hermes: HermesProfileEvent,\n native: NativeProfileEvent,\n): CombinedProfileEvent {\n return {\n ...hermes,\n profile: addNativeThreadCpuProfileToHermes(hermes.profile, native.profile, hermes.transaction.active_thread_id),\n ...(native.debug_meta?.images ? { debug_meta: { images: native.debug_meta.images } } : {}),\n measurements: native.measurements,\n };\n}\n\n/**\n * Merges Hermes And Native profiles into one.\n */\nexport function addNativeThreadCpuProfileToHermes(\n hermes: ThreadCpuProfile,\n native: ThreadCpuProfile,\n hermes_active_thread_id: string | undefined,\n): CombinedProfileEvent['profile'] {\n // assumes thread ids are unique\n hermes.thread_metadata = { ...native.thread_metadata, ...hermes.thread_metadata };\n // assumes queue ids are unique\n hermes.queue_metadata = { ...native.queue_metadata, ...hermes.queue_metadata };\n\n // recalculate frames and stacks using offset\n const framesOffset = hermes.frames.length;\n const stacksOffset = hermes.stacks.length;\n\n if (native.frames) {\n for (const frame of native.frames) {\n hermes.frames.push({\n function: frame.function,\n instruction_addr: frame.instruction_addr,\n platform: Platform.OS === 'ios' ? 'cocoa' : undefined,\n });\n }\n }\n hermes.stacks = [\n ...(hermes.stacks || []),\n ...(native.stacks || []).map(stack => stack.map(frameId => frameId + framesOffset)),\n ];\n hermes.samples = [\n ...(hermes.samples || []),\n ...(native.samples || [])\n .filter(sample => sample.thread_id !== hermes_active_thread_id)\n .map(sample => ({\n ...sample,\n stack_id: stacksOffset + sample.stack_id,\n })),\n ];\n\n return hermes;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/js/profiling/integration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAA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AI,EAAE,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;KACpF,CAAC;IACF,MAAM,CAAC,OAAO,GAAG;QACf,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACzB,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;aACtB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,KAAK,uBAAuB,CAAC;aAC9D,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,iCACV,MAAM,KACT,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,IACxC,CAAC;KACN,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Envelope, Event, Integration, Span, ThreadCpuProfile } from '@sentry/core';\nimport { debug, getActiveSpan, getClient, spanIsSampled, uuid4 } from '@sentry/core';\nimport { Platform } from 'react-native';\nimport type { ReactNativeClient } from '../client';\nimport { isHermesEnabled } from '../utils/environment';\nimport { isRootSpan } from '../utils/span';\nimport { NATIVE } from '../wrapper';\nimport { PROFILE_QUEUE } from './cache';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { NativeAndroidProfileEvent, NativeProfileEvent } from './nativeTypes';\nimport type { AndroidCombinedProfileEvent, CombinedProfileEvent, HermesProfileEvent, ProfileEvent } from './types';\nimport {\n addProfilesToEnvelope,\n createHermesProfilingEvent,\n enrichCombinedProfileWithEventContext,\n findProfiledTransactionsFromEnvelope,\n} from './utils';\n\nconst INTEGRATION_NAME = 'HermesProfiling';\n\nconst MS_TO_NS: number = 1e6;\n\nexport interface HermesProfilingOptions {\n /**\n * Enable or disable profiling of native (iOS and Android) threads\n *\n * @default true\n */\n platformProfilers?: boolean;\n}\n\nconst defaultOptions: Required<HermesProfilingOptions> = {\n platformProfilers: true,\n};\n\n/**\n * Profiling integration creates a profile for each transaction and adds it to the event envelope.\n *\n * @experimental\n */\nexport const hermesProfilingIntegration = (initOptions: HermesProfilingOptions = defaultOptions): Integration => {\n const usePlatformProfilers = initOptions.platformProfilers ?? true;\n let _currentProfile:\n | {\n span_id: string;\n profile_id: string;\n startTimestampNs: number;\n }\n | undefined;\n let _currentProfileTimeout: ReturnType<typeof setTimeout> | undefined;\n let isReady: boolean = false;\n\n const setupOnce = (): void => {\n if (isReady) {\n return;\n }\n isReady = true;\n\n if (!isHermesEnabled()) {\n debug.log('[Profiling] Hermes is not enabled, not adding profiling integration.');\n return;\n }\n\n const client = getClient();\n\n if (!client || typeof client.on !== 'function') {\n return;\n }\n\n _startCurrentProfileForActiveTransaction();\n client.on('spanStart', _startCurrentProfile);\n\n client.on('spanEnd', _finishCurrentProfileForSpan);\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (!PROFILE_QUEUE.size()) {\n return;\n }\n\n const profiledTransactions = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactions.length) {\n debug.log('[Profiling] no profiled transactions found in envelope');\n return;\n }\n\n const profilesToAddToEnvelope: ProfileEvent[] = [];\n for (const profiledTransaction of profiledTransactions) {\n const profile = _createProfileEventFor(profiledTransaction);\n if (profile) {\n profilesToAddToEnvelope.push(profile);\n }\n }\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n };\n\n const _startCurrentProfileForActiveTransaction = (): void => {\n if (_currentProfile) {\n return;\n }\n const activeSpan = getActiveSpan();\n activeSpan && _startCurrentProfile(activeSpan);\n };\n\n const _startCurrentProfile = (activeSpan: Span): void => {\n if (!isRootSpan(activeSpan)) {\n return;\n }\n\n _finishCurrentProfile();\n\n const shouldStartProfiling = _shouldStartProfiling(activeSpan);\n if (!shouldStartProfiling) {\n return;\n }\n\n _currentProfileTimeout = setTimeout(_finishCurrentProfile, MAX_PROFILE_DURATION_MS);\n _startNewProfile(activeSpan);\n };\n\n const _shouldStartProfiling = (activeSpan: Span): boolean => {\n if (!spanIsSampled(activeSpan)) {\n debug.log('[Profiling] Transaction is not sampled, skipping profiling');\n return false;\n }\n\n const client = getClient<ReactNativeClient>();\n const options = client?.getOptions?.();\n\n const profilesSampleRate =\n options && typeof options.profilesSampleRate === 'number' ? options.profilesSampleRate : undefined;\n if (profilesSampleRate === undefined) {\n debug.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');\n return false;\n }\n\n // Check if we should sample this profile\n if (Math.random() > profilesSampleRate) {\n debug.log('[Profiling] Skip profiling transaction due to sampling.');\n return false;\n }\n\n return true;\n };\n\n /**\n * Starts a new profile and links it to the transaction.\n */\n const _startNewProfile = (activeSpan: Span): void => {\n const profileStartTimestampNs = startProfiling(usePlatformProfilers);\n if (!profileStartTimestampNs) {\n return;\n }\n\n _currentProfile = {\n span_id: activeSpan.spanContext().spanId,\n profile_id: uuid4(),\n startTimestampNs: profileStartTimestampNs,\n };\n activeSpan.setAttribute('profile_id', _currentProfile.profile_id);\n debug.log('[Profiling] started profiling: ', _currentProfile.profile_id);\n };\n\n /**\n * Stops current profile if the ending span is the currently profiled span.\n */\n const _finishCurrentProfileForSpan = (span: Span): void => {\n if (!isRootSpan(span)) {\n return;\n }\n\n if (span.spanContext().spanId !== _currentProfile?.span_id) {\n debug.log(\n `[Profiling] Span (${span.spanContext().spanId}) ended is not the currently profiled span (${\n _currentProfile?.span_id\n }). Not stopping profiling.`,\n );\n return;\n }\n\n _finishCurrentProfile();\n };\n\n /**\n * Stops profiling and adds the profile to the queue to be processed on beforeEnvelope.\n */\n const _finishCurrentProfile = (): void => {\n _clearCurrentProfileTimeout();\n if (_currentProfile === undefined) {\n return;\n }\n\n const profile = stopProfiling(_currentProfile.startTimestampNs);\n if (!profile) {\n debug.warn('[Profiling] Stop failed. Cleaning up...');\n _currentProfile = undefined;\n return;\n }\n\n PROFILE_QUEUE.add(_currentProfile.profile_id, profile);\n\n debug.log('[Profiling] finished profiling: ', _currentProfile.profile_id);\n _currentProfile = undefined;\n };\n\n const _createProfileEventFor = (profiledTransaction: Event): ProfileEvent | null => {\n const profile_id = profiledTransaction?.contexts?.trace?.data?.profile_id;\n\n if (typeof profile_id !== 'string') {\n debug.log('[Profiling] cannot find profile for a transaction without a profile context');\n return null;\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profiledTransaction?.contexts?.trace?.data?.profile_id) {\n delete profiledTransaction.contexts.trace.data.profile_id;\n }\n\n const profile = PROFILE_QUEUE.get(profile_id);\n PROFILE_QUEUE.delete(profile_id);\n\n if (!profile) {\n debug.log(`[Profiling] cannot find profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n return null;\n }\n\n const profileWithEvent = enrichCombinedProfileWithEventContext(profile_id, profile, profiledTransaction);\n debug.log(`[Profiling] Created profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n\n return profileWithEvent;\n };\n\n const _clearCurrentProfileTimeout = (): void => {\n _currentProfileTimeout !== undefined && clearTimeout(_currentProfileTimeout);\n _currentProfileTimeout = undefined;\n };\n\n return {\n name: INTEGRATION_NAME,\n setupOnce,\n };\n};\n\n/**\n * Starts Profilers and returns the timestamp when profiling started in nanoseconds.\n */\nexport function startProfiling(platformProfilers: boolean): number | null {\n const started = NATIVE.startProfiling(platformProfilers);\n if (!started) {\n return null;\n }\n\n return Date.now() * MS_TO_NS;\n}\n\n/**\n * Stops Profilers and returns collected combined profile.\n */\nexport function stopProfiling(\n profileStartTimestampNs: number,\n): CombinedProfileEvent | AndroidCombinedProfileEvent | null {\n const collectedProfiles = NATIVE.stopProfiling();\n if (!collectedProfiles) {\n return null;\n }\n const profileEndTimestampNs = Date.now() * MS_TO_NS;\n\n const hermesProfile = convertToSentryProfile(collectedProfiles.hermesProfile);\n if (!hermesProfile) {\n return null;\n }\n\n const hermesProfileEvent = createHermesProfilingEvent(hermesProfile);\n if (!hermesProfileEvent) {\n return null;\n }\n\n if (collectedProfiles.androidProfile) {\n const durationNs = profileEndTimestampNs - profileStartTimestampNs;\n return createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);\n } else if (collectedProfiles.nativeProfile) {\n return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);\n }\n\n return hermesProfileEvent;\n}\n\n/**\n * Creates Android profile event with attached javascript profile.\n */\nexport function createAndroidWithHermesProfile(\n hermes: HermesProfileEvent,\n nativeAndroid: NativeAndroidProfileEvent,\n durationNs: number,\n): AndroidCombinedProfileEvent {\n return {\n ...nativeAndroid,\n platform: 'android',\n js_profile: hermes.profile,\n duration_ns: durationNs.toString(10),\n active_thread_id: hermes.transaction.active_thread_id,\n };\n}\n\n/**\n * Merges Hermes and Native profile events into one.\n */\nexport function addNativeProfileToHermesProfile(\n hermes: HermesProfileEvent,\n native: NativeProfileEvent,\n): CombinedProfileEvent {\n return {\n ...hermes,\n profile: addNativeThreadCpuProfileToHermes(hermes.profile, native.profile, hermes.transaction.active_thread_id),\n ...(native.debug_meta?.images ? { debug_meta: { images: native.debug_meta.images } } : {}),\n measurements: native.measurements,\n };\n}\n\n/**\n * Merges Hermes And Native profiles into one.\n */\nexport function addNativeThreadCpuProfileToHermes(\n hermes: ThreadCpuProfile,\n native: ThreadCpuProfile,\n hermes_active_thread_id: string | undefined,\n): CombinedProfileEvent['profile'] {\n // assumes thread ids are unique\n hermes.thread_metadata = { ...native.thread_metadata, ...hermes.thread_metadata };\n // assumes queue ids are unique\n hermes.queue_metadata = { ...native.queue_metadata, ...hermes.queue_metadata };\n\n // recalculate frames and stacks using offset\n const framesOffset = hermes.frames.length;\n const stacksOffset = hermes.stacks.length;\n\n if (native.frames) {\n for (const frame of native.frames) {\n hermes.frames.push({\n function: frame.function,\n instruction_addr: frame.instruction_addr,\n platform: Platform.OS === 'ios' ? 'cocoa' : undefined,\n });\n }\n }\n hermes.stacks = [\n ...(hermes.stacks || []),\n ...(native.stacks || []).map(stack => stack.map(frameId => frameId + framesOffset)),\n ];\n hermes.samples = [\n ...(hermes.samples || []),\n ...(native.samples || [])\n .filter(sample => sample.thread_id !== hermes_active_thread_id)\n .map(sample => ({\n ...sample,\n stack_id: stacksOffset + sample.stack_id,\n })),\n ];\n\n return hermes;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debug, forEachEnvelopeItem } from '@sentry/core';
|
|
2
2
|
import { getDefaultEnvironment } from '../utils/environment';
|
|
3
3
|
import { getDebugMetadata } from './debugid';
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export function isValidProfile(profile) {
|
|
|
10
10
|
// Log a warning if the profile has less than 2 samples so users can know why
|
|
11
11
|
// they are not seeing any profiling data and we cant avoid the back and forth
|
|
12
12
|
// of asking them to provide us with a dump of the profile data.
|
|
13
|
-
|
|
13
|
+
debug.log('[Profiling] Discarding profile because it contains less than 2 samples');
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -59,7 +59,7 @@ export function enrichCombinedProfileWithEventContext(profile_id, profile, event
|
|
|
59
59
|
// warn users that this is happening if they enable debug flag
|
|
60
60
|
if ((trace_id === null || trace_id === void 0 ? void 0 : trace_id.length) !== 32) {
|
|
61
61
|
if (__DEV__) {
|
|
62
|
-
|
|
62
|
+
debug.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
return Object.assign(Object.assign({}, profile), { event_id: profile_id, runtime: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;A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AE,EACjC,YAAY,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,IAC9B;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAA4B;IACrE,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,GAAG;QACZ,OAAO;QACP,WAAW,EAAE;YACX,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,QAAwB;IAChF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,OAAO,QAAQ,CAAC;KACjB;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,oCAAoC;QACpC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Envelope, Event, ThreadCpuProfile } from '@sentry/core';\nimport { forEachEnvelopeItem, logger } from '@sentry/core';\nimport { getDefaultEnvironment } from '../utils/environment';\nimport { getDebugMetadata } from './debugid';\nimport type {\n AndroidCombinedProfileEvent,\n AndroidProfileEvent,\n CombinedProfileEvent,\n HermesProfileEvent,\n ProfileEvent,\n RawThreadCpuProfile,\n} from './types';\n\n/**\n *\n */\nexport function isValidProfile(profile: ThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n if (__DEV__) {\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n }\n return false;\n }\n return true;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param envelope\n * @returns\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: Event[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type\n for (let j = 1; j < item.length; j++) {\n const event = item[j];\n\n // @ts-expect-error accessing private property\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (event.contexts?.trace?.data?.profile_id) {\n events.push(item[j] as Event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param event\n * @returns {ProfileEvent | null}\n */\nexport function enrichCombinedProfileWithEventContext(\n profile_id: string,\n profile: CombinedProfileEvent | AndroidCombinedProfileEvent,\n event: Event,\n): ProfileEvent | null {\n if ('js_profile' in profile) {\n return enrichAndroidProfileWithEventContext(profile_id, profile, event);\n }\n\n if (!profile.profile || !isValidProfile(profile.profile)) {\n return null;\n }\n\n const trace_id = event.contexts?.trace?.trace_id || '';\n\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n if (__DEV__) {\n logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n }\n\n return {\n ...profile,\n event_id: profile_id,\n runtime: {\n name: 'hermes',\n version: '', // TODO: get hermes version\n },\n timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),\n release: event.release || '',\n environment: event.environment || getDefaultEnvironment(),\n os: {\n name: event.contexts?.os?.name || '',\n version: event.contexts?.os?.version || '',\n build_number: event.contexts?.os?.build || '',\n },\n device: {\n locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '',\n model: event.contexts?.device?.model || '',\n manufacturer: event.contexts?.device?.manufacturer || '',\n architecture: event.contexts?.device?.arch || '',\n is_emulator: event.contexts?.device?.simulator || false,\n },\n transaction: {\n name: event.transaction || '',\n id: event.event_id || '',\n trace_id,\n active_thread_id: profile.transaction?.active_thread_id || '',\n },\n debug_meta: {\n images: [...getDebugMetadata(), ...(profile.debug_meta?.images || [])],\n },\n };\n}\n\n/**\n * Creates Android profiling envelope item.\n */\nexport function enrichAndroidProfileWithEventContext(\n profile_id: string,\n profile: AndroidCombinedProfileEvent,\n event: Event,\n): AndroidProfileEvent | null {\n return {\n ...profile,\n debug_meta: {\n images: getDebugMetadata(),\n },\n build_id: profile.build_id || '',\n\n device_cpu_frequencies: [],\n device_is_emulator: event.contexts?.device?.simulator || false,\n device_locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '',\n device_manufacturer: event.contexts?.device?.manufacturer || '',\n device_model: event.contexts?.device?.model || '',\n device_os_name: event.contexts?.os?.name || '',\n device_os_version: event.contexts?.os?.version || '',\n\n device_physical_memory_bytes:\n (event.contexts?.device?.memory_size && Number(event.contexts.device.memory_size).toString(10)) || '',\n\n environment: event.environment || getDefaultEnvironment(),\n\n profile_id,\n\n timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),\n\n release: event.release || '',\n dist: event.dist || '',\n\n transaction_id: event.event_id || '',\n transaction_name: event.transaction || '',\n trace_id: event.contexts?.trace?.trace_id || '',\n\n version_name: event.release || '',\n version_code: event.dist || '',\n };\n}\n\n/**\n * Creates profiling event compatible carrier Object from raw Hermes profile.\n */\nexport function createHermesProfilingEvent(profile: RawThreadCpuProfile): HermesProfileEvent {\n return {\n platform: 'javascript',\n version: '1',\n profile,\n transaction: {\n active_thread_id: profile.active_thread_id,\n },\n };\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param envelope\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: ProfileEvent[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"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CAAA,MAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,KAAK,0CAAE,QAAQ,KAAI,EAAE,EAE/C,YAAY,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,EACjC,YAAY,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,IAC9B;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAA4B;IACrE,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,GAAG;QACZ,OAAO;QACP,WAAW,EAAE;YACX,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAkB,EAAE,QAAwB;IAChF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,OAAO,QAAQ,CAAC;KACjB;IAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,oCAAoC;QACpC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Envelope, Event, ThreadCpuProfile } from '@sentry/core';\nimport { debug, forEachEnvelopeItem } from '@sentry/core';\nimport { getDefaultEnvironment } from '../utils/environment';\nimport { getDebugMetadata } from './debugid';\nimport type {\n AndroidCombinedProfileEvent,\n AndroidProfileEvent,\n CombinedProfileEvent,\n HermesProfileEvent,\n ProfileEvent,\n RawThreadCpuProfile,\n} from './types';\n\n/**\n *\n */\nexport function isValidProfile(profile: ThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n if (__DEV__) {\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n debug.log('[Profiling] Discarding profile because it contains less than 2 samples');\n }\n return false;\n }\n return true;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param envelope\n * @returns\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: Event[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type\n for (let j = 1; j < item.length; j++) {\n const event = item[j];\n\n // @ts-expect-error accessing private property\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (event.contexts?.trace?.data?.profile_id) {\n events.push(item[j] as Event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param event\n * @returns {ProfileEvent | null}\n */\nexport function enrichCombinedProfileWithEventContext(\n profile_id: string,\n profile: CombinedProfileEvent | AndroidCombinedProfileEvent,\n event: Event,\n): ProfileEvent | null {\n if ('js_profile' in profile) {\n return enrichAndroidProfileWithEventContext(profile_id, profile, event);\n }\n\n if (!profile.profile || !isValidProfile(profile.profile)) {\n return null;\n }\n\n const trace_id = event.contexts?.trace?.trace_id || '';\n\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id?.length !== 32) {\n if (__DEV__) {\n debug.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n }\n\n return {\n ...profile,\n event_id: profile_id,\n runtime: {\n name: 'hermes',\n version: '', // TODO: get hermes version\n },\n timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),\n release: event.release || '',\n environment: event.environment || getDefaultEnvironment(),\n os: {\n name: event.contexts?.os?.name || '',\n version: event.contexts?.os?.version || '',\n build_number: event.contexts?.os?.build || '',\n },\n device: {\n locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '',\n model: event.contexts?.device?.model || '',\n manufacturer: event.contexts?.device?.manufacturer || '',\n architecture: event.contexts?.device?.arch || '',\n is_emulator: event.contexts?.device?.simulator || false,\n },\n transaction: {\n name: event.transaction || '',\n id: event.event_id || '',\n trace_id,\n active_thread_id: profile.transaction?.active_thread_id || '',\n },\n debug_meta: {\n images: [...getDebugMetadata(), ...(profile.debug_meta?.images || [])],\n },\n };\n}\n\n/**\n * Creates Android profiling envelope item.\n */\nexport function enrichAndroidProfileWithEventContext(\n profile_id: string,\n profile: AndroidCombinedProfileEvent,\n event: Event,\n): AndroidProfileEvent | null {\n return {\n ...profile,\n debug_meta: {\n images: getDebugMetadata(),\n },\n build_id: profile.build_id || '',\n\n device_cpu_frequencies: [],\n device_is_emulator: event.contexts?.device?.simulator || false,\n device_locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '',\n device_manufacturer: event.contexts?.device?.manufacturer || '',\n device_model: event.contexts?.device?.model || '',\n device_os_name: event.contexts?.os?.name || '',\n device_os_version: event.contexts?.os?.version || '',\n\n device_physical_memory_bytes:\n (event.contexts?.device?.memory_size && Number(event.contexts.device.memory_size).toString(10)) || '',\n\n environment: event.environment || getDefaultEnvironment(),\n\n profile_id,\n\n timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(),\n\n release: event.release || '',\n dist: event.dist || '',\n\n transaction_id: event.event_id || '',\n transaction_name: event.transaction || '',\n trace_id: event.contexts?.trace?.trace_id || '',\n\n version_name: event.release || '',\n version_code: event.dist || '',\n };\n}\n\n/**\n * Creates profiling event compatible carrier Object from raw Hermes profile.\n */\nexport function createHermesProfilingEvent(profile: RawThreadCpuProfile): HermesProfileEvent {\n return {\n platform: 'javascript',\n version: '1',\n profile,\n transaction: {\n active_thread_id: profile.active_thread_id,\n },\n };\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param envelope\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: ProfileEvent[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { debug } from '@sentry/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { UIManager, View } from 'react-native';
|
|
4
4
|
import { isExpoGo } from '../utils/environment';
|
|
@@ -25,7 +25,7 @@ const UnmaskFallback = (viewProps) => {
|
|
|
25
25
|
const hasViewManagerConfig = (nativeComponentName) => { var _a; return (_a = UIManager.hasViewManagerConfig) === null || _a === void 0 ? void 0 : _a.call(UIManager, nativeComponentName); };
|
|
26
26
|
const Mask = (() => {
|
|
27
27
|
if (isExpoGo() || !hasViewManagerConfig(MaskNativeComponentName)) {
|
|
28
|
-
|
|
28
|
+
debug.warn(`[SentrySessionReplay] Can't load ${MaskNativeComponentName}.`);
|
|
29
29
|
return MaskFallback;
|
|
30
30
|
}
|
|
31
31
|
// Based on @react-native/babel-plugin-codegen output
|
|
@@ -36,7 +36,7 @@ const Mask = (() => {
|
|
|
36
36
|
})();
|
|
37
37
|
const Unmask = (() => {
|
|
38
38
|
if (isExpoGo() || !hasViewManagerConfig(UnmaskNativeComponentName)) {
|
|
39
|
-
|
|
39
|
+
debug.warn(`[SentrySessionReplay] Can't load ${UnmaskNativeComponentName}.`);
|
|
40
40
|
return UnmaskFallback;
|
|
41
41
|
}
|
|
42
42
|
// Based on @react-native/babel-plugin-codegen output
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomMask.js","sourceRoot":"","sources":["../../../src/js/replay/CustomMask.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CustomMask.js","sourceRoot":"","sources":["../../../src/js/replay/CustomMask.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,IAAI,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;IACrD,8KAA8K;IAC9K,OAAO,uBAAuB,CAAC,GAAG,CAAC,uBAAuB,EAAE,GAAG,EAAE,CAAC,CAAC;QACjE,eAAe,EAAE,uBAAuB;KACzC,CAAC,CAAC,CAAC;AACN,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,MAAM,GAAG,CAAC,GAA8D,EAAE;IAC9E,IAAI,QAAQ,EAAE,IAAI,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,EAAE;QAClE,KAAK,CAAC,IAAI,CAAC,oCAAoC,yBAAyB,GAAG,CAAC,CAAC;QAC7E,OAAO,cAAc,CAAC;KACvB;IAED,qDAAqD;IACrD,8KAA8K;IAC9K,OAAO,uBAAuB,CAAC,GAAG,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,CAAC;QACnE,eAAe,EAAE,yBAAyB;KAC3C,CAAC,CAAC,CAAC;AACN,CAAC,CAAC,EAAE,CAAC;AAEL,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { debug } from '@sentry/core';\nimport * as React from 'react';\nimport type { HostComponent, ViewProps } from 'react-native';\nimport { UIManager, View } from 'react-native';\nimport { isExpoGo } from '../utils/environment';\n\nconst NativeComponentRegistry: {\n get<T, C extends Record<string, unknown>>(componentName: string, createViewConfig: () => C): HostComponent<T>;\n// eslint-disable-next-line @typescript-eslint/no-var-requires\n} = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\n\nconst MaskNativeComponentName = 'RNSentryReplayMask';\nconst UnmaskNativeComponentName = 'RNSentryReplayUnmask';\n\nconst warnMessage = (component: string): string => `[SentrySessionReplay] ${component} component is not supported on the current platform. If ${component} should be supported, please ensure that the application build is up to date.`;\n\nconst warn = (component: string): void => {\n setTimeout(() => {\n // Missing mask component could cause leaking PII, we have to ensure that the warning is visible\n // even if the app is running without debug.\n // eslint-disable-next-line no-console\n console.warn(warnMessage(component));\n }, 0);\n};\n\nconst MaskFallback = (viewProps: ViewProps): React.ReactElement => {\n warn('Mask');\n return <View {...viewProps} />;\n};\n\nconst UnmaskFallback = (viewProps: ViewProps): React.ReactElement => {\n warn('Unmask');\n return <View {...viewProps} />;\n};\n\nconst hasViewManagerConfig = (nativeComponentName: string): boolean => UIManager.hasViewManagerConfig?.(nativeComponentName);\n\nconst Mask = ((): HostComponent<ViewProps> | React.ComponentType<ViewProps> => {\n if (isExpoGo() || !hasViewManagerConfig(MaskNativeComponentName)) {\n debug.warn(`[SentrySessionReplay] Can't load ${MaskNativeComponentName}.`);\n return MaskFallback;\n }\n\n // Based on @react-native/babel-plugin-codegen output\n // https://github.com/facebook/react-native/blob/b32c6c2cc1bc566a85a883901dbf5e23b5a75b61/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js#L139\n return NativeComponentRegistry.get(MaskNativeComponentName, () => ({\n uiViewClassName: MaskNativeComponentName,\n }));\n})()\n\nconst Unmask = ((): HostComponent<ViewProps> | React.ComponentType<ViewProps> => {\n if (isExpoGo() || !hasViewManagerConfig(UnmaskNativeComponentName)) {\n debug.warn(`[SentrySessionReplay] Can't load ${UnmaskNativeComponentName}.`);\n return UnmaskFallback;\n }\n\n // Based on @react-native/babel-plugin-codegen output\n // https://github.com/facebook/react-native/blob/b32c6c2cc1bc566a85a883901dbf5e23b5a75b61/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js#L139\n return NativeComponentRegistry.get(UnmaskNativeComponentName, () => ({\n uiViewClassName: UnmaskNativeComponentName,\n }));\n})();\n\nexport { Mask, Unmask, MaskFallback, UnmaskFallback };\n"]}
|