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

FFS-2492: store applicant id in session, use it when logging events as the dist… #460

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/app/controllers/cbv/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def capture_page_view
event_logger.track("CbvPageView", request, {
cbv_flow_id: @cbv_flow.id,
invitation_id: @cbv_flow.cbv_flow_invitation_id,
cbv_applicant_id: @cbv_flow.cbv_applicant_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this work if the vast majority of the mixpanel events don't have the cbv_applicant_id field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it wouldn't. Maybe I'm misunderstanding how the applicant id works. I assumed that all people going through the cbv flow would have one, invited or not. But if that's not the case then maybe I should fall back to a distinct ID of "invite-#" when applicant ID is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've verified all the events have the applicant id

client_agency_id: @cbv_flow.client_agency_id,
path: request.path
})
Expand Down
8 changes: 4 additions & 4 deletions app/lib/mixpanel_event_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def initialize
end

def track(event_type, request, attributes = {})
# Use the "invitation_id" attribute as the distinct_id as it currently best
# Use the "cbv_applicant_id" attribute as the distinct_id as it currently best
# represents the concept of a unique user.
invitation_id = attributes.fetch(:invitation_id, "")
applicant_id = attributes.fetch(:cbv_applicant_id, "")
distinct_id = ""
if invitation_id.present?
distinct_id = "applicant-#{invitation_id}"
if applicant_id.present?
distinct_id = "applicant-#{applicant_id}"

# This creates a profile for a distinct user
flow_id = attributes.fetch(:cbv_flow_id, "")
Expand Down