system.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. import type {FocusTrap} from 'focus-trap';
  2. import type exportGlobals from 'sentry/bootstrap/exportGlobals';
  3. import {Theme} from 'sentry/utils/theme';
  4. import type {User} from './user';
  5. export enum SentryInitRenderReactComponent {
  6. INDICATORS = 'Indicators',
  7. SETUP_WIZARD = 'SetupWizard',
  8. SYSTEM_ALERTS = 'SystemAlerts',
  9. U2F_SIGN = 'U2fSign',
  10. SU_ACCESS_FORM = 'SuperuserAccessForm',
  11. }
  12. export type OnSentryInitConfiguration =
  13. | {
  14. element: string;
  15. input: string;
  16. name: 'passwordStrength';
  17. }
  18. | {
  19. component: SentryInitRenderReactComponent;
  20. container: string;
  21. name: 'renderReact';
  22. props?: Record<string, any>;
  23. }
  24. | {
  25. name: 'onReady';
  26. onReady: (globals: typeof exportGlobals) => void;
  27. };
  28. declare global {
  29. interface Window {
  30. /**
  31. * Primary entrypoint for rendering the sentry app. This is typically
  32. * called in the django templates, or in the case of the EXPERIMENTAL_SPA,
  33. * after config hydration.
  34. */
  35. SentryRenderApp: () => void;
  36. /**
  37. * Used to close tooltips for testing purposes.
  38. */
  39. __closeAllTooltips: () => void;
  40. /**
  41. * The config object provided by the backend.
  42. */
  43. __initialData: Config;
  44. /**
  45. * This allows our server-rendered templates to push configuration that should be
  46. * run after we render our main application.
  47. *
  48. * An example of this is dynamically importing the `passwordStrength` module only
  49. * on the organization login page.
  50. */
  51. __onSentryInit:
  52. | OnSentryInitConfiguration[]
  53. | {
  54. push: (config: OnSentryInitConfiguration) => void;
  55. };
  56. /**
  57. * Used to open tooltips for testing purposes.
  58. */
  59. __openAllTooltips: () => void;
  60. /**
  61. * Pipeline
  62. */
  63. __pipelineInitialData: PipelineInitialData;
  64. /**
  65. * Assets public location
  66. */
  67. __sentryGlobalStaticPrefix: string;
  68. /**
  69. * This is used for testing purposes as an interem while we translate tests
  70. * to React Testing Library.
  71. *
  72. * See the useLegacyStore hook for more unformation about this.
  73. */
  74. _legacyStoreHookUpdate: (update: () => void) => void;
  75. // typing currently used for demo add on
  76. // TODO: improve typing
  77. SentryApp?: {
  78. ConfigStore: any;
  79. HookStore: any;
  80. Modal: any;
  81. getModalPortal: () => HTMLElement;
  82. modalFocusTrap?: {
  83. current?: FocusTrap;
  84. };
  85. };
  86. /**
  87. * Sentrys version string
  88. */
  89. __SENTRY__VERSION?: string;
  90. /**
  91. * Set to true if adblock could be installed.
  92. * See sentry/js/ads.js for how this global is disabled.
  93. */
  94. adblockSuspected?: boolean;
  95. /**
  96. * The CSRF cookie ised on the backend
  97. */
  98. csrfCookieName?: string;
  99. sentryEmbedCallback?: ((embed: any) => void) | null;
  100. }
  101. }
  102. export interface Config {
  103. apmSampling: number;
  104. csrfCookieName: string;
  105. demoMode: boolean;
  106. disableU2FForSUForm: boolean;
  107. distPrefix: string;
  108. dsn: string;
  109. enableAnalytics: boolean;
  110. features: Set<string>;
  111. gravatarBaseUrl: string;
  112. invitesEnabled: boolean;
  113. isAuthenticated: boolean;
  114. // Maintain isOnPremise key for backcompat (plugins?).
  115. isOnPremise: boolean;
  116. isSelfHosted: boolean;
  117. languageCode: string;
  118. lastOrganization: string | null;
  119. links: {
  120. organizationUrl: string | undefined;
  121. regionUrl: string | undefined;
  122. sentryUrl: string;
  123. };
  124. /**
  125. * This comes from django (django.contrib.messages)
  126. */
  127. messages: {level: keyof Theme['alert']; message: string}[];
  128. needsUpgrade: boolean;
  129. privacyUrl: string | null;
  130. sentryConfig: {
  131. dsn: string;
  132. release: string;
  133. whitelistUrls: string[];
  134. };
  135. singleOrganization: boolean;
  136. supportEmail: string;
  137. termsUrl: string | null;
  138. theme: 'light' | 'dark';
  139. urlPrefix: string;
  140. user: User;
  141. userIdentity: {
  142. email: string;
  143. id: string;
  144. ip_address: string;
  145. isStaff: boolean;
  146. };
  147. validateSUForm: boolean;
  148. version: {
  149. build: string;
  150. current: string;
  151. latest: string;
  152. upgradeAvailable: boolean;
  153. };
  154. statuspage?: {
  155. api_host: string;
  156. id: string;
  157. };
  158. }
  159. export type PipelineInitialData = {
  160. name: string;
  161. props: Record<string, any>;
  162. };
  163. export type Broadcast = {
  164. cta: string;
  165. dateCreated: string;
  166. dateExpires: string;
  167. hasSeen: boolean;
  168. id: string;
  169. isActive: boolean;
  170. link: string;
  171. message: string;
  172. title: string;
  173. };
  174. export type SentryServiceIncident = {
  175. affectedComponents: Array<{
  176. name: string;
  177. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  178. updatedAt: string;
  179. }>;
  180. createdAt: string;
  181. id: string;
  182. name: string;
  183. status: string;
  184. updates: Array<{
  185. body: string;
  186. status: string;
  187. updatedAt: string;
  188. }>;
  189. url: string;
  190. };
  191. export type SentryServiceStatus = {
  192. incidents: SentryServiceIncident[];
  193. indicator: 'major' | 'minor' | 'none';
  194. url: string;
  195. };
  196. export type PromptActivity = {
  197. dismissedTime?: number;
  198. snoozedTime?: number;
  199. };