Use AWS data instead of Salesforce territory to activate Heap
We discovered that we didn't need the Salesforce sales territory data to determine if an account requires GDPR compliance or not. Instead, we can use the existing billing code data plus the AWS regions. This removes the previous dependency on Salesforce territory data, adds the dependency on AWS region codes, and modifies specs and callsites accordingly. refs FOO-3253 flag=send_usage_metrics test plan=specs pass Change-Id: If8710ec59704eed6a5fbe8e7e007119842c47a11 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/306495 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Xander Moffatt <xmoffatt@instructure.com> Reviewed-by: Charley Kline <ckline@instructure.com> QA-Review: Charley Kline <ckline@instructure.com> Product-Review: Charley Kline <ckline@instructure.com>
This commit is contained in:
parent
488496ca46
commit
4814f47619
|
@ -74,7 +74,7 @@ module FeatureFlags
|
|||
end
|
||||
|
||||
def self.usage_metrics_allowed_hook(context)
|
||||
UsageMetricsPredicate.new(context).call
|
||||
UsageMetricsPredicate.new(context, Shard.current.database_server.config[:region]).call
|
||||
end
|
||||
|
||||
def self.analytics_2_after_state_change_hook(_user, context, _old_state, _new_state)
|
||||
|
|
|
@ -20,12 +20,13 @@
|
|||
|
||||
module FeatureFlags
|
||||
class UsageMetricsPredicate
|
||||
def initialize(context)
|
||||
def initialize(context, region)
|
||||
@context = context
|
||||
@region = region
|
||||
end
|
||||
|
||||
def call
|
||||
overridden? || (us_billing_code? && domestic_territory?)
|
||||
overridden? || (us_billing_code? && in_approved_us_aws_region?)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -35,18 +36,11 @@ module FeatureFlags
|
|||
end
|
||||
|
||||
def us_billing_code?
|
||||
verify_external_integration? "salesforce_billing_country_code", "US"
|
||||
@context&.root_account&.external_integration_keys&.find_by(key_type: "salesforce_billing_country_code")&.key_value == "US"
|
||||
end
|
||||
|
||||
# Calling out here that `key_type: "salesforce_territory_region")&.key_value == "domestic"`
|
||||
# is totally made up right now and won't resolve anything until we add salesforce
|
||||
# data with these values
|
||||
def domestic_territory?
|
||||
verify_external_integration? "salesforce_territory_region", "domestic"
|
||||
end
|
||||
|
||||
def verify_external_integration?(key, value)
|
||||
@context&.root_account&.external_integration_keys&.find_by(key_type: key)&.key_value == value
|
||||
def in_approved_us_aws_region?
|
||||
["us-east-1", "us-west-2"].include? @region
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,8 @@ describe FeatureFlags::UsageMetricsPredicate do
|
|||
let(:external_integration_keys) { nil }
|
||||
let(:root_account) { double(settings: settings, external_integration_keys: external_integration_keys) }
|
||||
let(:context) { double(root_account: root_account) }
|
||||
let(:predicate) { FeatureFlags::UsageMetricsPredicate.new context }
|
||||
let(:region) { nil }
|
||||
let(:predicate) { FeatureFlags::UsageMetricsPredicate.new context, region }
|
||||
|
||||
it "defaults to false" do
|
||||
expect(predicate.call).to be_falsey
|
||||
|
@ -37,13 +38,13 @@ describe FeatureFlags::UsageMetricsPredicate do
|
|||
end
|
||||
end
|
||||
|
||||
describe "when in domestic territory and us billing" do
|
||||
describe "when US billing country and approved US aws region" do
|
||||
let(:external_integration_keys) do
|
||||
keys = double
|
||||
allow(keys).to receive(:find_by).with({ key_type: "salesforce_billing_country_code" }) { double(key_value: "US") }
|
||||
allow(keys).to receive(:find_by).with({ key_type: "salesforce_territory_region" }) { double(key_value: "domestic") }
|
||||
keys
|
||||
end
|
||||
let(:region) { "us-east-1" }
|
||||
|
||||
it "returns true" do
|
||||
expect(predicate.call).to be_truthy
|
||||
|
|
Loading…
Reference in New Issue