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

JavaScript tracker exclude query parameters #17887

Closed
wants to merge 10 commits into from

Conversation

bx80
Copy link
Contributor

@bx80 bx80 commented Aug 14, 2021

Description:

Fixes #11627

Adds a new option to the JavaScript tracker to exclude query parameters from the tracked URL.

_paq.push(["setExcludedQueryParams", ["uid", "sid"]]);

Existing purify() and removeUrlParameter() functions were reused.

The tracker code generator has been updated to automatically add this option to the generated javascript tracking code using the excluded query parameters configured under Websites > Settings.

Tracker code generator unit tests have also been updated to test for valid tracker code and string escaping with the option enabled.

(Initially used "setIgnoreUrlParams" as the option name as per issue report, but though it would be more consistent to use "setExcludedQueryParams" to match the existing config option and UI terminology.)

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@tsteur
Copy link
Member

tsteur commented Aug 15, 2021

Thanks for this @bx80 👍 It's not been reviewed yet but noticed that this PR may include changes from your other PR?

@bx80 bx80 force-pushed the 11627-tracker-ignore-url-params branch from 40ddd4b to 0f4ca5e Compare August 16, 2021 00:02
@bx80
Copy link
Contributor Author

bx80 commented Aug 16, 2021

Sorry about that, I unintentionally created a sub-branch of the other PR. I've now rebased the branch so it only has the relevant commits.

@sgiehl sgiehl added the Needs Review PRs that need a code review label Aug 16, 2021
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

It would be awesome to also have some javascript tests for that. They could be added after this:

equal( tracker.hook.test._purify('http://example.com/?q=xyz#hash'), 'http://example.com/?q=xyz', 'http://example.com/?q=xyz#hash');

Not sure how familiar you are with those tests, but it could be something like:

        tracker.setExcludedQueryParams(['sid', 'test']);

        equal( tracker.hook.test._purify('http://example.com/?sid=12345&test5=1'), 'http://example.com/?test5=1', 'http://example.com/?sid=12345&test5=1');
        equal( tracker.hook.test._purify('http://example.com/?asid=12345&test=1'), 'http://example.com/?asid=12345', 'http://example.com/?asid=12345&test=1');
        equal( tracker.hook.test._purify('http://example.com/?sid=test#hash'), 'http://example.com/', 'http://example.com/?sid=test#hash');

js/piwik.js Outdated Show resolved Hide resolved
@sgiehl sgiehl added this to the 4.5.0 milestone Aug 26, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 3, 2021

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Sep 3, 2021
Copy link
Contributor

@justinvelluppillai justinvelluppillai left a comment

Choose a reason for hiding this comment

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

Looks good to me to merge. @sgiehl?

@justinvelluppillai
Copy link
Contributor

build js

@github-actions github-actions bot removed the Stale The label used by the Close Stale Issues action label Sep 6, 2021
@sgiehl
Copy link
Member

sgiehl commented Sep 6, 2021

@justinvelluppillai building js doesn't work for pull requests coming from forks. I guess in theory it would be possible to enable that for our action (if the issuer allows edits by us), but not sure how much effort it would be.

Did you test the changes locally. I had only done a code review yet. If you can confirm that it works as expected, I guess it could be merged (once the build assets are updated)

btw. I have also added another missing JS test.

@justinvelluppillai
Copy link
Contributor

@sgiehl yeah I realised that after I attempted it hence my laughing emoji at my comment! How do we normally add the built assets, build them locally and commit to the PR?

@sgiehl
Copy link
Member

sgiehl commented Sep 6, 2021

To do that, guess you would need to check out the fork, or at least add it as remote. Alternatively you could merge the PR into a new branch in our repo. Build the assets there and recreate the PR from that branch.

Btw. Feel free to create a new issue to adjust our action to also build assets for forks when possible

@github-actions
Copy link
Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Sep 14, 2021
@bx80
Copy link
Contributor Author

bx80 commented Sep 20, 2021

Closed due to git branch merge issues and replaced by PR #18031

@bx80 bx80 closed this Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review Stale The label used by the Close Stale Issues action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JavaScript Tracker: Add possibility to set URL parameters to ignore
4 participants