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: remove ReactGA and migrate to GA4 for tracking #2071

Merged
merged 7 commits into from
Dec 26, 2023

Conversation

EshaanAgg
Copy link
Contributor

@EshaanAgg EshaanAgg commented Dec 25, 2023

Which problem is this PR solving?

Fixes #1332

Description of the changes

  • Remove the ReactGA library for analytics and instead load the script ourselves asynchronously
  • Manually make calls to the gtag function with the appropriate parameters

How was this change tested?

  • NA

Checklist

@EshaanAgg EshaanAgg requested a review from a team as a code owner December 25, 2023 15:31
@EshaanAgg EshaanAgg requested review from jkowall and removed request for a team December 25, 2023 15:31
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

I think the approach is great! One less dependency.

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
@EshaanAgg EshaanAgg changed the title [WIP] feat: remove ReactGA and migrate to GA4 feat: remove ReactGA and migrate to GA4 for tracking Dec 26, 2023
Copy link

codecov bot commented Dec 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (65b01d4) 96.56% compared to head (a5aa8c7) 96.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2071      +/-   ##
==========================================
+ Coverage   96.56%   96.57%   +0.01%     
==========================================
  Files         255      254       -1     
  Lines        7623     7626       +3     
  Branches     1985     1986       +1     
==========================================
+ Hits         7361     7365       +4     
+ Misses        262      261       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
import ReactGA from 'react-ga';
import { WindowWithGATracking } from './ga';

declare let window: WindowWithGATracking;

// eslint-disable-next-line import/prefer-default-export
export const logTrackingCalls = () => {
Copy link
Member

Choose a reason for hiding this comment

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

can we move this function inside ga.tsx (and tests)? I don't see it being used outside, so odd to expose as public, especially since the dataLayer contact is for GA only.

Copy link
Member

Choose a reason for hiding this comment

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

in fact, if feels like it could be combined with the gtag() function instead of always calling it explicitly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aight. The combining idea sounds nice. I'll check it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have combined the logging with the gtag function itself in the latest implementation. This WindowWithGATracking is now only defined and used in ga.tsx

packages/jaeger-ui/src/utils/tracking/ga.tsx Outdated Show resolved Hide resolved
// defined in utils/tracking/ga.ts
dataLayer: never;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate why this change is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thoughts, the most ideal implementation would be for dataLayer to have the appropriate types within ga.ts and have the type never outside it so that no other module tries to access or modify the same.

This had been my initial reasoning but I think it would be better to remove it considering the way you have advised to handle the types in the previous comment.

@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Dec 26, 2023
Signed-off-by: Eshaan Aggarwal <96648934+EshaanAgg@users.noreply.github.com>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Thanks!

@yurishkuro yurishkuro merged commit cdd251b into jaegertracing:main Dec 26, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Support Google Analytics 4 properties
2 participants