Giter Site home page Giter Site logo

Comments (12)

mattrobenolt avatar mattrobenolt commented on April 28, 2024

I'll take a look at this today.

from sentry-javascript.

mattrobenolt avatar mattrobenolt commented on April 28, 2024

@jmagnusson I just tested this and all appears well. Are you using the latest version of raven? And if so, what browser?

from sentry-javascript.

jacobsvante avatar jacobsvante commented on April 28, 2024

Hopefully it's on my end. I have Raven 1.0.5 and testing has been done on OS X with Chrome. I just tested it in the latest versions of Firefox and Safari, but it seems that sentry doesn't actually record the event for those two browsers, even though the GET request is sent just fine with a 200 response code. The Chrome request is handled by sentry, but without the tags sent along as previously mentioned.

Other info:
Sentry 5.4.1
* is used in CORS-setting in Sentry

This is what the Raven-related code looks like:

require(['startup'], function() {
    require([
        'cs!app/state',
        'app/config',
        'raven'
    ], function(
        appstate,
        appConf,
        Raven
    ) {
    var host = window.location.host,
        ravenOpts = {tags: {host: host}};

        // Initialize the error handler
        Raven.config(appConf.sentryDSN).install();

        try {
            appstate();
        }
        catch (exc) {
            // TODO: Why doesn't tags appear in Sentry?
            // TODO #2: Maybe alert user that an error has occurred
            Raven.captureException(exc, ravenOpts);
            throw exc;
        }
    });
});

from sentry-javascript.

jacobsvante avatar jacobsvante commented on April 28, 2024

I've also tried the latest master (5f92fc02f6) combined with the TraceKit version this repo links to (2964a1e at the time of writing). No success.

I should also add that captureMessage works fine in all three browsers. captureException only works in Chrome as I previously mentioned.

from sentry-javascript.

jacobsvante avatar jacobsvante commented on April 28, 2024

Removing install() from the code above so that window.onerror handler isn't added didn't make a difference either.

Passing my ravenOpts directly to Raven.config didn't send along tags either (not even for captureMessage).

from sentry-javascript.

mattrobenolt avatar mattrobenolt commented on April 28, 2024

Are you trying to run from git directly, by any chance? Just including the src/raven.js is probably not the best idea.

Either way, could you intercept the makeRequest() function and see the data that's being sent?

from sentry-javascript.

jacobsvante avatar jacobsvante commented on April 28, 2024

I first tried the tagged 1.0.5 version found here, then also tried the src/raven.js and vendor/TraceKit/tracekit.js using the require.js shim config like this:

requirejs.config({
    paths: {
        jquery: 'ext/jquery',
        tracekit: 'ext/tracekit', // Error reporting
        raven: 'ext/raven', // Error reporting
    },
    shim: {
        jquery: {exports: 'jQuery'},
        tracekit: {exports: 'TraceKit', deps: ['jquery']},
        raven: {exports: 'Raven', deps: ['tracekit']},
    }
})

Both "flavors" had the same problems which I mentioned previously.

Here's the data being sent with makeRequest:

URL (same for all tested browsers):
http://our.sentry.dev/api/5/store/?sentry_version=2.0&sentry_client=raven-js/1.0.5&sentry_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&sentry_data=<json>

Gist with sentry_data for the different browsers can be found here

Our main.js where raven-js handler is added:

require(['startup'], function() {
    require([
        'cs!our/app/state',
        'our/app/config',
        'raven',
        'underscore.string'
    ], function(
        appstate,
        appConf,
        Raven,
        _s
    ) {
        var host = window.location.host,
            ravenOpts = {tags: {host: host}};

        // Initialize the error handler
        // Raven.install adds a global error handler to window.onerror
        Raven.config(appConf.sentryDSN, ravenOpts).install();

        throw Error('Testing captureException with raven-js');
        appstate();
    });
});

from sentry-javascript.

mattrobenolt avatar mattrobenolt commented on April 28, 2024

First of all, thanks a ton for the information! :)

Now, just to clarify, you've posted two different ways of tacking on the extra data. First, you showed it being added directly to captureException(), then second, you showed it added to the config() call. I'm guessing that they're both working incorrectly?

from sentry-javascript.

jacobsvante avatar jacobsvante commented on April 28, 2024

And thanks for making this awesome script! :-)

Actually I noticed that the catch-statement was never reached. It seems that the global window.onerror handler added by Raven.install re-raised the exception and script execution stopped after that. Maybe I could create a simple test so that it can be replicated.

from sentry-javascript.

mattrobenolt avatar mattrobenolt commented on April 28, 2024

Well, technically, an error that is cause, is supposed to be reraised. That is by design. Raven's job isn't supposed to intercept all of your errors and make them go away. Raven is just a middleware, if you will, that logs it. Typically, on an uncaught exception, you want the error to bubble up to the user and break because unexpected things can happen if your code keeps executing. So as a developer, it's your job to still catch your own errors and handle things appropriately.

from sentry-javascript.

sinyagin avatar sinyagin commented on April 28, 2024

Hello
I use 1.0.8.
Could you help me how can I send tags with function ?
function traceKitWindowOnError(message, url, lineNo)

var options = {
logger: 'my-logger',
tags: {
bank_id: "999999"}};
Raven.config(sentryUrl, options).install();
It doesn't send tags

from sentry-javascript.

mattrobenolt avatar mattrobenolt commented on April 28, 2024

This should all be working just fine. Open a new ticket if it's broken in 1.1.

from sentry-javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.