system.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. distPrefix: string;
  107. dsn: string;
  108. enableAnalytics: boolean;
  109. features: Set<string>;
  110. gravatarBaseUrl: string;
  111. invitesEnabled: boolean;
  112. isAuthenticated: boolean;
  113. // Maintain isOnPremise key for backcompat (plugins?).
  114. isOnPremise: boolean;
  115. isSelfHosted: boolean;
  116. languageCode: string;
  117. lastOrganization: string | null;
  118. /**
  119. * This comes from django (django.contrib.messages)
  120. */
  121. messages: {level: keyof Theme['alert']; message: string}[];
  122. needsUpgrade: boolean;
  123. organizationUrl: string | undefined;
  124. privacyUrl: string | null;
  125. sentryConfig: {
  126. dsn: string;
  127. release: string;
  128. whitelistUrls: string[];
  129. };
  130. sentryUrl: string;
  131. singleOrganization: boolean;
  132. supportEmail: string;
  133. termsUrl: string | null;
  134. theme: 'light' | 'dark';
  135. urlPrefix: string;
  136. user: User;
  137. userIdentity: {
  138. email: string;
  139. id: string;
  140. ip_address: string;
  141. isStaff: boolean;
  142. };
  143. validateSUForm: boolean;
  144. version: {
  145. build: string;
  146. current: string;
  147. latest: string;
  148. upgradeAvailable: boolean;
  149. };
  150. statuspage?: {
  151. api_host: string;
  152. id: string;
  153. };
  154. }
  155. export type PipelineInitialData = {
  156. name: string;
  157. props: Record<string, any>;
  158. };
  159. export type Broadcast = {
  160. cta: string;
  161. dateCreated: string;
  162. dateExpires: string;
  163. hasSeen: boolean;
  164. id: string;
  165. isActive: boolean;
  166. link: string;
  167. message: string;
  168. title: string;
  169. };
  170. export type SentryServiceIncident = {
  171. affectedComponents: Array<{
  172. name: string;
  173. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  174. updatedAt: string;
  175. }>;
  176. createdAt: string;
  177. id: string;
  178. name: string;
  179. status: string;
  180. updates: Array<{
  181. body: string;
  182. status: string;
  183. updatedAt: string;
  184. }>;
  185. url: string;
  186. };
  187. export type SentryServiceStatus = {
  188. incidents: SentryServiceIncident[];
  189. indicator: 'major' | 'minor' | 'none';
  190. url: string;
  191. };
  192. export type PromptActivity = {
  193. dismissedTime?: number;
  194. snoozedTime?: number;
  195. };