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

Add Amplitude events to the navbar "Create" menu #55843

Merged
merged 11 commits into from
Jan 26, 2024

Conversation

TurnerRiley
Copy link
Contributor

@TurnerRiley TurnerRiley commented Jan 19, 2024

Add Amplitude events to the navbar to track when a signed-out user clicks the "Create" menu and if they click an option within the menu.

My main concern is that we've seen problems before with Amplitude not logging a click event when the click triggers a redirect, I think because it doesn't have time to fire off before leaving the page the user was on. The tricky part about it is that it appears to work locally (i.e. the Amplitude log appears in the console right before navigating to the given url) so it's tough to tell whether it will work on production. I have confidence that the menu click event will work fine, but since each menu option is an <a> tag, I worry that the option click events won't log on Amplitude. After discussing with Dani, the plan is to wait and see if it works or not, and if it doens't work we'll remove the option event and find a new way of tracking that information.

"Signed Out User Clicks Create Dropdown" event:

Shows for signed-out user

click_create_signed_out

Does not show for signed-in user

click_create_signed_in

"Signed Out User Selects Create Dropdown Option" event:

Shows for signed-out user

click_option_signed_out

Does not show for signed-in user

click_option_signed_in

Links

Jira ticket: here

Testing story

Local testing.

Follow-up work

Observe whether "Signed Out User Selects Create Dropdown Option" events show up in Amplitude, and if they don't find a workaround to track that information.

.project_link#view_all_projects
= I18n.t("#{loc_prefix}view_all")
= render inline: File.read(Rails.root.join('..', 'shared', 'haml', 'create_menu_event_logger.haml')), type: :haml, locals: {is_signed_out: current_user.nil?, options: create_drop_down_items.map{|entry| entry[:title]}.append("view_all")}
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 used this line as reference for how to render a .haml file that's in the /shared directory. It wasn't working when I tried something simpler like = view :create_menu_event_logger, I think because it was expecting something in a views directory (which /shared doesn't have).

@TurnerRiley TurnerRiley requested a review from a team January 19, 2024 20:56
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like teacher tools will want to add more events to the top nav bar soon (mentioned in this slack message). Could we make this filename more generic to allow other teams to add events here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, will do!

Copy link
Contributor

@bethanyaconnor bethanyaconnor left a comment

Choose a reason for hiding this comment

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

Looks good! I know we have some Amplitude quota restrictions -- @dmcavoy do you foresee any issues with that?

@dmcavoy
Copy link
Contributor

dmcavoy commented Jan 25, 2024

Looks good! I know we have some Amplitude quota restrictions -- @dmcavoy do you foresee any issues with that?

No - We should be fine. If it gets bad I can block the event directly in amplitude.

@TurnerRiley TurnerRiley merged commit 2d5bde4 into staging Jan 26, 2024
2 checks passed
@TurnerRiley TurnerRiley deleted the amplitude-for-create-menu branch January 26, 2024 21:42
mikeharv pushed a commit that referenced this pull request Feb 5, 2024
* add click create dropdown event

* add option select event

* update file name

* update menu options variable name

* safe chain the map call

* add safe chaining for append

* simplify file reader for tests

* only add event listeners if element is present
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.

None yet

3 participants