123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import {
- EntryException,
- EntryType,
- Event,
- ExceptionValue,
- PlatformType,
- StacktraceType,
- Thread,
- } from 'sentry/types';
- const NATIVE_PLATFORMS = ['cocoa', 'native'] as Array<PlatformType>;
- function getPlatforms(exceptionValue: ExceptionValue | StacktraceType | null) {
- const frames = exceptionValue?.frames ?? [];
- const stacktraceFrames = (exceptionValue as ExceptionValue)?.stacktrace?.frames ?? [];
- if (!frames.length && !stacktraceFrames.length) {
- return [];
- }
- return [...frames, ...stacktraceFrames]
- .map(frame => frame.platform)
- .filter(platform => !!platform);
- }
- function getStackTracePlatforms(event: Event, exceptionEntry: EntryException) {
-
- const exceptionEntryPlatforms = (exceptionEntry.data.values ?? []).flatMap(
- getPlatforms
- );
-
- const stackTraceEntry = (event.entries.find(
- entry => entry.type === EntryType.STACKTRACE
- )?.data ?? {}) as StacktraceType;
-
- const stackTraceEntryPlatforms = Object.keys(stackTraceEntry).flatMap(key =>
- getPlatforms(stackTraceEntry[key])
- );
-
- const threadEntry = (event.entries.find(entry => entry.type === EntryType.THREADS)?.data
- .values ?? []) as Array<Thread>;
-
- const threadEntryPlatforms = threadEntry.flatMap(({stacktrace}) =>
- getPlatforms(stacktrace)
- );
- return new Set([
- ...exceptionEntryPlatforms,
- ...stackTraceEntryPlatforms,
- ...threadEntryPlatforms,
- ]);
- }
- function isNativeEvent(event: Event, exceptionEntry: EntryException) {
- const {platform} = event;
- if (platform && NATIVE_PLATFORMS.includes(platform)) {
- return true;
- }
- const stackTracePlatforms = getStackTracePlatforms(event, exceptionEntry);
- return NATIVE_PLATFORMS.some(nativePlatform => stackTracePlatforms.has(nativePlatform));
- }
- function isMinidumpEvent(exceptionEntry: EntryException) {
- const {data} = exceptionEntry;
- return (data.values ?? []).some(value => value.mechanism?.type === 'minidump');
- }
- function isAppleCrashReportEvent(exceptionEntry: EntryException) {
- const {data} = exceptionEntry;
- return (data.values ?? []).some(value => value.mechanism?.type === 'applecrashreport');
- }
- export function displayReprocessEventAction(orgFeatures: Array<string>, event?: Event) {
- if (!event || !orgFeatures.includes('reprocessing-v2')) {
- return false;
- }
- const {entries} = event;
- const exceptionEntry = entries.find(entry => entry.type === EntryType.EXCEPTION) as
- | EntryException
- | undefined;
- if (!exceptionEntry) {
- return false;
- }
-
-
-
-
-
-
- if (
- !isMinidumpEvent(exceptionEntry) &&
- !isAppleCrashReportEvent(exceptionEntry) &&
- !isNativeEvent(event, exceptionEntry)
- ) {
- return false;
- }
- return true;
- }
|