-
-
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
6d09b26
b60e58f
36fa985
a48dbb8
2be4560
4d3357b
900c188
b59ff29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| import {useState} from 'react'; | ||
| import styled from '@emotion/styled'; | ||
|
|
||
| import {LinkButton} from '@sentry/scraps/button'; | ||
| import {CodeBlock} from '@sentry/scraps/code'; | ||
|
|
||
| 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} from 'sentry/types/event'; | ||
| import {EntryType} from 'sentry/types/event'; | ||
| import {trackAnalytics} from 'sentry/utils/analytics'; | ||
| import {useOrganization} from 'sentry/utils/useOrganization'; | ||
|
|
||
| const ANDROID_NATIVE_SDK_PREFIX = 'sentry.native.android'; | ||
| const TOMBSTONES_DOCS_URL = | ||
| 'https://docs.sentry.io/platforms/android/configuration/tombstones/'; | ||
|
|
||
| const CODE_SNIPPETS: Record<string, string> = { | ||
| manifest: `<application> | ||
| <meta-data | ||
| android:name="io.sentry.tombstone.enable" | ||
| android:value="true" /> | ||
| </application>`, | ||
| kotlin: `SentryAndroid.init(context) { options -> | ||
| options.isReportHistoricalTombstones = true | ||
| }`, | ||
| java: `SentryAndroid.init(context, options -> { | ||
| options.setReportHistoricalTombstones(true); | ||
| });`, | ||
| }; | ||
|
|
||
| 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 => value.mechanism?.type === 'signalhandler' | ||
|
Check failure on line 43 in static/app/components/events/interfaces/crashContent/exception/androidNativeTombstonesBanner.tsx
|
||
| ) ?? false | ||
| ); | ||
| } | ||
|
|
||
| function isAndroidNativeSdk(event: Event): boolean { | ||
| return event.sdk?.name?.startsWith(ANDROID_NATIVE_SDK_PREFIX) ?? false; | ||
| } | ||
|
|
||
| export function shouldShowTombstonesBanner(event: Event): boolean { | ||
| return isAndroidNativeSdk(event) && hasSignalHandlerMechanism(event); | ||
| } | ||
|
|
||
| interface Props { | ||
| event: Event; | ||
| projectId: string; | ||
| } | ||
|
|
||
| export function AndroidNativeTombstonesBanner({event, projectId}: Props) { | ||
| const organization = useOrganization(); | ||
| const [codeTab, setCodeTab] = useState('manifest'); | ||
|
|
||
| const {isLoading, isError, isPromptDismissed, dismissPrompt, snoozePrompt} = usePrompt({ | ||
| feature: 'issue_android_tombstones_onboarding', | ||
| organization, | ||
| projectId, | ||
| daysToSnooze: 7, | ||
| }); | ||
|
|
||
| if (isLoading || isError || isPromptDismissed) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <BannerWrapper> | ||
| <div> | ||
| <BannerTitle>{t('Enable Tombstone Collection')}</BannerTitle> | ||
| <BannerDescription> | ||
| {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.' | ||
| )} | ||
| </BannerDescription> | ||
| <CodeBlock | ||
|
Check failure on line 85 in static/app/components/events/interfaces/crashContent/exception/androidNativeTombstonesBanner.tsx
|
||
| tabs={[ | ||
| {label: 'AndroidManifest.xml', value: 'manifest'}, | ||
| {label: 'Kotlin', value: 'kotlin'}, | ||
| {label: 'Java', value: 'java'}, | ||
| ]} | ||
| selectedTab={codeTab} | ||
| onTabClick={setCodeTab} | ||
| language={codeTab === 'manifest' ? 'xml' : codeTab} | ||
| > | ||
| {CODE_SNIPPETS[codeTab]} | ||
| </CodeBlock> | ||
| <LinkButton | ||
| style={{marginTop: '12px'}} | ||
| 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> | ||
| </div> | ||
| <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 BannerTitle = styled('div')` | ||
| font-size: ${p => p.theme.font.size.xl}; | ||
| margin-bottom: ${p => p.theme.space.md}; | ||
| font-weight: ${p => p.theme.font.weight.sans.medium}; | ||
| `; | ||
|
|
||
| const BannerDescription = styled('div')` | ||
| margin-bottom: ${p => p.theme.space.lg}; | ||
| max-width: 460px; | ||
| `; | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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
|
||
Uh oh!
There was an error while loading. Please reload this page.