event.tsx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. import type {
  2. RawSpanType,
  3. TraceContextType,
  4. } from 'sentry/components/events/interfaces/spans/types';
  5. import type {SymbolicatorStatus} from 'sentry/components/events/interfaces/types';
  6. import type {PlatformKey} from 'sentry/data/platformCategories';
  7. import type {IssueType} from 'sentry/types';
  8. import type {RawCrumb} from './breadcrumbs';
  9. import type {Image} from './debugImage';
  10. import type {IssueAttachment, IssueCategory} from './group';
  11. import type {Release} from './release';
  12. import type {RawStacktrace, StackTraceMechanism, StacktraceType} from './stacktrace';
  13. // TODO(epurkhiser): objc and cocoa should almost definitely be moved into PlatformKey
  14. export type PlatformType = PlatformKey | 'objc' | 'cocoa';
  15. export type Level = 'error' | 'fatal' | 'info' | 'warning' | 'sample' | 'unknown';
  16. /**
  17. * Grouping Configuration.
  18. */
  19. export type EventGroupComponent = {
  20. contributes: boolean;
  21. hint: string | null;
  22. id: string;
  23. name: string | null;
  24. values: EventGroupComponent[] | string[];
  25. };
  26. export type EventGroupingConfig = {
  27. base: string | null;
  28. changelog: string;
  29. delegates: string[];
  30. hidden: boolean;
  31. id: string;
  32. latest: boolean;
  33. risk: number;
  34. strategies: string[];
  35. };
  36. export type VariantEvidence = {
  37. desc: string;
  38. fingerprint: string;
  39. cause_span_hashes?: string[];
  40. cause_span_ids?: string[];
  41. offender_span_hashes?: string[];
  42. offender_span_ids?: string[];
  43. op?: string;
  44. parent_span_hashes?: string[];
  45. parent_span_ids?: string[];
  46. };
  47. type EventGroupVariantKey = 'custom-fingerprint' | 'app' | 'default' | 'system';
  48. export enum EventGroupVariantType {
  49. CHECKSUM = 'checksum',
  50. FALLBACK = 'fallback',
  51. CUSTOM_FINGERPRINT = 'custom-fingerprint',
  52. COMPONENT = 'component',
  53. SALTED_COMPONENT = 'salted-component',
  54. PERFORMANCE_PROBLEM = 'performance-problem',
  55. }
  56. interface BaseVariant {
  57. description: string | null;
  58. hash: string | null;
  59. hashMismatch: boolean;
  60. key: string;
  61. type: string;
  62. }
  63. interface FallbackVariant extends BaseVariant {
  64. type: EventGroupVariantType.FALLBACK;
  65. }
  66. interface ChecksumVariant extends BaseVariant {
  67. type: EventGroupVariantType.CHECKSUM;
  68. }
  69. interface HasComponentGrouping {
  70. client_values?: Array<string>;
  71. component?: EventGroupComponent;
  72. config?: EventGroupingConfig;
  73. matched_rule?: string;
  74. values?: Array<string>;
  75. }
  76. interface ComponentVariant extends BaseVariant, HasComponentGrouping {
  77. type: EventGroupVariantType.COMPONENT;
  78. }
  79. interface CustomFingerprintVariant extends BaseVariant, HasComponentGrouping {
  80. type: EventGroupVariantType.CUSTOM_FINGERPRINT;
  81. }
  82. interface SaltedComponentVariant extends BaseVariant, HasComponentGrouping {
  83. type: EventGroupVariantType.SALTED_COMPONENT;
  84. }
  85. interface PerformanceProblemVariant extends BaseVariant {
  86. evidence: VariantEvidence;
  87. type: EventGroupVariantType.PERFORMANCE_PROBLEM;
  88. }
  89. export type EventGroupVariant =
  90. | FallbackVariant
  91. | ChecksumVariant
  92. | ComponentVariant
  93. | SaltedComponentVariant
  94. | CustomFingerprintVariant
  95. | PerformanceProblemVariant;
  96. export type EventGroupInfo = Record<EventGroupVariantKey, EventGroupVariant>;
  97. /**
  98. * SDK Update metadata
  99. */
  100. type EnableIntegrationSuggestion = {
  101. enables: Array<SDKUpdatesSuggestion>;
  102. integrationName: string;
  103. type: 'enableIntegration';
  104. integrationUrl?: string | null;
  105. };
  106. export type UpdateSdkSuggestion = {
  107. enables: Array<SDKUpdatesSuggestion>;
  108. newSdkVersion: string;
  109. sdkName: string;
  110. type: 'updateSdk';
  111. sdkUrl?: string | null;
  112. };
  113. type ChangeSdkSuggestion = {
  114. enables: Array<SDKUpdatesSuggestion>;
  115. newSdkName: string;
  116. type: 'changeSdk';
  117. sdkUrl?: string | null;
  118. };
  119. export type SDKUpdatesSuggestion =
  120. | EnableIntegrationSuggestion
  121. | UpdateSdkSuggestion
  122. | ChangeSdkSuggestion;
  123. /**
  124. * Frames, Threads and Event interfaces.
  125. */
  126. export interface Thread {
  127. crashed: boolean;
  128. current: boolean;
  129. id: number;
  130. rawStacktrace: RawStacktrace;
  131. stacktrace: StacktraceType | null;
  132. lockReason?: string | null;
  133. name?: string | null;
  134. state?: string | null;
  135. }
  136. export type Frame = {
  137. absPath: string | null;
  138. colNo: number | null;
  139. context: Array<[number, string]>;
  140. errors: Array<any> | null;
  141. filename: string | null;
  142. function: string | null;
  143. inApp: boolean;
  144. instructionAddr: string | null;
  145. lineNo: number | null;
  146. module: string | null;
  147. package: string | null;
  148. platform: PlatformType | null;
  149. rawFunction: string | null;
  150. symbol: string | null;
  151. symbolAddr: string | null;
  152. trust: any | null;
  153. vars: Record<string, any> | null;
  154. addrMode?: string;
  155. isPrefix?: boolean;
  156. isSentinel?: boolean;
  157. // map exists if the frame has a source map
  158. map?: string | null;
  159. mapUrl?: string | null;
  160. minGroupingLevel?: number;
  161. origAbsPath?: string | null;
  162. symbolicatorStatus?: SymbolicatorStatus;
  163. };
  164. export enum FrameBadge {
  165. SENTINEL = 'sentinel',
  166. PREFIX = 'prefix',
  167. GROUPING = 'grouping',
  168. }
  169. export type ExceptionValue = {
  170. mechanism: StackTraceMechanism | null;
  171. module: string | null;
  172. rawStacktrace: RawStacktrace;
  173. stacktrace: StacktraceType | null;
  174. threadId: number | null;
  175. type: string;
  176. value: string;
  177. frames?: Frame[] | null;
  178. };
  179. export type ExceptionType = {
  180. excOmitted: any | null;
  181. hasSystemFrames: boolean;
  182. values?: Array<ExceptionValue>;
  183. };
  184. export type TreeLabelPart =
  185. | string
  186. | {
  187. classbase?: string;
  188. datapath?: (string | number)[];
  189. filebase?: string;
  190. function?: string;
  191. is_prefix?: boolean;
  192. // is_sentinel is no longer being used,
  193. // but we will still assess whether we will use this property in the near future.
  194. is_sentinel?: boolean;
  195. package?: string;
  196. type?: string;
  197. };
  198. // This type is incomplete
  199. export type EventMetadata = {
  200. current_level?: number;
  201. current_tree_label?: TreeLabelPart[];
  202. directive?: string;
  203. display_title_with_tree_label?: boolean;
  204. filename?: string;
  205. finest_tree_label?: TreeLabelPart[];
  206. function?: string;
  207. message?: string;
  208. origin?: string;
  209. stripped_crash?: boolean;
  210. title?: string;
  211. type?: string;
  212. uri?: string;
  213. value?: string;
  214. };
  215. export enum EventOrGroupType {
  216. ERROR = 'error',
  217. CSP = 'csp',
  218. HPKP = 'hpkp',
  219. EXPECTCT = 'expectct',
  220. EXPECTSTAPLE = 'expectstaple',
  221. DEFAULT = 'default',
  222. TRANSACTION = 'transaction',
  223. GENERIC = 'generic',
  224. }
  225. /**
  226. * Event interface types.
  227. */
  228. export enum EntryType {
  229. EXCEPTION = 'exception',
  230. MESSAGE = 'message',
  231. REQUEST = 'request',
  232. STACKTRACE = 'stacktrace',
  233. TEMPLATE = 'template',
  234. CSP = 'csp',
  235. EXPECTCT = 'expectct',
  236. EXPECTSTAPLE = 'expectstaple',
  237. HPKP = 'hpkp',
  238. BREADCRUMBS = 'breadcrumbs',
  239. THREADS = 'threads',
  240. THREAD_STATE = 'thread-state',
  241. THREAD_TAGS = 'thread-tags',
  242. DEBUGMETA = 'debugmeta',
  243. SPANS = 'spans',
  244. RESOURCES = 'resources',
  245. }
  246. type EntryDebugMeta = {
  247. data: {
  248. images: Array<Image | null>;
  249. };
  250. type: EntryType.DEBUGMETA;
  251. };
  252. type EntryBreadcrumbs = {
  253. data: {
  254. values: Array<RawCrumb>;
  255. };
  256. type: EntryType.BREADCRUMBS;
  257. };
  258. export type EntryThreads = {
  259. data: {
  260. values?: Array<Thread>;
  261. };
  262. type: EntryType.THREADS;
  263. };
  264. export type EntryException = {
  265. data: ExceptionType;
  266. type: EntryType.EXCEPTION;
  267. };
  268. type EntryStacktrace = {
  269. data: StacktraceType;
  270. type: EntryType.STACKTRACE;
  271. };
  272. export type EntrySpans = {
  273. data: RawSpanType[];
  274. type: EntryType.SPANS;
  275. };
  276. type EntryMessage = {
  277. data: {
  278. formatted: string;
  279. params?: Record<string, any> | any[];
  280. };
  281. type: EntryType.MESSAGE;
  282. };
  283. export type EntryRequest = {
  284. data: {
  285. method: string;
  286. url: string;
  287. cookies?: [key: string, value: string][];
  288. data?: string | null | Record<string, any> | [key: string, value: any][];
  289. env?: Record<string, string>;
  290. fragment?: string | null;
  291. headers?: [key: string, value: string][];
  292. inferredContentType?:
  293. | null
  294. | 'application/json'
  295. | 'application/x-www-form-urlencoded'
  296. | 'multipart/form-data';
  297. query?: [key: string, value: string][] | string;
  298. };
  299. type: EntryType.REQUEST;
  300. };
  301. type EntryTemplate = {
  302. data: Frame;
  303. type: EntryType.TEMPLATE;
  304. };
  305. type EntryCsp = {
  306. data: Record<string, any>;
  307. type: EntryType.CSP;
  308. };
  309. type EntryGeneric = {
  310. data: Record<string, any>;
  311. type: EntryType.EXPECTCT | EntryType.EXPECTSTAPLE | EntryType.HPKP;
  312. };
  313. type EntryResources = {
  314. data: any; // Data is unused here
  315. type: EntryType.RESOURCES;
  316. };
  317. export type Entry =
  318. | EntryDebugMeta
  319. | EntryBreadcrumbs
  320. | EntryThreads
  321. | EntryException
  322. | EntryStacktrace
  323. | EntrySpans
  324. | EntryMessage
  325. | EntryRequest
  326. | EntryTemplate
  327. | EntryCsp
  328. | EntryGeneric
  329. | EntryResources;
  330. // Contexts: https://develop.sentry.dev/sdk/event-payloads/contexts/
  331. export interface BaseContext {
  332. type: string;
  333. }
  334. export enum DeviceContextKey {
  335. ARCH = 'arch',
  336. BATTERY_LEVEL = 'battery_level',
  337. BATTERY_STATUS = 'battery_status',
  338. BOOT_TIME = 'boot_time',
  339. BRAND = 'brand',
  340. CHARGING = 'charging',
  341. CPU_DESCRIPTION = 'cpu_description',
  342. DEVICE_TYPE = 'device_type',
  343. DEVICE_UNIQUE_IDENTIFIER = 'device_unique_identifier',
  344. EXTERNAL_FREE_STORAGE = 'external_free_storage',
  345. EXTERNAL_STORAGE_SIZE = 'external_storage_size',
  346. EXTERNAL_TOTAL_STORAGE = 'external_total_storage',
  347. FAMILY = 'family',
  348. FREE_MEMORY = 'free_memory',
  349. FREE_STORAGE = 'free_storage',
  350. LOW_MEMORY = 'low_memory',
  351. MANUFACTURER = 'manufacturer',
  352. MEMORY_SIZE = 'memory_size',
  353. MODEL = 'model',
  354. MODEL_ID = 'model_id',
  355. NAME = 'name',
  356. ONLINE = 'online',
  357. ORIENTATION = 'orientation',
  358. PROCESSOR_COUNT = 'processor_count',
  359. PROCESSOR_FREQUENCY = 'processor_frequency',
  360. SCREEN_DENSITY = 'screen_density',
  361. SCREEN_DPI = 'screen_dpi',
  362. SCREEN_HEIGHT_PIXELS = 'screen_height_pixels',
  363. SCREEN_RESOLUTION = 'screen_resolution',
  364. SCREEN_WIDTH_PIXELS = 'screen_width_pixels',
  365. SIMULATOR = 'simulator',
  366. STORAGE_SIZE = 'storage_size',
  367. SUPPORTS_ACCELEROMETER = 'supports_accelerometer',
  368. SUPPORTS_AUDIO = 'supports_audio',
  369. SUPPORTS_GYROSCOPE = 'supports_gyroscope',
  370. SUPPORTS_LOCATION_SERVICE = 'supports_location_service',
  371. SUPPORTS_VIBRATION = 'supports_vibration',
  372. USABLE_MEMORY = 'usable_memory',
  373. }
  374. // https://develop.sentry.dev/sdk/event-payloads/contexts/#device-context
  375. export interface DeviceContext
  376. extends Partial<Record<DeviceContextKey, unknown>>,
  377. BaseContext {
  378. type: 'device';
  379. [DeviceContextKey.NAME]: string;
  380. [DeviceContextKey.ARCH]?: string;
  381. [DeviceContextKey.BATTERY_LEVEL]?: number;
  382. [DeviceContextKey.BATTERY_STATUS]?: string;
  383. [DeviceContextKey.BOOT_TIME]?: string;
  384. [DeviceContextKey.BRAND]?: string;
  385. [DeviceContextKey.CHARGING]?: boolean;
  386. [DeviceContextKey.CPU_DESCRIPTION]?: string;
  387. [DeviceContextKey.DEVICE_TYPE]?: string;
  388. [DeviceContextKey.DEVICE_UNIQUE_IDENTIFIER]?: string;
  389. [DeviceContextKey.EXTERNAL_FREE_STORAGE]?: number;
  390. [DeviceContextKey.EXTERNAL_STORAGE_SIZE]?: number;
  391. [DeviceContextKey.EXTERNAL_TOTAL_STORAGE]?: number;
  392. [DeviceContextKey.FAMILY]?: string;
  393. [DeviceContextKey.FREE_MEMORY]?: number;
  394. [DeviceContextKey.FREE_STORAGE]?: number;
  395. [DeviceContextKey.LOW_MEMORY]?: boolean;
  396. [DeviceContextKey.MANUFACTURER]?: string;
  397. [DeviceContextKey.MEMORY_SIZE]?: number;
  398. [DeviceContextKey.MODEL]?: string;
  399. [DeviceContextKey.MODEL_ID]?: string;
  400. [DeviceContextKey.ONLINE]?: boolean;
  401. [DeviceContextKey.ORIENTATION]?: 'portrait' | 'landscape';
  402. [DeviceContextKey.PROCESSOR_COUNT]?: number;
  403. [DeviceContextKey.PROCESSOR_FREQUENCY]?: number;
  404. [DeviceContextKey.SCREEN_DENSITY]?: number;
  405. [DeviceContextKey.SCREEN_DPI]?: number;
  406. [DeviceContextKey.SCREEN_HEIGHT_PIXELS]?: number;
  407. [DeviceContextKey.SCREEN_RESOLUTION]?: string;
  408. [DeviceContextKey.SCREEN_WIDTH_PIXELS]?: number;
  409. [DeviceContextKey.SIMULATOR]?: boolean;
  410. [DeviceContextKey.STORAGE_SIZE]?: number;
  411. [DeviceContextKey.SUPPORTS_ACCELEROMETER]?: boolean;
  412. [DeviceContextKey.SUPPORTS_AUDIO]?: boolean;
  413. [DeviceContextKey.SUPPORTS_GYROSCOPE]?: boolean;
  414. [DeviceContextKey.SUPPORTS_LOCATION_SERVICE]?: boolean;
  415. [DeviceContextKey.SUPPORTS_VIBRATION]?: boolean;
  416. [DeviceContextKey.USABLE_MEMORY]?: number;
  417. // This field is deprecated in favour of locale field in culture context
  418. language?: string;
  419. // This field is deprecated in favour of timezone field in culture context
  420. timezone?: string;
  421. }
  422. enum RuntimeContextKey {
  423. BUILD = 'build',
  424. NAME = 'name',
  425. RAW_DESCRIPTION = 'raw_description',
  426. VERSION = 'version',
  427. }
  428. // https://develop.sentry.dev/sdk/event-payloads/contexts/#runtime-context
  429. interface RuntimeContext
  430. extends Partial<Record<RuntimeContextKey, unknown>>,
  431. BaseContext {
  432. type: 'runtime';
  433. [RuntimeContextKey.BUILD]?: string;
  434. [RuntimeContextKey.NAME]?: string;
  435. [RuntimeContextKey.RAW_DESCRIPTION]?: string;
  436. [RuntimeContextKey.VERSION]?: number;
  437. }
  438. type OSContext = {
  439. build: string;
  440. kernel_version: string;
  441. name: string;
  442. type: string;
  443. version: string;
  444. };
  445. export enum OtelContextKey {
  446. ATTRIBUTES = 'attributes',
  447. RESOURCE = 'resource',
  448. }
  449. // OpenTelemetry Context
  450. // https://develop.sentry.dev/sdk/performance/opentelemetry/#opentelemetry-context
  451. interface OtelContext extends Partial<Record<OtelContextKey, unknown>>, BaseContext {
  452. type: 'otel';
  453. [OtelContextKey.ATTRIBUTES]?: Record<string, unknown>;
  454. [OtelContextKey.RESOURCE]?: Record<string, unknown>;
  455. }
  456. export enum UnityContextKey {
  457. COPY_TEXTURE_SUPPORT = 'copy_texture_support',
  458. EDITOR_VERSION = 'editor_version',
  459. INSTALL_MODE = 'install_mode',
  460. RENDERING_THREADING_MODE = 'rendering_threading_mode',
  461. TARGET_FRAME_RATE = 'target_frame_rate',
  462. }
  463. // Unity Context
  464. // TODO(Priscila): Add this context to the docs
  465. export interface UnityContext {
  466. [UnityContextKey.COPY_TEXTURE_SUPPORT]: string;
  467. [UnityContextKey.EDITOR_VERSION]: string;
  468. [UnityContextKey.INSTALL_MODE]: string;
  469. [UnityContextKey.RENDERING_THREADING_MODE]: string;
  470. [UnityContextKey.TARGET_FRAME_RATE]: string;
  471. type: 'unity';
  472. }
  473. export enum MemoryInfoContextKey {
  474. ALLOCATED_BYTES = 'allocated_bytes',
  475. FRAGMENTED_BYTES = 'fragmented_bytes',
  476. HEAP_SIZE_BYTES = 'heap_size_bytes',
  477. HIGH_MEMORY_LOAD_THRESHOLD_BYTES = 'high_memory_load_threshold_bytes',
  478. TOTAL_AVAILABLE_MEMORY_BYTES = 'total_available_memory_bytes',
  479. MEMORY_LOAD_BYTES = 'memory_load_bytes',
  480. TOTAL_COMMITTED_BYTES = 'total_committed_bytes',
  481. PROMOTED_BYTES = 'promoted_bytes',
  482. PINNED_OBJECTS_COUNT = 'pinned_objects_count',
  483. PAUSE_TIME_PERCENTAGE = 'pause_time_percentage',
  484. INDEX = 'index',
  485. FINALIZATION_PENDING_COUNT = 'finalization_pending_count',
  486. COMPACTED = 'compacted',
  487. CONCURRENT = 'concurrent',
  488. PAUSE_DURATIONS = 'pause_durations',
  489. }
  490. // MemoryInfo Context
  491. // TODO(Priscila): Add this context to the docs
  492. export interface MemoryInfoContext {
  493. type: 'Memory Info' | 'memory_info';
  494. [MemoryInfoContextKey.FINALIZATION_PENDING_COUNT]: number;
  495. [MemoryInfoContextKey.COMPACTED]: boolean;
  496. [MemoryInfoContextKey.CONCURRENT]: boolean;
  497. [MemoryInfoContextKey.PAUSE_DURATIONS]: number[];
  498. [MemoryInfoContextKey.TOTAL_AVAILABLE_MEMORY_BYTES]?: number;
  499. [MemoryInfoContextKey.MEMORY_LOAD_BYTES]?: number;
  500. [MemoryInfoContextKey.TOTAL_COMMITTED_BYTES]?: number;
  501. [MemoryInfoContextKey.PROMOTED_BYTES]?: number;
  502. [MemoryInfoContextKey.PINNED_OBJECTS_COUNT]?: number;
  503. [MemoryInfoContextKey.PAUSE_TIME_PERCENTAGE]?: number;
  504. [MemoryInfoContextKey.INDEX]?: number;
  505. [MemoryInfoContextKey.ALLOCATED_BYTES]?: number;
  506. [MemoryInfoContextKey.FRAGMENTED_BYTES]?: number;
  507. [MemoryInfoContextKey.HEAP_SIZE_BYTES]?: number;
  508. [MemoryInfoContextKey.HIGH_MEMORY_LOAD_THRESHOLD_BYTES]?: number;
  509. }
  510. export enum ThreadPoolInfoContextKey {
  511. MIN_WORKER_THREADS = 'min_worker_threads',
  512. MIN_COMPLETION_PORT_THREADS = 'min_completion_port_threads',
  513. MAX_WORKER_THREADS = 'max_worker_threads',
  514. MAX_COMPLETION_PORT_THREADS = 'max_completion_port_threads',
  515. AVAILABLE_WORKER_THREADS = 'available_worker_threads',
  516. AVAILABLE_COMPLETION_PORT_THREADS = 'available_completion_port_threads',
  517. }
  518. // ThreadPoolInfo Context
  519. // TODO(Priscila): Add this context to the docs
  520. export interface ThreadPoolInfoContext {
  521. type: 'ThreadPool Info' | 'threadpool_info';
  522. [ThreadPoolInfoContextKey.MIN_WORKER_THREADS]: number;
  523. [ThreadPoolInfoContextKey.MIN_COMPLETION_PORT_THREADS]: number;
  524. [ThreadPoolInfoContextKey.MAX_WORKER_THREADS]: number;
  525. [ThreadPoolInfoContextKey.MAX_COMPLETION_PORT_THREADS]: number;
  526. [ThreadPoolInfoContextKey.AVAILABLE_WORKER_THREADS]: number;
  527. [ThreadPoolInfoContextKey.AVAILABLE_COMPLETION_PORT_THREADS]: number;
  528. }
  529. export enum ProfileContextKey {
  530. PROFILE_ID = 'profile_id',
  531. }
  532. export interface ProfileContext {
  533. [ProfileContextKey.PROFILE_ID]?: string;
  534. }
  535. export interface ReplayContext {
  536. replay_id: string;
  537. type: string;
  538. }
  539. export interface BrowserContext {
  540. name: string;
  541. version: string;
  542. }
  543. type EventContexts = {
  544. 'Memory Info'?: MemoryInfoContext;
  545. 'ThreadPool Info'?: ThreadPoolInfoContext;
  546. browser?: BrowserContext;
  547. client_os?: OSContext;
  548. device?: DeviceContext;
  549. feedback?: Record<string, any>;
  550. memory_info?: MemoryInfoContext;
  551. os?: OSContext;
  552. otel?: OtelContext;
  553. // TODO (udameli): add better types here
  554. // once perf issue data shape is more clear
  555. performance_issue?: any;
  556. replay?: ReplayContext;
  557. runtime?: RuntimeContext;
  558. threadpool_info?: ThreadPoolInfoContext;
  559. trace?: TraceContextType;
  560. unity?: UnityContext;
  561. };
  562. export type Measurement = {value: number; unit?: string};
  563. export type EventTag = {key: string; value: string};
  564. export type EventUser = {
  565. data?: string | null;
  566. email?: string;
  567. id?: string;
  568. ip_address?: string;
  569. name?: string | null;
  570. username?: string | null;
  571. };
  572. export type PerformanceDetectorData = {
  573. causeSpanIds: string[];
  574. offenderSpanIds: string[];
  575. parentSpanIds: string[];
  576. issueType?: IssueType;
  577. };
  578. type EventEvidenceDisplay = {
  579. /**
  580. * Used for alerting, probably not useful for the UI
  581. */
  582. important: boolean;
  583. name: string;
  584. value: string;
  585. };
  586. export type EventOccurrence = {
  587. detectionTime: string;
  588. eventId: string;
  589. /**
  590. * Arbitrary data that vertical teams can pass to assist with rendering the page.
  591. * This is intended mostly for use with customizing the UI, not in the generic UI.
  592. */
  593. evidenceData: Record<string, any>;
  594. /**
  595. * Data displayed in the evidence table. Used in all issue types besides errors.
  596. */
  597. evidenceDisplay: EventEvidenceDisplay[];
  598. fingerprint: string[];
  599. id: string;
  600. issueTitle: string;
  601. resourceId: string;
  602. subtitle: string;
  603. type: number;
  604. };
  605. type EventRelease = Pick<
  606. Release,
  607. | 'commitCount'
  608. | 'data'
  609. | 'dateCreated'
  610. | 'dateReleased'
  611. | 'deployCount'
  612. | 'id'
  613. | 'lastCommit'
  614. | 'lastDeploy'
  615. | 'ref'
  616. | 'status'
  617. | 'url'
  618. | 'userAgent'
  619. | 'version'
  620. | 'versionInfo'
  621. >;
  622. interface EventBase {
  623. contexts: EventContexts;
  624. crashFile: IssueAttachment | null;
  625. culprit: string;
  626. dateReceived: string;
  627. dist: string | null;
  628. entries: Entry[];
  629. errors: any[];
  630. eventID: string;
  631. fingerprints: string[];
  632. id: string;
  633. location: string | null;
  634. message: string;
  635. metadata: EventMetadata;
  636. occurrence: EventOccurrence | null;
  637. projectID: string;
  638. size: number;
  639. tags: EventTag[];
  640. title: string;
  641. type:
  642. | EventOrGroupType.CSP
  643. | EventOrGroupType.DEFAULT
  644. | EventOrGroupType.EXPECTCT
  645. | EventOrGroupType.EXPECTSTAPLE
  646. | EventOrGroupType.HPKP;
  647. user: EventUser | null;
  648. _meta?: Record<string, any>;
  649. context?: Record<string, any>;
  650. dateCreated?: string;
  651. device?: Record<string, any>;
  652. endTimestamp?: number;
  653. groupID?: string;
  654. groupingConfig?: {
  655. enhancements: string;
  656. id: string;
  657. };
  658. issueCategory?: IssueCategory;
  659. latestEventID?: string | null;
  660. measurements?: Record<string, Measurement>;
  661. nextEventID?: string | null;
  662. oldestEventID?: string | null;
  663. packages?: Record<string, string>;
  664. platform?: PlatformType;
  665. previousEventID?: string | null;
  666. projectSlug?: string;
  667. release?: EventRelease | null;
  668. sdk?: {
  669. name: string;
  670. version: string;
  671. } | null;
  672. sdkUpdates?: Array<SDKUpdatesSuggestion>;
  673. userReport?: any;
  674. }
  675. interface TraceEventContexts extends EventContexts {
  676. browser?: BrowserContext;
  677. profile?: ProfileContext;
  678. }
  679. export interface EventTransaction
  680. extends Omit<EventBase, 'entries' | 'type' | 'contexts'> {
  681. contexts: TraceEventContexts;
  682. endTimestamp: number;
  683. // EntryDebugMeta is required for profiles to render in the span
  684. // waterfall with the correct symbolication statuses
  685. entries: (EntrySpans | EntryRequest | EntryDebugMeta)[];
  686. startTimestamp: number;
  687. type: EventOrGroupType.TRANSACTION;
  688. perfProblem?: PerformanceDetectorData;
  689. }
  690. export interface EventError extends Omit<EventBase, 'entries' | 'type'> {
  691. entries: (
  692. | EntryException
  693. | EntryStacktrace
  694. | EntryRequest
  695. | EntryThreads
  696. | EntryDebugMeta
  697. )[];
  698. type: EventOrGroupType.ERROR;
  699. }
  700. export type Event = EventError | EventTransaction | EventBase;
  701. // Response from EventIdLookupEndpoint
  702. // /organizations/${orgSlug}/eventids/${eventId}/
  703. export type EventIdResponse = {
  704. event: Event;
  705. eventId: string;
  706. groupId: string;
  707. organizationSlug: string;
  708. projectSlug: string;
  709. };