event.tsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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} 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. PERFORMANCE = 'performance',
  194. }
  195. type EntryDebugMeta = {
  196. data: {
  197. images: Array<Image | null>;
  198. };
  199. type: EntryType.DEBUGMETA;
  200. };
  201. type EntryBreadcrumbs = {
  202. data: {
  203. values: Array<RawCrumb>;
  204. };
  205. type: EntryType.BREADCRUMBS;
  206. };
  207. export type EntryThreads = {
  208. data: {
  209. values?: Array<Thread>;
  210. };
  211. type: EntryType.THREADS;
  212. };
  213. export type EntryException = {
  214. data: ExceptionType;
  215. type: EntryType.EXCEPTION;
  216. };
  217. type EntryStacktrace = {
  218. data: StacktraceType;
  219. type: EntryType.STACKTRACE;
  220. };
  221. type EntrySpans = {
  222. data: any;
  223. type: EntryType.SPANS; // data is not used
  224. };
  225. export type EntrySpanTree = {
  226. data: {
  227. focusedSpanIds: string[];
  228. };
  229. type: EntryType.SPANTREE;
  230. };
  231. export type EntryPerformance = {
  232. data: any; // data is not used
  233. type: EntryType.PERFORMANCE;
  234. };
  235. type EntryMessage = {
  236. data: {
  237. formatted: string;
  238. params?: Record<string, any> | any[];
  239. };
  240. type: EntryType.MESSAGE;
  241. };
  242. export type EntryRequest = {
  243. data: {
  244. method: string;
  245. url: string;
  246. cookies?: [key: string, value: string][];
  247. data?: string | null | Record<string, any> | [key: string, value: any][];
  248. env?: Record<string, string>;
  249. fragment?: string | null;
  250. headers?: [key: string, value: string][];
  251. inferredContentType?:
  252. | null
  253. | 'application/json'
  254. | 'application/x-www-form-urlencoded'
  255. | 'multipart/form-data';
  256. query?: [key: string, value: string][] | string;
  257. };
  258. type: EntryType.REQUEST;
  259. };
  260. type EntryTemplate = {
  261. data: Frame;
  262. type: EntryType.TEMPLATE;
  263. };
  264. type EntryCsp = {
  265. data: Record<string, any>;
  266. type: EntryType.CSP;
  267. };
  268. type EntryGeneric = {
  269. data: Record<string, any>;
  270. type: EntryType.EXPECTCT | EntryType.EXPECTSTAPLE | EntryType.HPKP;
  271. };
  272. export type Entry =
  273. | EntryDebugMeta
  274. | EntryBreadcrumbs
  275. | EntryThreads
  276. | EntryException
  277. | EntryStacktrace
  278. | EntrySpans
  279. | EntrySpanTree
  280. | EntryPerformance
  281. | EntryMessage
  282. | EntryRequest
  283. | EntryTemplate
  284. | EntryCsp
  285. | EntryGeneric;
  286. // Contexts
  287. type RuntimeContext = {
  288. type: 'runtime';
  289. build?: string;
  290. name?: string;
  291. raw_description?: string;
  292. version?: number;
  293. };
  294. type DeviceContext = {
  295. arch: string;
  296. family: string;
  297. model: string;
  298. type: string;
  299. };
  300. type OSContext = {
  301. build: string;
  302. kernel_version: string;
  303. name: string;
  304. type: string;
  305. version: string;
  306. };
  307. type EventContexts = {
  308. client_os?: OSContext;
  309. device?: DeviceContext;
  310. os?: OSContext;
  311. // TODO (udameli): add better types here
  312. // once perf issue data shape is more clear
  313. performance_issue?: any;
  314. runtime?: RuntimeContext;
  315. trace?: TraceContextType;
  316. };
  317. export type Measurement = {value: number; unit?: string};
  318. export type EventTag = {key: string; value: string};
  319. export type EventUser = {
  320. data?: string | null;
  321. email?: string;
  322. id?: string;
  323. ip_address?: string;
  324. name?: string | null;
  325. username?: string | null;
  326. };
  327. interface EventBase {
  328. contexts: EventContexts;
  329. crashFile: IssueAttachment | null;
  330. culprit: string;
  331. dateReceived: string;
  332. dist: string | null;
  333. entries: Entry[];
  334. errors: any[];
  335. eventID: string;
  336. fingerprints: string[];
  337. groupingConfig: {
  338. enhancements: string;
  339. id: string;
  340. };
  341. id: string;
  342. location: string | null;
  343. message: string;
  344. metadata: EventMetadata;
  345. projectID: string;
  346. size: number;
  347. tags: EventTag[];
  348. title: string;
  349. type:
  350. | EventOrGroupType.CSP
  351. | EventOrGroupType.DEFAULT
  352. | EventOrGroupType.EXPECTCT
  353. | EventOrGroupType.EXPECTSTAPLE
  354. | EventOrGroupType.HPKP;
  355. user: EventUser | null;
  356. _meta?: Record<string, any>;
  357. context?: Record<string, any>;
  358. dateCreated?: string;
  359. device?: Record<string, any>;
  360. endTimestamp?: number;
  361. groupID?: string;
  362. latestEventID?: string | null;
  363. measurements?: Record<string, Measurement>;
  364. nextEventID?: string | null;
  365. oldestEventID?: string | null;
  366. packages?: Record<string, string>;
  367. platform?: PlatformType;
  368. previousEventID?: string | null;
  369. projectSlug?: string;
  370. release?: Release | null;
  371. sdk?: {
  372. name: string;
  373. version: string;
  374. } | null;
  375. sdkUpdates?: Array<SDKUpdatesSuggestion>;
  376. userReport?: any;
  377. }
  378. interface TraceEventContexts extends EventContexts {
  379. trace?: TraceContextType;
  380. }
  381. export interface EventTransaction
  382. extends Omit<EventBase, 'entries' | 'type' | 'contexts'> {
  383. contexts: TraceEventContexts;
  384. endTimestamp: number;
  385. entries: (EntrySpans | EntryRequest)[];
  386. startTimestamp: number;
  387. type: EventOrGroupType.TRANSACTION;
  388. }
  389. export interface EventError extends Omit<EventBase, 'entries' | 'type'> {
  390. entries: (
  391. | EntryException
  392. | EntryStacktrace
  393. | EntryRequest
  394. | EntryThreads
  395. | EntryDebugMeta
  396. | EntryPerformance
  397. | EntrySpanTree
  398. )[];
  399. type: EventOrGroupType.ERROR;
  400. }
  401. export type Event = EventError | EventTransaction | EventBase;
  402. // Response from EventIdLookupEndpoint
  403. // /organizations/${orgSlug}/eventids/${eventId}/
  404. export type EventIdResponse = {
  405. event: Event;
  406. eventId: string;
  407. groupId: string;
  408. organizationSlug: string;
  409. projectSlug: string;
  410. };