sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

User feedback form not working, calling "sentry:9000"

Open jvanmaaren opened this issue 7 years ago • 4 comments

Hi everyone,

We want to integrate Sentry in JS (React), with user feedback, and I’ve followed the steps from the docs: https://docs.sentry.io/enriching-error-data/user-feedback/?platform=browser

I’m forcing an error with throw new Error(‘test’) and Sentry works like a charm! The error shows up in the dashboard, so far so good.

However… The user feedback form does pop up, but when I submit the form, I get an error in my console "net::ERR_NAME_NOT_RESOLVED"

This path is called: http://sentry:9000/api/embed/error-page/?dsn=https://[email protected]&eventId=idhere

The UI then shows: “An unknown error occurred while submitting your report. Please try again.”

Seems strange to me why it is calling this port, and not the DSN?

Any help would be greatly appreciated!

jvanmaaren avatar Aug 08 '19 10:08 jvanmaaren

Hey,

Here's how the URL is built: https://github.com/getsentry/sentry-javascript/blob/12847c6a88b243e29c9e3099e9d53348ef46c2e1/packages/core/src/api.ts#L70-L101

It looks like _getBaseUrl() is returning http://sentry:9000 for you.

Let's see how it's done:

  private _getBaseUrl(): string {
    const dsn = this._dsnObject;
    const protocol = dsn.protocol ? `${dsn.protocol}:` : '';
    const port = dsn.port ? `:${dsn.port}` : '';
    return `${protocol}//${dsn.host}${port}`;
  }

Protocol is fine, port is fine, but dsn.host is not correct (it returns just sentry for you), which should be impossible if you use string version of Dsn. (it can also accept dsn in form of object).

Can you paste your Sentry.init call here?

kamilogorek avatar Aug 09 '19 11:08 kamilogorek

Hey kamilogorek, our init call is copied from the doc (also, we're on @sentry/browser version 5.6.1):

const ourDSN = 'https://[email protected]/123';

Sentry.init({
    dsn: ourDSN,
    beforeSend(event, hint) {
      // Check if it is an exception, and if so, show the report dialog
      if (event.exception) {
        Sentry.showReportDialog({ eventId: event.event_id });
      }
      return event;
    }
  });

jvanmaaren avatar Aug 09 '19 14:08 jvanmaaren

const api = new API('https://[email protected]/123');
console.log(api.getReportDialogEndpoint({
  eventId: 'abc',
}));
//  https://sentry.oursite.nl/api/embed/error-page/?dsn=https://[email protected]/123&eventId=abc

That looks as it should.

I also tested it locally:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://browser.sentry-cdn.com/5.6.1/bundle.js" crossorigin="anonymous"></script>
    <script type="text/javascript">
      const ourDSN = 'https://[email protected]/123';

      Sentry.init({
        dsn: ourDSN,
        beforeSend(event, hint) {
          // Check if it is an exception, and if so, show the report dialog
          if (event.exception) {
            Sentry.showReportDialog({ eventId: event.event_id });
          }
          return event;
        }
      });

      throw new Error('whoops');
    </script>
  </head>
  <body></body>
</html>

And it performs a correct request.

image

Are you able to reproduce it locally somehow?

kamilogorek avatar Aug 09 '19 16:08 kamilogorek

@kamilogorek after much head-scratching we found that there was a mistake in our Sentry installation, nothing wrong with the sentry files

Thanks for the help anyway!

jvanmaaren avatar Aug 16 '19 13:08 jvanmaaren