event.tsx 22 KB

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