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

Commit

Permalink
[bug 1169261] Fix event tracking
Browse files Browse the repository at this point in the history
Event tracking needs the provider version number so we can distinguish
between flows for successive algorithms. Further, the "suggest" event
needs to be synchronous while the "view*" events can be asynchronous.
  • Loading branch information
willkg committed Jun 3, 2015
1 parent 004af6f commit 6fcf93b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fjord/suggest/providers/sumosuggest.py
Expand Up @@ -14,7 +14,9 @@
# suggestions.
PROVIDER_VERSION = 1

EVENT_CATEGORY = 'sumo_suggest'
# Append provider version so that if we change the algorithm, we
# increment the version and then we can compare the two flows.
EVENT_CATEGORY = 'sumo_suggest' + str(PROVIDER_VERSION)

SUMO_HOST = 'https://support.mozilla.org'
SUMO_SUGGEST_API_URL = SUMO_HOST + '/api/2/search/suggest/'
Expand Down Expand Up @@ -124,7 +126,7 @@ def handle_redirect(self, request, redirect):
'ec': EVENT_CATEGORY,
'ea': 'view' if rank != 'aaq' else 'viewaaq',
'el': url
})
}, async=True)

return url

Expand Down Expand Up @@ -194,11 +196,13 @@ def get_suggestions(self, feedback, request=None):
logger.exception('SUMO Suggest API raised exception.')
return []

# Note: This needs to be synchronous so that "suggest" events
# come before their respective "view*" events.
ga_track_event({
'cid': str(feedback.id),
'ec': EVENT_CATEGORY,
'ea': 'suggest'
})
}, async=False)

links = self.docs_to_links(docs)

Expand Down

0 comments on commit 6fcf93b

Please sign in to comment.