system.tsx 4.9 KB

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