event.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  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 {RawCrumb} from './breadcrumbs';
  9. import type {Image} from './debugImage';
  10. import type {IssueAttachment, IssueCategory, IssueType} from './group';
  11. import type {PlatformKey} from './project';
  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. // This type is incomplete
  208. export type EventMetadata = {
  209. current_level?: number;
  210. directive?: string;
  211. filename?: string;
  212. function?: string;
  213. message?: string;
  214. origin?: string;
  215. stripped_crash?: boolean;
  216. title?: string;
  217. type?: string;
  218. uri?: string;
  219. value?: string;
  220. };
  221. export enum EventOrGroupType {
  222. ERROR = 'error',
  223. CSP = 'csp',
  224. HPKP = 'hpkp',
  225. EXPECTCT = 'expectct',
  226. EXPECTSTAPLE = 'expectstaple',
  227. NEL = 'nel',
  228. DEFAULT = 'default',
  229. TRANSACTION = 'transaction',
  230. AGGREGATE_TRANSACTION = 'aggregateTransaction',
  231. GENERIC = 'generic',
  232. }
  233. /**
  234. * Event interface types.
  235. */
  236. export enum EntryType {
  237. EXCEPTION = 'exception',
  238. MESSAGE = 'message',
  239. REQUEST = 'request',
  240. STACKTRACE = 'stacktrace',
  241. TEMPLATE = 'template',
  242. CSP = 'csp',
  243. EXPECTCT = 'expectct',
  244. EXPECTSTAPLE = 'expectstaple',
  245. HPKP = 'hpkp',
  246. BREADCRUMBS = 'breadcrumbs',
  247. THREADS = 'threads',
  248. THREAD_STATE = 'thread-state',
  249. THREAD_TAGS = 'thread-tags',
  250. DEBUGMETA = 'debugmeta',
  251. SPANS = 'spans',
  252. RESOURCES = 'resources',
  253. }
  254. export type EntryDebugMeta = {
  255. data: {
  256. images: Array<Image | null>;
  257. };
  258. type: EntryType.DEBUGMETA;
  259. };
  260. export type EntryBreadcrumbs = {
  261. data: {
  262. values: Array<RawCrumb>;
  263. };
  264. type: EntryType.BREADCRUMBS;
  265. };
  266. export type EntryThreads = {
  267. data: {
  268. values?: Array<Thread>;
  269. };
  270. type: EntryType.THREADS;
  271. };
  272. export type EntryException = {
  273. data: ExceptionType;
  274. type: EntryType.EXCEPTION;
  275. };
  276. export type EntryStacktrace = {
  277. data: StacktraceType;
  278. type: EntryType.STACKTRACE;
  279. };
  280. export type EntrySpans = {
  281. data: RawSpanType[];
  282. type: EntryType.SPANS;
  283. };
  284. export type AggregateEntrySpans = {
  285. data: AggregateSpanType[];
  286. type: EntryType.SPANS;
  287. };
  288. type EntryMessage = {
  289. data: {
  290. formatted: string;
  291. params?: Record<string, any> | any[];
  292. };
  293. type: EntryType.MESSAGE;
  294. };
  295. export interface EntryRequestDataDefault {
  296. apiTarget: null;
  297. method: string;
  298. url: string;
  299. cookies?: [key: string, value: string][];
  300. data?: string | null | Record<string, any> | [key: string, value: any][];
  301. env?: Record<string, string>;
  302. fragment?: string | null;
  303. headers?: [key: string, value: string][];
  304. inferredContentType?:
  305. | null
  306. | 'application/json'
  307. | 'application/x-www-form-urlencoded'
  308. | 'multipart/form-data';
  309. query?: [key: string, value: string][] | string;
  310. }
  311. export interface EntryRequestDataGraphQl
  312. extends Omit<EntryRequestDataDefault, 'apiTarget' | 'data'> {
  313. apiTarget: 'graphql';
  314. data: {
  315. query: string;
  316. variables: Record<string, string | number | null>;
  317. operationName?: string;
  318. };
  319. }
  320. export type EntryRequest = {
  321. data: EntryRequestDataDefault | EntryRequestDataGraphQl;
  322. type: EntryType.REQUEST;
  323. };
  324. type EntryTemplate = {
  325. data: Frame;
  326. type: EntryType.TEMPLATE;
  327. };
  328. type EntryCsp = {
  329. data: Record<string, any>;
  330. type: EntryType.CSP;
  331. };
  332. type EntryGeneric = {
  333. data: Record<string, any>;
  334. type: EntryType.EXPECTCT | EntryType.EXPECTSTAPLE | EntryType.HPKP;
  335. };
  336. type EntryResources = {
  337. data: any; // Data is unused here
  338. type: EntryType.RESOURCES;
  339. };
  340. export type Entry =
  341. | EntryDebugMeta
  342. | EntryBreadcrumbs
  343. | EntryThreads
  344. | EntryException
  345. | EntryStacktrace
  346. | EntrySpans
  347. | EntryMessage
  348. | EntryRequest
  349. | EntryTemplate
  350. | EntryCsp
  351. | EntryGeneric
  352. | EntryResources;
  353. // Contexts: https://develop.sentry.dev/sdk/event-payloads/contexts/
  354. export interface BaseContext {
  355. type: string;
  356. }
  357. export enum DeviceContextKey {
  358. ARCH = 'arch',
  359. BATTERY_LEVEL = 'battery_level',
  360. BATTERY_STATUS = 'battery_status',
  361. BOOT_TIME = 'boot_time',
  362. BRAND = 'brand',
  363. CHARGING = 'charging',
  364. CPU_DESCRIPTION = 'cpu_description',
  365. DEVICE_TYPE = 'device_type',
  366. DEVICE_UNIQUE_IDENTIFIER = 'device_unique_identifier',
  367. EXTERNAL_FREE_STORAGE = 'external_free_storage',
  368. EXTERNAL_STORAGE_SIZE = 'external_storage_size',
  369. EXTERNAL_TOTAL_STORAGE = 'external_total_storage',
  370. FAMILY = 'family',
  371. FREE_MEMORY = 'free_memory',
  372. FREE_STORAGE = 'free_storage',
  373. LOW_MEMORY = 'low_memory',
  374. MANUFACTURER = 'manufacturer',
  375. MEMORY_SIZE = 'memory_size',
  376. MODEL = 'model',
  377. MODEL_ID = 'model_id',
  378. NAME = 'name',
  379. ONLINE = 'online',
  380. ORIENTATION = 'orientation',
  381. PROCESSOR_COUNT = 'processor_count',
  382. PROCESSOR_FREQUENCY = 'processor_frequency',
  383. SCREEN_DENSITY = 'screen_density',
  384. SCREEN_DPI = 'screen_dpi',
  385. SCREEN_HEIGHT_PIXELS = 'screen_height_pixels',
  386. SCREEN_RESOLUTION = 'screen_resolution',
  387. SCREEN_WIDTH_PIXELS = 'screen_width_pixels',
  388. SIMULATOR = 'simulator',
  389. STORAGE_SIZE = 'storage_size',
  390. SUPPORTS_ACCELEROMETER = 'supports_accelerometer',
  391. SUPPORTS_AUDIO = 'supports_audio',
  392. SUPPORTS_GYROSCOPE = 'supports_gyroscope',
  393. SUPPORTS_LOCATION_SERVICE = 'supports_location_service',
  394. SUPPORTS_VIBRATION = 'supports_vibration',
  395. USABLE_MEMORY = 'usable_memory',
  396. }
  397. // https://develop.sentry.dev/sdk/event-payloads/contexts/#device-context
  398. export interface DeviceContext
  399. extends Partial<Record<DeviceContextKey, unknown>>,
  400. BaseContext {
  401. type: 'device';
  402. [DeviceContextKey.NAME]: string;
  403. [DeviceContextKey.ARCH]?: string;
  404. [DeviceContextKey.BATTERY_LEVEL]?: number;
  405. [DeviceContextKey.BATTERY_STATUS]?: string;
  406. [DeviceContextKey.BOOT_TIME]?: string;
  407. [DeviceContextKey.BRAND]?: string;
  408. [DeviceContextKey.CHARGING]?: boolean;
  409. [DeviceContextKey.CPU_DESCRIPTION]?: string;
  410. [DeviceContextKey.DEVICE_TYPE]?: string;
  411. [DeviceContextKey.DEVICE_UNIQUE_IDENTIFIER]?: string;
  412. [DeviceContextKey.EXTERNAL_FREE_STORAGE]?: number;
  413. [DeviceContextKey.EXTERNAL_STORAGE_SIZE]?: number;
  414. [DeviceContextKey.EXTERNAL_TOTAL_STORAGE]?: number;
  415. [DeviceContextKey.FAMILY]?: string;
  416. [DeviceContextKey.FREE_MEMORY]?: number;
  417. [DeviceContextKey.FREE_STORAGE]?: number;
  418. [DeviceContextKey.LOW_MEMORY]?: boolean;
  419. [DeviceContextKey.MANUFACTURER]?: string;
  420. [DeviceContextKey.MEMORY_SIZE]?: number;
  421. [DeviceContextKey.MODEL]?: string;
  422. [DeviceContextKey.MODEL_ID]?: string;
  423. [DeviceContextKey.ONLINE]?: boolean;
  424. [DeviceContextKey.ORIENTATION]?: 'portrait' | 'landscape';
  425. [DeviceContextKey.PROCESSOR_COUNT]?: number;
  426. [DeviceContextKey.PROCESSOR_FREQUENCY]?: number;
  427. [DeviceContextKey.SCREEN_DENSITY]?: number;
  428. [DeviceContextKey.SCREEN_DPI]?: number;
  429. [DeviceContextKey.SCREEN_HEIGHT_PIXELS]?: number;
  430. [DeviceContextKey.SCREEN_RESOLUTION]?: string;
  431. [DeviceContextKey.SCREEN_WIDTH_PIXELS]?: number;
  432. [DeviceContextKey.SIMULATOR]?: boolean;
  433. [DeviceContextKey.STORAGE_SIZE]?: number;
  434. [DeviceContextKey.SUPPORTS_ACCELEROMETER]?: boolean;
  435. [DeviceContextKey.SUPPORTS_AUDIO]?: boolean;
  436. [DeviceContextKey.SUPPORTS_GYROSCOPE]?: boolean;
  437. [DeviceContextKey.SUPPORTS_LOCATION_SERVICE]?: boolean;
  438. [DeviceContextKey.SUPPORTS_VIBRATION]?: boolean;
  439. [DeviceContextKey.USABLE_MEMORY]?: number;
  440. // This field is deprecated in favour of locale field in culture context
  441. language?: string;
  442. // This field is deprecated in favour of timezone field in culture context
  443. timezone?: string;
  444. }
  445. enum RuntimeContextKey {
  446. BUILD = 'build',
  447. NAME = 'name',
  448. RAW_DESCRIPTION = 'raw_description',
  449. VERSION = 'version',
  450. }
  451. // https://develop.sentry.dev/sdk/event-payloads/contexts/#runtime-context
  452. interface RuntimeContext
  453. extends Partial<Record<RuntimeContextKey, unknown>>,
  454. BaseContext {
  455. type: 'runtime';
  456. [RuntimeContextKey.BUILD]?: string;
  457. [RuntimeContextKey.NAME]?: string;
  458. [RuntimeContextKey.RAW_DESCRIPTION]?: string;
  459. [RuntimeContextKey.VERSION]?: number;
  460. }
  461. type OSContext = {
  462. build: string;
  463. kernel_version: string;
  464. name: string;
  465. type: string;
  466. version: string;
  467. };
  468. export enum OtelContextKey {
  469. ATTRIBUTES = 'attributes',
  470. RESOURCE = 'resource',
  471. }
  472. // OpenTelemetry Context
  473. // https://develop.sentry.dev/sdk/performance/opentelemetry/#opentelemetry-context
  474. interface OtelContext extends Partial<Record<OtelContextKey, unknown>>, BaseContext {
  475. type: 'otel';
  476. [OtelContextKey.ATTRIBUTES]?: Record<string, unknown>;
  477. [OtelContextKey.RESOURCE]?: Record<string, unknown>;
  478. }
  479. export enum UnityContextKey {
  480. COPY_TEXTURE_SUPPORT = 'copy_texture_support',
  481. EDITOR_VERSION = 'editor_version',
  482. INSTALL_MODE = 'install_mode',
  483. RENDERING_THREADING_MODE = 'rendering_threading_mode',
  484. TARGET_FRAME_RATE = 'target_frame_rate',
  485. }
  486. // Unity Context
  487. // TODO(Priscila): Add this context to the docs
  488. export interface UnityContext {
  489. [UnityContextKey.COPY_TEXTURE_SUPPORT]: string;
  490. [UnityContextKey.EDITOR_VERSION]: string;
  491. [UnityContextKey.INSTALL_MODE]: string;
  492. [UnityContextKey.RENDERING_THREADING_MODE]: string;
  493. [UnityContextKey.TARGET_FRAME_RATE]: string;
  494. type: 'unity';
  495. }
  496. export enum MemoryInfoContextKey {
  497. ALLOCATED_BYTES = 'allocated_bytes',
  498. FRAGMENTED_BYTES = 'fragmented_bytes',
  499. HEAP_SIZE_BYTES = 'heap_size_bytes',
  500. HIGH_MEMORY_LOAD_THRESHOLD_BYTES = 'high_memory_load_threshold_bytes',
  501. TOTAL_AVAILABLE_MEMORY_BYTES = 'total_available_memory_bytes',
  502. MEMORY_LOAD_BYTES = 'memory_load_bytes',
  503. TOTAL_COMMITTED_BYTES = 'total_committed_bytes',
  504. PROMOTED_BYTES = 'promoted_bytes',
  505. PINNED_OBJECTS_COUNT = 'pinned_objects_count',
  506. PAUSE_TIME_PERCENTAGE = 'pause_time_percentage',
  507. INDEX = 'index',
  508. FINALIZATION_PENDING_COUNT = 'finalization_pending_count',
  509. COMPACTED = 'compacted',
  510. CONCURRENT = 'concurrent',
  511. PAUSE_DURATIONS = 'pause_durations',
  512. }
  513. // MemoryInfo Context
  514. // TODO(Priscila): Add this context to the docs
  515. export interface MemoryInfoContext {
  516. type: 'Memory Info' | 'memory_info';
  517. [MemoryInfoContextKey.FINALIZATION_PENDING_COUNT]: number;
  518. [MemoryInfoContextKey.COMPACTED]: boolean;
  519. [MemoryInfoContextKey.CONCURRENT]: boolean;
  520. [MemoryInfoContextKey.PAUSE_DURATIONS]: number[];
  521. [MemoryInfoContextKey.TOTAL_AVAILABLE_MEMORY_BYTES]?: number;
  522. [MemoryInfoContextKey.MEMORY_LOAD_BYTES]?: number;
  523. [MemoryInfoContextKey.TOTAL_COMMITTED_BYTES]?: number;
  524. [MemoryInfoContextKey.PROMOTED_BYTES]?: number;
  525. [MemoryInfoContextKey.PINNED_OBJECTS_COUNT]?: number;
  526. [MemoryInfoContextKey.PAUSE_TIME_PERCENTAGE]?: number;
  527. [MemoryInfoContextKey.INDEX]?: number;
  528. [MemoryInfoContextKey.ALLOCATED_BYTES]?: number;
  529. [MemoryInfoContextKey.FRAGMENTED_BYTES]?: number;
  530. [MemoryInfoContextKey.HEAP_SIZE_BYTES]?: number;
  531. [MemoryInfoContextKey.HIGH_MEMORY_LOAD_THRESHOLD_BYTES]?: number;
  532. }
  533. export enum ThreadPoolInfoContextKey {
  534. MIN_WORKER_THREADS = 'min_worker_threads',
  535. MIN_COMPLETION_PORT_THREADS = 'min_completion_port_threads',
  536. MAX_WORKER_THREADS = 'max_worker_threads',
  537. MAX_COMPLETION_PORT_THREADS = 'max_completion_port_threads',
  538. AVAILABLE_WORKER_THREADS = 'available_worker_threads',
  539. AVAILABLE_COMPLETION_PORT_THREADS = 'available_completion_port_threads',
  540. }
  541. // ThreadPoolInfo Context
  542. // TODO(Priscila): Add this context to the docs
  543. export interface ThreadPoolInfoContext {
  544. type: 'ThreadPool Info' | 'threadpool_info';
  545. [ThreadPoolInfoContextKey.MIN_WORKER_THREADS]: number;
  546. [ThreadPoolInfoContextKey.MIN_COMPLETION_PORT_THREADS]: number;
  547. [ThreadPoolInfoContextKey.MAX_WORKER_THREADS]: number;
  548. [ThreadPoolInfoContextKey.MAX_COMPLETION_PORT_THREADS]: number;
  549. [ThreadPoolInfoContextKey.AVAILABLE_WORKER_THREADS]: number;
  550. [ThreadPoolInfoContextKey.AVAILABLE_COMPLETION_PORT_THREADS]: number;
  551. }
  552. export enum ProfileContextKey {
  553. PROFILE_ID = 'profile_id',
  554. PROFILER_ID = 'profiler_id',
  555. }
  556. export interface ProfileContext {
  557. [ProfileContextKey.PROFILE_ID]?: string;
  558. [ProfileContextKey.PROFILER_ID]?: string;
  559. }
  560. export enum ReplayContextKey {
  561. REPLAY_ID = 'replay_id',
  562. }
  563. export interface ReplayContext {
  564. [ReplayContextKey.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. export 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; type?: string; 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: (
  721. | EntrySpans
  722. | EntryRequest
  723. | EntryDebugMeta
  724. | AggregateEntrySpans
  725. | EntryBreadcrumbs
  726. )[];
  727. startTimestamp: number;
  728. type: EventOrGroupType.TRANSACTION;
  729. _metrics_summary?: MetricsSummary;
  730. perfProblem?: PerformanceDetectorData;
  731. }
  732. export interface AggregateEventTransaction
  733. extends Omit<
  734. EventTransaction,
  735. | 'crashFile'
  736. | 'culprit'
  737. | 'dist'
  738. | 'dateReceived'
  739. | 'errors'
  740. | 'location'
  741. | 'metadata'
  742. | 'message'
  743. | 'occurrence'
  744. | 'type'
  745. | 'size'
  746. | 'user'
  747. | 'eventID'
  748. | 'fingerprints'
  749. | 'id'
  750. | 'projectID'
  751. | 'tags'
  752. | 'title'
  753. > {
  754. count: number;
  755. frequency: number;
  756. total: number;
  757. type: EventOrGroupType.AGGREGATE_TRANSACTION;
  758. }
  759. export interface EventError extends Omit<EventBase, 'entries' | 'type'> {
  760. entries: (
  761. | EntryException
  762. | EntryStacktrace
  763. | EntryRequest
  764. | EntryThreads
  765. | EntryDebugMeta
  766. )[];
  767. type: EventOrGroupType.ERROR;
  768. }
  769. export type Event = EventError | EventTransaction | EventBase;
  770. // Response from EventIdLookupEndpoint
  771. // /organizations/${orgSlug}/eventids/${eventId}/
  772. export type EventIdResponse = {
  773. event: Event;
  774. eventId: string;
  775. groupId: string;
  776. organizationSlug: string;
  777. projectSlug: string;
  778. };