Skip to content

Vue integration does not work when using Sentry Client directly #3381

@eslawski

Description

@eslawski

Package + Version

  • @sentry/browser
  • @sentry/integrations

Version:

@sentry/browser: 6.2.5
@sentry/integrations: 6.2.5

Description

We are using the Sentry BrowserClient as follows:

import Vue from "vue";
import * as Sentry from "@sentry/browser";
import { Vue as VueIntegration } from "@sentry/integrations";

const sentryClient = new Sentry.BrowserClient({
    dsn: "blah",
    integrations: [
        ...Sentry.defaultIntegrations,
        new VueIntegration({
            Vue,
            attachProps: true,
            logErrors: true
        })
    ],
});
const sentryHub = new Sentry.Hub(sentryClient);

// For non-Vue errors we can capture manually by doing this
this.sentryHub.run((sentryHub) => sentryHub.captureException(error))

// However we don't get the automatic error handling/reporting VueIntegration should be providing

We understand that the VueIntegration is designed to hook into the Vue.config.errorHandler and automatically report errors out as they arise. We did some debugging, and can confirm that the errorHandler is properly attaching itself.

However when an error is handled by this function, it never actually gets sent out to the Sentry. The root cause appears to be an issue with the getCurrentHub() not containing the Vue integration (this check fails).

Using BrowserClient directly like this (as opposed to Sentry.init) is important to our microfrontend architecture where teams own smaller parts of a single page (sometimes even using different technologies: Vue, React, etc.). Having a way to report out errors to different dsns is a requirement for us. And we would love to be able to use the Vue Integration (and other technologies) too!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions