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

Implement remaining product metrics #196

Merged
merged 6 commits into from
Aug 22, 2024
Merged

Conversation

tdooner
Copy link
Contributor

@tdooner tdooner commented Aug 20, 2024

Ticket

Resolves FFS-705.

Changes

  • Track NewRelic event for CaseworkerLogin
  • Add site_id to all NewRelic events
  • Add user_id to ApplicantInvitedToFlow NewRelic events
  • Add more metadata when tracking PDF share event
  • Track seconds between invitation sent, flow start, and completion

Context for reviewers

When we initially implemented NewRelic, it was too early and we didn't have all
the constructs necessary to instrument these product metrics. Now, we do, so
I've added metadata to various parts in order to capture all the metrics in the
attached ticket.

Testing

Now that the NewRelic account is set up, the easiest way to validate this change
is to merge this, build the dashboards, and then accept the ticket based off of
the dashboards as data flows in.

This will allow us to create a dashboard of the unique number of
caseworker users.
This will facilitate creating dashboards broken out per site.
This necessitates passing the `current_user` object into the
CbvInvitationService, but necessary if we want to have a NewRelic
understanding of the number of invitations per caseworker.
We need to track a few fields in order to give us metrics on how mayn
accounts are linked, as well as the number of paystubs and account
descriptions.

This logic gets me worried for bugs, since it's in a critical place, so
I'm putting it in a rescue block so it doesn't break the sending of the
actual documents.
This commit adds metadata tracking for the seconds in two intervals:
1. invitation sent and flow start, and
2. flow start and flow completion

Although, these can be reconstituted later from the database timestamps,
it might be best to just send them to NewRelic so we can put them on a
dashboard easily.
We will set NEW_RELIC_ENV=demo on our demo site, and
NEW_RELIC_ENV=production on our production site.
@tdooner tdooner marked this pull request as ready for review August 22, 2024 00:51
Copy link
Contributor

@GeorgeCodes19 GeorgeCodes19 left a comment

Choose a reason for hiding this comment

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

LGTM

let(:cbv_flow_invitation) { cbv_flow.cbv_flow_invitation }

before do
session[:cbv_flow_invitation] = cbv_flow_invitation
end

around do |ex|
Copy link
Contributor

Choose a reason for hiding this comment

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

what's going on 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.

I make an assertion in the test that it calculates the number of "seconds since flow started" correctly, so freezing time is necessary so the calculation is exact (and doesn't take into account the time it took for the test to run).

@@ -1,4 +1,6 @@
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
after_action :track_event
Copy link
Contributor

Choose a reason for hiding this comment

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

😎

@tdooner tdooner merged commit 9bb1582 into main Aug 22, 2024
19 checks passed
@tdooner tdooner deleted the td/FFS-705-product-metrics branch August 22, 2024 17:11
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