Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vue): export vueInit func #5757

Closed

Conversation

Rockergmail
Copy link
Contributor

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

support export vueInit

@Rockergmail
Copy link
Contributor Author

Rockergmail commented Sep 16, 2022

As to why we need export vueInit.
We tried serveral hacks to use Sentry in micro frontend app (using qiankun.js). See the thread here.
The working way is using Sentry in main app, and using custom transport. With the filename of stacks, we know which subapp causing the error, and then mapping the subapp dsn to the newUrl. Finally we change the newUrl to the transport.
But this way we can not listen errors of vue's components unless we add the custom errorHandler in Vue option. That's what vueInit has done.
So we need export vueInit

@AbhiPrasad AbhiPrasad changed the title feat: support export vueInit feat(vue): export vueInit func Sep 16, 2022
@AbhiPrasad
Copy link
Member

I think this is a very reasonable request! Could you also update the docs to add this info? https://docs.sentry.io/platforms/javascript/guides/vue/

@Rockergmail
Copy link
Contributor Author

I can't found the repo of docs for @sentry/vue. So I just write here. @AbhiPrasad

Vue 2/3 - Multiple Apps Initial Indepentently

import { createApp } from "vue3";
import Vue from "vue2";
import * as Sentry from "@sentry/vue";

const appOne = createApp({
  // ...
});
Sentry.init({
  app: appOne
});

// Vue2 initialization before loaded asynchronously as a subapp
setTimout(() => {
    const appTwo = new Vue({
        // ...
    })
    Sentry.vueInit(Vue)
}, 0)
// Vue3 initialization before loaded asynchronously as a subapp
setTimout(() => {
    const appThree = createApp({
    // ...
    });
    Sentry.vueInit(appThree)
}, 1000)

@AbhiPrasad AbhiPrasad added the Package: vue Issues related to the Sentry Vue SDK label Sep 19, 2022
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked about this as a team and decided we aren't going to proceed with this change, since you can just call attachErrorHandler and createTracingMixins by yourself if you need it, vueInit is just sugar over those functions.

We want to control the public API exposed to users - because it helps make future changes much easier (less breaking changes needed).

Thank you for opening a PR! Hopefully you can just vendor what you need here.

@AbhiPrasad AbhiPrasad closed this Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: vue Issues related to the Sentry Vue SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants