11package org.prebid.server.functional.tests
22
3+ import org.prebid.server.functional.model.ChannelType
4+ import org.prebid.server.functional.model.config.AccountAnalyticsConfig
5+ import org.prebid.server.functional.model.config.AccountConfig
36import org.prebid.server.functional.model.db.Account
47import org.prebid.server.functional.model.db.StoredRequest
58import org.prebid.server.functional.model.request.auction.BidRequest
9+ import org.prebid.server.functional.model.request.auction.Events
610import org.prebid.server.functional.model.request.auction.PrebidStoredRequest
711import org.prebid.server.functional.util.PBSUtils
812
913import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP
14+ import static org.prebid.server.functional.model.request.auction.DistributionChannel.DOOH
1015import static org.prebid.server.functional.model.request.auction.DistributionChannel.SITE
1116
1217class EventsSpec extends BaseSpec {
@@ -31,7 +36,7 @@ class EventsSpec extends BaseSpec {
3136 assert bidResponse. seatbid[0 ]. bid[0 ]. ext. prebid. events. imp
3237
3338 where :
34- distributionChannel << [SITE , APP ]
39+ distributionChannel << [SITE , APP , DOOH ]
3540 }
3641
3742 def " PBS should not generate event tracker URLs when events are disabled for account" () {
@@ -54,7 +59,7 @@ class EventsSpec extends BaseSpec {
5459 assert ! bidResponse. seatbid[0 ]. bid[0 ]. ext. prebid. events?. imp
5560
5661 where :
57- distributionChannel << [SITE , APP ]
62+ distributionChannel << [SITE , APP , DOOH ]
5863 }
5964
6065 def " PBS should resolve publisher id for events when events are enabled for account" () {
@@ -78,7 +83,7 @@ class EventsSpec extends BaseSpec {
7883 assert bidResponseEvents. imp. contains(" a=${ accountId} " )
7984
8085 where :
81- distributionChannel << [SITE , APP ]
86+ distributionChannel << [SITE , APP , DOOH ]
8287 }
8388
8489 def " PBS should resolve publisher id from stored request for events when events enabled" () {
@@ -110,6 +115,124 @@ class EventsSpec extends BaseSpec {
110115 assert bidResponseEvents. imp. contains(" a=${ accountId} " )
111116
112117 where :
113- distributionChannel << [SITE , APP ]
118+ distributionChannel << [SITE , APP , DOOH ]
119+ }
120+
121+ def " Account-level analytics settings should apply when request events config is absent" () {
122+ given : " BidRequest without events config"
123+ def accountId = PBSUtils . randomNumber as String
124+ def bidRequest = BidRequest . getDefaultBidRequest(requestType). tap {
125+ setAccountId(accountId)
126+ }
127+
128+ and : " Account with analytics events disabled for corresponding channel"
129+ def analyticsConfig = new AccountAnalyticsConfig (auctionEvents : [(accountConfigChannelType): false ])
130+ def account = new Account (uuid : accountId, eventsEnabled : true , config : new AccountConfig (analytics : analyticsConfig))
131+ accountDao. save(account)
132+
133+ when : " Auction request is processed"
134+ def bidResponse = defaultPbsService. sendAuctionRequest(bidRequest)
135+
136+ then : " Events should not be present in response due to stored request disablement"
137+ assert ! bidResponse. seatbid[0 ]. bid[0 ]. ext?. prebid?. events
138+
139+ where :
140+ requestType | accountConfigChannelType
141+ SITE | ChannelType . WEB
142+ APP | ChannelType . APP
143+ DOOH | ChannelType . DOOH
144+ }
145+
146+ def " Request level events config should override account-level analytics settings" () {
147+ given : " BidRequest with events config"
148+ def accountId = PBSUtils . randomNumber as String
149+ def bidRequest = BidRequest . getDefaultBidRequest(requestType). tap {
150+ setAccountId(accountId)
151+ ext. prebid. events = new Events (enabled : requestEventEnablement)
152+ }
153+
154+ and : " Account with analytics events disabled for corresponding channel"
155+ def analyticsConfig = new AccountAnalyticsConfig (auctionEvents : [(accountConfigChannelType): false ])
156+ def account = new Account (uuid : accountId, eventsEnabled : true , config : new AccountConfig (analytics : analyticsConfig))
157+ accountDao. save(account)
158+
159+ when : " Auction request is processed"
160+ def bidResponse = defaultPbsService. sendAuctionRequest(bidRequest)
161+
162+ then : " Events should be present in response despite account-level disablement"
163+ def bidResponseEvents = bidResponse. seatbid[0 ]. bid[0 ]. ext. prebid. events
164+ assert bidResponseEvents. win. contains(" a=${ accountId} " )
165+ assert bidResponseEvents. imp. contains(" a=${ accountId} " )
166+
167+ where :
168+ requestEventEnablement | requestType | accountConfigChannelType
169+ null | SITE | ChannelType . WEB
170+ null | APP | ChannelType . APP
171+ null | DOOH | ChannelType . DOOH
172+
173+ true | SITE | ChannelType . WEB
174+ true | APP | ChannelType . APP
175+ true | DOOH | ChannelType . DOOH
176+ }
177+
178+ def " Request-level events disabled should override account-level analytics settings" () {
179+ given : " BidRequest with events explicitly disabled at request level"
180+ def accountId = PBSUtils . randomNumber as String
181+
182+ def bidRequest = BidRequest . getDefaultBidRequest(requestType). tap {
183+ setAccountId(accountId)
184+ ext. prebid. events = new Events (enabled : false )
185+ }
186+
187+ and : " Account with analytics events enabled for corresponding channel"
188+ def analyticsConfig = new AccountAnalyticsConfig (auctionEvents : [(accountConfigChannelType): true ])
189+ def account = new Account (uuid : accountId, eventsEnabled : true , config : new AccountConfig (analytics : analyticsConfig))
190+ accountDao. save(account)
191+
192+ when : " Auction request is processed"
193+ def bidResponse = defaultPbsService. sendAuctionRequest(bidRequest)
194+
195+ then : " Events should not be present in response due to request-level disablement"
196+ assert ! bidResponse. seatbid[0 ]. bid[0 ]. ext?. prebid?. events
197+
198+ where :
199+ requestType | accountConfigChannelType
200+ SITE | ChannelType . WEB
201+ APP | ChannelType . APP
202+ DOOH | ChannelType . DOOH
203+ }
204+
205+ def " Stored request events config should override account-level analytics settings when request config is absent" () {
206+ given : " BidRequest referencing stored request without events config"
207+ def storedRequestId = PBSUtils . randomString
208+ def bidRequest = BidRequest . getDefaultBidRequest(distributionChannel). tap {
209+ ext. prebid. storedRequest = new PrebidStoredRequest (id : storedRequestId)
210+ setAccountId(null )
211+ }
212+
213+ and : " Stored request with account id and events disabled"
214+ def accountId = PBSUtils . randomNumber as String
215+ def storedRequest = BidRequest . getDefaultBidRequest(distributionChannel). tap {
216+ setAccountId(accountId)
217+ ext. prebid. events = new Events (enabled : false )
218+ }
219+ storedRequestDao. save(StoredRequest . getStoredRequest(accountId, storedRequestId, storedRequest))
220+
221+ and : " Account with analytics events enabled for corresponding channel"
222+ def analyticsConfig = new AccountAnalyticsConfig (auctionEvents : [(accountConfigChannelType): true ])
223+ def account = new Account (uuid : accountId, eventsEnabled : true , config : new AccountConfig (analytics : analyticsConfig))
224+ accountDao. save(account)
225+
226+ when : " Auction request is processed"
227+ def bidResponse = defaultPbsService. sendAuctionRequest(bidRequest)
228+
229+ then : " Events should not be present in response due to stored request disablement"
230+ assert ! bidResponse. seatbid[0 ]. bid[0 ]. ext?. prebid?. events
231+
232+ where :
233+ distributionChannel | accountConfigChannelType
234+ SITE | ChannelType . WEB
235+ APP | ChannelType . APP
236+ DOOH | ChannelType . DOOH
114237 }
115238}
0 commit comments