-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document analytics events via YARD (LG-5590) (#6014)
- Adds AnalyticsEvents module where we can put explicitly typed events - Add script that uses YARD to parse these and output JSON that we could use to power more accessible documentation * Use Makefile to generate the JSON * Update analytics lint command and fix analytics lint errors * Switch to dasherized /api/analytics-events endpoint, add to CORS allowlist * gitignore * eslint ignore doc dir * build analytics_events JSON building to build-post-config * Serve the analytics events data from Rails so that the CORS middleware wraps it * Migrate ACCOUNT_RESET * Migrate ACCOUNT_DELETE_SUBMITTED * Migrate ACCOUNT_DELETE_VISITED * Migrate ACCOUNT_DELETION event changelog: Internal, Documentation, Add documentation for analytics events in events.log
- Loading branch information
1 parent
321eaeb
commit 51ff7b0
Showing
27 changed files
with
533 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
public | ||
vendor | ||
coverage | ||
doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -786,6 +786,7 @@ DEPENDENCIES | |
webmock | ||
xmldsig (~> 0.6) | ||
xmlenc (~> 0.7, >= 0.7.1) | ||
yard | ||
zonebie | ||
zxcvbn (= 0.1.7) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Serve a static file from Rails so that the CORS middleware can add the correct headers | ||
class AnalyticsEventsController < ApplicationController | ||
prepend_before_action :skip_session_load | ||
prepend_before_action :skip_session_expiration | ||
skip_before_action :disable_caching | ||
|
||
JSON_FILE = Rails.root.join('public', 'api', '_analytics-events.json') | ||
|
||
def index | ||
if File.exist?(JSON_FILE) | ||
expires_in 15.minutes, public: true | ||
|
||
send_file JSON_FILE, type: 'application/json', disposition: 'inline' | ||
else | ||
render_not_found | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
module AnalyticsEvents | ||
# @identity.idp.event_name Account Reset | ||
# @param [Boolean] success | ||
# @param ["cancel", "delete", "cancel token validation", "granted token validation", | ||
# "notifications"] event | ||
# @param [String] message_id from AWS Pinpoint API | ||
# @param [String] request_id from AWS Pinpoint API | ||
# @param [Boolean] sms_phone | ||
# @param [Boolean] totp does the user have an authentication app as a 2FA option? | ||
# @param [Boolean] piv_cac does the user have PIV/CAC as a 2FA option? | ||
# @param [Integer] count number of notifications sent | ||
# @param [Hash] errors | ||
# @param [Hash] error_details | ||
# @param [String] user_id | ||
# @param [Integer] account_age_in_days | ||
# @param [Hash] mfa_method_counts | ||
# @param [Integer] email_addresses number of email addresses the user has | ||
# Tracks events related to a user requesting to delete their account during the sign in process | ||
# (because they have no other means to sign in). | ||
def account_reset( | ||
success: nil, | ||
event: nil, | ||
message_id: nil, | ||
piv_cac: nil, | ||
request_id: nil, | ||
sms_phone: nil, | ||
totp: nil, | ||
count: nil, | ||
errors: nil, | ||
user_id: nil, | ||
account_age_in_days: nil, | ||
mfa_method_counts: nil, | ||
pii_like_keypaths: nil, | ||
error_details: nil, | ||
email_addresses: nil | ||
) | ||
track_event( | ||
'Account Reset', | ||
{ | ||
success: success, | ||
event: event, | ||
message_id: message_id, | ||
piv_cac: piv_cac, | ||
request_id: request_id, | ||
sms_phone: sms_phone, | ||
totp: totp, | ||
count: count, | ||
errors: errors, | ||
user_id: user_id, | ||
account_age_in_days: account_age_in_days, | ||
mfa_method_counts: mfa_method_counts, | ||
pii_like_keypaths: pii_like_keypaths, | ||
error_details: error_details, | ||
email_addresses: email_addresses, | ||
}.compact, | ||
) | ||
end | ||
|
||
# @identity.idp.event_name Account Delete submitted | ||
# @param [Boolean] success | ||
# When a user submits a form to delete their account | ||
def account_delete_submitted(success:) | ||
track_event('Account Delete submitted', success: success) | ||
end | ||
|
||
# @identity.idp.event_name Account Delete visited | ||
# When a user visits the page to delete their account | ||
def account_delete_visited | ||
track_event('Account Delete visited') | ||
end | ||
|
||
# @identity.idp.event_name Account Deletion Requested | ||
# @param [String] request_came_from the controller/action the request came from | ||
# When a user deletes their account | ||
def account_deletion(request_came_from:) | ||
track_event('Account Deletion Requested', request_came_from: request_came_from) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.