Add additional event capturing for some interactions #1596
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/5520
Closes https://github.com/mitodl/hq/issues/5283
https://github.com/mitodl/hq/issues/5254
Description (What does it do?)
We need some events to fire when certain events happen in the frontend. These include:
These aren't necessarily captured in an intuitive way automatically by PostHog, so this adds explicit events to capture these interactions.
lr_add_to_listevent. This contains the same data aslrd_view(so, basic resource info) plus the type of list the resource was added to (either a user list or a learning path).search_updatedevent. This captures:isEnterflag if the learner has adjusted their search term - this is True if they have submitted via Enter key, or False if they clicked the submit button/icon.How can this be tested?
If you don't have your own PostHog account set up, you can either set one up for this or use the MIT Learn Test project in the OL PostHog account.
Note
If you're rolling your own, it is imperative that you also set up this transformation in Data Pipelines - it should exist in the list if you hit Add Transformation in PostHog.
The URL parameters to convert should be set to
q,resource_type,certification_type,delivery,department,topic,offered_by,free,professionaland the Prefix should be set tosearch_param_. I also turn on Ignore case and Add to user properties but these aren't strictly required.Test
lr_add_to_listby adding a course to a list. You should see the event pop up in the Activity view (note that it may take a bit of time for it to show up).Test
search_updateby making changes to your search - select some facets, update your term. This should result in some events being captured in PostHog.Additional Context
search_updatewill fire once for each facet that is chosen. So, if you select multiple items in a row, you will end up with events for all of those individual selections. This is by design at this point - we will revisit later if we need to but we're explicitly not debouncing it now.In testing, I noticed that there's a bug in https://github.com/PostHog/posthog-app-url-parameters-to-event-properties with regard to query parameter arrays: it does not handle them properly, so you only see whatever the first one is from the param. The facets code appends to the list rather than prepends so this means if you choose more than one of a given type of facet you'll only ever see the first one you chose. (This is especially noticeable for Topics.) This should really be fixed upstream so will work that out separately.