event.tsx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. import type {TraceContextType} from 'sentry/components/events/interfaces/spans/types';
  2. import type {SymbolicatorStatus} from 'sentry/components/events/interfaces/types';
  3. import type {PlatformKey} from 'sentry/data/platformCategories';
  4. import type {RawCrumb} from './breadcrumbs';
  5. import type {Image} from './debugImage';
  6. import type {IssueAttachment, IssueCategory} from './group';
  7. import type {Release} from './release';
  8. import type {RawStacktrace, StackTraceMechanism, StacktraceType} from './stacktrace';
  9. // TODO(epurkhiser): objc and cocoa should almost definitely be moved into PlatformKey
  10. export type PlatformType = PlatformKey | 'objc' | 'cocoa';
  11. export type Level = 'error' | 'fatal' | 'info' | 'warning' | 'sample' | 'unknown';
  12. /**
  13. * Grouping Configuration.
  14. */
  15. export type EventGroupComponent = {
  16. contributes: boolean;
  17. hint: string | null;
  18. id: string;
  19. name: string | null;
  20. values: EventGroupComponent[] | string[];
  21. };
  22. export type EventGroupingConfig = {
  23. base: string | null;
  24. changelog: string;
  25. delegates: string[];
  26. hidden: boolean;
  27. id: string;
  28. latest: boolean;
  29. risk: number;
  30. strategies: string[];
  31. };
  32. export type VariantEvidence = {
  33. desc: string;
  34. fingerprint: string;
  35. cause_span_hashes?: string[];
  36. offender_span_hashes?: string[];
  37. op?: string;
  38. parent_span_hashes?: string[];
  39. };
  40. type EventGroupVariantKey = 'custom-fingerprint' | 'app' | 'default' | 'system';
  41. export enum EventGroupVariantType {
  42. CHECKSUM = 'checksum',
  43. FALLBACK = 'fallback',
  44. CUSTOM_FINGERPRINT = 'custom-fingerprint',
  45. COMPONENT = 'component',
  46. SALTED_COMPONENT = 'salted-component',
  47. PERFORMANCE_PROBLEM = 'performance-problem',
  48. }
  49. interface BaseVariant {
  50. description: string | null;
  51. hash: string | null;
  52. hashMismatch: boolean;
  53. key: string;
  54. type: string;
  55. }
  56. interface FallbackVariant extends BaseVariant {
  57. type: EventGroupVariantType.FALLBACK;
  58. }
  59. interface ChecksumVariant extends BaseVariant {
  60. type: EventGroupVariantType.CHECKSUM;
  61. }
  62. interface HasComponentGrouping {
  63. client_values?: Array<string>;
  64. component?: EventGroupComponent;
  65. config?: EventGroupingConfig;
  66. matched_rule?: string;
  67. values?: Array<string>;
  68. }
  69. interface ComponentVariant extends BaseVariant, HasComponentGrouping {
  70. type: EventGroupVariantType.COMPONENT;
  71. }
  72. interface CustomFingerprintVariant extends BaseVariant, HasComponentGrouping {
  73. type: EventGroupVariantType.CUSTOM_FINGERPRINT;
  74. }
  75. interface SaltedComponentVariant extends BaseVariant, HasComponentGrouping {
  76. type: EventGroupVariantType.SALTED_COMPONENT;
  77. }
  78. interface PerformanceProblemVariant extends BaseVariant {
  79. evidence: VariantEvidence;
  80. type: EventGroupVariantType.PERFORMANCE_PROBLEM;
  81. }
  82. export type EventGroupVariant =
  83. | FallbackVariant
  84. | ChecksumVariant
  85. | ComponentVariant
  86. | SaltedComponentVariant
  87. | CustomFingerprintVariant
  88. | PerformanceProblemVariant;
  89. export type EventGroupInfo = Record<EventGroupVariantKey, EventGroupVariant>;
  90. /**
  91. * SDK Update metadata
  92. */
  93. type EnableIntegrationSuggestion = {
  94. enables: Array<SDKUpdatesSuggestion>;
  95. integrationName: string;
  96. type: 'enableIntegration';
  97. integrationUrl?: string | null;
  98. };
  99. export type UpdateSdkSuggestion = {
  100. enables: Array<SDKUpdatesSuggestion>;
  101. newSdkVersion: string;
  102. sdkName: string;
  103. type: 'updateSdk';
  104. sdkUrl?: string | null;
  105. };
  106. type ChangeSdkSuggestion = {
  107. enables: Array<SDKUpdatesSuggestion>;
  108. newSdkName: string;
  109. type: 'changeSdk';
  110. sdkUrl?: string | null;
  111. };
  112. export type SDKUpdatesSuggestion =
  113. | EnableIntegrationSuggestion
  114. | UpdateSdkSuggestion
  115. | ChangeSdkSuggestion;
  116. /**
  117. * Frames, Threads and Event interfaces.
  118. */
  119. export interface Thread {
  120. crashed: boolean;
  121. current: boolean;
  122. id: number;
  123. rawStacktrace: RawStacktrace;
  124. stacktrace: StacktraceType | null;
  125. name?: string | null;
  126. }
  127. export type Frame = {
  128. absPath: string | null;
  129. colNo: number | null;
  130. context: Array<[number, string]>;
  131. errors: Array<any> | null;
  132. filename: string | null;
  133. function: string | null;
  134. inApp: boolean;
  135. instructionAddr: string | null;
  136. lineNo: number | null;
  137. module: string | null;
  138. package: string | null;
  139. platform: PlatformType | null;
  140. rawFunction: string | null;
  141. symbol: string | null;
  142. symbolAddr: string | null;
  143. trust: any | null;
  144. vars: Record<string, any> | null;
  145. addrMode?: string;
  146. isPrefix?: boolean;
  147. isSentinel?: boolean;
  148. map?: string | null;
  149. mapUrl?: string | null;
  150. minGroupingLevel?: number;
  151. origAbsPath?: string | null;
  152. symbolicatorStatus?: SymbolicatorStatus;
  153. };
  154. export enum FrameBadge {
  155. SENTINEL = 'sentinel',
  156. PREFIX = 'prefix',
  157. GROUPING = 'grouping',
  158. }
  159. export type ExceptionValue = {
  160. mechanism: StackTraceMechanism | null;
  161. module: string | null;
  162. rawStacktrace: RawStacktrace;
  163. stacktrace: StacktraceType | null;
  164. threadId: number | null;
  165. type: string;
  166. value: string;
  167. frames?: Frame[] | null;
  168. };
  169. export type ExceptionType = {
  170. excOmitted: any | null;
  171. hasSystemFrames: boolean;
  172. values?: Array<ExceptionValue>;
  173. };
  174. export type TreeLabelPart =
  175. | string
  176. | {
  177. classbase?: string;
  178. datapath?: (string | number)[];
  179. filebase?: string;
  180. function?: string;
  181. is_prefix?: boolean;
  182. // is_sentinel is no longer being used,
  183. // but we will still assess whether we will use this property in the near future.
  184. is_sentinel?: boolean;
  185. package?: string;
  186. type?: string;
  187. };
  188. // This type is incomplete
  189. export type EventMetadata = {
  190. current_level?: number;
  191. current_tree_label?: TreeLabelPart[];
  192. directive?: string;
  193. display_title_with_tree_label?: boolean;
  194. filename?: string;
  195. finest_tree_label?: TreeLabelPart[];
  196. function?: string;
  197. message?: string;
  198. origin?: string;
  199. stripped_crash?: boolean;
  200. title?: string;
  201. type?: string;
  202. uri?: string;
  203. value?: string;
  204. };
  205. export enum EventOrGroupType {
  206. ERROR = 'error',
  207. CSP = 'csp',
  208. HPKP = 'hpkp',
  209. EXPECTCT = 'expectct',
  210. EXPECTSTAPLE = 'expectstaple',
  211. DEFAULT = 'default',
  212. TRANSACTION = 'transaction',
  213. }
  214. /**
  215. * Event interface types.
  216. */
  217. export enum EntryType {
  218. EXCEPTION = 'exception',
  219. MESSAGE = 'message',
  220. REQUEST = 'request',
  221. STACKTRACE = 'stacktrace',
  222. TEMPLATE = 'template',
  223. CSP = 'csp',
  224. EXPECTCT = 'expectct',
  225. EXPECTSTAPLE = 'expectstaple',
  226. HPKP = 'hpkp',
  227. BREADCRUMBS = 'breadcrumbs',
  228. THREADS = 'threads',
  229. DEBUGMETA = 'debugmeta',
  230. SPANS = 'spans',
  231. RESOURCES = 'resources',
  232. }
  233. type EntryDebugMeta = {
  234. data: {
  235. images: Array<Image | null>;
  236. };
  237. type: EntryType.DEBUGMETA;
  238. };
  239. type EntryBreadcrumbs = {
  240. data: {
  241. values: Array<RawCrumb>;
  242. };
  243. type: EntryType.BREADCRUMBS;
  244. };
  245. export type EntryThreads = {
  246. data: {
  247. values?: Array<Thread>;
  248. };
  249. type: EntryType.THREADS;
  250. };
  251. export type EntryException = {
  252. data: ExceptionType;
  253. type: EntryType.EXCEPTION;
  254. };
  255. type EntryStacktrace = {
  256. data: StacktraceType;
  257. type: EntryType.STACKTRACE;
  258. };
  259. type EntrySpans = {
  260. data: any;
  261. type: EntryType.SPANS;
  262. };
  263. type EntryMessage = {
  264. data: {
  265. formatted: string;
  266. params?: Record<string, any> | any[];
  267. };
  268. type: EntryType.MESSAGE;
  269. };
  270. export type EntryRequest = {
  271. data: {
  272. method: string;
  273. url: string;
  274. cookies?: [key: string, value: string][];
  275. data?: string | null | Record<string, any> | [key: string, value: any][];
  276. env?: Record<string, string>;
  277. fragment?: string | null;
  278. headers?: [key: string, value: string][];
  279. inferredContentType?:
  280. | null
  281. | 'application/json'
  282. | 'application/x-www-form-urlencoded'
  283. | 'multipart/form-data';
  284. query?: [key: string, value: string][] | string;
  285. };
  286. type: EntryType.REQUEST;
  287. };
  288. type EntryTemplate = {
  289. data: Frame;
  290. type: EntryType.TEMPLATE;
  291. };
  292. type EntryCsp = {
  293. data: Record<string, any>;
  294. type: EntryType.CSP;
  295. };
  296. type EntryGeneric = {
  297. data: Record<string, any>;
  298. type: EntryType.EXPECTCT | EntryType.EXPECTSTAPLE | EntryType.HPKP;
  299. };
  300. type EntryResources = {
  301. data: any; // Data is unused here
  302. type: EntryType.RESOURCES;
  303. };
  304. export type Entry =
  305. | EntryDebugMeta
  306. | EntryBreadcrumbs
  307. | EntryThreads
  308. | EntryException
  309. | EntryStacktrace
  310. | EntrySpans
  311. | EntryMessage
  312. | EntryRequest
  313. | EntryTemplate
  314. | EntryCsp
  315. | EntryGeneric
  316. | EntryResources;
  317. // Contexts
  318. type RuntimeContext = {
  319. type: 'runtime';
  320. build?: string;
  321. name?: string;
  322. raw_description?: string;
  323. version?: number;
  324. };
  325. type DeviceContext = {
  326. arch: string;
  327. family: string;
  328. model: string;
  329. type: string;
  330. };
  331. type OSContext = {
  332. build: string;
  333. kernel_version: string;
  334. name: string;
  335. type: string;
  336. version: string;
  337. };
  338. type EventContexts = {
  339. client_os?: OSContext;
  340. device?: DeviceContext;
  341. os?: OSContext;
  342. // TODO (udameli): add better types here
  343. // once perf issue data shape is more clear
  344. performance_issue?: any;
  345. runtime?: RuntimeContext;
  346. trace?: TraceContextType;
  347. };
  348. export type Measurement = {value: number; unit?: string};
  349. export type EventTag = {key: string; value: string};
  350. export type EventUser = {
  351. data?: string | null;
  352. email?: string;
  353. id?: string;
  354. ip_address?: string;
  355. name?: string | null;
  356. username?: string | null;
  357. };
  358. export type PerformanceDetectorData = {
  359. causeSpanIds: string[];
  360. offenderSpanIds: string[];
  361. parentSpanIds: string[];
  362. };
  363. interface EventBase {
  364. contexts: EventContexts;
  365. crashFile: IssueAttachment | null;
  366. culprit: string;
  367. dateReceived: string;
  368. dist: string | null;
  369. entries: Entry[];
  370. errors: any[];
  371. eventID: string;
  372. fingerprints: string[];
  373. id: string;
  374. location: string | null;
  375. message: string;
  376. metadata: EventMetadata;
  377. projectID: string;
  378. size: number;
  379. tags: EventTag[];
  380. title: string;
  381. type:
  382. | EventOrGroupType.CSP
  383. | EventOrGroupType.DEFAULT
  384. | EventOrGroupType.EXPECTCT
  385. | EventOrGroupType.EXPECTSTAPLE
  386. | EventOrGroupType.HPKP;
  387. user: EventUser | null;
  388. _meta?: Record<string, any>;
  389. context?: Record<string, any>;
  390. dateCreated?: string;
  391. device?: Record<string, any>;
  392. endTimestamp?: number;
  393. groupID?: string;
  394. groupingConfig?: {
  395. enhancements: string;
  396. id: string;
  397. };
  398. issueCategory?: IssueCategory;
  399. latestEventID?: string | null;
  400. measurements?: Record<string, Measurement>;
  401. nextEventID?: string | null;
  402. oldestEventID?: string | null;
  403. packages?: Record<string, string>;
  404. platform?: PlatformType;
  405. previousEventID?: string | null;
  406. projectSlug?: string;
  407. release?: Release | null;
  408. sdk?: {
  409. name: string;
  410. version: string;
  411. } | null;
  412. sdkUpdates?: Array<SDKUpdatesSuggestion>;
  413. userReport?: any;
  414. }
  415. interface TraceEventContexts extends EventContexts {
  416. trace?: TraceContextType;
  417. }
  418. export interface EventTransaction
  419. extends Omit<EventBase, 'entries' | 'type' | 'contexts'> {
  420. contexts: TraceEventContexts;
  421. endTimestamp: number;
  422. entries: (EntrySpans | EntryRequest)[];
  423. startTimestamp: number;
  424. type: EventOrGroupType.TRANSACTION;
  425. perfProblem?: PerformanceDetectorData;
  426. }
  427. export interface EventError extends Omit<EventBase, 'entries' | 'type'> {
  428. entries: (
  429. | EntryException
  430. | EntryStacktrace
  431. | EntryRequest
  432. | EntryThreads
  433. | EntryDebugMeta
  434. )[];
  435. type: EventOrGroupType.ERROR;
  436. }
  437. export type Event = EventError | EventTransaction | EventBase;
  438. // Response from EventIdLookupEndpoint
  439. // /organizations/${orgSlug}/eventids/${eventId}/
  440. export type EventIdResponse = {
  441. event: Event;
  442. eventId: string;
  443. groupId: string;
  444. organizationSlug: string;
  445. projectSlug: string;
  446. };