Sentry-javascript: Raven.showReportDialog not working with Cordova project

Created on 24 Oct 2016  Â·  14Comments  Â·  Source: getsentry/sentry-javascript

The Raven.showReportDialog does work with Cordova iOS / Android platforms, I got the the 403 Forbidden error when trying to run the following in Safari console

Raven.captureMessage('hello')
Raven.showReportDialog();

[Error] Failed to load resource: the server responded with a status of 403 (FORBIDDEN) (error-page, line 0)  https://sentry.*.*/api/embed/error-page/?eventId=d7fc7cb94a9441ca977960d6f75ddb0a&dsn=*

The above snippets work fine in Cordova Browser platform.

I'd suspect that it has something to do with the fact the both iOS / Android platforms running the index.html in file:// protocol instead of http:// protocol Browser

All 14 comments

@kenvunz – thanks for the heads up. I'll see how this works using file:// from my desktop web browser.

Hey!

Did you get something new @benvinegar ?

I can confirm this is happening in an electron project as well

Raven.captureException("Sentry Feedback Error")
Raven.showReportDialog()

In console

Failed to load resource: the server responded with a status of 403 (FORBIDDEN)

Ditto. It would be great to have this working in Electron and Cordova, the two main platforms we're targeting...

I have tried the same thing with ionic (cordova) it works from browser, does not work when run on android / ios

Have just stumbled across this whilst using Electron, here is the solution that I am using:

const {app, BrowserWindow, session} = require('electron')

function setup () {
  session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
    details.requestHeaders['Origin'] = 'www.example.com'; //Set the Origin to whatever you want.
    callback({ cancel: false, requestHeaders: details.requestHeaders });
  });
}

app.on('ready', setup);

N.B. This will add an Origin header to all requests in Electron.

Any news on a way to fix this for Cordova? 😃

@leroydev have you seen this thread? https://github.com/getsentry/raven-js/issues/949#issuecomment-309964423

@kamilogorek That involves deploying the secret key to all end devices, which doesn't seem like the cleanest fix..

I haven't dig into the issue yet, just found a similar one. Will do that soon.

Since there's no origin checking on mobile devices for Cordova apps, there's very little difference between using a "secret" key or using a public key. These keys permit write-only access of event data; they do not confer any other API access.

@leroydev does this resolve your issue?

We have a new Cordova SDK https://github.com/getsentry/sentry-cordova
Documentation: https://docs.sentry.io/clients/cordova/

Feedback is highly appreciated, closing this.

@HazAT I might be overlooking something, but it seems like the Sentry Cordova client library hasn't got support for showReportDialog yet (which would make this issue still relevant).

Was this page helpful?
0 / 5 - 0 ratings