event.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  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. PROFILER_ID = 'profiler_id',
  572. }
  573. export interface ProfileContext {
  574. [ProfileContextKey.PROFILE_ID]?: string;
  575. [ProfileContextKey.PROFILER_ID]?: string;
  576. }
  577. export enum ReplayContextKey {
  578. REPLAY_ID = 'replay_id',
  579. }
  580. export interface ReplayContext {
  581. [ReplayContextKey.REPLAY_ID]: string;
  582. type: string;
  583. }
  584. export interface BrowserContext {
  585. name: string;
  586. version: string;
  587. }
  588. export interface ResponseContext {
  589. data: unknown;
  590. type: 'response';
  591. }
  592. export type EventContexts = {
  593. 'Memory Info'?: MemoryInfoContext;
  594. 'ThreadPool Info'?: ThreadPoolInfoContext;
  595. browser?: BrowserContext;
  596. client_os?: OSContext;
  597. device?: DeviceContext;
  598. feedback?: Record<string, any>;
  599. memory_info?: MemoryInfoContext;
  600. os?: OSContext;
  601. otel?: OtelContext;
  602. // TODO (udameli): add better types here
  603. // once perf issue data shape is more clear
  604. performance_issue?: any;
  605. profile?: ProfileContext;
  606. replay?: ReplayContext;
  607. response?: ResponseContext;
  608. runtime?: RuntimeContext;
  609. threadpool_info?: ThreadPoolInfoContext;
  610. trace?: TraceContextType;
  611. unity?: UnityContext;
  612. };
  613. export type Measurement = {value: number; type?: string; unit?: string};
  614. export type EventTag = {key: string; value: string};
  615. export type EventUser = {
  616. data?: string | null;
  617. email?: string;
  618. id?: string;
  619. ip_address?: string;
  620. name?: string | null;
  621. username?: string | null;
  622. };
  623. export type PerformanceDetectorData = {
  624. causeSpanIds: string[];
  625. offenderSpanIds: string[];
  626. parentSpanIds: string[];
  627. issueType?: IssueType;
  628. };
  629. type EventEvidenceDisplay = {
  630. /**
  631. * Used for alerting, probably not useful for the UI
  632. */
  633. important: boolean;
  634. name: string;
  635. value: string;
  636. };
  637. export type EventOccurrence = {
  638. detectionTime: string;
  639. eventId: string;
  640. /**
  641. * Arbitrary data that vertical teams can pass to assist with rendering the page.
  642. * This is intended mostly for use with customizing the UI, not in the generic UI.
  643. */
  644. evidenceData: Record<string, any>;
  645. /**
  646. * Data displayed in the evidence table. Used in all issue types besides errors.
  647. */
  648. evidenceDisplay: EventEvidenceDisplay[];
  649. fingerprint: string[];
  650. id: string;
  651. issueTitle: string;
  652. resourceId: string;
  653. subtitle: string;
  654. type: number;
  655. };
  656. type EventRelease = Pick<
  657. Release,
  658. | 'commitCount'
  659. | 'data'
  660. | 'dateCreated'
  661. | 'dateReleased'
  662. | 'deployCount'
  663. | 'id'
  664. | 'lastCommit'
  665. | 'lastDeploy'
  666. | 'ref'
  667. | 'status'
  668. | 'url'
  669. | 'userAgent'
  670. | 'version'
  671. | 'versionInfo'
  672. >;
  673. interface EventBase {
  674. contexts: EventContexts;
  675. crashFile: IssueAttachment | null;
  676. culprit: string;
  677. dateReceived: string;
  678. dist: string | null;
  679. entries: Entry[];
  680. errors: any[];
  681. eventID: string;
  682. fingerprints: string[];
  683. id: string;
  684. location: string | null;
  685. message: string;
  686. metadata: EventMetadata;
  687. occurrence: EventOccurrence | null;
  688. projectID: string;
  689. size: number;
  690. tags: EventTag[];
  691. title: string;
  692. type:
  693. | EventOrGroupType.CSP
  694. | EventOrGroupType.DEFAULT
  695. | EventOrGroupType.EXPECTCT
  696. | EventOrGroupType.EXPECTSTAPLE
  697. | EventOrGroupType.HPKP;
  698. user: EventUser | null;
  699. _meta?: Record<string, any>;
  700. context?: Record<string, any>;
  701. dateCreated?: string;
  702. device?: Record<string, any>;
  703. endTimestamp?: number;
  704. groupID?: string;
  705. groupingConfig?: {
  706. enhancements: string;
  707. id: string;
  708. };
  709. issueCategory?: IssueCategory;
  710. latestEventID?: string | null;
  711. measurements?: Record<string, Measurement>;
  712. nextEventID?: string | null;
  713. oldestEventID?: string | null;
  714. packages?: Record<string, string>;
  715. platform?: PlatformKey;
  716. previousEventID?: string | null;
  717. projectSlug?: string;
  718. release?: EventRelease | null;
  719. resolvedWith?: string[];
  720. sdk?: {
  721. name: string;
  722. version: string;
  723. } | null;
  724. sdkUpdates?: Array<SDKUpdatesSuggestion>;
  725. userReport?: any;
  726. }
  727. interface TraceEventContexts extends EventContexts {
  728. browser?: BrowserContext;
  729. profile?: ProfileContext;
  730. }
  731. export interface EventTransaction
  732. extends Omit<EventBase, 'entries' | 'type' | 'contexts'> {
  733. contexts: TraceEventContexts;
  734. endTimestamp: number;
  735. // EntryDebugMeta is required for profiles to render in the span
  736. // waterfall with the correct symbolication statuses
  737. entries: (
  738. | EntrySpans
  739. | EntryRequest
  740. | EntryDebugMeta
  741. | AggregateEntrySpans
  742. | EntryBreadcrumbs
  743. )[];
  744. startTimestamp: number;
  745. type: EventOrGroupType.TRANSACTION;
  746. _metrics_summary?: MetricsSummary;
  747. perfProblem?: PerformanceDetectorData;
  748. }
  749. export interface AggregateEventTransaction
  750. extends Omit<
  751. EventTransaction,
  752. | 'crashFile'
  753. | 'culprit'
  754. | 'dist'
  755. | 'dateReceived'
  756. | 'errors'
  757. | 'location'
  758. | 'metadata'
  759. | 'message'
  760. | 'occurrence'
  761. | 'type'
  762. | 'size'
  763. | 'user'
  764. | 'eventID'
  765. | 'fingerprints'
  766. | 'id'
  767. | 'projectID'
  768. | 'tags'
  769. | 'title'
  770. > {
  771. count: number;
  772. frequency: number;
  773. total: number;
  774. type: EventOrGroupType.AGGREGATE_TRANSACTION;
  775. }
  776. export interface EventError extends Omit<EventBase, 'entries' | 'type'> {
  777. entries: (
  778. | EntryException
  779. | EntryStacktrace
  780. | EntryRequest
  781. | EntryThreads
  782. | EntryDebugMeta
  783. )[];
  784. type: EventOrGroupType.ERROR;
  785. }
  786. export type Event = EventError | EventTransaction | EventBase;
  787. // Response from EventIdLookupEndpoint
  788. // /organizations/${orgSlug}/eventids/${eventId}/
  789. export type EventIdResponse = {
  790. event: Event;
  791. eventId: string;
  792. groupId: string;
  793. organizationSlug: string;
  794. projectSlug: string;
  795. };