event.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import {DebugImage} from 'app/components/events/interfaces/debugMeta/types';
  2. import {TraceContextType} from 'app/components/events/interfaces/spans/types';
  3. import {Breadcrumb} from './breadcrumbs';
  4. import {Thread} from './events';
  5. import {StacktraceType} from './stacktrace';
  6. import {
  7. EventAttachment,
  8. EventMetadata,
  9. ExceptionType,
  10. Frame,
  11. PlatformType,
  12. Release,
  13. SDKUpdatesSuggestion,
  14. } from '.';
  15. export enum EntryType {
  16. EXCEPTION = 'exception',
  17. MESSAGE = 'message',
  18. REQUEST = 'request',
  19. STACKTRACE = 'stacktrace',
  20. TEMPLATE = 'template',
  21. CSP = 'csp',
  22. EXPECTCT = 'expectct',
  23. EXPECTSTAPLE = 'expectstaple',
  24. HPKP = 'hpkp',
  25. BREADCRUMBS = 'breadcrumbs',
  26. THREADS = 'threads',
  27. DEBUGMETA = 'debugmeta',
  28. SPANS = 'spans',
  29. }
  30. type EntryDebugMeta = {
  31. type: EntryType.DEBUGMETA;
  32. data: {
  33. images: Array<DebugImage>;
  34. };
  35. };
  36. type EntryBreadcrumbs = {
  37. type: EntryType.BREADCRUMBS;
  38. data: {
  39. values: Array<Breadcrumb>;
  40. };
  41. };
  42. export type EntryThreads = {
  43. type: EntryType.THREADS;
  44. data: {
  45. values?: Array<Thread>;
  46. };
  47. };
  48. export type EntryException = {
  49. type: EntryType.EXCEPTION;
  50. data: ExceptionType;
  51. };
  52. type EntryStacktrace = {
  53. type: EntryType.STACKTRACE;
  54. data: StacktraceType;
  55. };
  56. type EntrySpans = {
  57. type: EntryType.SPANS;
  58. data: any; // data is not used
  59. };
  60. type EntryMessage = {
  61. type: EntryType.MESSAGE;
  62. data: {
  63. formatted: string;
  64. params?: Record<string, any> | any[];
  65. };
  66. };
  67. export type EntryRequest = {
  68. type: EntryType.REQUEST;
  69. data: {
  70. url: string;
  71. method: string;
  72. data?: string | null | Record<string, any> | [key: string, value: any][];
  73. query?: [key: string, value: string][];
  74. fragment?: string;
  75. cookies?: [key: string, value: string][];
  76. headers?: [key: string, value: string][];
  77. env?: Record<string, string>;
  78. inferredContentType?:
  79. | null
  80. | 'application/json'
  81. | 'application/x-www-form-urlencoded'
  82. | 'multipart/form-data';
  83. };
  84. };
  85. type EntryTemplate = {
  86. type: EntryType.TEMPLATE;
  87. data: Frame;
  88. };
  89. type EntryCsp = {
  90. type: EntryType.CSP;
  91. data: Record<string, any>;
  92. };
  93. type EntryGeneric = {
  94. type: EntryType.EXPECTCT | EntryType.EXPECTSTAPLE | EntryType.HPKP;
  95. data: Record<string, any>;
  96. };
  97. export type Entry =
  98. | EntryDebugMeta
  99. | EntryBreadcrumbs
  100. | EntryThreads
  101. | EntryException
  102. | EntryStacktrace
  103. | EntrySpans
  104. | EntryMessage
  105. | EntryRequest
  106. | EntryTemplate
  107. | EntryCsp
  108. | EntryGeneric;
  109. // Contexts
  110. type RuntimeContext = {
  111. type: 'runtime';
  112. version: number;
  113. build?: string;
  114. name?: string;
  115. };
  116. type DeviceContext = {
  117. arch: string;
  118. family: string;
  119. model: string;
  120. type: string;
  121. };
  122. type OSContext = {
  123. kernel_version: string;
  124. version: string;
  125. type: string;
  126. build: string;
  127. name: string;
  128. };
  129. type EventContexts = {
  130. runtime?: RuntimeContext;
  131. trace?: TraceContextType;
  132. device?: DeviceContext;
  133. os?: OSContext;
  134. client_os?: OSContext;
  135. };
  136. export type Measurement = {value: number};
  137. export type EventTag = {key: string; value: string};
  138. export type EventUser = {
  139. username?: string;
  140. name?: string;
  141. ip_address?: string;
  142. email?: string;
  143. id?: string;
  144. };
  145. type EventBase = {
  146. id: string;
  147. eventID: string;
  148. title: string;
  149. culprit: string;
  150. dateCreated: string;
  151. dist: string | null;
  152. metadata: EventMetadata;
  153. contexts: EventContexts;
  154. user: EventUser;
  155. message: string;
  156. entries: Entry[];
  157. errors: any[];
  158. previousEventID?: string;
  159. nextEventID?: string;
  160. projectSlug: string;
  161. projectID: string;
  162. tags: EventTag[];
  163. size: number;
  164. location: string;
  165. oldestEventID: string | null;
  166. latestEventID: string | null;
  167. groupingConfig: {
  168. id: string;
  169. enhancements: string;
  170. };
  171. crashFile: EventAttachment | null;
  172. groupID?: string;
  173. context?: Record<string, any>;
  174. device?: Record<string, any>;
  175. packages?: Record<string, string>;
  176. platform?: PlatformType;
  177. dateReceived?: string;
  178. endTimestamp?: number;
  179. userReport?: any;
  180. sdk?: {
  181. name: string;
  182. version: string;
  183. };
  184. sdkUpdates?: Array<SDKUpdatesSuggestion>;
  185. measurements?: Record<string, Measurement>;
  186. release?: Release;
  187. };
  188. export type EventTransaction = Omit<EventBase, 'entries' | 'type'> & {
  189. entries: (EntrySpans | EntryRequest)[];
  190. startTimestamp: number;
  191. endTimestamp: number;
  192. type: 'transaction';
  193. title?: string;
  194. contexts?: {
  195. trace?: TraceContextType;
  196. };
  197. };
  198. export type EventError = Omit<EventBase, 'entries' | 'type'> & {
  199. entries: (EntryException | EntryStacktrace | EntryRequest)[];
  200. type: 'error';
  201. };
  202. // This type is incomplete
  203. export type Event = EventError | EventTransaction | ({type: string} & EventBase);