Skip to content

Commit ef57ce6

Browse files
authored
fix: handle consent management filtering per connection (#5718)
1 parent 670bee0 commit ef57ce6

File tree

4 files changed

+992
-692
lines changed

4 files changed

+992
-692
lines changed

processor/consent.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ type GenericConsentManagementProviderConfig struct {
3737
Filters and returns destinations based on the consents configured for the destination and the user consents present in the event.
3838
3939
Supports legacy and generic consent management.
40+
For GCM based filtering, uses source and destination IDs to fetch the appropriate GCM data from the config.
4041
*/
41-
func (proc *Handle) getConsentFilteredDestinations(event types.SingularEventT, destinations []backendconfig.DestinationT) []backendconfig.DestinationT {
42+
func (proc *Handle) getConsentFilteredDestinations(event types.SingularEventT, sourceID string, destinations []backendconfig.DestinationT) []backendconfig.DestinationT {
4243
// If the event does not have denied consent IDs, do not filter any destinations
4344
consentManagementInfo, err := getConsentManagementInfo(event)
4445
if err != nil {
@@ -52,7 +53,7 @@ func (proc *Handle) getConsentFilteredDestinations(event types.SingularEventT, d
5253

5354
return lo.Filter(destinations, func(dest backendconfig.DestinationT, _ int) bool {
5455
// Generic consent management
55-
if cmpData := proc.getGCMData(dest.ID, consentManagementInfo.Provider); len(cmpData.Consents) > 0 {
56+
if cmpData := proc.getGCMData(sourceID, dest.ID, consentManagementInfo.Provider); len(cmpData.Consents) > 0 {
5657

5758
finalResolutionStrategy := consentManagementInfo.ResolutionStrategy
5859

@@ -103,17 +104,17 @@ func (proc *Handle) getKetchConsentData(destinationID string) []string {
103104
return proc.config.ketchConsentCategoriesMap[destinationID]
104105
}
105106

106-
func (proc *Handle) getGCMData(destinationID, provider string) GenericConsentManagementProviderData {
107+
func (proc *Handle) getGCMData(sourceID, destinationID, provider string) GenericConsentManagementProviderData {
107108
proc.config.configSubscriberLock.RLock()
108109
defer proc.config.configSubscriberLock.RUnlock()
109110

110111
defRetVal := GenericConsentManagementProviderData{}
111-
destinationData, ok := proc.config.destGenericConsentManagementMap[destinationID]
112+
destinationData, ok := proc.config.genericConsentManagementMap[SourceID(sourceID)][DestinationID(destinationID)]
112113
if !ok {
113114
return defRetVal
114115
}
115116

116-
providerData, ok := destinationData[provider]
117+
providerData, ok := destinationData[ConsentProviderKey(provider)]
117118
if !ok {
118119
return defRetVal
119120
}
@@ -161,8 +162,8 @@ func getKetchConsentCategories(dest *backendconfig.DestinationT) []string {
161162
})
162163
}
163164

164-
func getGenericConsentManagementData(dest *backendconfig.DestinationT) (map[string]GenericConsentManagementProviderData, error) {
165-
genericConsentManagementData := make(map[string]GenericConsentManagementProviderData)
165+
func getGenericConsentManagementData(dest *backendconfig.DestinationT) (ConsentProviderMap, error) {
166+
genericConsentManagementData := make(ConsentProviderMap)
166167

167168
if _, ok := dest.Config["consentManagement"]; !ok {
168169
return genericConsentManagementData, nil
@@ -192,7 +193,7 @@ func getGenericConsentManagementData(dest *backendconfig.DestinationT) (map[stri
192193
)
193194

194195
if len(consentIDs) > 0 {
195-
genericConsentManagementData[providerConfig.Provider] = GenericConsentManagementProviderData{
196+
genericConsentManagementData[ConsentProviderKey(providerConfig.Provider)] = GenericConsentManagementProviderData{
196197
ResolutionStrategy: providerConfig.ResolutionStrategy,
197198
Consents: consentIDs,
198199
}

0 commit comments

Comments
 (0)