Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ class BackupCodeVerificationController < ApplicationController
before_action :check_sp_required_mfa_bypass

def show
analytics.track_event(
Analytics::MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT, context: context
)
analytics.multi_factor_auth_enter_backup_code_visit(context: context)
@presenter = TwoFactorAuthCode::BackupCodePresenter.new(
view: view_context,
data: { current_user: current_user },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ class PersonalKeyVerificationController < ApplicationController
before_action :check_personal_key_enabled

def show
analytics.track_event(
Analytics::MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT, context: context
)
analytics.multi_factor_auth_enter_personal_key_visit(context: context)
@presenter = TwoFactorAuthCode::PersonalKeyPresenter.new
@personal_key_form = PersonalKeyForm.new(current_user)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PivCacVerificationController < ApplicationController
before_action :reset_attempt_count_if_user_no_longer_locked_out, only: :show

def show
analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, analytics_properties)
analytics.multi_factor_auth_enter_piv_cac(**analytics_properties)
if params[:token]
process_token
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def show
@presenter = presenter_for_two_factor_authentication_method
return unless FeatureManagement.prefill_otp_codes?
@code = ROTP::TOTP.new(current_user.auth_app_configurations.first.otp_secret_key).now
analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_TOTP_VISIT)
analytics.multi_factor_auth_enter_totp_visit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

context is a required parameter for multi_factor_auth_enter_totp_visit, so this errors.

ArgumentError at /login/two_factor/authenticator
missing keyword: :context

Fortunately, this code is guarded by FeatureManagement.prefill_otp_codes?, so it's really only an issue in local development.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Although... now that I think of it, we probably want to be logging this event in all cases, not only prefill_otp_codes? 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Follow-up at #6522

end

def create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class WebauthnVerificationController < ApplicationController

def show
save_challenge_in_session
analytics.track_event(Analytics::MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT, analytics_properties)
analytics.multi_factor_auth_enter_webauthn_visit(**analytics_properties)
@presenter = presenter_for_two_factor_authentication_method
end

Expand Down
5 changes: 0 additions & 5 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ def session_started_at
LOGOUT_INITIATED = 'Logout Initiated'
MULTI_FACTOR_AUTH = 'Multi-Factor Authentication'
MULTI_FACTOR_AUTH_ENTER_OTP_VISIT = 'Multi-Factor Authentication: enter OTP visited'
MULTI_FACTOR_AUTH_ENTER_PIV_CAC = 'Multi-Factor Authentication: enter PIV CAC visited'
MULTI_FACTOR_AUTH_ENTER_TOTP_VISIT = 'Multi-Factor Authentication: enter TOTP visited'
MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT = 'Multi-Factor Authentication: enter personal key visited'
MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT = 'Multi-Factor Authentication: enter backup code visited'
MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT = 'Multi-Factor Authentication: enter webAuthn authentication visited'
MULTI_FACTOR_AUTH_MAX_ATTEMPTS = 'Multi-Factor Authentication: max attempts reached'
MULTI_FACTOR_AUTH_OPTION_LIST = 'Multi-Factor Authentication: option list'
MULTI_FACTOR_AUTH_OPTION_LIST_VISIT = 'Multi-Factor Authentication: option list visited'
Expand Down
66 changes: 66 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,72 @@ def idv_start_over(
)
end

# @param ["authentication","reauthentication","confirmation"] context user session context
# User visited the page to enter a backup code as their MFA
def multi_factor_auth_enter_backup_code_visit(context:, **extra)
track_event(
'Multi-Factor Authentication: enter backup code visited',
context: context,
**extra,
)
end

# @param ["authentication","reauthentication","confirmation"] context user session context
# User visited the page to enter a personal key as their mfa (legacy flow)
def multi_factor_auth_enter_personal_key_visit(context:, **extra)
track_event(
'Multi-Factor Authentication: enter personal key visited',
context: context,
**extra,
)
end

# @param ["authentication","reauthentication","confirmation"] context user session context
# @param ["piv_cac"] multi_factor_auth_method
# @param [Integer, nil] piv_cac_configuration_id PIV/CAC configuration database ID
# User used a PIV/CAC as their mfa
def multi_factor_auth_enter_piv_cac(
context:,
multi_factor_auth_method:,
piv_cac_configuration_id:,
**extra
)
track_event(
'Multi-Factor Authentication: enter PIV CAC visited',
context: context,
multi_factor_auth_method: multi_factor_auth_method,
piv_cac_configuration_id: piv_cac_configuration_id,
**extra,
)
end

# @param ["authentication","reauthentication","confirmation"] context user session context
# User visited the page to enter a TOTP as their mfa
def multi_factor_auth_enter_totp_visit(context:, **extra)
track_event('Multi-Factor Authentication: enter TOTP visited', context: context, **extra)
end

# @param ["authentication","reauthentication","confirmation"] context user session context
# @param ["webauthn","webauthn_platform"] multi_factor_auth_method which webauthn method was used,
# webauthn means a roaming authenticator like a yubikey, webauthn_platform means a platform
# authenticator like face or touch ID
# @param [Integer, nil] webauthn_configuration_id webauthn database ID
# User visited the page to authenticate with webauthn (yubikey, face ID or touch ID)
def multi_factor_auth_enter_webauthn_visit(
context:,
multi_factor_auth_method:,
webauthn_configuration_id:,
**extra
)
track_event(
'Multi-Factor Authentication: enter webAuthn authentication visited',
context: context,
multi_factor_auth_method: multi_factor_auth_method,
webauthn_configuration_id: webauthn_configuration_id,
**extra,
)
end

# User has visited the page that lets them confirm if they want a new personal key
def profile_personal_key_visit
track_event('Profile: Visited new personal key')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
analytics_hash = { context: 'authentication' }

expect(@analytics).to receive(:track_event).
with(Analytics::MULTI_FACTOR_AUTH_ENTER_BACKUP_CODE_VISIT, analytics_hash)
with('Multi-Factor Authentication: enter backup code visited', analytics_hash)

get :show
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
analytics_hash = { context: 'authentication' }

expect(@analytics).to receive(:track_event).
with(Analytics::MULTI_FACTOR_AUTH_ENTER_PERSONAL_KEY_VISIT, analytics_hash)
with('Multi-Factor Authentication: enter personal key visited', analytics_hash)

get :show
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
}

expect(@analytics).to receive(:track_event).
with(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, attributes)
with('Multi-Factor Authentication: enter PIV CAC visited', attributes)

submit_attributes = {
success: true,
Expand Down Expand Up @@ -181,7 +181,7 @@
}

expect(@analytics).to receive(:track_event).
with(Analytics::MULTI_FACTOR_AUTH_ENTER_PIV_CAC, attributes)
with('Multi-Factor Authentication: enter PIV CAC visited', attributes)

submit_attributes = {
success: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
result = { context: 'authentication',
multi_factor_auth_method: 'webauthn_platform', webauthn_configuration_id: nil }
expect(@analytics).to have_received(:track_event).with(
Analytics::MULTI_FACTOR_AUTH_ENTER_WEBAUTHN_VISIT,
'Multi-Factor Authentication: enter webAuthn authentication visited',
result,
)
end
Expand Down