From 9c3e02020260a54911f47be338510208e4ff6b0b Mon Sep 17 00:00:00 2001 From: Douglas Price Date: Tue, 14 May 2024 11:18:38 -0400 Subject: [PATCH 1/2] LG-13317: Log 10-digit OTP A/B test params for OTP sends [skip changelog] Co-authored-by: Mitchell Henke --- app/services/analytics_events.rb | 3 +++ app/services/idv/send_phone_confirmation_otp.rb | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index b874bbe0812..cd2b15c6291 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -2851,6 +2851,7 @@ def idv_phone_confirmation_otp_rate_limit_sends( # @param [Idv::ProofingComponentsLogging] proofing_components User's current proofing components # @param [String,nil] active_profile_idv_level ID verification level of user's active profile. # @param [String,nil] pending_profile_idv_level ID verification level of user's pending profile. + # @param [Hash, nil] ab_tests data for ongoing A/B tests # The user resent an OTP during the IDV phone step def idv_phone_confirmation_otp_resent( success:, @@ -2864,6 +2865,7 @@ def idv_phone_confirmation_otp_resent( proofing_components: nil, active_profile_idv_level: nil, pending_profile_idv_level: nil, + ab_tests: nil, **extra ) track_event( @@ -2879,6 +2881,7 @@ def idv_phone_confirmation_otp_resent( proofing_components: proofing_components, active_profile_idv_level: active_profile_idv_level, pending_profile_idv_level: pending_profile_idv_level, + ab_tests: ab_tests, **extra, ) end diff --git a/app/services/idv/send_phone_confirmation_otp.rb b/app/services/idv/send_phone_confirmation_otp.rb index 036ed2e6672..848b0dde011 100644 --- a/app/services/idv/send_phone_confirmation_otp.rb +++ b/app/services/idv/send_phone_confirmation_otp.rb @@ -112,6 +112,11 @@ def extra_analytics_attributes phone_fingerprint: Pii::Fingerprinter.fingerprint(parsed_phone.e164), rate_limit_exceeded: rate_limit_exceeded?, telephony_response: @telephony_response, + ab_tests: { + AbTests::IDV_TEN_DIGIT_OTP.experiment_name => { + bucket: bucket, + }, + }, } end From 9b209ccd4c98d2ddc4425c914f9cd4946ccab475 Mon Sep 17 00:00:00 2001 From: Douglas Price Date: Tue, 14 May 2024 12:16:30 -0400 Subject: [PATCH 2/2] only include ab test data if enabled --- app/services/idv/send_phone_confirmation_otp.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/services/idv/send_phone_confirmation_otp.rb b/app/services/idv/send_phone_confirmation_otp.rb index 848b0dde011..1770541eaba 100644 --- a/app/services/idv/send_phone_confirmation_otp.rb +++ b/app/services/idv/send_phone_confirmation_otp.rb @@ -105,19 +105,23 @@ def otp_sent_response end def extra_analytics_attributes - { + attributes = { otp_delivery_preference: delivery_method, country_code: parsed_phone.country, area_code: parsed_phone.area_code, phone_fingerprint: Pii::Fingerprinter.fingerprint(parsed_phone.e164), rate_limit_exceeded: rate_limit_exceeded?, telephony_response: @telephony_response, - ab_tests: { + } + if IdentityConfig.store.ab_testing_idv_ten_digit_otp_enabled + attributes[:ab_tests] = { AbTests::IDV_TEN_DIGIT_OTP.experiment_name => { bucket: bucket, }, - }, - } + } + end + + attributes end def parsed_phone