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

feat: Mixpanel Event Tracking – SSI/Action Plan (M2-7698) #543

Merged
merged 10 commits into from
Nov 7, 2024

Conversation

farmerpaul
Copy link
Contributor

@farmerpaul farmerpaul commented Oct 24, 2024

  • Tests for the changes have been added

πŸ“ Description

πŸ”— Jira Ticket M2-7698

This PR adds new event properties to existing Mixpanel events during an assessment in the web app, as well as adds three new events. The events affected are:

  • Assessment Started
  • Assessment completed 1
  • Activity Resume Button Pressed
  • Activity Restart Button Pressed
  • Response Report Generated (new) 1
  • Response Report Download Clicked (new) 1
  • Save & Exit Clicked (new) 1

The new properties added are:

For the new "Response Report …" events:

  • Item ID: the ID of the Phrase Builder item
  • Total Response Reports: the total number of Phrase Builder items in the activity

For all the above events:

  • Item Types: an array of unique item types in use for the current activity
  • Feature array containing SSI: when the activity contains the Phrase Builder item type, and when performing actions on an Action Plan item type 2

πŸ“Έ Screenshots

N/A

πŸͺ€ Peer Testing

Refer to the ticket description for a table listing what events to expect, how to trigger them, and what properties should be attached to them.

For each event:

  1. Follow the instructions under the Trigger column to trigger the event.
  2. Open Mixpanel, and navigate to the Events tab.
  3. Refresh if needed.
    Expected outcome: The event matching the Event Name column should have been added to the top of the list.
  4. Expand the event and open the Your Properties tab:
    Expected outcome: The custom properties for that event mentioned in the Details column should be listed.

✏️ Notes

1: To be able to access the list of item types used for the current activity at these times during an assessment, it was necessary to perform another API call to adequately populate the SurveyContext (which is available during these events), basically due to inconsistency in similar API responses. See this commit for details.

2: The Feature property used to be a scalar string, but since Feature is already used for Multi-informant (during Take Now) it was agreed that it should now be an array property, containing all active "features".

@farmerpaul farmerpaul marked this pull request as ready for review October 24, 2024 17:56
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-543.d15zn9do8xbzga.amplifyapp.com

@farmerpaul farmerpaul force-pushed the M2-7698-action-plan-event-tracking branch from 79f56fc to d1c69a8 Compare October 28, 2024 22:47
Create Mixpanel utilities for conveniently adding the `Item Types` and
optionally populating the `Feature` property for all events tracked
during an assessment. Simplifies some existing tracking code.

The the `Feature` property is now an array after discussions with
the data team, since it's now used for multiple features that can be
present at the same time, and as an array it requires careful handling.
To be able to add "Item Types" to this and other events required of this
Jira task, a call to the `applets/{applet_id}/base_info` endpoint is
needed to fetch the item types contained in the activity being
completed. As anoying as it is to have to make another request because
of incomplete data coming from `applets/{applet_id}`, this seems to be
the most convenient way forward for now. We can optimize performance if
needed down the road; it will likely require fixing the BE to return
more consistent data.
Tracks `Report Generated`, `Report Download Clicked` and
`Save & Exit Clicked` events.
This should allow tests to pass locally without messing with env vars.
@farmerpaul farmerpaul force-pushed the M2-7698-action-plan-event-tracking branch from d1c69a8 to a20e283 Compare October 28, 2024 22:48
@farmerpaul farmerpaul requested review from sultanofcardio and removed request for sultanofcardio October 28, 2024 23:00
Copy link
Contributor

@sultanofcardio sultanofcardio left a comment

Choose a reason for hiding this comment

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

Nice work. Left you a couple comments for consideration.

One thing that gave me pause was the idea of incurring an extra request just to satisfy the Item Types analytics. I think we should do a follow-up task that adds the containsResponseTypes property to the useAppletByIdQuery response

@farmerpaul farmerpaul force-pushed the M2-7698-action-plan-event-tracking branch from 520a61e to f9b2c87 Compare October 29, 2024 13:14
@farmerpaul
Copy link
Contributor Author

One thing that gave me pause was the idea of incurring an extra request just to satisfy the Item Types analytics. I think we should do a follow-up task that adds the containsResponseTypes property to the useAppletByIdQuery response

Agreed, I was hoping not to have to make an extra request, but I didn't see a way around it for now. Incorporating containsResponseTypes into the the main applet GET endpoint would influence our approach in solving M2-7906: Optimize Mobile-Only Item Type/Activity Check as well, since I suspect it would mean the FE would then have everything it needs to determine mobile- and web-only activities… lemme think how best to combine the two issues.

@farmerpaul farmerpaul force-pushed the M2-7698-action-plan-event-tracking branch from 5a70ff9 to 6add2d1 Compare October 30, 2024 17:53
@farmerpaul farmerpaul merged commit 4db3c41 into dev Nov 7, 2024
3 checks passed
@farmerpaul farmerpaul deleted the M2-7698-action-plan-event-tracking branch November 7, 2024 15:19
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.

2 participants