Closed Bug 1438708 Opened 7 years ago Closed 7 years ago

Determine Google Analytics UA at runtime instead of build time

Categories

(Socorro :: Webapp, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: miles, Assigned: osmose)

References

Details

Attachments

(1 file)

The webapp needs to have working Google Analytics per environment. There's an interesting caveat here: due to limitations in the pre-docker infra, we hardcoded the prod GA key in the code. [0] See bug 1314258 for more info. We need to override this with Google Analytics IDs for -new-stage and -new-prod, as currently all of our analytics for each of our sites is going to the -prod GA property (I think). [0] https://github.com/mozilla-services/socorro/blob/master/webapp-django/crashstats/settings/base.py#L516-L520
Socorro determines the UA to use at build time by compiling it into the generated frontend code using this django-pipeline compiler: https://github.com/mozilla-services/socorro/blob/master/webapp-django/crashstats/crashstats/pipelinecompilers.py The problem is that, at build time, we have no config (bug 1314258), including knowledge of which environment we'll be running in. This means we can't have a different UA for staging vs prod, because they use the same built frontend files. An alternative would be to expose the Django-settings-based UA as a data-attribute in the HTML of each webpage, and have the Google analytics code pull it at runtime. That way, we only use the UA at a point where we know which environment we're in and have pulled config from the environment. We'll probably want to remove the default value while fixing this, so we'll have to configure the stage and prod environments in both old and new infra with appropriate GOOGLE_ANALYTICS_ID environment variables. We can actually set those config values before the patch lands since nothing else at runtime uses the value. miles: Would you be willing/able to set the GOOGLE_ANALYTICS_ID environment variable in each of the 4 environments with the appropriate UAs?
Assignee: miles → mkelly
Component: Infra → Webapp
Flags: needinfo?(miles)
Summary: [ops infra socorro] google analytics for the webapp → Determine Google Analytics UA at runtime instead of build time
So, I realized that those were already set in all 4 environments. Done-zo.
Flags: needinfo?(miles)
Commits pushed to master at https://github.com/mozilla-services/socorro https://github.com/mozilla-services/socorro/commit/eefaf1352feb4a7ee87157ebde6a194c567d2112 Fix bug 1438708: Pull GA id from setings at runtime instead of build time. Also removes some outdated GA settings that were once used for server-side analytics, but are now unused. https://github.com/mozilla-services/socorro/commit/997a9a224f78f092efd6df6eca8c36cea0308882 Merge pull request #4359 from Osmose/ga-runtime Fix bug 1438708: Pull GA id from setings at runtime instead of build time.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: