javascriptreactjstypescriptsentry

Sentry Logger [warn]: Discarded session because of missing or non-string release


As per the Sentry setup guide for a React FE project

Sentry setup guide in React

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "SOME_SENTRY_DNS",
  // Setting this option to true will send default PII data to Sentry.
  // For example, automatic IP address collection on events
  sendDefaultPii: true
});

const container = document.getElementById(“app”);
const root = createRoot(container);
root.render(<App />);

I've adjusted that to

const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN;
const SENTRY_ENV = process.env.REACT_APP_SENTRY_ENVIRONMENT || "development";

Sentry.init({
  dsn: SENTRY_DSN,
  environment: SENTRY_ENV,
  sendDefaultPii: true,
  debug: true,
  autoSessionTracking: false,
  beforeSend(event) {
    console.log("Sentry about to send event:", event);
    return event;
  },
});

but still keep getting

Sentry Logger [warn]: Discarded session because of missing or non-string release

enter image description here


Solution

  • To fix it, I had to include a release, like so

    const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN;
    const SENTRY_ENV = process.env.REACT_APP_SENTRY_ENVIRONMENT || "development";
    const SENTRY_RELEASE = process.env.REACT_APP_RELEASE || "dev";
    
    Sentry.init({
      dsn: SENTRY_DSN,
      environment: SENTRY_ENV,
      release: SENTRY_RELEASE,
      sendDefaultPii: true,
      debug: true,
      autoSessionTracking: false,
      beforeSend(event) {
        console.log("Sentry about to send event:", event);
        return event;
      },
    });
    

    Now it works as expected

    Sentry FE errors