event.tsx 22 KB

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