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