Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Update GAAppInstalls to know when we switched to UA (bug 1028448)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Sep 23, 2014
1 parent 3c3e11a commit b4b1fb6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions monolith/aggregator/plugins/ganalytics.py
Expand Up @@ -201,8 +201,12 @@ class GAAppInstalls(BaseGoogleAnalytics):
Monolith, or global install counts by excluding the filter.
"""
region_dimension = 'ga:customVarValue11'
date_region_added = datetime.date(2014, 1, 21)
# The old pre-universal analytics way.
region_var = 'ga:customVarValue11'
date_var_added = datetime.date(2014, 1, 21)
# The universal analytics way.
region_dimension = 'ga:dimension11'
date_dimension_added = datetime.date(2014, 7, 18)

def extract(self, start_date, end_date):
# Override `extract` to customize dimensions based on date.
Expand All @@ -213,10 +217,18 @@ def extract(self, start_date, end_date):
iso = current.isoformat()

dimensions = self.dimensions[:]
if (self.region_dimension in dimensions and
current < self.date_region_added):

# Remove region vars and add them back based on date.
if self.region_var in dimensions:
dimensions.remove(self.region_var)
if self.region_dimension in dimensions:
dimensions.remove(self.region_dimension)

if self.date_var_added <= current < self.date_dimension_added:
dimensions.append(self.region_var)
elif self.date_dimension_added <= current:
dimensions.append(self.region_dimension)

options = {'ids': self.profile_id,
'start_date': iso,
'end_date': iso,
Expand Down

0 comments on commit b4b1fb6

Please sign in to comment.