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