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: Add GoogleAnalytics 4 to frontend-platform #472

Merged
merged 5 commits into from Apr 18, 2023

Conversation

UvgenGen
Copy link
Contributor

Description:
alternative implementation for #471

Added support for GA4 to frontend-platform:

  • implemented GoogleAnalyticsLoader class
  • added loadExternalScripts function to inititalize.js
  • Added tests for GoogleAnalyticsLoader.
  • The Google Analytics ID can be configured in the edx-platform MFE_CONFIG settings:
MFE_CONFIG = {
    "GOOGLE_ANALYTICS_4_ID": "G-TEST"
}

or, the ID can be set in the frontend-platform .env file as:
GOOGLE_ANALYTICS_4_ID="G-TEST"

Merge checklist:

  • Consider running your code modifications in the included example app within frontend-platform. This can be done by running npm start and opening http://localhost:8080.
  • Consider testing your code modifications in another local micro-frontend using local aliases configured via the module.config.js file in frontend-build.
  • Verify your commit title/body conforms to the conventional commits format (e.g., fix, feat) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.

Post merge:

  • After the build finishes for the merged commit, verify the new release has been pushed to NPM.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 10, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @UvgenGen! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.52 🎉

Comparison is base (e3acefc) 81.76% compared to head (292d2fe) 82.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #472      +/-   ##
==========================================
+ Coverage   81.76%   82.29%   +0.52%     
==========================================
  Files          38       39       +1     
  Lines         938      966      +28     
  Branches      172      176       +4     
==========================================
+ Hits          767      795      +28     
  Misses        159      159              
  Partials       12       12              
Impacted Files Coverage Δ
src/initialize.js 98.59% <100.00%> (+0.13%) ⬆️
src/scripts/GoogleAnalyticsLoader.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -157,6 +158,13 @@ export async function runtimeConfig() {
}
}

export async function loadExternalScripts(externalScripts, data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove async from this function, yeah? We're not awaiting it where it's called, and it has no await keywords in it.

Copy link
Contributor

@davidjoy davidjoy left a comment

Choose a reason for hiding this comment

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

Gorgeous. 🤩

One tiny nit about an async keyword, but this looks great. I'm approving so you don't feel like you need a re-review, but I do think we should remove the async keyword from loadExternalScripts.

@UvgenGen
Copy link
Contributor Author

@davidjoy Thank you) I removed the async keyword from loadExternalScripts and rebased PR

Copy link

@bmtcril bmtcril left a comment

Choose a reason for hiding this comment

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

Sorry for the radio silence, I was off the last couple of days. This looks good to me as well, are any changes needed to openedx/edx-platform#32032 to support this? I'm not sure if I'm reading it wrong, but the reference to MFE_CONFIG here seems different from what's in there.

Also pinging @arbrandes since he was involved in the last solution, just to make sure I'm not missing anything we'd planned for there.

@UvgenGen
Copy link
Contributor Author

@bmtcril no changes needed for edx-platform. We use two settings:

  • GOOGLE_ANALYTICS_4_ID = "G-test" - for platform
  • for MFE's:
MFE_CONFIG = {
    "GOOGLE_ANALYTICS_4_ID": "G-test"
}

@UvgenGen UvgenGen changed the title [DRAFT][FC-0014] alternative implementation. Add GA 4 to frontend-platform as separeted service component [FC-0014] alternative implementation. Add GA 4 to frontend-platform as separeted service component Apr 12, 2023
@bmtcril
Copy link

bmtcril commented Apr 13, 2023

Thanks for all of the work on this, Adolfo is away for a bit so I don't think there's any need to wait on his review. 👍

Copy link
Contributor

@arbrandes arbrandes 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!

@arbrandes arbrandes changed the title [FC-0014] alternative implementation. Add GA 4 to frontend-platform as separeted service component feat: Add GoogleAnalytics 4 to frontend-platform Apr 18, 2023
@arbrandes arbrandes merged commit c174b29 into openedx:master Apr 18, 2023
6 checks passed
@openedx-webhooks
Copy link

@UvgenGen 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants