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

feat(ga): transport for event tracking #371

Merged
merged 1 commit into from Jan 9, 2020
Merged

feat(ga): transport for event tracking #371

merged 1 commit into from Jan 9, 2020

Conversation

goosmurf
Copy link
Contributor

@goosmurf goosmurf commented Jan 9, 2020

  • What kind of change does this PR introduce?

GA provider for analytics.js implementations has a (what appears to be long standing) bug that doesn't correctly pass the "transport" option to GA.

  • What is the current behavior? Link to open issue?

When transport is set to "beacon" the resulting hit is still sent using an image by default.

  • What is the new behavior?

When transport is set to "beacon" eventTrack() now correctly uses analytics.js' support for navigator.sendBeacon().

The core of the problem seems to be an incorrect use of the GA API.

The ga.send() function only accepts a single fieldsObject: https://developers.google.com/analytics/devguides/collection/analyticsjs/tracker-object-reference#send

Demonstration of the underlying issue: https://gist.githack.com/goosmurf/9fec28db0e9747baa70a0120af59e389/raw/f2a18b1cdde9bcfb33fb272c05d5fcaa1cbc95a7/mixed-transport.html

Watch the network tab in dev tools and you'll see that the "Broken beacon" is sent using an image, whereas the "Working beacon" is sent via navigator.sendBeacon (identifiable by both the HTTP method being POST as well as the Initiator on the request).

@codecov-io
Copy link

Codecov Report

Merging #371 into master will increase coverage by 0.09%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
+ Coverage   75.06%   75.15%   +0.09%     
==========================================
  Files          32       32              
  Lines         818      817       -1     
  Branches      149      149              
==========================================
  Hits          614      614              
+ Misses        135      134       -1     
  Partials       69       69
Impacted Files Coverage Δ
src/lib/providers/ga/ga.ts 64.77% <50%> (+0.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf90e8f...7bf0bfe. Read the comment docs.

@scttcper scttcper changed the title fix transport for event tracking fix(ga): transport for event tracking Jan 9, 2020
@scttcper scttcper changed the title fix(ga): transport for event tracking feat(ga): transport for event tracking Jan 9, 2020
@scttcper scttcper merged commit 311ef79 into angulartics:master Jan 9, 2020
@scttcper
Copy link
Collaborator

scttcper commented Jan 9, 2020

🎉 This PR is included in version 8.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants