Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Config Backwards Compatibility: Account GDPR/CCPA Integration Enabled #3155

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 1 addition & 17 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,11 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r
}}
}
}
usingGDPRChannelEnabled := useGDPRChannelEnabled(account)
usingCCPAChannelEnabled := useCCPAChannelEnabled(account)

if usingGDPRChannelEnabled {
me.RecordAccountGDPRChannelEnabledWarning(accountID)
}
if usingCCPAChannelEnabled {
me.RecordAccountCCPAChannelEnabledWarning(accountID)
}
for _, purposeName := range deprecatedPurposeFields {
me.RecordAccountGDPRPurposeWarning(accountID, purposeName)
}
if len(deprecatedPurposeFields) > 0 || usingGDPRChannelEnabled || usingCCPAChannelEnabled {
if len(deprecatedPurposeFields) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know that this line gets removed in another Remove Config PR, but it leaves me wondering if the RecordAccountUpgradeStatus metric should be removed as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 merged with master to resolve conflicts and removed RecordAccountUpgradeStatus in the process.

me.RecordAccountUpgradeStatus(accountID)
}

Expand Down Expand Up @@ -257,14 +249,6 @@ func ConvertGDPREnforcePurposeFields(config []byte) (newConfig []byte, err error
return newConfig, nil, deprecatedPurposeFields
}

func useGDPRChannelEnabled(account *config.Account) bool {
return account.GDPR.ChannelEnabled.IsSet() && !account.GDPR.IntegrationEnabled.IsSet()
}

func useCCPAChannelEnabled(account *config.Account) bool {
return account.CCPA.ChannelEnabled.IsSet() && !account.CCPA.IntegrationEnabled.IsSet()
}

// deprecateEventsEnabledField is responsible for ensuring backwards compatibility of "events_enabled" field.
// This function favors "events.enabled" field over deprecated "events_enabled" field, if values for both are set.
// If only deprecated "events_enabled" field is set then it sets the same value to "events.enabled" field.
Expand Down
74 changes: 0 additions & 74 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,56 +393,6 @@ func TestConvertGDPREnforcePurposeFields(t *testing.T) {
}
}

func TestGdprCcpaChannelEnabledMetrics(t *testing.T) {
cfg := &config.Configuration{}
fetcher := &mockAccountFetcher{}
assert.NoError(t, cfg.MarshalAccountDefaults())

testCases := []struct {
name string
givenAccountID string
givenMetric string
expectedMetricCount int
}{
{
name: "ChannelEnabledGDPR",
givenAccountID: "gdpr_channel_enabled_acct",
givenMetric: "RecordAccountGDPRChannelEnabledWarning",
expectedMetricCount: 1,
},
{
name: "ChannelEnabledCCPA",
givenAccountID: "ccpa_channel_enabled_acct",
givenMetric: "RecordAccountCCPAChannelEnabledWarning",
expectedMetricCount: 1,
},
{
name: "NotChannelEnabledCCPA",
givenAccountID: "valid_acct",
givenMetric: "RecordAccountCCPAChannelEnabledWarning",
expectedMetricCount: 0,
},
{
name: "NotChannelEnabledGDPR",
givenAccountID: "valid_acct",
givenMetric: "RecordAccountGDPRChannelEnabledWarning",
expectedMetricCount: 0,
},
}

for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
metrics := &metrics.MetricsEngineMock{}
metrics.Mock.On(test.givenMetric, mock.Anything, mock.Anything).Return()
metrics.Mock.On("RecordAccountUpgradeStatus", mock.Anything, mock.Anything).Return()

_, _ = GetAccount(context.Background(), cfg, fetcher, test.givenAccountID, metrics)

metrics.AssertNumberOfCalls(t, test.givenMetric, test.expectedMetricCount)
})
}
}

func TestGdprPurposeWarningMetrics(t *testing.T) {
cfg := &config.Configuration{}
fetcher := &mockAccountFetcher{}
Expand Down Expand Up @@ -537,12 +487,6 @@ func TestAccountUpgradeStatusGetAccount(t *testing.T) {
givenMetrics []string
expectedMetricCount int
}{
{
name: "MultipleDeprecatedConfigs",
givenAccountIDs: []string{"gdpr_channel_enabled_deprecated_purpose_acct"},
givenMetrics: []string{"RecordAccountGDPRChannelEnabledWarning", "RecordAccountGDPRPurposeWarning"},
expectedMetricCount: 1,
},
{
name: "ZeroDeprecatedConfigs",
givenAccountIDs: []string{"valid_acct"},
Expand All @@ -555,24 +499,6 @@ func TestAccountUpgradeStatusGetAccount(t *testing.T) {
givenMetrics: []string{"RecordAccountGDPRPurposeWarning"},
expectedMetricCount: 1,
},
{
name: "OneDeprecatedConfigGDPRChannelEnabled",
givenAccountIDs: []string{"gdpr_channel_enabled_acct"},
givenMetrics: []string{"RecordAccountGDPRChannelEnabledWarning"},
expectedMetricCount: 1,
},
{
name: "OneDeprecatedConfigCCPAChannelEnabled",
givenAccountIDs: []string{"ccpa_channel_enabled_acct"},
givenMetrics: []string{"RecordAccountCCPAChannelEnabledWarning"},
expectedMetricCount: 1,
},
{
name: "MultipleAccountsWithDeprecatedConfigs",
givenAccountIDs: []string{"gdpr_channel_enabled_acct", "gdpr_deprecated_purpose1"},
givenMetrics: []string{"RecordAccountGDPRChannelEnabledWarning", "RecordAccountGDPRPurposeWarning"},
expectedMetricCount: 2,
},
}

for _, test := range testCases {
Expand Down
18 changes: 4 additions & 14 deletions config/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ type CookieSync struct {

// AccountCCPA represents account-specific CCPA configuration
type AccountCCPA struct {
Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"`
IntegrationEnabled AccountChannel `mapstructure:"integration_enabled" json:"integration_enabled"`
ChannelEnabled AccountChannel `mapstructure:"channel_enabled" json:"channel_enabled"`
Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"`
ChannelEnabled AccountChannel `mapstructure:"channel_enabled" json:"channel_enabled"`
}

type AccountPriceFloors struct {
Expand Down Expand Up @@ -95,17 +94,14 @@ func (pf *AccountPriceFloors) IsAdjustForBidAdjustmentEnabled() bool {
func (a *AccountCCPA) EnabledForChannelType(channelType ChannelType) *bool {
if channelEnabled := a.ChannelEnabled.GetByChannelType(channelType); channelEnabled != nil {
return channelEnabled
} else if integrationEnabled := a.IntegrationEnabled.GetByChannelType(channelType); integrationEnabled != nil {
return integrationEnabled
}
return a.Enabled
}

// AccountGDPR represents account-specific GDPR configuration
type AccountGDPR struct {
Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"`
IntegrationEnabled AccountChannel `mapstructure:"integration_enabled" json:"integration_enabled"`
ChannelEnabled AccountChannel `mapstructure:"channel_enabled" json:"channel_enabled"`
Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"`
ChannelEnabled AccountChannel `mapstructure:"channel_enabled" json:"channel_enabled"`
// Array of basic enforcement vendors that is used to create the hash table so vendor names can be instantly accessed
BasicEnforcementVendors []string `mapstructure:"basic_enforcement_vendors" json:"basic_enforcement_vendors"`
BasicEnforcementVendorsMap map[string]struct{}
Expand All @@ -130,8 +126,6 @@ type AccountGDPR struct {
func (a *AccountGDPR) EnabledForChannelType(channelType ChannelType) *bool {
if channelEnabled := a.ChannelEnabled.GetByChannelType(channelType); channelEnabled != nil {
return channelEnabled
} else if integrationEnabled := a.IntegrationEnabled.GetByChannelType(channelType); integrationEnabled != nil {
return integrationEnabled
}
return a.Enabled
}
Expand Down Expand Up @@ -299,10 +293,6 @@ func (m AccountModules) ModuleConfig(id string) (json.RawMessage, error) {
return m[vendor][module], nil
}

func (a *AccountChannel) IsSet() bool {
return a.AMP != nil || a.App != nil || a.Video != nil || a.Web != nil || a.DOOH != nil
}

type AccountPrivacy struct {
AllowActivities *AllowActivities `mapstructure:"allowactivities" json:"allowactivities"`
IPv6Config IPv6 `mapstructure:"ipv6" json:"ipv6"`
Expand Down
Loading