Skip to content

react: Sentry.ErrorBoundary showDialog doesn't infer user #3257

@zanona

Description

@zanona

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

"@sentry/react": "^6.1.0"

Description

https://codesandbox.io/s/sentry-show-dialog-user-d1lgw?file=/src/index.js

Whenever using the property showDialog on <Sentry.ErrorBoundary>, even though the user has been set previously, the dialog won't infer those settings and autofill the name and email fields on the widget form.

import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom";
import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: process.env.SENTRY_DSN //ADD YOURS
});

function App() {
  const [foo, setFoo] = useState("ahoy");
  useEffect(() => {
    Sentry.setUser({ email: "[email protected]", name: "Foobar" });
  }, []);

  return (
    <Sentry.ErrorBoundary showDialog fallback={<h1>Error</h1>}>
      <h1>Hello {foo}</h1>
      <button onClick={() => setFoo({ foo: true })}>Break the world</button>
    </Sentry.ErrorBoundary>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions