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 @@ -32,7 +32,7 @@ def error
end

def delete
analytics.track_event(Analytics::USER_REGISTRATION_PIV_CAC_DISABLED)
analytics.user_registration_piv_cac_disabled
remove_piv_cac
clear_piv_cac_information
create_user_event(:piv_cac_disabled)
Expand All @@ -55,8 +55,7 @@ def submit_new_piv_cac

def track_piv_cac_setup_visit
mfa_user = MfaContext.new(current_user)
analytics.track_event(
Analytics::USER_REGISTRATION_PIV_CAC_SETUP_VISIT,
analytics.user_registration_piv_cac_setup_visit(
enabled_mfa_methods_count: mfa_user.enabled_mfa_methods_count,
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users/piv_cac_login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def two_factor_authentication_method
end

def render_prompt
analytics.track_event(Analytics::USER_REGISTRATION_PIV_CAC_SETUP_VISIT)
analytics.user_registration_piv_cac_setup_visit
@presenter = PivCacAuthenticationLoginPresenter.new(piv_cac_login_form, url_options)
render :new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def decline
private

def render_prompt
analytics.track_event(Analytics::USER_REGISTRATION_PIV_CAC_SETUP_VISIT)
analytics.user_registration_piv_cac_setup_visit
render :prompt
end

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/users/webauthn_setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def new
remember_device_default: remember_device_default,
platform_authenticator: @platform_authenticator,
)
analytics.track_event(Analytics::WEBAUTHN_SETUP_VISIT, result.to_h)
analytics.webauthn_setup_visit(**result.to_h)
save_challenge_in_session
@exclude_credentials = exclude_credentials
flash_error(result.errors) unless result.success?
Expand Down Expand Up @@ -116,8 +116,7 @@ def handle_failed_delete

def track_delete(success)
counts_hash = MfaContext.new(current_user.reload).enabled_two_factor_configuration_counts_hash
analytics.track_event(
Analytics::WEBAUTHN_DELETED,
analytics.webauthn_deleted(
success: success,
mfa_method_counts: counts_hash,
pii_like_keypaths: [[:mfa_method_counts, :phone]],
Expand Down
6 changes: 0 additions & 6 deletions app/services/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,5 @@ def session_started_at
USER_REGISTRATION_EMAIL = 'User Registration: Email Submitted'
USER_REGISTRATION_EMAIL_CONFIRMATION = 'User Registration: Email Confirmation'
USER_REGISTRATION_EMAIL_CONFIRMATION_RESEND = 'User Registration: Email Confirmation requested due to invalid token'
USER_REGISTRATION_PERSONAL_KEY_VISIT = 'User Registration: personal key visited'
USER_REGISTRATION_PIV_CAC_DISABLED = 'User Registration: piv cac disabled'
USER_REGISTRATION_PIV_CAC_SETUP_VISIT = 'User Registration: piv cac setup visited'
VENDOR_OUTAGE = 'Vendor Outage'
WEBAUTHN_DELETED = 'WebAuthn Deleted'
WEBAUTHN_SETUP_VISIT = 'WebAuthn Setup Visited'
end
# rubocop:enable Layout/LineLength
60 changes: 60 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,20 @@ def user_registration_2fa_setup(
)
end

# Tracks when user's piv cac is disabled
def user_registration_piv_cac_disabled
track_event('User Registration: piv cac disabled')
end

# Tracks when user's piv cac setup
# @param [Integer] enabled_mfa_methods_count
def user_registration_piv_cac_setup_visit(**extra)
track_event(
'User Registration: piv cac setup visited',
**extra,
)
end

# Tracks when user visits Suggest Another MFA Page
def user_registration_suggest_another_mfa_notice_visited
track_event('User Registration: Suggest Another MFA Notice visited')
Expand All @@ -1923,6 +1937,52 @@ def user_registration_2fa_setup_visit
track_event('User Registration: 2FA Setup visited')
end

# @param [String] redirect_from
# @param [Hash] vendor_status
# Tracks when vendor has outage
def vendor_outage(
redirect_from:,
vendor_status:,
**extra
)
track_event(
'Vendor Outage',
redirect_from: redirect_from,
vendor_status: vendor_status,
**extra,
)
end

# @param [Boolean] success
# @param [Integer] mfa_method_counts
# Tracks when WebAuthn is deleted
def webauthn_deleted(success:, mfa_method_counts:, pii_like_keypaths:, **extra)
track_event(
'WebAuthn Deleted',
success: success,
mfa_method_counts: mfa_method_counts,
pii_like_keypaths: pii_like_keypaths,
**extra,
)
end

# @param [Hash] platform_authenticator
# @param [Hash] errors
# @param [Integer] enabled_mfa_methods_count
# @param [Boolean] success
# Tracks when WebAuthn setup is visited
def webauthn_setup_visit(platform_authenticator:, errors:, enabled_mfa_methods_count:, success:,
**extra)
track_event(
'WebAuthn Setup Visited',
platform_authenticator: platform_authenticator,
errors: errors,
enabled_mfa_methods_count: enabled_mfa_methods_count,
success: success,
**extra,
)
end

# Tracks when user visits enter email page
def user_registration_enter_email_visit
track_event('User Registration: enter email visited')
Expand Down
5 changes: 2 additions & 3 deletions app/services/vendor_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def outage_message
def track_event(analytics)
raise ArgumentError, 'analytics instance required' if analytics.nil?

tracking_data = {
analytics.vendor_outage(
vendor_status: {
acuant: IdentityConfig.store.vendor_status_acuant,
lexisnexis_instant_verify: IdentityConfig.store.vendor_status_lexisnexis_instant_verify,
Expand All @@ -89,8 +89,7 @@ def track_event(analytics)
voice: IdentityConfig.store.vendor_status_voice,
},
redirect_from: from,
}
analytics.track_event(Analytics::VENDOR_OUTAGE, tracking_data)
)
end

private
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/users/webauthn_setup_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

expect(@analytics).to receive(:track_event).
with(
Analytics::WEBAUTHN_SETUP_VISIT,
'WebAuthn Setup Visited',
platform_authenticator: false,
errors: {},
enabled_mfa_methods_count: 0,
Expand Down Expand Up @@ -120,7 +120,7 @@
mfa_method_counts: { auth_app: 1, phone: 1 },
pii_like_keypaths: [[:mfa_method_counts, :phone]],
}
expect(@analytics).to receive(:track_event).with(Analytics::WEBAUTHN_DELETED, result)
expect(@analytics).to receive(:track_event).with('WebAuthn Deleted', result)

delete :delete, params: { id: webauthn_configuration.id }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/services/vendor_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
it 'logs status of all vendors' do
analytics = FakeAnalytics.new
expect(analytics).to receive(:track_event).with(
Analytics::VENDOR_OUTAGE,
'Vendor Outage',
redirect_from: from,
vendor_status: VendorStatus::ALL_VENDORS.index_with do |_vendor|
satisfy { |status| IdentityConfig::VENDOR_STATUS_OPTIONS.include?(status) }
Expand Down