Skip to content

Explicitly document Flow State Machine analytics events (LG-6748)#7191

Merged
zachmargolis merged 15 commits intomainfrom
margolis-explicit-doc-auth-analytics
Oct 25, 2022
Merged

Explicitly document Flow State Machine analytics events (LG-6748)#7191
zachmargolis merged 15 commits intomainfrom
margolis-explicit-doc-auth-analytics

Conversation

@zachmargolis
Copy link
Contributor

@zachmargolis zachmargolis commented Oct 21, 2022

🎫 Ticket

LG-6748

🛠 Summary of changes

Explicitly documents analytics events. I ran spec/features/idv/analytics_spec.rb repeatedly until it passed, but didn't give complete coverage.

Draft mode because it's not 100% done. Here are the things I want to get to:

  • alphabetize analytics_events.rb
  • add actual YARD doc params for each new event (I plan to copy from idv/analytics_spec.rb)
    • but maybe this could be in a follow-up PR? at least this way we get documentation that they exist
    • Confirmed, this will be in follow-up PRs. Tracking tickets: LG-7892, LG-7893
  • Make sure Inherited Proofing classes don't break (Idv::Steps::InheritedProofing::AgreementStep et al)

📜 Testing Plan

  • Make sure that we can run through flows and don't get NoMethodErrors on the various Step and Action classes

changelog: Internal, Logging, Document doc auth analytics events
Comment on lines +3030 to +3033
# @identity.idp.previous_event_name IdV: in person proofing ssn visited
def idv_doc_auth_ssn_visited(**extra)
track_event('IdV: doc auth ssn visited', **extra)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

per my RFC this is me collapsing two events that are essentially the same into one.

See the idv/analytics_spec.rb changes for a sense of what difference this would make to the actual flow

Comment on lines +8 to +10
def self.analytics_submitted_event
:idv_doc_auth_verify_document_status_submitted
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our existing pattern for a lot of the Flow State Machine has been to define things as constants and dynamically read them.

I broke from that pattern because I believe class methods are a better choice, and more conventional for Ruby.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should revisit some of the others? Which are you referring to? (STEP_INDICATOR_STEP? others?)

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 mean even the FLOW_STATE_MACHINE_SETTINGS constants count too in controllers.

I think we could file it as a nice-to-have that we switch to methods (maybe even add some syntax sugar/DSL-like methods to declare them), but our usages aren't complicate enough that it's a problem.

for example if we subclassed steps more, methods would be much better than constants because it's clearer to override a method than a constant.

Time.zone.parse(value)
end

DOC_AUTH = 'Doc Auth' # visited or submitted is appended
Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL... so much more than "visited" or "submitted" were added to these 😭

Comment on lines +8 to +10
def self.analytics_submitted_event
:idv_doc_auth_verify_document_status_submitted
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think we should revisit some of the others? Which are you referring to? (STEP_INDICATOR_STEP? others?)

Comment on lines +27 to +30
analytics.public_send(
flow.step_handler(step).analytics_submitted_event,
**result.to_h.merge(analytics_properties),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to think how we validate that these methods are defined. I suppose we can rely on the fact that an error would be thrown in feature specs if they weren't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I've been relying on spec coverage, which is not a guarantee. Another approach I've been using to spot-check has been checking for all *step.rb and *action.rb files, but unfortunately due to some of the optional steps, not all steps have all analytics methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another thing I discovered, the guards for if @analytics_id basically prevented us from trying to log information, I am trying removing that here to see we discover more errors: #7213

@zachmargolis zachmargolis marked this pull request as ready for review October 24, 2022 18:37
@zachmargolis zachmargolis requested a review from aduth October 24, 2022 20:55
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@zachmargolis zachmargolis merged commit d0b8f24 into main Oct 25, 2022
@zachmargolis zachmargolis deleted the margolis-explicit-doc-auth-analytics branch October 25, 2022 19: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