event.tsx 22 KB

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