event.tsx 22 KB

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