event.tsx 22 KB

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