event.tsx 21 KB

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