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

[ Issue 389 ] Add Google Analytics #453

Merged
merged 7 commits into from
Sep 6, 2023

Conversation

SammySteiner
Copy link
Contributor

@SammySteiner SammySteiner commented Sep 1, 2023

Summary

Fixes #389

Time to review: 5 minutes

Changes proposed

  • Added environments.ts to manage public environment variables
  • Added scripts to _app.tsx to configure google analytics for the application
  • Created Google tag for site traffic and general metrics
  • Created Google tag for DAP for beta.grants.gov for HHS/ASFR
  • Created different environments for tags and analytics to distinguish dev, test, and prod

Context for reviewers

Because we're using the node environment to distinguish between dev, test, and prod, our AWS dev environment will be reported with production. The dev metrics will come from local development environments.
Waiting on admin access to our analytics account to configure dev and test enviornments.
Waiting on admin access to our analytics account to configure DAP directly in the GA console

@SammySteiner SammySteiner marked this pull request as ready for review September 5, 2023 13:32
Copy link
Collaborator

@acouch acouch left a comment

Choose a reason for hiding this comment

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

Looks great, thanks. Makes the most sense to include all envs now, even if we remove them later.

const NEXT_ENVS = ["development", "test", "production"] as const;
export type NextPublicAppEnv = (typeof NEXT_ENVS)[number];

const CURRENT_ENV = process.env.NODE_ENV ?? "development";
Copy link
Contributor

@daphnegold daphnegold Sep 5, 2023

Choose a reason for hiding this comment

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

Where is NODE_ENV being set? Our application is environment agnostic at the moment, and prefer it that way (have intentionally made decisions to maintain that). Just not sure this will hit anything but "development" at this point.

EDIT: Thanks for explaining offline that it's just how we start the app and what's happening with AWS accounts both being production.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NODE_ENV is set when we run npm run start automagically by node to development and that is a flag that node uses to set certain configs. npm run test sets it to test, and serving it from the server.js file sets it to production. We could have more finely tuned control by using env files, but that would add some overhead that I don't think we need yet.

@daphnegold
Copy link
Contributor

Because we're using the node environment to distinguish between dev, test, and prod, our AWS dev environment will be reported with production. The dev metrics will come from local development environments.

Not sure I understand why AWS dev environment is reported to production. So "dev" is local development, what is test?

@SammySteiner SammySteiner merged commit b2f6172 into main Sep 6, 2023
@SammySteiner SammySteiner deleted the sammysteiner/issue-389-google-analytics branch September 6, 2023 12:53
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.

[Task]: set up analytics for beta.grants.gov
3 participants