event.tsx 23 KB

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