Sentry-javascript: IE11 Syntax error "Sentry.configureScope((scope) => {"

Created on 3 Dec 2018  路  4Comments  路  Source: getsentry/sentry-javascript

Package + Version

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

Version:

4.4.1

Description

We are getting javascript errors on IE11 Windows 10 when trying to add context like this:

<script>
        Sentry.configureScope((scope) => {
            scope.setUser({ "email": "[email protected]" });
        });
</script>

Here is a simply test showing the error:

http://jsfiddle.net/mrcarl79/4faprkhw/2/embedded/result/

The full code for this simple test is as follows, have I set this up correctly? It seems to work fine on other browsers.

<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="https://browser.sentry-cdn.com/4.4.1/bundle.min.js" crossorigin="anonymous"></script>
    <script type="text/javascript">
        Sentry.init({
            dsn: 'https://[email protected]/1336341'
        });
    </script>
</head>
<body>
    <script>
        Sentry.configureScope((scope) => {
            scope.setUser({ "email": "[email protected]" });
        });
    </script>
</body>
</html>

All 4 comments

Don't use arrow functions if you want to support IE11, simple as that.
You can use TS or babel to transpile your code.

Hi Simon, Something I'm not familiar with but may give me enough to go on to fix this in our use case. I would like to point out for Sentry that this code is straight from the documentation here https://docs.sentry.io/enriching-error-data/context/?platform=browser so they are supplying examples that doesn't work in the latest version of IE so maybe some comments or changes are needed there if this is the issue. Thanks for the help :)

Great looks like it is working so will comment and close. The change from the documented code for anyone interested in having it work in IE and not familiar with this arrow function issue as I was is as follows:

    <script>
        Sentry.configureScope(function (scope) {
            scope.setUser({ "email": "[email protected]" });
        });
    </script>

@mrcarl79 I think the intent of the sentry team is to show you modern best practises and not necessarily provide super backwards compatible code, as a web developer you should know what browsers you want to support and what features you can use in the process, this really isn't a documentation issue.

Was this page helpful?
0 / 5 - 0 ratings