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

Fix Vue 3 loop #1145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions examples/vuejs3/src/rollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ const rollbar = new Rollbar(config);
export default {
install(app) {
app.config.errorHandler = (error, vm, info) => {
rollbar.error(error, { vueComponent: vm, info });
if (app.config.devtools) {
console.error(error);
}
};

// In case the error is from the router or am helper
// calling vm could generate a loop and freeze the browser
// rollbar.error(error, { vueComponent: vm, info });

rollbar.error(error, { info });

if (app.config.devtools) console.error(error);
}


app.config.warningHandler = (error, vm, info) => {
rollbar.warning(error, { info });
Comment on lines +11 to +22

Choose a reason for hiding this comment

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

I think a more appropriate example is to grab the most relevant and common data off the component, with coalesced fallbacks to empty data.

I also think it's best to stick with the existing format of multiline conditionals. It's a style choice, but the more common one, and since that's how the example was previously styled, I think we should stick to it for consistency across the docs

Suggested change
// In case the error is from the router or am helper
// calling vm could generate a loop and freeze the browser
// rollbar.error(error, { vueComponent: vm, info });
rollbar.error(error, { info });
if (app.config.devtools) console.error(error);
}
app.config.warningHandler = (error, vm, info) => {
rollbar.warning(error, { info });
// In case the error is from the router or a helper
// calling vm could generate a loop and freeze the browser
// Instead, we pick the relevant data off the vm instance
const vueComponent = {
name: vm.$options?.name ?? 'AnonymousComponent',
props: vm.$props ?? {},
data: vm.$data ?? {},
attributes: vm.$attributes ?? {},
route: vm.$route ?? {},
};
rollbar.error(error, { vueComponent, info });
if (app.config.devtools) {
console.error(error);
}
app.config.warningHandler = (error, vm, info) => {
rollbar.warning(error, { vueComponent, info });


if (app.config.devtools) console.log('just a warning, but!,error)

Choose a reason for hiding this comment

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

For consistency across the docs, I suggest we keep this to multiline format

Suggested change
if (app.config.devtools) console.log('just a warning, but!,error)
if (app.config.devtools) {
console.log('just a warning, but!, error)
}

}

app.provide('rollbar', rollbar);
},
};