event.tsx 4.7 KB

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