event.tsx 22 KB

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