event.tsx 10.0 KB

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