Skip to content

Commit

Permalink
LG-15056 | Socure A/B test (#11544)
Browse files Browse the repository at this point in the history
changelog: Upcoming Features, Socure, Model Socure shadow mode as an A/B test
  • Loading branch information
n1zyy authored Nov 26, 2024
1 parent 61aa8f9 commit 9d8431d
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 3 deletions.
13 changes: 12 additions & 1 deletion app/jobs/resolution_proofing_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def perform(
timing: timer.results,
)

if IdentityConfig.store.idv_socure_shadow_mode_enabled
if use_shadow_mode?(user:)
SocureShadowModeProofingJob.perform_later(
document_capture_session_result_id: document_capture_session&.result_id,
encrypted_arguments:,
Expand All @@ -85,6 +85,17 @@ def perform(
end
end

def use_shadow_mode?(user:)
IdentityConfig.store.idv_socure_shadow_mode_enabled &&
AbTests::SOCURE_IDV_SHADOW_MODE.bucket(
request: nil,
service_provider: nil,
session: nil,
user:,
user_session: nil,
) == :shadow_mode_enabled
end

private

# @return [CallbackLogData]
Expand Down
1 change: 1 addition & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ socure_docv_webhook_secret_key: ''
socure_docv_webhook_secret_key_queue: '[]'
socure_idplus_api_key: ''
socure_idplus_base_url: ''
socure_idplus_shadow_mode_percent: 0
socure_idplus_timeout_in_seconds: 5
socure_reason_code_api_key: ''
socure_reason_code_base_url: ''
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/ab_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ def self.all
IdentityConfig.store.recommend_webauthn_platform_for_sms_ab_test_authentication_percent,
},
).freeze

SOCURE_IDV_SHADOW_MODE = AbTest.new(
experiment_name: 'Socure shadow mode',
should_log: ['IdV: doc auth verify proofing results'].to_set,
buckets: {
shadow_mode_enabled: IdentityConfig.store.socure_idplus_shadow_mode_percent,
},
).freeze
end
2 changes: 1 addition & 1 deletion lib/ab_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def initialize(
# @param [ActionDispatch::Request] request
# @param [String,nil] service_provider Issuer string for the service provider associated with
# the current session.
# @params [Hash] session
# @param [Hash] session
# @param [User] user
# @param [Hash] user_session
def bucket(request:, service_provider:, session:, user:, user_session:)
Expand Down
1 change: 1 addition & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def self.store
config.add(:socure_docv_webhook_secret_key, type: :string)
config.add(:socure_idplus_api_key, type: :string)
config.add(:socure_idplus_base_url, type: :string)
config.add(:socure_idplus_shadow_mode_percent, type: :integer)
config.add(:socure_idplus_timeout_in_seconds, type: :integer)
config.add(:socure_reason_code_api_key, type: :string)
config.add(:socure_reason_code_base_url, type: :string)
Expand Down
40 changes: 40 additions & 0 deletions spec/config/initializers/ab_tests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,44 @@
end
end
end

describe 'SOCURE_IDV_SHADOW_MODE' do
let(:user) { create(:user) }

subject(:bucket) do
AbTests::SOCURE_IDV_SHADOW_MODE.bucket(
request: nil,
service_provider: nil,
session: nil,
user:,
user_session: nil,
)
end

before do
allow(IdentityConfig.store).to receive(
:socure_idplus_shadow_mode_percent,
).and_return(0)
reload_ab_tests
end

context 'when the A/B test is disabled' do
it 'does not return a bucket' do
expect(bucket).to be_nil
end
end

context 'when the A/B test is enabled' do
before do
allow(IdentityConfig.store).to receive(
:socure_idplus_shadow_mode_percent,
).and_return(100)
reload_ab_tests
end

it 'returns a bucket' do
expect(bucket).to eq :shadow_mode_enabled
end
end
end
end
2 changes: 1 addition & 1 deletion spec/jobs/resolution_proofing_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
context 'socure shadow mode' do
context 'turned on' do
before do
allow(IdentityConfig.store).to receive(:idv_socure_shadow_mode_enabled).and_return(true)
allow(instance).to receive(:use_shadow_mode?).and_return(true)
end

it 'schedules a SocureShadowModeProofingJob' do
Expand Down

0 comments on commit 9d8431d

Please sign in to comment.