Skip to content

Session Replay for Remix SDK not populating anything #9078

Closed
@sergical

Description

@sergical

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/remix

SDK Version

7.64

Framework Version

18.2

Link to Sentry event

No response

SDK Setup

import { useLocation, useMatches } from '@remix-run/react';
import { useEffect } from 'react';

import configuration from '~/configuration';
import { ENVIRONMENT, isBrowser } from '~/modules/utils';
import getLogger from './logger';

let initialized = false;

/**
 * @description Loads and initializes Sentry for tracking runtime errors
 */
async function initializeBrowserSentry() {
  const dsn = configuration.sentry.dsn;
  const Sentry = await import('@sentry/remix');

  if (!isBrowser || initialized) {
    return;
  }

  if (!dsn) {
    warnSentryNotConfigured();
  }

  Sentry.init({
    dsn,
    integrations: [
      new Sentry.BrowserTracing({
        routingInstrumentation: Sentry.remixRouterInstrumentation(
          useEffect,
          useLocation,
          useMatches,
        ),
      }),
      // Replay is only available in the client
      new Sentry.Replay(),
    ],
    tracesSampleRate: 1.0,
    // Capture Replay for 10% of all sessions,
    // plus for 100% of sessions with an error
    replaysSessionSampleRate: 0.1,
    replaysOnErrorSampleRate: 1.0,
    environment: ENVIRONMENT,
    tracePropagationTargets: ['localhost', /^https:\/\/seapeopleapp\.com\/api/],
    beforeSend: (event, hint) => {
      if (ENVIRONMENT === 'development') {
        getLogger().error(
          'Sentry exception',
          hint.originalException || hint.syntheticException,
          event.level,
        );
        return null;
      }
      return event;
    },
  });

  initialized = true;
}

function warnSentryNotConfigured() {
  console.warn(
    `Sentry DSN was not provided. Please add a SENTRY_DSN environment variable to enable error tracking.`,
  );
}

export default initializeBrowserSentry;

Steps to Reproduce

import { useEffect } from 'react';
import initializeBrowserSentry from '~/modules/utils/initialize-browser-sentry';

/**
 * @description Hook to initialize Sentry when a component mounts. This
 * needs to be used in the root component you want to track errors for. Due
 * to its large size, we recommend you can add it to {@link RouteShell} (as is
 * by default) so it will only get loaded for the application pages
 */
function useSentry() {
  useEffect(() => {
    void initializeBrowserSentry();
  }, []);
}

export default useSentry;
import useSentry from '~/modules/hooks/useSentry';

const SentryBrowserWrapper: React.FCC = ({ children }) => {
  useSentry();

  return <>{children}</>;
};

export default SentryBrowserWrapper;

Expected Result

Session replay showing up when an error is hit

Actual Result

Session replay page is in an empty state

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: remixIssues related to the Sentry Remix SDKPackage: replayIssues related to the Sentry Replay SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions