system.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import {Theme} from '@emotion/react';
  2. import type {FocusTrap} from 'focus-trap';
  3. import type exportGlobals from 'sentry/bootstrap/exportGlobals';
  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. // typing currently used for demo add on
  69. // TODO: improve typing
  70. SentryApp?: {
  71. ConfigStore: any;
  72. HookStore: any;
  73. Modal: any;
  74. getModalPortal: () => HTMLElement;
  75. modalFocusTrap?: {
  76. current?: FocusTrap;
  77. };
  78. };
  79. /**
  80. * Sentrys version string
  81. */
  82. __SENTRY__VERSION?: string;
  83. /**
  84. * Set to true if adblock could be installed.
  85. * See sentry/js/ads.js for how this global is disabled.
  86. */
  87. adblockSuspected?: boolean;
  88. /**
  89. * The CSRF cookie used on the backend
  90. */
  91. csrfCookieName?: string;
  92. sentryEmbedCallback?: ((embed: any) => void) | null;
  93. /**
  94. * The domain of which the superuser cookie is set onto.
  95. */
  96. superUserCookieDomain?: string;
  97. /**
  98. * The superuser cookie used on the backend
  99. */
  100. superUserCookieName?: string;
  101. }
  102. }
  103. interface CustomerDomain {
  104. organizationUrl: string | undefined;
  105. sentryUrl: string;
  106. subdomain: string;
  107. }
  108. export interface Config {
  109. apmSampling: number;
  110. csrfCookieName: string;
  111. customerDomain: CustomerDomain | null;
  112. demoMode: boolean;
  113. disableU2FForSUForm: boolean;
  114. distPrefix: string;
  115. dsn: string;
  116. enableAnalytics: boolean;
  117. features: Set<string>;
  118. gravatarBaseUrl: string;
  119. invitesEnabled: boolean;
  120. isAuthenticated: boolean;
  121. // Maintain isOnPremise key for backcompat (plugins?).
  122. isOnPremise: boolean;
  123. isSelfHosted: boolean;
  124. languageCode: string;
  125. lastOrganization: string | null;
  126. links: {
  127. organizationUrl: string | undefined;
  128. regionUrl: string | undefined;
  129. sentryUrl: string;
  130. };
  131. /**
  132. * This comes from django (django.contrib.messages)
  133. */
  134. messages: {level: keyof Theme['alert']; message: string}[];
  135. needsUpgrade: boolean;
  136. privacyUrl: string | null;
  137. sentryConfig: {
  138. dsn: string;
  139. release: string;
  140. whitelistUrls: string[];
  141. };
  142. singleOrganization: boolean;
  143. superUserCookieDomain: string | null;
  144. superUserCookieName: string;
  145. supportEmail: string;
  146. termsUrl: string | null;
  147. theme: 'light' | 'dark';
  148. urlPrefix: string;
  149. user: User;
  150. userIdentity: {
  151. email: string;
  152. id: string;
  153. ip_address: string;
  154. isStaff: boolean;
  155. };
  156. validateSUForm: boolean;
  157. version: {
  158. build: string;
  159. current: string;
  160. latest: string;
  161. upgradeAvailable: boolean;
  162. };
  163. statuspage?: {
  164. api_host: string;
  165. id: string;
  166. };
  167. }
  168. export type PipelineInitialData = {
  169. name: string;
  170. props: Record<string, any>;
  171. };
  172. export type Broadcast = {
  173. cta: string;
  174. dateCreated: string;
  175. dateExpires: string;
  176. hasSeen: boolean;
  177. id: string;
  178. isActive: boolean;
  179. link: string;
  180. message: string;
  181. title: string;
  182. };
  183. export type SentryServiceIncident = {
  184. affectedComponents: Array<{
  185. name: string;
  186. status: 'degraded_performance' | 'partial_outage' | 'major_outage' | 'operational';
  187. updatedAt: string;
  188. }>;
  189. createdAt: string;
  190. id: string;
  191. name: string;
  192. status: string;
  193. updates: Array<{
  194. body: string;
  195. status: string;
  196. updatedAt: string;
  197. }>;
  198. url: string;
  199. };
  200. export type SentryServiceStatus = {
  201. incidents: SentryServiceIncident[];
  202. indicator: 'major' | 'minor' | 'none';
  203. url: string;
  204. };
  205. export type PromptActivity = {
  206. dismissedTime?: number;
  207. snoozedTime?: number;
  208. };