-
Notifications
You must be signed in to change notification settings - Fork 17
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(router): subsequent navigation to the same url should not trigger… #89
Conversation
Hi @p-aron and thank you very much I think this behavior should be opt-in (and it can easily be a non-breaking change). Maybe it could be introduced as a |
Hello thank you for your response. I am thinking about what you wrote that it should not be a breaking change. I am not sure how my change can be a breaking change. Do you mean a comparator?: (previous: T, current: T) => boolean function which is passed to distinctUntilChanged? |
I understand the use case and agree with it
Your change is breaking, since some urls won't be tracked anymore. This is a change in behavior that some users may not expect.
yes exactly
If not provided, the default would be a comparator that mimics function compareUrlAfterRedirect(event1, event2) {
return event1.urlAfterRedirects === event2.urlAfterRedirects`;
} |
I understand that it changes the behavior, but it would not stop other's code from compiling or running. My problem is that distinctUntilKeyChanged('urlAfterRedirects') is a bug in the code; it does not do what it is intended to do. So the change would fix other people's applications. Is distinctUntilKeyChanged('urlAfterRedirects') a bug in the code or a feature? If it is moved into a config, then people will need to update their code. Are you saying there are people for whom this would not be a fix? Or that we can not be sure? |
This is a breaking change, because it can make some applications fail to run correctly after that.
Why is it a bug? I think it does exactly what is was supposed to do. But I understand is is maybe not expected by everyone's apps. That's why making it configurable is a good idea :)
No, if we keep it as a default behavior (= if not configured explicitly by user), people won’t need to update their code, that’s the point.
Yes, this behavior has never been reported as a bug. Also, some apps may rely on the current behavior and we must not break them. |
Ok I did not know about the onSameUrlNavigation: reload option. So I was wrong when I said it is dead code.
I think it is more probable that people did not discover this. For me it is hard to imagine a scenario when somebody relies on tracking page views when modifying query params. But anyhow I understand your concerns. I will do the necessary modifications. |
Imagine you navigate to The current behavior matches that and this initial choice for distinct on query params was to be consistent. FYI, Matomo provides a way to handle that server-side (see FAQ). Anyway I totally understand and quite agree to what you're saying and maybe the initial choice was not the best, since it is not fixable in all cases on frontend-side. I was just wondering about not introducing breaking changes too early, but I agree that this topic can be discussed and default behavior may (or should) be updated! Your PR is a good improvement as it allows users to configure what they want for their specific scenario. |
…ccording to custom url comparator EmmanuelRoux#72
@p-aron I pushed some changes to implement what I was explaining I now wonder if this is not over-engineered for a relatively simple use-case... but it'll do the job :) So, the default behavior is unchanged, but it can be easily configured: provideMatomo(
{ ... },
withRouter({
navigationEndComparator: 'ignoreQueryParams', // <-- This is your initial request
})
); And leaving the ability to compare using custom function (e.g. for comparing only some specific query params, or any other processing) : provideMatomo(
{ ... },
withRouter({
navigationEndComparator: (previous, current) => {
return /* ...custom comparison logic here */;
}
})
); |
# [6.2.0](v6.1.3...v6.2.0) (2024-05-28) ### Bug Fixes * **tracker:** add default value for `acceptDoNotTrack` option ([243fc46](243fc46)) * upgrade schematics to non-deprecated module names ([946ef9f](946ef9f)) ### Features * add compatibility with Angular 18 ([7828aed](7828aed)), closes [#90](#90) * add FormAnalytics support ([ccdcfac](ccdcfac)) * **router:** allow ignoring subsequent navigation to the same url ([#89](#89)) ([1cb504c](1cb504c)), closes [#72](#72) * **tracker:** add new `disableCampaignParameters` configuration option ([88258fa](88258fa)) * **tracker:** add new `disableCampaignParameters` tracker method ([4cfda65](4cfda65))
🎉 This PR is included in version 6.2.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@EmmanuelRoux Sorry I couldn't implement it yet. Thanks for implementing.
Yes I can not see the use case for providing custom comparator. But I like I can pass |
@EmmanuelRoux |
Hi @p-aron, maybe I didn't understand your initial request : I thought it was to ignore query params changes, and that's exactly what So what's your exact need?
|
I am trying to fix #72. I am not sure if my approach is acceptable. I am not sure how PageUrlProvider could be used. location.pathname also contains the pathname without the queryparam.
If my understanding is correct then the previous distinctUntilKeyChanged('urlAfterRedirects') was deadcode because if user navigates to the same url NavigationEnd event is not triggered only NavigationSkipped.