event.tsx 22 KB

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