event.tsx 9.7 KB

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