@sentry/react-native 6.15.1 → 6.16.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 +9 -2
- package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
- package/dist/js/feedback/FeedbackWidget.d.ts +1 -0
- package/dist/js/feedback/FeedbackWidget.d.ts.map +1 -1
- package/dist/js/feedback/FeedbackWidget.js +16 -5
- package/dist/js/feedback/FeedbackWidget.js.map +1 -1
- package/dist/js/feedback/ScreenshotButton.js +1 -1
- package/dist/js/feedback/ScreenshotButton.js.map +1 -1
- package/dist/js/playground/animations.d.ts +4 -0
- package/dist/js/playground/animations.d.ts.map +1 -0
- package/dist/js/playground/animations.js +4 -0
- package/dist/js/playground/animations.js.map +1 -0
- package/dist/js/playground/examples.d.ts +13 -0
- package/dist/js/playground/examples.d.ts.map +1 -0
- package/dist/js/playground/examples.js +35 -0
- package/dist/js/playground/examples.js.map +1 -0
- package/dist/js/playground/images.d.ts +4 -0
- package/dist/js/playground/images.d.ts.map +1 -0
- package/dist/js/playground/images.js +4 -0
- package/dist/js/playground/images.js.map +1 -0
- package/dist/js/playground/index.d.ts +2 -0
- package/dist/js/playground/index.d.ts.map +1 -0
- package/dist/js/playground/index.js +2 -0
- package/dist/js/playground/index.js.map +1 -0
- package/dist/js/playground/modal.d.ts +29 -0
- package/dist/js/playground/modal.d.ts.map +1 -0
- package/dist/js/playground/modal.js +253 -0
- package/dist/js/playground/modal.js.map +1 -0
- package/dist/js/tracing/integrations/appStart.d.ts +7 -1
- package/dist/js/tracing/integrations/appStart.d.ts.map +1 -1
- package/dist/js/tracing/integrations/appStart.js +60 -9
- package/dist/js/tracing/integrations/appStart.js.map +1 -1
- package/dist/js/tracing/span.js +3 -3
- package/dist/js/tracing/span.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/ios/RNSentryVersion.m +1 -1
- package/package.json +1 -1
- package/react-native.config.js +4 -4
- package/scripts/sentry_utils.rb +5 -0
- package/ts3.8/dist/js/feedback/FeedbackWidget.d.ts +1 -0
- package/ts3.8/dist/js/playground/animations.d.ts +4 -0
- package/ts3.8/dist/js/playground/examples.d.ts +13 -0
- package/ts3.8/dist/js/playground/images.d.ts +4 -0
- package/ts3.8/dist/js/playground/index.d.ts +2 -0
- package/ts3.8/dist/js/playground/modal.d.ts +29 -0
- package/ts3.8/dist/js/tracing/integrations/appStart.d.ts +7 -1
- package/ts3.8/dist/js/version.d.ts +1 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
import { logger } from '@sentry/core';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Animated, Image, Modal, Platform, Pressable, SafeAreaView, StyleSheet, Text, useColorScheme, View, } from 'react-native';
|
|
5
|
+
import { getDevServer } from '../integrations/debugsymbolicatorutils';
|
|
6
|
+
import { isExpo, isExpoGo, isWeb } from '../utils/environment';
|
|
7
|
+
import { bug as bugAnimation, hi as hiAnimation, thumbsup as thumbsupAnimation } from './animations';
|
|
8
|
+
import { nativeCrashExample, tryCatchExample, uncaughtErrorExample } from './examples';
|
|
9
|
+
import { bug as bugImage, hi as hiImage, thumbsup as thumbsupImage } from './images';
|
|
10
|
+
/**
|
|
11
|
+
* Wrapper to add Sentry Playground to your application
|
|
12
|
+
* to test your Sentry React Native SDK setup.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import * as Sentry from '@sentry/react-native';
|
|
17
|
+
* import { withSentryPlayground } from '@sentry/react-native/playground';
|
|
18
|
+
*
|
|
19
|
+
* function App() {
|
|
20
|
+
* return <View>...</View>;
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* export default withSentryPlayground(Sentry.wrap(App), {
|
|
24
|
+
* projectId: '123456',
|
|
25
|
+
* organizationSlug: 'my-org'
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export const withSentryPlayground = (Component, options = {}) => {
|
|
30
|
+
const Wrapper = (props) => {
|
|
31
|
+
return (React.createElement(React.Fragment, null,
|
|
32
|
+
React.createElement(SentryPlayground, { projectId: options.projectId, organizationSlug: options.organizationSlug }),
|
|
33
|
+
React.createElement(Component, Object.assign({}, props))));
|
|
34
|
+
};
|
|
35
|
+
Wrapper.displayName = `withSentryPlayground()`;
|
|
36
|
+
return Wrapper;
|
|
37
|
+
};
|
|
38
|
+
export const SentryPlayground = ({ projectId, organizationSlug, }) => {
|
|
39
|
+
const issuesStreamUrl = projectId && organizationSlug
|
|
40
|
+
? `https://${organizationSlug}.sentry.io/issues/?project=${projectId}&statsPeriod=1h`
|
|
41
|
+
: 'https://sentry.io/';
|
|
42
|
+
const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;
|
|
43
|
+
const [show, setShow] = React.useState(true);
|
|
44
|
+
const [animation, setAnimation] = React.useState('hi');
|
|
45
|
+
const onAnimationPress = () => {
|
|
46
|
+
switch (animation) {
|
|
47
|
+
case 'hi':
|
|
48
|
+
setAnimation('thumbsup');
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
setAnimation('hi');
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const showOpenSentryButton = !isExpo();
|
|
55
|
+
const isNativeCrashDisabled = isWeb() || isExpoGo() || __DEV__;
|
|
56
|
+
const animationContainerYPosition = React.useRef(new Animated.Value(0)).current;
|
|
57
|
+
const springAnimation = Animated.sequence([
|
|
58
|
+
Animated.timing(animationContainerYPosition, {
|
|
59
|
+
toValue: -50,
|
|
60
|
+
duration: 300,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
}),
|
|
63
|
+
Animated.spring(animationContainerYPosition, {
|
|
64
|
+
toValue: 0,
|
|
65
|
+
friction: 4,
|
|
66
|
+
tension: 40,
|
|
67
|
+
useNativeDriver: true,
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
const changeAnimationToBug = (func) => {
|
|
71
|
+
setAnimation('bug');
|
|
72
|
+
springAnimation.start(() => {
|
|
73
|
+
func();
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
return (React.createElement(Modal, { presentationStyle: "formSheet", visible: show, animationType: "slide", onRequestClose: () => {
|
|
77
|
+
setShow(false);
|
|
78
|
+
} },
|
|
79
|
+
React.createElement(SafeAreaView, { style: styles.background },
|
|
80
|
+
React.createElement(View, { style: styles.container },
|
|
81
|
+
React.createElement(Text, { style: styles.welcomeText }, "Welcome to Sentry Playground!"),
|
|
82
|
+
React.createElement(Animated.View, { style: {
|
|
83
|
+
width: '100%',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
transform: [{ translateY: animationContainerYPosition }],
|
|
87
|
+
}, onTouchEnd: () => {
|
|
88
|
+
springAnimation.start();
|
|
89
|
+
} },
|
|
90
|
+
React.createElement(Pressable, { onPress: onAnimationPress },
|
|
91
|
+
React.createElement(Animation, { id: animation }))),
|
|
92
|
+
React.createElement(View, { style: styles.listContainer },
|
|
93
|
+
React.createElement(Row, { title: 'captureException()', description: 'In a try-catch scenario, errors can be reported using manual APIs.', actionDescription: 'Try', action: tryCatchExample }),
|
|
94
|
+
React.createElement(Row, { title: 'throw new Error()', description: 'Uncaught errors are automatically reported by the React Native Global Handler.', actionDescription: 'Throw', action: () => changeAnimationToBug(uncaughtErrorExample) }),
|
|
95
|
+
React.createElement(Row, { title: 'throw RuntimeException()', description: isNativeCrashDisabled
|
|
96
|
+
? 'For testing native crashes, build the mobile application in release mode.'
|
|
97
|
+
: 'Unhandled errors in native layers such as Java, Objective-C, C, Swift, or Kotlin are automatically reported.', actionDescription: 'Crash', action: nativeCrashExample, last: true, disabled: isNativeCrashDisabled })),
|
|
98
|
+
React.createElement(View, { style: { marginTop: 40 } }),
|
|
99
|
+
React.createElement(View, { style: {
|
|
100
|
+
width: '100%',
|
|
101
|
+
flexDirection: 'row',
|
|
102
|
+
justifyContent: 'space-evenly', // Space between buttons
|
|
103
|
+
} },
|
|
104
|
+
showOpenSentryButton && (React.createElement(Button, { secondary: true, title: 'Open Sentry', onPress: () => {
|
|
105
|
+
openURLInBrowser(issuesStreamUrl);
|
|
106
|
+
} })),
|
|
107
|
+
React.createElement(Button, { title: 'Go to my App', onPress: () => {
|
|
108
|
+
setShow(false);
|
|
109
|
+
} }))))));
|
|
110
|
+
};
|
|
111
|
+
const Animation = ({ id }) => {
|
|
112
|
+
const shouldFallbackToImage = Platform.OS === 'android';
|
|
113
|
+
switch (id) {
|
|
114
|
+
case 'hi':
|
|
115
|
+
return (React.createElement(Image, { source: { uri: shouldFallbackToImage ? hiImage : hiAnimation }, style: { width: 100, height: 100 } }));
|
|
116
|
+
case 'bug':
|
|
117
|
+
return (React.createElement(Image, { source: { uri: shouldFallbackToImage ? bugImage : bugAnimation }, style: { width: 100, height: 100 } }));
|
|
118
|
+
case 'thumbsup':
|
|
119
|
+
return (React.createElement(Image, { source: { uri: shouldFallbackToImage ? thumbsupImage : thumbsupAnimation }, style: { width: 100, height: 100 } }));
|
|
120
|
+
default:
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const Row = ({ last = false,
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
126
|
+
action = () => { }, actionDescription, title, description, disabled = false, }) => {
|
|
127
|
+
const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;
|
|
128
|
+
return (React.createElement(View, { style: [styles.rowContainer, last && styles.lastRowContainer] },
|
|
129
|
+
React.createElement(View, { style: { flexShrink: 1, paddingRight: 12 } },
|
|
130
|
+
React.createElement(Text, { style: styles.rowTitle }, title),
|
|
131
|
+
React.createElement(Text, { style: { color: 'rgb(146, 130, 170)', fontSize: 12 } }, description)),
|
|
132
|
+
React.createElement(View, null,
|
|
133
|
+
React.createElement(Button, { disabled: disabled, secondary: true, onPress: action, title: actionDescription }))));
|
|
134
|
+
};
|
|
135
|
+
const Button = ({ onPress, title, secondary, disabled = false, }) => {
|
|
136
|
+
const styles = useColorScheme() === 'dark' ? defaultDarkStyles : lightStyles;
|
|
137
|
+
return (React.createElement(View, { style: [styles.buttonBottomLayer, styles.buttonCommon, secondary && styles.buttonSecondaryBottomLayer] },
|
|
138
|
+
React.createElement(Pressable, { style: ({ pressed }) => [
|
|
139
|
+
styles.buttonMainContainer,
|
|
140
|
+
pressed && styles.buttonMainContainerPressed,
|
|
141
|
+
styles.buttonCommon,
|
|
142
|
+
secondary && styles.buttonSecondaryContainer,
|
|
143
|
+
disabled && styles.buttonDisabledContainer,
|
|
144
|
+
], onPress: onPress, disabled: disabled },
|
|
145
|
+
React.createElement(Text, { style: [styles.buttonText, secondary && styles.buttonSecondaryText, disabled && styles.buttonDisabledText] }, title))));
|
|
146
|
+
};
|
|
147
|
+
const defaultDarkStyles = StyleSheet.create({
|
|
148
|
+
welcomeText: { color: 'rgb(246, 245, 250)', fontSize: 24, fontWeight: 'bold' },
|
|
149
|
+
background: {
|
|
150
|
+
flex: 1,
|
|
151
|
+
backgroundColor: 'rgb(26, 20, 31)',
|
|
152
|
+
width: '100%',
|
|
153
|
+
minHeight: '100%',
|
|
154
|
+
alignItems: 'center',
|
|
155
|
+
justifyContent: 'center', // Center content vertically
|
|
156
|
+
},
|
|
157
|
+
container: {
|
|
158
|
+
flex: 1,
|
|
159
|
+
flexDirection: 'column',
|
|
160
|
+
padding: 12,
|
|
161
|
+
marginTop: 20,
|
|
162
|
+
width: '100%',
|
|
163
|
+
alignItems: 'center',
|
|
164
|
+
justifyContent: 'space-evenly', // Center image and button container
|
|
165
|
+
},
|
|
166
|
+
buttonContainer: {
|
|
167
|
+
flexDirection: 'row',
|
|
168
|
+
marginTop: 20, // Add some space above the buttons
|
|
169
|
+
},
|
|
170
|
+
listContainer: {
|
|
171
|
+
backgroundColor: 'rgb(39, 36, 51)',
|
|
172
|
+
width: '100%',
|
|
173
|
+
flexDirection: 'column',
|
|
174
|
+
marginTop: 20,
|
|
175
|
+
borderColor: 'rgb(7, 5, 15)',
|
|
176
|
+
borderWidth: 1,
|
|
177
|
+
borderRadius: 8,
|
|
178
|
+
},
|
|
179
|
+
rowTitle: {
|
|
180
|
+
color: 'rgb(246, 245, 250)',
|
|
181
|
+
fontSize: 14,
|
|
182
|
+
fontWeight: 'bold',
|
|
183
|
+
textAlign: 'left',
|
|
184
|
+
fontFamily: 'Menlo',
|
|
185
|
+
},
|
|
186
|
+
rowContainer: {
|
|
187
|
+
overflow: 'hidden',
|
|
188
|
+
flexDirection: 'row',
|
|
189
|
+
justifyContent: 'space-between',
|
|
190
|
+
paddingTop: 16,
|
|
191
|
+
paddingBottom: 10,
|
|
192
|
+
paddingHorizontal: 10,
|
|
193
|
+
borderColor: 'rgb(7, 5, 15)',
|
|
194
|
+
borderBottomWidth: 1,
|
|
195
|
+
},
|
|
196
|
+
lastRowContainer: {
|
|
197
|
+
borderBottomWidth: 0, // Remove border for the last row
|
|
198
|
+
},
|
|
199
|
+
buttonCommon: {
|
|
200
|
+
borderRadius: 8,
|
|
201
|
+
},
|
|
202
|
+
buttonBottomLayer: {
|
|
203
|
+
backgroundColor: 'rgb(7, 5, 15)',
|
|
204
|
+
},
|
|
205
|
+
buttonMainContainer: {
|
|
206
|
+
paddingVertical: 8,
|
|
207
|
+
paddingHorizontal: 13,
|
|
208
|
+
backgroundColor: 'rgb(117, 83, 255)',
|
|
209
|
+
transform: [{ translateY: -4 }],
|
|
210
|
+
borderWidth: 1,
|
|
211
|
+
borderColor: 'rgb(7, 5, 15)',
|
|
212
|
+
},
|
|
213
|
+
buttonSecondaryContainer: {
|
|
214
|
+
backgroundColor: 'rgb(39, 36, 51)',
|
|
215
|
+
},
|
|
216
|
+
buttonSecondaryBottomLayer: {},
|
|
217
|
+
buttonSecondaryText: {},
|
|
218
|
+
buttonMainContainerPressed: {
|
|
219
|
+
transform: [{ translateY: 0 }],
|
|
220
|
+
},
|
|
221
|
+
buttonText: {
|
|
222
|
+
color: 'rgb(246, 245, 250)',
|
|
223
|
+
fontSize: 16,
|
|
224
|
+
fontWeight: 'bold',
|
|
225
|
+
textAlign: 'center',
|
|
226
|
+
},
|
|
227
|
+
buttonDisabledText: {
|
|
228
|
+
color: 'rgb(146, 130, 170)',
|
|
229
|
+
},
|
|
230
|
+
buttonDisabledContainer: {
|
|
231
|
+
transform: [{ translateY: -2 }],
|
|
232
|
+
backgroundColor: 'rgb(39, 36, 51)',
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
const lightStyles = StyleSheet.create(Object.assign(Object.assign({}, defaultDarkStyles), { welcomeText: Object.assign(Object.assign({}, defaultDarkStyles.welcomeText), { color: 'rgb(24, 20, 35)' }), background: Object.assign(Object.assign({}, defaultDarkStyles.background), { backgroundColor: 'rgb(251, 250, 255)' }), buttonMainContainer: Object.assign(Object.assign({}, defaultDarkStyles.buttonMainContainer), { backgroundColor: 'rgb(117, 83, 255)', borderColor: 'rgb(85, 61, 184)' }), buttonBottomLayer: {
|
|
236
|
+
backgroundColor: 'rgb(85, 61, 184)',
|
|
237
|
+
}, buttonSecondaryContainer: {
|
|
238
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
239
|
+
borderColor: 'rgb(218, 215, 229)',
|
|
240
|
+
}, buttonSecondaryBottomLayer: {
|
|
241
|
+
backgroundColor: 'rgb(218, 215, 229)',
|
|
242
|
+
}, buttonText: Object.assign({}, defaultDarkStyles.buttonText), buttonSecondaryText: Object.assign(Object.assign({}, defaultDarkStyles.buttonText), { color: 'rgb(24, 20, 35)' }), rowTitle: Object.assign(Object.assign({}, defaultDarkStyles.rowTitle), { color: 'rgb(24, 20, 35)' }), rowContainer: Object.assign(Object.assign({}, defaultDarkStyles.rowContainer), { borderColor: 'rgb(218, 215, 229)' }), listContainer: Object.assign(Object.assign({}, defaultDarkStyles.listContainer), { borderColor: 'rgb(218, 215, 229)', backgroundColor: 'rgb(255, 255, 255)' }), buttonDisabledContainer: Object.assign(Object.assign({}, defaultDarkStyles.buttonDisabledContainer), { backgroundColor: 'rgb(238, 235, 249)' }) }));
|
|
243
|
+
function openURLInBrowser(url) {
|
|
244
|
+
// This doesn't work for Expo project with Web enabled
|
|
245
|
+
// disable-next-line @typescript-eslint/no-floating-promises
|
|
246
|
+
fetch(`${getDevServer().url}open-url`, {
|
|
247
|
+
method: 'POST',
|
|
248
|
+
body: JSON.stringify({ url }),
|
|
249
|
+
}).catch(e => {
|
|
250
|
+
logger.error('Error opening URL:', e);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../../../src/js/playground/modal.tsx"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,cAAc,EACd,IAAI,GACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,EAAE,IAAI,WAAW,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,GAAG,IAAI,QAAQ,EAAE,EAAE,IAAI,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AAErF;;;;;;;;;;;;;;;;;;GAkBG;AACH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 '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';\n\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 => {\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 // This doesn't work for Expo project with Web enabled\n // disable-next-line @typescript-eslint/no-floating-promises\n fetch(`${getDevServer().url}open-url`, {\n method: 'POST',\n body: JSON.stringify({ url }),\n }).catch(e => {\n logger.error('Error opening URL:', e);\n });\n}\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Integration } from '@sentry/core';
|
|
2
|
+
import type { NativeFramesResponse } from '../../NativeRNSentry';
|
|
2
3
|
export type AppStartIntegration = Integration & {
|
|
3
4
|
captureStandaloneAppStart: () => Promise<void>;
|
|
4
5
|
};
|
|
6
|
+
interface AppStartEndData {
|
|
7
|
+
timestampMs: number;
|
|
8
|
+
endFrames: NativeFramesResponse | null;
|
|
9
|
+
}
|
|
5
10
|
/**
|
|
6
11
|
* Records the application start end.
|
|
7
12
|
* Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.
|
|
@@ -31,7 +36,7 @@ export declare function _setRootComponentCreationTimestampMs(timestampMs: number
|
|
|
31
36
|
*
|
|
32
37
|
* @private
|
|
33
38
|
*/
|
|
34
|
-
export declare const
|
|
39
|
+
export declare const _setAppStartEndData: (data: AppStartEndData) => void;
|
|
35
40
|
/**
|
|
36
41
|
* For testing purposes only.
|
|
37
42
|
*
|
|
@@ -50,4 +55,5 @@ export declare const appStartIntegration: ({ standalone, }?: {
|
|
|
50
55
|
*/
|
|
51
56
|
standalone?: boolean;
|
|
52
57
|
}) => AppStartIntegration;
|
|
58
|
+
export {};
|
|
53
59
|
//# sourceMappingURL=appStart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appStart.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/appStart.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,WAAW,EAAoC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"appStart.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/appStart.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,WAAW,EAAoC,MAAM,cAAc,CAAC;AAiBjG,OAAO,KAAK,EAA0B,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAgBzF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAC9C,yBAAyB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AAeF,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACxC;AAQD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BzF;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAK7E;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAG9E;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,SAAU,eAAe,KAAG,IAG3D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sCAAsC,IAAI,IAAI,CAE7D;AAyBD;;GAEG;AACH,eAAO,MAAM,mBAAmB;IAG9B;;;;;OAKG;iBACU,OAAO;MACb,mBA8RR,CAAC"}
|
|
@@ -28,7 +28,7 @@ const MAX_APP_START_DURATION_MS = 60000;
|
|
|
28
28
|
const MAX_APP_START_AGE_MS = 60000;
|
|
29
29
|
/** App Start transaction name */
|
|
30
30
|
const APP_START_TX_NAME = 'App Start';
|
|
31
|
-
let
|
|
31
|
+
let appStartEndData = undefined;
|
|
32
32
|
let isRecordedAppStartEndTimestampMsManual = false;
|
|
33
33
|
let rootComponentCreationTimestampMs = undefined;
|
|
34
34
|
let isRootComponentCreationTimestampMsManual = false;
|
|
@@ -53,7 +53,21 @@ export function _captureAppStart({ isManual }) {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
isRecordedAppStartEndTimestampMsManual = isManual;
|
|
56
|
-
|
|
56
|
+
const timestampMs = timestampInSeconds() * 1000;
|
|
57
|
+
let endFrames = null;
|
|
58
|
+
if (NATIVE.enableNative) {
|
|
59
|
+
try {
|
|
60
|
+
endFrames = yield NATIVE.fetchNativeFrames();
|
|
61
|
+
logger.debug('[AppStart] Captured end frames for app start.', endFrames);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
logger.debug('[AppStart] Failed to capture end frames for app start.', error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_setAppStartEndData({
|
|
68
|
+
timestampMs,
|
|
69
|
+
endFrames,
|
|
70
|
+
});
|
|
57
71
|
yield ((_a = client.getIntegrationByName(INTEGRATION_NAME)) === null || _a === void 0 ? void 0 : _a.captureStandaloneAppStart());
|
|
58
72
|
});
|
|
59
73
|
}
|
|
@@ -62,8 +76,7 @@ export function _captureAppStart({ isManual }) {
|
|
|
62
76
|
* Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.
|
|
63
77
|
*/
|
|
64
78
|
export function setRootComponentCreationTimestampMs(timestampMs) {
|
|
65
|
-
|
|
66
|
-
logger.warn('Setting Root component creation timestamp after app start end is set.');
|
|
79
|
+
(appStartEndData === null || appStartEndData === void 0 ? void 0 : appStartEndData.timestampMs) && logger.warn('Setting Root component creation timestamp after app start end is set.');
|
|
67
80
|
rootComponentCreationTimestampMs && logger.warn('Overwriting already set root component creation timestamp.');
|
|
68
81
|
rootComponentCreationTimestampMs = timestampMs;
|
|
69
82
|
isRootComponentCreationTimestampMsManual = true;
|
|
@@ -82,9 +95,9 @@ export function _setRootComponentCreationTimestampMs(timestampMs) {
|
|
|
82
95
|
*
|
|
83
96
|
* @private
|
|
84
97
|
*/
|
|
85
|
-
export const
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
export const _setAppStartEndData = (data) => {
|
|
99
|
+
appStartEndData && logger.warn('Overwriting already set app start end data.');
|
|
100
|
+
appStartEndData = data;
|
|
88
101
|
};
|
|
89
102
|
/**
|
|
90
103
|
* For testing purposes only.
|
|
@@ -94,6 +107,27 @@ export const _setAppStartEndTimestampMs = (timestampMs) => {
|
|
|
94
107
|
export function _clearRootComponentCreationTimestampMs() {
|
|
95
108
|
rootComponentCreationTimestampMs = undefined;
|
|
96
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Attaches frame data to a span's data object.
|
|
112
|
+
*/
|
|
113
|
+
function attachFrameDataToSpan(span, frames) {
|
|
114
|
+
if (frames.totalFrames <= 0 && frames.slowFrames <= 0 && frames.totalFrames <= 0) {
|
|
115
|
+
logger.warn(`[AppStart] Detected zero slow or frozen frames. Not adding measurements to spanId (${span.span_id}).`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
span.data = span.data || {};
|
|
119
|
+
span.data['frames.total'] = frames.totalFrames;
|
|
120
|
+
span.data['frames.slow'] = frames.slowFrames;
|
|
121
|
+
span.data['frames.frozen'] = frames.frozenFrames;
|
|
122
|
+
logger.debug('[AppStart] Attached frame data to span.', {
|
|
123
|
+
spanId: span.span_id,
|
|
124
|
+
frameData: {
|
|
125
|
+
total: frames.totalFrames,
|
|
126
|
+
slow: frames.slowFrames,
|
|
127
|
+
frozen: frames.frozenFrames,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
97
131
|
/**
|
|
98
132
|
* Adds AppStart spans from the native layer to the transaction event.
|
|
99
133
|
*/
|
|
@@ -165,6 +199,20 @@ export const appStartIntegration = ({ standalone = false, } = {}) => {
|
|
|
165
199
|
return;
|
|
166
200
|
}
|
|
167
201
|
logger.debug('[AppStart] App start tracking standalone root span (transaction).');
|
|
202
|
+
if (!(appStartEndData === null || appStartEndData === void 0 ? void 0 : appStartEndData.endFrames) && NATIVE.enableNative) {
|
|
203
|
+
try {
|
|
204
|
+
const endFrames = yield NATIVE.fetchNativeFrames();
|
|
205
|
+
logger.debug('[AppStart] Captured end frames for standalone app start.', endFrames);
|
|
206
|
+
const currentTimestamp = (appStartEndData === null || appStartEndData === void 0 ? void 0 : appStartEndData.timestampMs) || timestampInSeconds() * 1000;
|
|
207
|
+
_setAppStartEndData({
|
|
208
|
+
timestampMs: currentTimestamp,
|
|
209
|
+
endFrames,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
logger.debug('[AppStart] Failed to capture frames for standalone app start.', error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
168
216
|
const span = startInactiveSpan({
|
|
169
217
|
forceTransaction: true,
|
|
170
218
|
name: APP_START_TX_NAME,
|
|
@@ -222,9 +270,9 @@ export const appStartIntegration = ({ standalone = false, } = {}) => {
|
|
|
222
270
|
logger.warn('[AppStart] App start timestamp could not be loaded from the native layer.');
|
|
223
271
|
return;
|
|
224
272
|
}
|
|
225
|
-
const appStartEndTimestampMs =
|
|
273
|
+
const appStartEndTimestampMs = (appStartEndData === null || appStartEndData === void 0 ? void 0 : appStartEndData.timestampMs) || getBundleStartTimestampMs();
|
|
226
274
|
if (!appStartEndTimestampMs) {
|
|
227
|
-
logger.warn('[AppStart] Javascript failed to record app start end. `
|
|
275
|
+
logger.warn('[AppStart] Javascript failed to record app start end. `_setAppStartEndData` was not called nor could the bundle start be found.');
|
|
228
276
|
return;
|
|
229
277
|
}
|
|
230
278
|
const isAppStartWithinBounds = !!event.start_timestamp && appStartTimestampMs >= event.start_timestamp * 1000 - MAX_APP_START_AGE_MS;
|
|
@@ -282,6 +330,9 @@ export const appStartIntegration = ({ standalone = false, } = {}) => {
|
|
|
282
330
|
parent_span_id: event.contexts.trace.span_id,
|
|
283
331
|
origin,
|
|
284
332
|
});
|
|
333
|
+
if (appStartEndData === null || appStartEndData === void 0 ? void 0 : appStartEndData.endFrames) {
|
|
334
|
+
attachFrameDataToSpan(appStartSpanJSON, appStartEndData.endFrames);
|
|
335
|
+
}
|
|
285
336
|
const jsExecutionSpanJSON = createJSExecutionStartSpan(appStartSpanJSON, rootComponentCreationTimestampMs);
|
|
286
337
|
const appStartSpans = [
|
|
287
338
|
appStartSpanJSON,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appStart.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/appStart.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,eAAe,EACf,MAAM,EACN,gCAAgC,EAChC,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,cAAc,IAAI,0BAA0B,EAC5C,cAAc,IAAI,0BAA0B,GAC7C,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,cAAc,IAAI,iBAAiB,EACnC,cAAc,IAAI,iBAAiB,EACnC,OAAO,IAAI,UAAU,GACtB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1F,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAMpC;;;;GAIG;AACH,MAAM,yBAAyB,GAAG,KAAM,CAAC;AAEzC,4FAA4F;AAC5F,MAAM,oBAAoB,GAAG,KAAM,CAAC;AAEpC,iCAAiC;AACjC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAEtC,IA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G,eAAe,CAAC,gBAAgB,EAAE;QACjE,OAAO,mBAAmB,CAAC,UAAU,EAAE;YACrC,WAAW,EAAE,6BAA6B;YAC1C,eAAe,EAAE,eAAe,CAAC,kBAAkB,GAAG,IAAI;YAC1D,SAAS,EAAE,WAAW,GAAG,IAAI;YAC7B,MAAM,EAAE,0BAA0B;SACnC,CAAC,CAAC;KACJ;SAAM;QACL,OAAO,mBAAmB,CAAC,UAAU,EAAE;YACrC,WAAW,EAAE,YAAY;YACzB,eAAe,EAAE,eAAe,CAAC,kBAAkB,GAAG,IAAI;YAC1D,SAAS,EAAE,eAAe,CAAC,gBAAgB,GAAG,IAAI;YAClD,MAAM,EAAE,0BAA0B;SACnC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["/* eslint-disable complexity, max-lines */\nimport type { Client, Event, Integration, Span, SpanJSON, TransactionEvent } from '@sentry/core';\nimport {\n getCapturedScopesOnSpan,\n getClient,\n getCurrentScope,\n logger,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n startInactiveSpan,\n timestampInSeconds,\n} from '@sentry/core';\n\nimport { getAppRegistryIntegration } from '../../integrations/appRegistry';\nimport {\n APP_START_COLD as APP_START_COLD_MEASUREMENT,\n APP_START_WARM as APP_START_WARM_MEASUREMENT,\n} from '../../measurements';\nimport type { NativeAppStartResponse } from '../../NativeRNSentry';\nimport type { ReactNativeClientOptions } from '../../options';\nimport { convertSpanToTransaction, isRootSpan, setEndTimeValue } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\nimport {\n APP_START_COLD as APP_START_COLD_OP,\n APP_START_WARM as APP_START_WARM_OP,\n UI_LOAD as UI_LOAD_OP,\n} from '../ops';\nimport { SPAN_ORIGIN_AUTO_APP_START, SPAN_ORIGIN_MANUAL_APP_START } from '../origin';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '../semanticAttributes';\nimport { setMainThreadInfo } from '../span';\nimport { createChildSpanJSON, createSpanJSON, getBundleStartTimestampMs } from '../utils';\n\nconst INTEGRATION_NAME = 'AppStart';\n\nexport type AppStartIntegration = Integration & {\n captureStandaloneAppStart: () => Promise<void>;\n};\n\n/**\n * We filter out app start more than 60s.\n * This could be due to many different reasons.\n * We've seen app starts with hours, days and even months.\n */\nconst MAX_APP_START_DURATION_MS = 60_000;\n\n/** We filter out App starts which timestamp is 60s and more before the transaction start */\nconst MAX_APP_START_AGE_MS = 60_000;\n\n/** App Start transaction name */\nconst APP_START_TX_NAME = 'App Start';\n\nlet recordedAppStartEndTimestampMs: number | undefined = undefined;\nlet isRecordedAppStartEndTimestampMsManual = false;\n\nlet rootComponentCreationTimestampMs: number | undefined = undefined;\nlet isRootComponentCreationTimestampMsManual = false;\n\n/**\n * Records the application start end.\n * Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.\n */\nexport function captureAppStart(): Promise<void> {\n return _captureAppStart({ isManual: true });\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport async function _captureAppStart({ isManual }: { isManual: boolean }): Promise<void> {\n const client = getClient();\n if (!client) {\n logger.warn('[AppStart] Could not capture App Start, missing client.');\n return;\n }\n\n isRecordedAppStartEndTimestampMsManual = isManual;\n _setAppStartEndTimestampMs(timestampInSeconds() * 1000);\n await client.getIntegrationByName<AppStartIntegration>(INTEGRATION_NAME)?.captureStandaloneAppStart();\n}\n\n/**\n * Sets the root component first constructor call timestamp.\n * Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.\n */\nexport function setRootComponentCreationTimestampMs(timestampMs: number): void {\n recordedAppStartEndTimestampMs &&\n logger.warn('Setting Root component creation timestamp after app start end is set.');\n rootComponentCreationTimestampMs && logger.warn('Overwriting already set root component creation timestamp.');\n rootComponentCreationTimestampMs = timestampMs;\n isRootComponentCreationTimestampMsManual = true;\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport function _setRootComponentCreationTimestampMs(timestampMs: number): void {\n setRootComponentCreationTimestampMs(timestampMs);\n isRootComponentCreationTimestampMsManual = false;\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport const _setAppStartEndTimestampMs = (timestampMs: number): void => {\n recordedAppStartEndTimestampMs && logger.warn('Overwriting already set app start.');\n recordedAppStartEndTimestampMs = timestampMs;\n};\n\n/**\n * For testing purposes only.\n *\n * @private\n */\nexport function _clearRootComponentCreationTimestampMs(): void {\n rootComponentCreationTimestampMs = undefined;\n}\n\n/**\n * Adds AppStart spans from the native layer to the transaction event.\n */\nexport const appStartIntegration = ({\n standalone = false,\n}: {\n /**\n * Should the integration send App Start as a standalone root span (transaction)?\n * If false, App Start will be added as a child span to the first transaction.\n *\n * @default false\n */\n standalone?: boolean;\n} = {}): AppStartIntegration => {\n let _client: Client | undefined = undefined;\n let isEnabled = true;\n let appStartDataFlushed = false;\n let afterAllSetupCalled = false;\n let firstStartedActiveRootSpanId: string | undefined = undefined;\n\n const setup = (client: Client): void => {\n _client = client;\n const { enableAppStartTracking } = client.getOptions() as ReactNativeClientOptions;\n\n if (!enableAppStartTracking) {\n isEnabled = false;\n logger.warn('[AppStart] App start tracking is disabled.');\n }\n\n client.on('spanStart', recordFirstStartedActiveRootSpanId);\n };\n\n const afterAllSetup = (client: Client): void => {\n if (afterAllSetupCalled) {\n return;\n }\n afterAllSetupCalled = true;\n\n // TODO: automatically set standalone based on the presence of the native layer navigation integration\n\n getAppRegistryIntegration(client)?.onRunApplication(() => {\n if (appStartDataFlushed) {\n logger.log('[AppStartIntegration] Resetting app start data flushed flag based on runApplication call.');\n appStartDataFlushed = false;\n firstStartedActiveRootSpanId = undefined;\n } else {\n logger.log(\n '[AppStartIntegration] Waiting for initial app start was flush, before updating based on runApplication call.',\n );\n }\n });\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (!isEnabled || standalone) {\n return event;\n }\n\n if (event.type !== 'transaction') {\n // App start data is only relevant for transactions\n return event;\n }\n\n await attachAppStartToTransactionEvent(event as TransactionEvent);\n\n return event;\n };\n\n const recordFirstStartedActiveRootSpanId = (rootSpan: Span): void => {\n if (firstStartedActiveRootSpanId) {\n return;\n }\n\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n setFirstStartedActiveRootSpanId(rootSpan.spanContext().spanId);\n };\n\n /**\n * For testing purposes only.\n * @private\n */\n const setFirstStartedActiveRootSpanId = (spanId: string | undefined): void => {\n firstStartedActiveRootSpanId = spanId;\n logger.debug('[AppStart] First started active root span id recorded.', firstStartedActiveRootSpanId);\n };\n\n async function captureStandaloneAppStart(): Promise<void> {\n if (!standalone) {\n logger.debug(\n '[AppStart] App start tracking is enabled. App start will be added to the first transaction as a child span.',\n );\n return;\n }\n\n logger.debug('[AppStart] App start tracking standalone root span (transaction).');\n\n const span = startInactiveSpan({\n forceTransaction: true,\n name: APP_START_TX_NAME,\n op: UI_LOAD_OP,\n });\n if (span instanceof SentryNonRecordingSpan) {\n // Tracing is disabled or the transaction was sampled\n return;\n }\n\n setEndTimeValue(span, timestampInSeconds());\n _client.emit('spanEnd', span);\n\n const event = convertSpanToTransaction(span);\n if (!event) {\n logger.warn('[AppStart] Failed to convert App Start span to transaction.');\n return;\n }\n\n await attachAppStartToTransactionEvent(event);\n if (!event.spans || event.spans.length === 0) {\n // No spans were added to the transaction, so we don't need to send it\n return;\n }\n\n const scope = getCapturedScopesOnSpan(span).scope || getCurrentScope();\n scope.captureEvent(event);\n }\n\n async function attachAppStartToTransactionEvent(event: TransactionEvent): Promise<void> {\n if (appStartDataFlushed) {\n // App start data is only relevant for the first transaction of the app run\n return;\n }\n\n if (!firstStartedActiveRootSpanId) {\n logger.warn('[AppStart] No first started active root span id recorded. Can not attach app start.');\n return;\n }\n\n if (!event.contexts || !event.contexts.trace) {\n logger.warn('[AppStart] Transaction event is missing trace context. Can not attach app start.');\n return;\n }\n\n if (firstStartedActiveRootSpanId !== event.contexts.trace.span_id) {\n logger.warn(\n '[AppStart] First started active root span id does not match the transaction event span id. Can not attached app start.',\n );\n return;\n }\n\n const appStart = await NATIVE.fetchNativeAppStart();\n if (!appStart) {\n logger.warn('[AppStart] Failed to retrieve the app start metrics from the native layer.');\n return;\n }\n if (appStart.has_fetched) {\n logger.warn('[AppStart] Measured app start metrics were already reported from the native layer.');\n return;\n }\n\n const appStartTimestampMs = appStart.app_start_timestamp_ms;\n if (!appStartTimestampMs) {\n logger.warn('[AppStart] App start timestamp could not be loaded from the native layer.');\n return;\n }\n\n const appStartEndTimestampMs = recordedAppStartEndTimestampMs || getBundleStartTimestampMs();\n if (!appStartEndTimestampMs) {\n logger.warn(\n '[AppStart] Javascript failed to record app start end. `setAppStartEndTimestampMs` was not called nor could the bundle start be found.',\n );\n return;\n }\n\n const isAppStartWithinBounds =\n !!event.start_timestamp && appStartTimestampMs >= event.start_timestamp * 1_000 - MAX_APP_START_AGE_MS;\n if (!__DEV__ && !isAppStartWithinBounds) {\n logger.warn('[AppStart] App start timestamp is too far in the past to be used for app start span.');\n return;\n }\n\n const appStartDurationMs = appStartEndTimestampMs - appStartTimestampMs;\n if (!__DEV__ && appStartDurationMs >= MAX_APP_START_DURATION_MS) {\n // Dev builds can have long app start waiting over minute for the first bundle to be produced\n logger.warn('[AppStart] App start duration is over a minute long, not adding app start span.');\n return;\n }\n\n if (appStartDurationMs < 0) {\n // This can happen when MainActivity on Android is recreated,\n // and the app start end timestamp is not updated, for example\n // due to missing `Sentry.wrap(RootComponent)` call.\n logger.warn(\n '[AppStart] Last recorded app start end timestamp is before the app start timestamp.',\n 'This is usually caused by missing `Sentry.wrap(RootComponent)` call.',\n );\n return;\n }\n\n appStartDataFlushed = true;\n\n event.contexts.trace.data = event.contexts.trace.data || {};\n event.contexts.trace.data[SEMANTIC_ATTRIBUTE_SENTRY_OP] = UI_LOAD_OP;\n event.contexts.trace.op = UI_LOAD_OP;\n\n const origin = isRecordedAppStartEndTimestampMsManual ? SPAN_ORIGIN_MANUAL_APP_START : SPAN_ORIGIN_AUTO_APP_START;\n event.contexts.trace.data[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = origin;\n event.contexts.trace.origin = origin;\n\n const appStartTimestampSeconds = appStartTimestampMs / 1000;\n event.start_timestamp = appStartTimestampSeconds;\n\n event.spans = event.spans || [];\n /** event.spans reference */\n const children: SpanJSON[] = event.spans;\n\n const maybeTtidSpan = children.find(({ op }) => op === 'ui.load.initial_display');\n if (maybeTtidSpan) {\n maybeTtidSpan.start_timestamp = appStartTimestampSeconds;\n setSpanDurationAsMeasurementOnTransactionEvent(event, 'time_to_initial_display', maybeTtidSpan);\n }\n\n const maybeTtfdSpan = children.find(({ op }) => op === 'ui.load.full_display');\n if (maybeTtfdSpan) {\n maybeTtfdSpan.start_timestamp = appStartTimestampSeconds;\n setSpanDurationAsMeasurementOnTransactionEvent(event, 'time_to_full_display', maybeTtfdSpan);\n }\n\n const appStartEndTimestampSeconds = appStartEndTimestampMs / 1000;\n if (event.timestamp && event.timestamp < appStartEndTimestampSeconds) {\n logger.debug(\n '[AppStart] Transaction event timestamp is before app start end. Adjusting transaction event timestamp.',\n );\n event.timestamp = appStartEndTimestampSeconds;\n }\n\n const op = appStart.type === 'cold' ? APP_START_COLD_OP : APP_START_WARM_OP;\n const appStartSpanJSON: SpanJSON = createSpanJSON({\n op,\n description: appStart.type === 'cold' ? 'Cold App Start' : 'Warm App Start',\n start_timestamp: appStartTimestampSeconds,\n timestamp: appStartEndTimestampSeconds,\n trace_id: event.contexts.trace.trace_id,\n parent_span_id: event.contexts.trace.span_id,\n origin,\n });\n const jsExecutionSpanJSON = createJSExecutionStartSpan(appStartSpanJSON, rootComponentCreationTimestampMs);\n\n const appStartSpans = [\n appStartSpanJSON,\n ...(jsExecutionSpanJSON ? [jsExecutionSpanJSON] : []),\n ...convertNativeSpansToSpanJSON(appStartSpanJSON, appStart.spans),\n ];\n\n children.push(...appStartSpans);\n logger.debug('[AppStart] Added app start spans to transaction event.', JSON.stringify(appStartSpans, undefined, 2));\n\n const measurementKey = appStart.type === 'cold' ? APP_START_COLD_MEASUREMENT : APP_START_WARM_MEASUREMENT;\n const measurementValue = {\n value: appStartDurationMs,\n unit: 'millisecond',\n };\n event.measurements = event.measurements || {};\n event.measurements[measurementKey] = measurementValue;\n logger.debug(\n `[AppStart] Added app start measurement to transaction event.`,\n JSON.stringify(measurementValue, undefined, 2),\n );\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n afterAllSetup,\n processEvent,\n captureStandaloneAppStart,\n setFirstStartedActiveRootSpanId,\n } as AppStartIntegration;\n};\n\nfunction setSpanDurationAsMeasurementOnTransactionEvent(event: TransactionEvent, label: string, span: SpanJSON): void {\n if (!span.timestamp || !span.start_timestamp) {\n logger.warn('Span is missing start or end timestamp. Cam not set measurement on transaction event.');\n return;\n }\n\n event.measurements = event.measurements || {};\n event.measurements[label] = {\n value: (span.timestamp - span.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n}\n\n/**\n * Adds JS Execution before React Root. If `Sentry.wrap` is not used, create a span for the start of JS Bundle execution.\n */\nfunction createJSExecutionStartSpan(\n parentSpan: SpanJSON,\n rootComponentCreationTimestampMs: number | undefined,\n): SpanJSON | undefined {\n const bundleStartTimestampMs = getBundleStartTimestampMs();\n if (!bundleStartTimestampMs) {\n return undefined;\n }\n\n const bundleStartTimestampSeconds = bundleStartTimestampMs / 1000;\n if (bundleStartTimestampSeconds < parentSpan.start_timestamp) {\n logger.warn('Bundle start timestamp is before the app start span start timestamp. Skipping JS execution span.');\n return undefined;\n }\n\n if (!rootComponentCreationTimestampMs) {\n logger.warn('Missing the root component first constructor call timestamp.');\n return createChildSpanJSON(parentSpan, {\n description: 'JS Bundle Execution Start',\n start_timestamp: bundleStartTimestampSeconds,\n timestamp: bundleStartTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n }\n\n return createChildSpanJSON(parentSpan, {\n description: 'JS Bundle Execution Before React Root',\n start_timestamp: bundleStartTimestampSeconds,\n timestamp: rootComponentCreationTimestampMs / 1000,\n origin: isRootComponentCreationTimestampMsManual ? SPAN_ORIGIN_MANUAL_APP_START : SPAN_ORIGIN_AUTO_APP_START,\n });\n}\n\n/**\n * Adds native spans to the app start span.\n */\nfunction convertNativeSpansToSpanJSON(parentSpan: SpanJSON, nativeSpans: NativeAppStartResponse['spans']): SpanJSON[] {\n return nativeSpans\n .filter(span => span.start_timestamp_ms / 1000 >= parentSpan.start_timestamp)\n .map(span => {\n if (span.description === 'UIKit init') {\n return setMainThreadInfo(createUIKitSpan(parentSpan, span));\n }\n\n return setMainThreadInfo(\n createChildSpanJSON(parentSpan, {\n description: span.description,\n start_timestamp: span.start_timestamp_ms / 1000,\n timestamp: span.end_timestamp_ms / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n }),\n );\n });\n}\n\n/**\n * UIKit init is measured by the native layers till the native SDK start\n * RN initializes the native SDK later, the end timestamp would be wrong\n */\nfunction createUIKitSpan(parentSpan: SpanJSON, nativeUIKitSpan: NativeAppStartResponse['spans'][number]): SpanJSON {\n const bundleStart = getBundleStartTimestampMs();\n\n // If UIKit init ends after the bundle start, the native SDK was auto-initialized\n // and so the end timestamp is incorrect.\n // The timestamps can't equal, as RN initializes after UIKit.\n if (bundleStart && bundleStart < nativeUIKitSpan.end_timestamp_ms) {\n return createChildSpanJSON(parentSpan, {\n description: 'UIKit Init to JS Exec Start',\n start_timestamp: nativeUIKitSpan.start_timestamp_ms / 1000,\n timestamp: bundleStart / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n } else {\n return createChildSpanJSON(parentSpan, {\n description: 'UIKit Init',\n start_timestamp: nativeUIKitSpan.start_timestamp_ms / 1000,\n timestamp: nativeUIKitSpan.end_timestamp_ms / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"appStart.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/appStart.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,eAAe,EACf,MAAM,EACN,gCAAgC,EAChC,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C7B,eAAe,EAAE,IAAI,CAAC,kBAAkB,GAAG,IAAI;YAC/C,SAAS,EAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI;YACvC,MAAM,EAAE,0BAA0B;SACnC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,UAAoB,EAAE,eAAwD;IACrG,MAAM,WAAW,GAAG,yBAAyB,EAAE,CAAC;IAEhD,iFAAiF;IACjF,yCAAyC;IACzC,6DAA6D;IAC7D,IAAI,WAAW,IAAI,WAAW,GAAG,eAAe,CAAC,gBAAgB,EAAE;QACjE,OAAO,mBAAmB,CAAC,UAAU,EAAE;YACrC,WAAW,EAAE,6BAA6B;YAC1C,eAAe,EAAE,eAAe,CAAC,kBAAkB,GAAG,IAAI;YAC1D,SAAS,EAAE,WAAW,GAAG,IAAI;YAC7B,MAAM,EAAE,0BAA0B;SACnC,CAAC,CAAC;KACJ;SAAM;QACL,OAAO,mBAAmB,CAAC,UAAU,EAAE;YACrC,WAAW,EAAE,YAAY;YACzB,eAAe,EAAE,eAAe,CAAC,kBAAkB,GAAG,IAAI;YAC1D,SAAS,EAAE,eAAe,CAAC,gBAAgB,GAAG,IAAI;YAClD,MAAM,EAAE,0BAA0B;SACnC,CAAC,CAAC;KACJ;AACH,CAAC","sourcesContent":["/* eslint-disable complexity, max-lines */\nimport type { Client, Event, Integration, Span, SpanJSON, TransactionEvent } from '@sentry/core';\nimport {\n getCapturedScopesOnSpan,\n getClient,\n getCurrentScope,\n logger,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SentryNonRecordingSpan,\n startInactiveSpan,\n timestampInSeconds,\n} from '@sentry/core';\n\nimport { getAppRegistryIntegration } from '../../integrations/appRegistry';\nimport {\n APP_START_COLD as APP_START_COLD_MEASUREMENT,\n APP_START_WARM as APP_START_WARM_MEASUREMENT,\n} from '../../measurements';\nimport type { NativeAppStartResponse, NativeFramesResponse } from '../../NativeRNSentry';\nimport type { ReactNativeClientOptions } from '../../options';\nimport { convertSpanToTransaction, isRootSpan, setEndTimeValue } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\nimport {\n APP_START_COLD as APP_START_COLD_OP,\n APP_START_WARM as APP_START_WARM_OP,\n UI_LOAD as UI_LOAD_OP,\n} from '../ops';\nimport { SPAN_ORIGIN_AUTO_APP_START, SPAN_ORIGIN_MANUAL_APP_START } from '../origin';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_OP } from '../semanticAttributes';\nimport { setMainThreadInfo } from '../span';\nimport { createChildSpanJSON, createSpanJSON, getBundleStartTimestampMs } from '../utils';\n\nconst INTEGRATION_NAME = 'AppStart';\n\nexport type AppStartIntegration = Integration & {\n captureStandaloneAppStart: () => Promise<void>;\n};\n\n/**\n * We filter out app start more than 60s.\n * This could be due to many different reasons.\n * We've seen app starts with hours, days and even months.\n */\nconst MAX_APP_START_DURATION_MS = 60_000;\n\n/** We filter out App starts which timestamp is 60s and more before the transaction start */\nconst MAX_APP_START_AGE_MS = 60_000;\n\n/** App Start transaction name */\nconst APP_START_TX_NAME = 'App Start';\n\ninterface AppStartEndData {\n timestampMs: number;\n endFrames: NativeFramesResponse | null;\n}\n\nlet appStartEndData: AppStartEndData | undefined = undefined;\nlet isRecordedAppStartEndTimestampMsManual = false;\n\nlet rootComponentCreationTimestampMs: number | undefined = undefined;\nlet isRootComponentCreationTimestampMsManual = false;\n\n/**\n * Records the application start end.\n * Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.\n */\nexport function captureAppStart(): Promise<void> {\n return _captureAppStart({ isManual: true });\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport async function _captureAppStart({ isManual }: { isManual: boolean }): Promise<void> {\n const client = getClient();\n if (!client) {\n logger.warn('[AppStart] Could not capture App Start, missing client.');\n return;\n }\n\n isRecordedAppStartEndTimestampMsManual = isManual;\n\n const timestampMs = timestampInSeconds() * 1000;\n let endFrames: NativeFramesResponse | null = null;\n\n if (NATIVE.enableNative) {\n try {\n endFrames = await NATIVE.fetchNativeFrames();\n logger.debug('[AppStart] Captured end frames for app start.', endFrames);\n } catch (error) {\n logger.debug('[AppStart] Failed to capture end frames for app start.', error);\n }\n }\n\n _setAppStartEndData({\n timestampMs,\n endFrames,\n });\n\n await client.getIntegrationByName<AppStartIntegration>(INTEGRATION_NAME)?.captureStandaloneAppStart();\n}\n\n/**\n * Sets the root component first constructor call timestamp.\n * Used automatically by `Sentry.wrap` and `Sentry.ReactNativeProfiler`.\n */\nexport function setRootComponentCreationTimestampMs(timestampMs: number): void {\n appStartEndData?.timestampMs && logger.warn('Setting Root component creation timestamp after app start end is set.');\n rootComponentCreationTimestampMs && logger.warn('Overwriting already set root component creation timestamp.');\n rootComponentCreationTimestampMs = timestampMs;\n isRootComponentCreationTimestampMsManual = true;\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport function _setRootComponentCreationTimestampMs(timestampMs: number): void {\n setRootComponentCreationTimestampMs(timestampMs);\n isRootComponentCreationTimestampMsManual = false;\n}\n\n/**\n * For internal use only.\n *\n * @private\n */\nexport const _setAppStartEndData = (data: AppStartEndData): void => {\n appStartEndData && logger.warn('Overwriting already set app start end data.');\n appStartEndData = data;\n};\n\n/**\n * For testing purposes only.\n *\n * @private\n */\nexport function _clearRootComponentCreationTimestampMs(): void {\n rootComponentCreationTimestampMs = undefined;\n}\n\n/**\n * Attaches frame data to a span's data object.\n */\nfunction attachFrameDataToSpan(span: SpanJSON, frames: NativeFramesResponse): void {\n if (frames.totalFrames <= 0 && frames.slowFrames <= 0 && frames.totalFrames <= 0) {\n logger.warn(`[AppStart] Detected zero slow or frozen frames. Not adding measurements to spanId (${span.span_id}).`);\n return;\n }\n span.data = span.data || {};\n span.data['frames.total'] = frames.totalFrames;\n span.data['frames.slow'] = frames.slowFrames;\n span.data['frames.frozen'] = frames.frozenFrames;\n\n logger.debug('[AppStart] Attached frame data to span.', {\n spanId: span.span_id,\n frameData: {\n total: frames.totalFrames,\n slow: frames.slowFrames,\n frozen: frames.frozenFrames,\n },\n });\n}\n\n/**\n * Adds AppStart spans from the native layer to the transaction event.\n */\nexport const appStartIntegration = ({\n standalone = false,\n}: {\n /**\n * Should the integration send App Start as a standalone root span (transaction)?\n * If false, App Start will be added as a child span to the first transaction.\n *\n * @default false\n */\n standalone?: boolean;\n} = {}): AppStartIntegration => {\n let _client: Client | undefined = undefined;\n let isEnabled = true;\n let appStartDataFlushed = false;\n let afterAllSetupCalled = false;\n let firstStartedActiveRootSpanId: string | undefined = undefined;\n\n const setup = (client: Client): void => {\n _client = client;\n const { enableAppStartTracking } = client.getOptions() as ReactNativeClientOptions;\n\n if (!enableAppStartTracking) {\n isEnabled = false;\n logger.warn('[AppStart] App start tracking is disabled.');\n }\n\n client.on('spanStart', recordFirstStartedActiveRootSpanId);\n };\n\n const afterAllSetup = (client: Client): void => {\n if (afterAllSetupCalled) {\n return;\n }\n afterAllSetupCalled = true;\n\n // TODO: automatically set standalone based on the presence of the native layer navigation integration\n\n getAppRegistryIntegration(client)?.onRunApplication(() => {\n if (appStartDataFlushed) {\n logger.log('[AppStartIntegration] Resetting app start data flushed flag based on runApplication call.');\n appStartDataFlushed = false;\n firstStartedActiveRootSpanId = undefined;\n } else {\n logger.log(\n '[AppStartIntegration] Waiting for initial app start was flush, before updating based on runApplication call.',\n );\n }\n });\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (!isEnabled || standalone) {\n return event;\n }\n\n if (event.type !== 'transaction') {\n // App start data is only relevant for transactions\n return event;\n }\n\n await attachAppStartToTransactionEvent(event as TransactionEvent);\n\n return event;\n };\n\n const recordFirstStartedActiveRootSpanId = (rootSpan: Span): void => {\n if (firstStartedActiveRootSpanId) {\n return;\n }\n\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n setFirstStartedActiveRootSpanId(rootSpan.spanContext().spanId);\n };\n\n /**\n * For testing purposes only.\n * @private\n */\n const setFirstStartedActiveRootSpanId = (spanId: string | undefined): void => {\n firstStartedActiveRootSpanId = spanId;\n logger.debug('[AppStart] First started active root span id recorded.', firstStartedActiveRootSpanId);\n };\n\n async function captureStandaloneAppStart(): Promise<void> {\n if (!standalone) {\n logger.debug(\n '[AppStart] App start tracking is enabled. App start will be added to the first transaction as a child span.',\n );\n return;\n }\n\n logger.debug('[AppStart] App start tracking standalone root span (transaction).');\n\n if (!appStartEndData?.endFrames && NATIVE.enableNative) {\n try {\n const endFrames = await NATIVE.fetchNativeFrames();\n logger.debug('[AppStart] Captured end frames for standalone app start.', endFrames);\n\n const currentTimestamp = appStartEndData?.timestampMs || timestampInSeconds() * 1000;\n _setAppStartEndData({\n timestampMs: currentTimestamp,\n endFrames,\n });\n } catch (error) {\n logger.debug('[AppStart] Failed to capture frames for standalone app start.', error);\n }\n }\n\n const span = startInactiveSpan({\n forceTransaction: true,\n name: APP_START_TX_NAME,\n op: UI_LOAD_OP,\n });\n if (span instanceof SentryNonRecordingSpan) {\n // Tracing is disabled or the transaction was sampled\n return;\n }\n\n setEndTimeValue(span, timestampInSeconds());\n _client.emit('spanEnd', span);\n\n const event = convertSpanToTransaction(span);\n if (!event) {\n logger.warn('[AppStart] Failed to convert App Start span to transaction.');\n return;\n }\n\n await attachAppStartToTransactionEvent(event);\n if (!event.spans || event.spans.length === 0) {\n // No spans were added to the transaction, so we don't need to send it\n return;\n }\n\n const scope = getCapturedScopesOnSpan(span).scope || getCurrentScope();\n scope.captureEvent(event);\n }\n\n async function attachAppStartToTransactionEvent(event: TransactionEvent): Promise<void> {\n if (appStartDataFlushed) {\n // App start data is only relevant for the first transaction of the app run\n return;\n }\n\n if (!firstStartedActiveRootSpanId) {\n logger.warn('[AppStart] No first started active root span id recorded. Can not attach app start.');\n return;\n }\n\n if (!event.contexts || !event.contexts.trace) {\n logger.warn('[AppStart] Transaction event is missing trace context. Can not attach app start.');\n return;\n }\n\n if (firstStartedActiveRootSpanId !== event.contexts.trace.span_id) {\n logger.warn(\n '[AppStart] First started active root span id does not match the transaction event span id. Can not attached app start.',\n );\n return;\n }\n\n const appStart = await NATIVE.fetchNativeAppStart();\n if (!appStart) {\n logger.warn('[AppStart] Failed to retrieve the app start metrics from the native layer.');\n return;\n }\n if (appStart.has_fetched) {\n logger.warn('[AppStart] Measured app start metrics were already reported from the native layer.');\n return;\n }\n\n const appStartTimestampMs = appStart.app_start_timestamp_ms;\n if (!appStartTimestampMs) {\n logger.warn('[AppStart] App start timestamp could not be loaded from the native layer.');\n return;\n }\n\n const appStartEndTimestampMs = appStartEndData?.timestampMs || getBundleStartTimestampMs();\n if (!appStartEndTimestampMs) {\n logger.warn(\n '[AppStart] Javascript failed to record app start end. `_setAppStartEndData` was not called nor could the bundle start be found.',\n );\n return;\n }\n\n const isAppStartWithinBounds =\n !!event.start_timestamp && appStartTimestampMs >= event.start_timestamp * 1_000 - MAX_APP_START_AGE_MS;\n if (!__DEV__ && !isAppStartWithinBounds) {\n logger.warn('[AppStart] App start timestamp is too far in the past to be used for app start span.');\n return;\n }\n\n const appStartDurationMs = appStartEndTimestampMs - appStartTimestampMs;\n if (!__DEV__ && appStartDurationMs >= MAX_APP_START_DURATION_MS) {\n // Dev builds can have long app start waiting over minute for the first bundle to be produced\n logger.warn('[AppStart] App start duration is over a minute long, not adding app start span.');\n return;\n }\n\n if (appStartDurationMs < 0) {\n // This can happen when MainActivity on Android is recreated,\n // and the app start end timestamp is not updated, for example\n // due to missing `Sentry.wrap(RootComponent)` call.\n logger.warn(\n '[AppStart] Last recorded app start end timestamp is before the app start timestamp.',\n 'This is usually caused by missing `Sentry.wrap(RootComponent)` call.',\n );\n return;\n }\n\n appStartDataFlushed = true;\n\n event.contexts.trace.data = event.contexts.trace.data || {};\n event.contexts.trace.data[SEMANTIC_ATTRIBUTE_SENTRY_OP] = UI_LOAD_OP;\n event.contexts.trace.op = UI_LOAD_OP;\n\n const origin = isRecordedAppStartEndTimestampMsManual ? SPAN_ORIGIN_MANUAL_APP_START : SPAN_ORIGIN_AUTO_APP_START;\n event.contexts.trace.data[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = origin;\n event.contexts.trace.origin = origin;\n\n const appStartTimestampSeconds = appStartTimestampMs / 1000;\n event.start_timestamp = appStartTimestampSeconds;\n\n event.spans = event.spans || [];\n /** event.spans reference */\n const children: SpanJSON[] = event.spans;\n\n const maybeTtidSpan = children.find(({ op }) => op === 'ui.load.initial_display');\n if (maybeTtidSpan) {\n maybeTtidSpan.start_timestamp = appStartTimestampSeconds;\n setSpanDurationAsMeasurementOnTransactionEvent(event, 'time_to_initial_display', maybeTtidSpan);\n }\n\n const maybeTtfdSpan = children.find(({ op }) => op === 'ui.load.full_display');\n if (maybeTtfdSpan) {\n maybeTtfdSpan.start_timestamp = appStartTimestampSeconds;\n setSpanDurationAsMeasurementOnTransactionEvent(event, 'time_to_full_display', maybeTtfdSpan);\n }\n\n const appStartEndTimestampSeconds = appStartEndTimestampMs / 1000;\n if (event.timestamp && event.timestamp < appStartEndTimestampSeconds) {\n logger.debug(\n '[AppStart] Transaction event timestamp is before app start end. Adjusting transaction event timestamp.',\n );\n event.timestamp = appStartEndTimestampSeconds;\n }\n\n const op = appStart.type === 'cold' ? APP_START_COLD_OP : APP_START_WARM_OP;\n const appStartSpanJSON: SpanJSON = createSpanJSON({\n op,\n description: appStart.type === 'cold' ? 'Cold App Start' : 'Warm App Start',\n start_timestamp: appStartTimestampSeconds,\n timestamp: appStartEndTimestampSeconds,\n trace_id: event.contexts.trace.trace_id,\n parent_span_id: event.contexts.trace.span_id,\n origin,\n });\n\n if (appStartEndData?.endFrames) {\n attachFrameDataToSpan(appStartSpanJSON, appStartEndData.endFrames);\n }\n\n const jsExecutionSpanJSON = createJSExecutionStartSpan(appStartSpanJSON, rootComponentCreationTimestampMs);\n\n const appStartSpans = [\n appStartSpanJSON,\n ...(jsExecutionSpanJSON ? [jsExecutionSpanJSON] : []),\n ...convertNativeSpansToSpanJSON(appStartSpanJSON, appStart.spans),\n ];\n\n children.push(...appStartSpans);\n logger.debug('[AppStart] Added app start spans to transaction event.', JSON.stringify(appStartSpans, undefined, 2));\n\n const measurementKey = appStart.type === 'cold' ? APP_START_COLD_MEASUREMENT : APP_START_WARM_MEASUREMENT;\n const measurementValue = {\n value: appStartDurationMs,\n unit: 'millisecond',\n };\n event.measurements = event.measurements || {};\n event.measurements[measurementKey] = measurementValue;\n logger.debug(\n `[AppStart] Added app start measurement to transaction event.`,\n JSON.stringify(measurementValue, undefined, 2),\n );\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n afterAllSetup,\n processEvent,\n captureStandaloneAppStart,\n setFirstStartedActiveRootSpanId,\n } as AppStartIntegration;\n};\n\nfunction setSpanDurationAsMeasurementOnTransactionEvent(event: TransactionEvent, label: string, span: SpanJSON): void {\n if (!span.timestamp || !span.start_timestamp) {\n logger.warn('Span is missing start or end timestamp. Cam not set measurement on transaction event.');\n return;\n }\n\n event.measurements = event.measurements || {};\n event.measurements[label] = {\n value: (span.timestamp - span.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n}\n\n/**\n * Adds JS Execution before React Root. If `Sentry.wrap` is not used, create a span for the start of JS Bundle execution.\n */\nfunction createJSExecutionStartSpan(\n parentSpan: SpanJSON,\n rootComponentCreationTimestampMs: number | undefined,\n): SpanJSON | undefined {\n const bundleStartTimestampMs = getBundleStartTimestampMs();\n if (!bundleStartTimestampMs) {\n return undefined;\n }\n\n const bundleStartTimestampSeconds = bundleStartTimestampMs / 1000;\n if (bundleStartTimestampSeconds < parentSpan.start_timestamp) {\n logger.warn('Bundle start timestamp is before the app start span start timestamp. Skipping JS execution span.');\n return undefined;\n }\n\n if (!rootComponentCreationTimestampMs) {\n logger.warn('Missing the root component first constructor call timestamp.');\n return createChildSpanJSON(parentSpan, {\n description: 'JS Bundle Execution Start',\n start_timestamp: bundleStartTimestampSeconds,\n timestamp: bundleStartTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n }\n\n return createChildSpanJSON(parentSpan, {\n description: 'JS Bundle Execution Before React Root',\n start_timestamp: bundleStartTimestampSeconds,\n timestamp: rootComponentCreationTimestampMs / 1000,\n origin: isRootComponentCreationTimestampMsManual ? SPAN_ORIGIN_MANUAL_APP_START : SPAN_ORIGIN_AUTO_APP_START,\n });\n}\n\n/**\n * Adds native spans to the app start span.\n */\nfunction convertNativeSpansToSpanJSON(parentSpan: SpanJSON, nativeSpans: NativeAppStartResponse['spans']): SpanJSON[] {\n return nativeSpans\n .filter(span => span.start_timestamp_ms / 1000 >= parentSpan.start_timestamp)\n .map(span => {\n if (span.description === 'UIKit init') {\n return setMainThreadInfo(createUIKitSpan(parentSpan, span));\n }\n\n return setMainThreadInfo(\n createChildSpanJSON(parentSpan, {\n description: span.description,\n start_timestamp: span.start_timestamp_ms / 1000,\n timestamp: span.end_timestamp_ms / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n }),\n );\n });\n}\n\n/**\n * UIKit init is measured by the native layers till the native SDK start\n * RN initializes the native SDK later, the end timestamp would be wrong\n */\nfunction createUIKitSpan(parentSpan: SpanJSON, nativeUIKitSpan: NativeAppStartResponse['spans'][number]): SpanJSON {\n const bundleStart = getBundleStartTimestampMs();\n\n // If UIKit init ends after the bundle start, the native SDK was auto-initialized\n // and so the end timestamp is incorrect.\n // The timestamps can't equal, as RN initializes after UIKit.\n if (bundleStart && bundleStart < nativeUIKitSpan.end_timestamp_ms) {\n return createChildSpanJSON(parentSpan, {\n description: 'UIKit Init to JS Exec Start',\n start_timestamp: nativeUIKitSpan.start_timestamp_ms / 1000,\n timestamp: bundleStart / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n } else {\n return createChildSpanJSON(parentSpan, {\n description: 'UIKit Init',\n start_timestamp: nativeUIKitSpan.start_timestamp_ms / 1000,\n timestamp: nativeUIKitSpan.end_timestamp_ms / 1000,\n origin: SPAN_ORIGIN_AUTO_APP_START,\n });\n }\n}\n"]}
|
package/dist/js/tracing/span.js
CHANGED
|
@@ -20,9 +20,9 @@ export const startIdleNavigationSpan = (startSpanOption, { finalTimeout = defaul
|
|
|
20
20
|
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });
|
|
21
21
|
activeSpan.end();
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
const idleSpan = startIdleSpan(
|
|
25
|
-
logger.log(`[startIdleNavigationSpan] Starting ${
|
|
23
|
+
const finalStartSpanOptions = Object.assign(Object.assign({}, getDefaultIdleNavigationSpanOptions()), startSpanOption);
|
|
24
|
+
const idleSpan = startIdleSpan(finalStartSpanOptions, { finalTimeout, idleTimeout });
|
|
25
|
+
logger.log(`[startIdleNavigationSpan] Starting ${finalStartSpanOptions.op || 'unknown op'} transaction "${finalStartSpanOptions.name}" on scope`);
|
|
26
26
|
adjustTransactionDuration(client, idleSpan, finalTimeout);
|
|
27
27
|
idleSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_AUTO_NAVIGATION_CUSTOM);
|
|
28
28
|
return idleSpan;
|