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): Cast name parameter to string #4483

Merged
merged 4 commits into from
Feb 2, 2022

Conversation

Bobakanoosh
Copy link
Contributor

@Bobakanoosh Bobakanoosh commented Feb 1, 2022

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).

Solves #4482

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.

Instead of changing the types for all the transactions, let's just fix this for Vue for now!

Can we change

name: to.name || to.path,
and
name: to.name || (to.matched[0] && to.matched[0].path) || to.path,
to always pass strings?

@Bobakanoosh
Copy link
Contributor Author

That's a much more elegant solution lol. Updated to reflect your changes, I also found one more usage in
/packages/ember/addon/instance-initializers/sentry-performance.ts

and fixed it there

@@ -37,7 +37,7 @@ function getBackburner() {

function getTransitionInformation(transition: any, router: any) {
const fromRoute = transition?.from?.name;
const toRoute = transition && transition.to ? transition.to.name : router.currentRouteName;
const toRoute = transition && transition.to ? transition.to.name.toString() : router.currentRouteName;
Copy link
Member

Choose a reason for hiding this comment

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

Let’s avoid changing ember for now since the router should always return a string? We can come back to this later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

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.

Awesome, thank you for your contribution!

This won't be part of the next release as it is in progress (getsentry/publish#779), but it'll be part of the release after that (6.17.5 or 6.18.0)

@AbhiPrasad AbhiPrasad changed the title Fix types for name in /tracing/transactions.ts fix(vue): Cast name parameter to string Feb 2, 2022
@AbhiPrasad AbhiPrasad added the Package: vue Issues related to the Sentry Vue SDK label Feb 2, 2022
@Bobakanoosh
Copy link
Contributor Author

Any idea how long until that release? I really want to use this feature of Sentry but I can't until then

@AbhiPrasad
Copy link
Member

We can try to cut another patch release soon then!

@AbhiPrasad AbhiPrasad merged commit 6309dd6 into getsentry:master Feb 2, 2022
@AbhiPrasad
Copy link
Member

AbhiPrasad commented Feb 7, 2022

Hey, once getsentry/publish#798 gets merged in, this will be available in 6.17.5. Thanks for your patience!

Edit: Shipped! https://www.npmjs.com/package/@sentry/vue/v/6.17.5

@JoseOrtiz
Copy link

There was an issue here, as name is not always used, to.name is undefined, so to.name.toString() will fail when used in Vue

@AbhiPrasad
Copy link
Member

@JoseOrtiz Good catch, will open a PR to fix!

AbhiPrasad added a commit that referenced this pull request Feb 9, 2022
Ref: #4483

`to.name` can be undefined, so we should guard against it
@AbhiPrasad
Copy link
Member

Opened PR to address this: #4530, will cut a patch release right afterwards!

AbhiPrasad added a commit that referenced this pull request Feb 10, 2022
Ref: #4483

`to.name` can be undefined, so we should guard against it
@AbhiPrasad
Copy link
Member

@JoseOrtiz fix will be released with 6.17.7, which will be published once getsentry/publish#812 is approved.

@snoozbuster
Copy link
Contributor

hey @AbhiPrasad - I think this PR has another issue. to.name is not necessarily defined. I think in both of these cases, to.name?.toString() is probably the correct line of code (or, (to.name || to.path).toString()). in our case we have a 404 route that isn't named and it is causing a crash similar to the symbolic route issue. I should be able to mitigate this by adding a name to the route, but thought it was worth pointing out.

@AbhiPrasad
Copy link
Member

This is still occurring with the fix in #4530 @snoozbuster? That PR should mean we always check to to.name's existence.

PRs are welcome if we need to introduce additional guards.

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.

4 participants