event.tsx 21 KB

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