Skip to content

Commit

Permalink
fix: handle consent management configuration fallback for gcm (#4355)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Jan 31, 2024
1 parent f6396f9 commit 7e47ee9
Show file tree
Hide file tree
Showing 2 changed files with 458 additions and 26 deletions.
51 changes: 25 additions & 26 deletions processor/consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,42 @@ func (proc *Handle) getConsentFilteredDestinations(event types.SingularEventT, d
}

return lo.Filter(destinations, func(dest backendconfig.DestinationT, _ int) bool {
// This field differentiates legacy and generic consent management
if consentManagementInfo.Provider != "" {
// Generic consent management
// Generic consent management
if cmpData := proc.getGCMData(dest.ID, consentManagementInfo.Provider); len(cmpData.Consents) > 0 {

if cmpData := proc.getGCMData(dest.ID, consentManagementInfo.Provider); len(cmpData.Consents) > 0 {
finalResolutionStrategy := consentManagementInfo.ResolutionStrategy

finalResolutionStrategy := consentManagementInfo.ResolutionStrategy

// For custom provider, the resolution strategy is to be picked from the destination config
if consentManagementInfo.Provider == "custom" {
finalResolutionStrategy = cmpData.ResolutionStrategy
}
// For custom provider, the resolution strategy is to be picked from the destination config
if consentManagementInfo.Provider == "custom" {
finalResolutionStrategy = cmpData.ResolutionStrategy
}

switch finalResolutionStrategy {
// The user must consent to at least one of the configured consents in the destination
case "or":
return !lo.Every(consentManagementInfo.DeniedConsentIDs, cmpData.Consents)
switch finalResolutionStrategy {
// The user must consent to at least one of the configured consents in the destination
case "or":
return !lo.Every(consentManagementInfo.DeniedConsentIDs, cmpData.Consents)

// The user must consent to all of the configured consents in the destination
default: // "and"
return len(lo.Intersect(cmpData.Consents, consentManagementInfo.DeniedConsentIDs)) == 0
}
// The user must consent to all of the configured consents in the destination
default: // "and"
return len(lo.Intersect(cmpData.Consents, consentManagementInfo.DeniedConsentIDs)) == 0
}
return true
}

// Legacy consent management

// If the destination has oneTrustCookieCategories, returns false if any of the oneTrustCategories are present in deniedCategories
if oneTrustCategories := proc.getOneTrustConsentData(dest.ID); len(oneTrustCategories) > 0 {
return len(lo.Intersect(oneTrustCategories, consentManagementInfo.DeniedConsentIDs)) == 0
if consentManagementInfo.Provider == "" || consentManagementInfo.Provider == "oneTrust" {
// If the destination has oneTrustCookieCategories, returns false if any of the oneTrustCategories are present in deniedCategories
if oneTrustCategories := proc.getOneTrustConsentData(dest.ID); len(oneTrustCategories) > 0 {
return len(lo.Intersect(oneTrustCategories, consentManagementInfo.DeniedConsentIDs)) == 0
}
}

// If the destination has ketchConsentPurposes, returns false if all ketchPurposes are present in deniedCategories
if ketchPurposes := proc.getKetchConsentData(dest.ID); len(ketchPurposes) > 0 {
return !lo.Every(consentManagementInfo.DeniedConsentIDs, ketchPurposes)
if consentManagementInfo.Provider == "" || consentManagementInfo.Provider == "ketch" {
// If the destination has ketchConsentPurposes, returns false if all ketchPurposes are present in deniedCategories
if ketchPurposes := proc.getKetchConsentData(dest.ID); len(ketchPurposes) > 0 {
return !lo.Every(consentManagementInfo.DeniedConsentIDs, ketchPurposes)
}
}

return true
})
}
Expand Down

0 comments on commit 7e47ee9

Please sign in to comment.