-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(issue-details): Add android native tombstones onboarding banner #112478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
romtsn
wants to merge
8
commits into
master
Choose a base branch
from
romtsn/feat/android-tombstones-onboarding-banner
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+264
−1
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6d09b26
feat(issue-details): Add android native tombstones onboarding banner
romtsn b60e58f
ref(issue-details): Remove InterimSection wrapper from tombstones banner
romtsn 36fa985
Merge branch 'master' into romtsn/feat/android-tombstones-onboarding-…
romtsn a48dbb8
fix(issue-details): Fix typescript errors in tombstones banner
romtsn 2be4560
fix(issue-details): Address review feedback on tombstones banner
romtsn 4d3357b
feat(issue-details): Support React Native and Flutter in tombstones b…
romtsn 900c188
fix(issue-details): Fix typescript error for activeTab assertion
romtsn b59ff29
fix(issue-details): Remove dead white color from close button
romtsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
248 changes: 248 additions & 0 deletions
248
...app/components/events/interfaces/crashContent/exception/androidNativeTombstonesBanner.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| import {useState} from 'react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| import {LinkButton} from '@sentry/scraps/button'; | ||
| import {CodeBlock} from '@sentry/scraps/code'; | ||
| import {Flex} from '@sentry/scraps/layout'; | ||
| import {Heading, Text} from '@sentry/scraps/text'; | ||
|
|
||
| import {usePrompt} from 'sentry/actionCreators/prompts'; | ||
| import {DropdownMenu} from 'sentry/components/dropdownMenu'; | ||
| import {IconClose} from 'sentry/icons'; | ||
| import {t} from 'sentry/locale'; | ||
| import type {EntryException, Event, ExceptionValue} from 'sentry/types/event'; | ||
| import {EntryType} from 'sentry/types/event'; | ||
| import {trackAnalytics} from 'sentry/utils/analytics'; | ||
| import {useOrganization} from 'sentry/utils/useOrganization'; | ||
|
|
||
| const TOMBSTONES_DOCS_URL = | ||
| 'https://docs.sentry.io/platforms/android/configuration/tombstones/'; | ||
|
|
||
| type TabConfig = { | ||
| code: string; | ||
| label: string; | ||
| language: string; | ||
| value: string; | ||
| }; | ||
|
|
||
| type SdkConfig = { | ||
| defaultTab: string; | ||
| tabs: TabConfig[]; | ||
| }; | ||
|
|
||
| const ANDROID_SDK_CONFIG: SdkConfig = { | ||
| defaultTab: 'manifest', | ||
| tabs: [ | ||
| { | ||
| label: 'AndroidManifest.xml', | ||
| value: 'manifest', | ||
| language: 'xml', | ||
| code: `<!-- Requires sentry-android 8.35.0+ --> | ||
| <application> | ||
| <meta-data | ||
| android:name="io.sentry.tombstone.enable" | ||
| android:value="true" /> | ||
| </application>`, | ||
| }, | ||
| { | ||
| label: 'Kotlin', | ||
| value: 'kotlin', | ||
| language: 'kotlin', | ||
| code: `// Requires sentry-android 8.35.0+ | ||
| SentryAndroid.init(context) { options -> | ||
| options.isTombstoneEnabled = true | ||
| }`, | ||
| }, | ||
| { | ||
| label: 'Java', | ||
| value: 'java', | ||
| language: 'java', | ||
| code: `// Requires sentry-android 8.35.0+ | ||
| SentryAndroid.init(context, options -> { | ||
| options.setTombstoneEnabled(true); | ||
| });`, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const REACT_NATIVE_SDK_CONFIG: SdkConfig = { | ||
| defaultTab: 'javascript', | ||
| tabs: [ | ||
| { | ||
| label: 'JavaScript', | ||
| value: 'javascript', | ||
| language: 'javascript', | ||
| code: `// Requires @sentry/react-native 8.5.0+ | ||
| Sentry.init({ | ||
| enableTombstone: true, | ||
| });`, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const FLUTTER_SDK_CONFIG: SdkConfig = { | ||
| defaultTab: 'dart', | ||
| tabs: [ | ||
| { | ||
| label: 'Dart', | ||
| value: 'dart', | ||
| language: 'dart', | ||
| code: `// Requires sentry_flutter 9.15.0+ | ||
| await SentryFlutter.init( | ||
| (options) { | ||
| options.enableTombstone = true; | ||
| }, | ||
| );`, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const SDK_CONFIGS: Record<string, SdkConfig> = { | ||
| 'sentry.native.android': ANDROID_SDK_CONFIG, | ||
| 'sentry.native.android.react-native': REACT_NATIVE_SDK_CONFIG, | ||
| 'sentry.native.android.flutter': FLUTTER_SDK_CONFIG, | ||
| }; | ||
|
|
||
| function hasSignalHandlerMechanism(event: Event): boolean { | ||
| const exceptionEntry = event.entries?.find( | ||
| (entry): entry is EntryException => entry.type === EntryType.EXCEPTION | ||
| ); | ||
| if (!exceptionEntry) { | ||
| return false; | ||
| } | ||
| return ( | ||
| exceptionEntry.data.values?.some( | ||
| (value: ExceptionValue) => value.mechanism?.type === 'signalhandler' | ||
| ) ?? false | ||
| ); | ||
| } | ||
|
|
||
| function getSdkConfig(event: Event): SdkConfig | undefined { | ||
| const sdkName = event.sdk?.name; | ||
| if (!sdkName) { | ||
| return undefined; | ||
| } | ||
| return SDK_CONFIGS[sdkName]; | ||
| } | ||
|
|
||
| export function shouldShowTombstonesBanner(event: Event): boolean { | ||
| return getSdkConfig(event) !== undefined && hasSignalHandlerMechanism(event); | ||
| } | ||
|
|
||
| interface Props { | ||
| event: Event; | ||
| projectId: string; | ||
| } | ||
|
|
||
| export function AndroidNativeTombstonesBanner({event, projectId}: Props) { | ||
| const organization = useOrganization(); | ||
| const sdkConfig = getSdkConfig(event); | ||
| const [codeTab, setCodeTab] = useState(sdkConfig?.defaultTab ?? 'manifest'); | ||
|
|
||
| const {isLoading, isError, isPromptDismissed, dismissPrompt, snoozePrompt} = usePrompt({ | ||
| feature: 'issue_android_tombstones_onboarding', | ||
| organization, | ||
| projectId, | ||
| daysToSnooze: 7, | ||
| }); | ||
|
|
||
| if (isLoading || isError || isPromptDismissed || !sdkConfig) { | ||
| return null; | ||
| } | ||
|
|
||
| const activeTab = | ||
| sdkConfig.tabs.find(tab => tab.value === codeTab) ?? sdkConfig.tabs[0]!; | ||
|
|
||
| return ( | ||
| <BannerWrapper> | ||
| <Flex direction="column" gap="md"> | ||
| <Heading as="h4">{t('Enable Tombstone Collection')}</Heading> | ||
| <Text as="p" style={{maxWidth: 460}}> | ||
| {t( | ||
| 'This native crash was captured via the Android NDK integration only. Enable Tombstone collection in your application to get richer crash reports with more context, including additional thread information, better stack traces and more.' | ||
| )} | ||
| </Text> | ||
| <CodeBlock | ||
| tabs={sdkConfig.tabs.map(tab => ({label: tab.label, value: tab.value}))} | ||
| selectedTab={codeTab} | ||
| onTabClick={setCodeTab} | ||
| language={activeTab.language} | ||
| > | ||
| {activeTab.code} | ||
| </CodeBlock> | ||
| <LinkButton | ||
| style={{alignSelf: 'flex-start'}} | ||
| href={TOMBSTONES_DOCS_URL} | ||
| external | ||
| priority="primary" | ||
| size="sm" | ||
| analyticsEventName="Clicked Android Tombstones Onboarding CTA" | ||
| analyticsEventKey="issue-details.android-tombstones-onboarding-cta-clicked" | ||
| analyticsParams={{ | ||
| organization, | ||
| sdk_name: event.sdk?.name ?? '', | ||
| }} | ||
| > | ||
| {t('Learn More')} | ||
| </LinkButton> | ||
| </Flex> | ||
| <CloseDropdownMenu | ||
| position="bottom-end" | ||
| triggerProps={{ | ||
| showChevron: false, | ||
| priority: 'transparent', | ||
| icon: <IconClose variant="muted" />, | ||
| }} | ||
| size="xs" | ||
| items={[ | ||
| { | ||
| key: 'dismiss', | ||
| label: t('Dismiss'), | ||
| onAction: () => { | ||
| dismissPrompt(); | ||
| trackAnalytics('issue-details.android-tombstones-cta-dismiss', { | ||
| organization, | ||
| type: 'dismiss', | ||
| }); | ||
| }, | ||
| }, | ||
| { | ||
| key: 'snooze', | ||
| label: t('Snooze'), | ||
| onAction: () => { | ||
| snoozePrompt(); | ||
| trackAnalytics('issue-details.android-tombstones-cta-dismiss', { | ||
| organization, | ||
| type: 'snooze', | ||
| }); | ||
| }, | ||
| }, | ||
| ]} | ||
| /> | ||
| </BannerWrapper> | ||
| ); | ||
| } | ||
|
|
||
| const BannerWrapper = styled('div')` | ||
| position: relative; | ||
| border: 1px solid ${p => p.theme.tokens.border.primary}; | ||
| border-radius: ${p => p.theme.radius.md}; | ||
| padding: ${p => p.theme.space.xl}; | ||
| margin: ${p => p.theme.space.md} 0; | ||
| background: linear-gradient( | ||
| 90deg, | ||
| color-mix(in srgb, ${p => p.theme.tokens.background.secondary} 0%, transparent) 0%, | ||
| ${p => p.theme.tokens.background.secondary} 70%, | ||
| ${p => p.theme.tokens.background.secondary} 100% | ||
| ); | ||
| `; | ||
|
|
||
| const CloseDropdownMenu = styled(DropdownMenu)` | ||
| position: absolute; | ||
| display: block; | ||
| top: ${p => p.theme.space.md}; | ||
| right: ${p => p.theme.space.md}; | ||
| color: ${p => p.theme.colors.white}; | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cursor: pointer; | ||
| z-index: 1; | ||
| `; | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.