sentry-javascript: Sentry when running over capacitor as hybrid app stackrace is not having any information

Package + Version

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

Version:

"raven-js": "3.27.0",

Description

Code to install

Raven
                    .config(dsnToUse, {
                        release: "WSVue-" + AppConst.application.version + "-" + AppConst.application.bundleVersion,
                        environment: bootstrapAppService.getEnvironment(),
                        ignoreErrors: content.ignoreErrorsList,
                        tags: {appversion: appInfo.applicationVersion},
                        dataCallback: function (data) {
                            // do something to data
                            data.extra.localStorageData = getLocalStorageData();
                            return data;
                        }
                    })
                    .addPlugin(RavenVue, Vue)
                    .install();

With website environment it is working awesome. But I have same codebase as hybrid app using Capacitor.

Capacitor: https://capacitor.ionicframework.com/

Error infor logged is not having ang stack information.

Error data logged looks like this

{
  "project": "181355",
  "logger": "javascript",
  "platform": "javascript",
  "request": {
    "headers": {
      "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16B91"
    },
    "url": "capacitor://localhost#/app/developer"
  },
  "exception": {
    "values": [
      {
        "type": "Error",
        "value": "Forcing error fooboo tester",
        "stacktrace": {
          "frames": [
            {
              "filename": "[native code]",
              "lineno": null,
              "colno": null,
              "function": "Promise",
              "in_app": true
            },
            {
              "filename": "[native code]",
              "lineno": null,
              "colno": null,
              "function": "initializePromise",
              "in_app": true
            },
            {
              "filename": "[native code]",
              "lineno": null,
              "colno": null,
              "function": "Promise",
              "in_app": true
            },
            {
              "filename": "[native code]",
              "lineno": null,
              "colno": null,
              "function": "initializePromise",
              "in_app": true
            },
            {
              "filename": "[native code]",
              "lineno": null,
              "colno": null,
              "function": "forceError",
              "in_app": true
            }
          ]
        }
      }
    ],
    "mechanism": {
      "type": "generic",
      "handled": true
    }
  },
  "transaction": "[native code]",
  "trimHeadFrames": 0,
  "extra": {
    "message": "Forcing error fooboo tester",
    "code": "Forcing error fooboo tester.",
    "emailTried": "Forcing error fooboo. tester",
    "name": "Forcing error fooboo tester.",
    "session:duration": 66618
  },
  "tags": {
    "appversion": "4.4.6"
  },
  "breadcrumbs": {
    "values": [
      {
        "timestamp": 1549015935.474,
        "message": "Input: enableInputBlurring",
        "level": "debug",
        "category": "console"
      },
      {
        "timestamp": 1549015935.474,
        "message": "Input: enableScrollPadding",
        "level": "debug",
        "category": "console"
      },
      {
        "timestamp": 1549015935.481,
        "type": "http",
        "category": "xhr",
        "data": {
          "method": "GET",
          "url": "static/json/airports.json",
          "status_code": 200
        }
      },
      {
        "timestamp": 1549015935.745,
        "type": "http",
        "category": "xhr",
        "data": {
          "method": "GET",
          "url": "static/json/wx.json",
          "status_code": 200
        }
      },
      {
        "timestamp": 1549015935.759,
        "message": "checkUserAuthenticated",
        "level": "log",
        "category": "console"
      },
      {
        "timestamp": 1549015935.783,
        "message": "checkUserAuthenticated:Refreshing session",
        "level": "log",
        "category": "console"
      },
      {
        "timestamp": 1549015937.922,
        "type": "http",
        "category": "fetch",
        "data": {
          "method": "POST",
          "url": "https://cognito-idp.us-east-1.amazonaws.com/",
          "status_code": 200
        }
      },
      {
        "timestamp": 1549015938.318,
        "type": "http",
        "category": "fetch",
        "data": {
          "method": "POST",
          "url": "https://cognito-idp.us-east-1.amazonaws.com/",
          "status_code": 200
        }
      },
      {
        "timestamp": 1549015939.911,
        "type": "http",
        "category": "xhr",
        "data": {
          "method": "POST",
          "url": "https://cognito-identity.us-east-1.amazonaws.com/",
          "status_code": 200
        }
      }
    ]
  },
  "user": {
    "email": "********@gmail.com"
  },
  "environment": "DEV:CORDOVA:TFXC",
  "release": "WSVue-4.4.6-0.19.02.01.04.07",
  "event_id": "f137e408f8114bdcbc013be0b04f1f6a"
}

Stack information looks like this on sentry screenshot 2019-02-01 at 6 01 19 pm

Same error logged on website looks very nice

52032491-2975c300-2547-11e9-8800-2e0b23bc69f6

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@seanwu1105 nothing from me. I have this running in production now and haven’t seen any problems.

@albertinad I didn’t hear anything back from @kamilogorek so I’ll just create the PR and refer to this issue. If it doesn’t get picked up we can create a new issue I suppose.

@kamilogorek would you like me to create a new issue as suggested to @toddtarsi, or just submit a PR referring to this one?

As pointed out in @silviogutierrez’s comment above (https://github.com/getsentry/sentry-javascript/issues/1863#issuecomment-563364652) this is an issue particular to sentry-javascript’s tweaked version of tracekit, and can easily be fixed in this project (https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/tracekit.ts#L49).

Problem: Capacitor apps don’t send mappable stacktraces in iOS because the gecko regex doesn’t allow for their capacitor:// url scheme. Solution: Add the capacitor url scheme to the gecko regex.

I’m about to fork the project and make the change for my own use, if you’d like me to submit a pull request let me know!

@kamilogorek : I’ll try to put one together, but I actually found the issue. It’s quite simple, and exactly where you guessed it to be:

Right here: https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/tracekit.ts

The gecko and chrome variables both come back empty for the regex test on capacitor’s frames. That is, when running on iOS, capacitor’s frames have capacitor://localhost/foo/bar and on Android http://localhost. So Tracekit drops all frames in iOS except the ones with [native code] ones that match the regex. I would imagine it works fine on Android.

Simple running this (atrocious) sed command to change the gecko variable fixes the issue:

sed -i "s/moz-extension/moz-extension|capacitor/" node_modules/@sentry/browser/esm/tracekit.js

Should I open a PR against Tracekit to add the capacitor protocol? If you notice, the chrome regex is a little more flexible and already seems to have [-a-z] as part of the regex for any number of protocols. Should we try that in gecko too?