sentryReplayInit.tsx 797 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {useEffect} from 'react';
  2. import {Organization} from 'sentry/types';
  3. async function initSentryReplays() {
  4. const {SentryReplay} = await import('@sentry/replay');
  5. const replays = new SentryReplay({
  6. stickySession: true,
  7. });
  8. replays.setup();
  9. }
  10. /**
  11. * Load the Sentry Replay integration based on the feature flag.
  12. *
  13. * Can't use `useOrganization` because it throws on
  14. * `/settings/account/api/auth-token/` because organization is not *immediately*
  15. * set in context
  16. */
  17. export function SentryReplayInit({organization}: {organization: Organization | null}) {
  18. useEffect(() => {
  19. if (!organization) {
  20. return;
  21. }
  22. if (!organization.features.includes('session-replay-sdk')) {
  23. return;
  24. }
  25. initSentryReplays();
  26. }, [organization]);
  27. return null;
  28. }