Skip to content

Commit

Permalink
Add timestamp to event after prebid#1584 was merged
Browse files Browse the repository at this point in the history
  • Loading branch information
laurb9 committed Dec 1, 2020
1 parent 5e3b8cc commit 4fac314
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion exchange/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions exchange/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 13 additions & 9 deletions exchange/exchangetest/events-account-off-request-on.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"events_enabled": false,
"start_time_ms": 1234567890,
"incomingRequest": {
"ortbRequest": {
"id": "some-request-id",
Expand Down Expand Up @@ -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"
}
}
}
Expand All @@ -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"
}
}
}
Expand All @@ -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"
}
}
}
Expand All @@ -183,15 +184,18 @@
"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"
}
}
}
}
]
}
]
},
"prebid": {
"auctiontimestamp": 1234567890
}
}
}
}
20 changes: 12 additions & 8 deletions exchange/exchangetest/events-account-on-request-off.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"events_enabled": true,
"start_time_ms": 1234567890,
"incomingRequest": {
"ortbRequest": {
"id": "some-request-id",
Expand Down Expand Up @@ -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"
}
}
}
Expand All @@ -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"
}
}
}
Expand All @@ -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"
}
}
}
Expand All @@ -181,15 +182,18 @@
"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"
}
}
}
}
]
}
]
},
"prebid": {
"auctiontimestamp": 1234567890
}
}
}

0 comments on commit 4fac314

Please sign in to comment.