diff --git a/exchange/exchange.go b/exchange/exchange.go index a6c43763a54..4cf72e25699 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -119,7 +119,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * } cacheInstructions := getExtCacheInstructions(requestExt) - evData := getExtEventsData(&requestExt.Prebid, time.Now(), &r.Account, e.bidderInfo, e.externalURL) + evData := getExtEventsData(&requestExt.Prebid, r.StartTime, &r.Account, e.bidderInfo, e.externalURL) targData := getExtTargetData(requestExt, &cacheInstructions) if targData != nil { _, targData.cacheHost, targData.cachePath = e.cache.GetExtCacheData() diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index eb4a92d0aa3..b052d523429 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -1398,6 +1398,9 @@ func runSpec(t *testing.T, filename string, spec *exchangeSpec) { }, UserSyncs: mockIdFetcher(spec.IncomingRequest.Usersyncs), } + if spec.StartTime > 0 { + auctionRequest.StartTime = time.Unix(0, spec.StartTime*1e+6) + } bid, err := ex.HoldAuction(context.Background(), auctionRequest, debugLog) responseTimes := extractResponseTimes(t, filename, bid) @@ -2541,6 +2544,7 @@ type exchangeSpec struct { AssumeGDPRApplies bool `json:"assume_gdpr_applies"` DebugLog *DebugLog `json:"debuglog,omitempty"` EventsEnabled bool `json:"events_enabled,omitempty"` + StartTime int64 `json:"start_time_ms,omitempty"` } type exchangeRequest struct { diff --git a/exchange/exchangetest/events-account-off-request-on.json b/exchange/exchangetest/events-account-off-request-on.json index 1cbfff43205..2f6b5f1ac29 100644 --- a/exchange/exchangetest/events-account-off-request-on.json +++ b/exchange/exchangetest/events-account-off-request-on.json @@ -1,5 +1,6 @@ { "events_enabled": false, + "start_time_ms": 1234567890, "incomingRequest": { "ortbRequest": { "id": "some-request-id", @@ -127,8 +128,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1605928405805", - "win": "http://localhost/event?t=win&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1234567890", + "win": "http://localhost/event?t=win&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1234567890" } } } @@ -149,8 +150,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=winning-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=winning-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=winning-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=winning-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -166,8 +167,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=losing-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=losing-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=losing-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=losing-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -183,8 +184,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=other-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=other-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=other-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=other-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -192,6 +193,9 @@ ] } ] + }, + "prebid": { + "auctiontimestamp": 1234567890 } } -} \ No newline at end of file +} diff --git a/exchange/exchangetest/events-account-on-request-off.json b/exchange/exchangetest/events-account-on-request-off.json index 440e34d89bc..23b220c42d1 100644 --- a/exchange/exchangetest/events-account-on-request-off.json +++ b/exchange/exchangetest/events-account-on-request-off.json @@ -1,5 +1,6 @@ { "events_enabled": true, + "start_time_ms": 1234567890, "incomingRequest": { "ortbRequest": { "id": "some-request-id", @@ -125,8 +126,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1605928405805", - "win": "http://localhost/event?t=win&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1234567890", + "win": "http://localhost/event?t=win&b=contending-bid&a=testaccount&bidder=audienceNetwork&ts=1234567890" } } } @@ -147,8 +148,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=winning-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=winning-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=winning-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=winning-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -164,8 +165,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=losing-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=losing-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=losing-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=losing-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -181,8 +182,8 @@ "prebid": { "type": "video", "events": { - "imp": "http://localhost/event?t=imp&b=other-bid&a=testaccount&bidder=appnexus&ts=1605928405805", - "win": "http://localhost/event?t=win&b=other-bid&a=testaccount&bidder=appnexus&ts=1605928405805" + "imp": "http://localhost/event?t=imp&b=other-bid&a=testaccount&bidder=appnexus&ts=1234567890", + "win": "http://localhost/event?t=win&b=other-bid&a=testaccount&bidder=appnexus&ts=1234567890" } } } @@ -190,6 +191,9 @@ ] } ] + }, + "prebid": { + "auctiontimestamp": 1234567890 } } } \ No newline at end of file