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

Calling callback if provided for google analytics mock #4115

Closed
wants to merge 1 commit into from

Conversation

niklabh
Copy link

@niklabh niklabh commented Nov 14, 2018

URL(s) where the issue occurs

https://www.cars45.com/

Describe the issue

According to google analytics calling ga with a function as the first argument will call that callback with tracker.
https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference

ga(function(tracker) {
console.log(tracker); // Logs undefined.
});

Adding this behaviour to uBlock

Versions

  • Browser/version: [Chrome Version 70.0.3538.102 (Official Build) (64-bit)]
  • uBlock Origin version: [uBlock origin 1.17.0]

Notes

Added callback behaviour to mocked ga as well.

@niklabh
Copy link
Author

niklabh commented Nov 14, 2018

issue #4114

@mapx-
Copy link
Contributor

mapx- commented Nov 14, 2018

@gorhill

@gwarser
Copy link
Contributor

gwarser commented Oct 13, 2020

@gorhill

Reported here: https://www.reddit.com/r/uBlockOrigin/comments/j3jtaq/ublock_enabled_but_with_all_local_site_blocking/

Clicking on "Get started" button does nothing - should login(?).

ga is called with handleButtonClick:

image

@gorhill
Copy link
Member

gorhill commented Oct 13, 2020

Nice, thanks for the investigation. I see a reference about this in the documentation:

Invoking the ga() command queue function by passing it a function will schedule the passed function for execution at the next point in the queue.

I think the safest fix is to call asynchronously the passed function since this is how the real API behaves.

@gorhill
Copy link
Member

gorhill commented Oct 13, 2020

Err I didn't realize where I was commenting, it's what the pull request was about. Not sure why I was against it since the documentation is clear.

@gwarser
Copy link
Contributor

gwarser commented Oct 13, 2020

Yes, and no idea how my test scriptlet was working - my "patch" uses undeclared f variable.


Two more fixes and it really seems to work.

gorhill added a commit to gorhill/uBlock that referenced this pull request Oct 13, 2020
JustOff pushed a commit to gorhill/uBlock-for-firefox-legacy that referenced this pull request Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants