From 5fb13a915a3fd977b12f902c0a3c1a3329a6561a Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Thu, 24 Jun 2021 09:26:46 -0700 Subject: [PATCH 1/9] IX: merge eventtrackers with imptrackers for native bid responses --- adapters/ix/ix.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 5e10138f8f3..6cb9c8c5ac5 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -8,6 +8,8 @@ import ( "io/ioutil" "net/http" + "github.com/mxmCherry/openrtb/v15/native1" + native1response "github.com/mxmCherry/openrtb/v15/native1/response" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -417,6 +419,34 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } } + var bidNative *native1response.Response + if bidType == openrtb_ext.BidTypeNative { + unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative) + if unmarshalExtErr == nil && bidNative.EventTrackers != nil && len(bidNative.EventTrackers) > 0 { + + // create unique list of imp pixels urls from `imptrackers` and `eventtrackers` + uniqueImpPixels := map[string]bool{} + for _, v := range bidNative.ImpTrackers { + uniqueImpPixels[v] = true + } + + for _, v := range bidNative.EventTrackers { + if v.Event == native1.EventTypeImpression { + uniqueImpPixels[v.URL] = true + } + } + + // rewrite `imptrackers` with new deduped list of imp pixels + bidNative.ImpTrackers = make([]string, len(uniqueImpPixels)) + for k := range uniqueImpPixels { + bidNative.ImpTrackers = append(bidNative.ImpTrackers, k) + } + + json, _ := json.Marshal(bidNative) + bid.AdM = string(json) + } + } + bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ Bid: &bid, BidType: bidType, From 6d08585643f9a1eb00b0c17906da5cb0fcad2aa2 Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Thu, 24 Jun 2021 10:07:02 -0700 Subject: [PATCH 2/9] IX: add check to ensure event trackers of method=image --- adapters/ix/ix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 6cb9c8c5ac5..3e1345724d7 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -431,7 +431,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } for _, v := range bidNative.EventTrackers { - if v.Event == native1.EventTypeImpression { + if v.Event == native1.EventTypeImpression && v.Method == native1.EventTrackingMethodImage { uniqueImpPixels[v.URL] = true } } From 599dd76192e507221889cedfaffe7b70a7b2b74a Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Thu, 24 Jun 2021 12:33:09 -0700 Subject: [PATCH 3/9] handle native 1.1 and 1.2 payloads, add json tests --- adapters/ix/ix.go | 67 +++++++---- .../native-eventtrackers-compat.json | 104 ++++++++++++++++++ 2 files changed, 149 insertions(+), 22 deletions(-) create mode 100644 adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 3e1345724d7..03753c25605 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -7,6 +7,7 @@ import ( "fmt" "io/ioutil" "net/http" + "sort" "github.com/mxmCherry/openrtb/v15/native1" native1response "github.com/mxmCherry/openrtb/v15/native1/response" @@ -419,30 +420,22 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } } - var bidNative *native1response.Response + var bidNative1_1 *Native11Wrapper if bidType == openrtb_ext.BidTypeNative { - unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative) - if unmarshalExtErr == nil && bidNative.EventTrackers != nil && len(bidNative.EventTrackers) > 0 { - - // create unique list of imp pixels urls from `imptrackers` and `eventtrackers` - uniqueImpPixels := map[string]bool{} - for _, v := range bidNative.ImpTrackers { - uniqueImpPixels[v] = true - } - - for _, v := range bidNative.EventTrackers { - if v.Event == native1.EventTypeImpression && v.Method == native1.EventTrackingMethodImage { - uniqueImpPixels[v.URL] = true - } - } - - // rewrite `imptrackers` with new deduped list of imp pixels - bidNative.ImpTrackers = make([]string, len(uniqueImpPixels)) - for k := range uniqueImpPixels { - bidNative.ImpTrackers = append(bidNative.ImpTrackers, k) - } + unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_1) + if unmarshalExtErr == nil && bidNative1_1.Native.EventTrackers != nil && len(bidNative1_1.Native.EventTrackers) > 0 { + mergeNativeImpTrackers(&bidNative1_1.Native) + json, _ := json.Marshal(bidNative1_1) + bid.AdM = string(json) + } + } - json, _ := json.Marshal(bidNative) + var bidNative1_2 *native1response.Response + if bidType == openrtb_ext.BidTypeNative { + unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_2) + if unmarshalExtErr == nil && bidNative1_2.EventTrackers != nil && len(bidNative1_2.EventTrackers) > 0 { + mergeNativeImpTrackers(bidNative1_2) + json, _ := json.Marshal(bidNative1_2) bid.AdM = string(json) } } @@ -474,3 +467,33 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } return bidder, nil } + +// native 1.2 to 1.1 tracker compatibility handling + +type Native11Wrapper struct { + Native native1response.Response `json:"native,omitempty"` +} + +func mergeNativeImpTrackers(bidNative *native1response.Response) { + + // create unique list of imp pixels urls from `imptrackers` and `eventtrackers` + uniqueImpPixels := map[string]bool{} + for _, v := range bidNative.ImpTrackers { + uniqueImpPixels[v] = true + } + + for _, v := range bidNative.EventTrackers { + if v.Event == native1.EventTypeImpression && v.Method == native1.EventTrackingMethodImage { + uniqueImpPixels[v.URL] = true + } + } + + // rewrite `imptrackers` with new deduped list of imp pixels + bidNative.ImpTrackers = make([]string, 0) + for k := range uniqueImpPixels { + bidNative.ImpTrackers = append(bidNative.ImpTrackers, k) + } + + // sort so tests pass correctly + sort.Strings(bidNative.ImpTrackers) +} diff --git a/adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json b/adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json new file mode 100644 index 00000000000..a7478157e3f --- /dev/null +++ b/adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json @@ -0,0 +1,104 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + }, + "httpcalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"eventtrackers\":[{\"url\":\"https://example.com/imp-2.gif\",\"event\":1,\"method\":1},{\"url\":\"https://example.com/imp-3.gif\",\"event\":1,\"method\":1}],\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"]}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\",\"https://example.com/imp-3.gif\"],\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-2.gif\"},{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-3.gif\"}]}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + }, + "type": "native" + } + ] + } + ] +} From dd3a033a9e1d45dca87e2adef022234ddf980a8a Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Thu, 24 Jun 2021 13:19:46 -0700 Subject: [PATCH 4/9] update json tests for native 1.1 and 1.2 ad markup --- ...on => native-eventtrackers-compat-11.json} | 0 .../native-eventtrackers-compat-12.json | 104 ++++++++++++++++++ 2 files changed, 104 insertions(+) rename adapters/ix/ixtest/exemplary/{native-eventtrackers-compat.json => native-eventtrackers-compat-11.json} (100%) create mode 100644 adapters/ix/ixtest/exemplary/native-eventtrackers-compat-12.json diff --git a/adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json b/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-11.json similarity index 100% rename from adapters/ix/ixtest/exemplary/native-eventtrackers-compat.json rename to adapters/ix/ixtest/exemplary/native-eventtrackers-compat-11.json diff --git a/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-12.json b/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-12.json new file mode 100644 index 00000000000..36a239987a6 --- /dev/null +++ b/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-12.json @@ -0,0 +1,104 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + }, + "httpcalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"eventtrackers\":[{\"url\":\"https://example.com/imp-2.gif\",\"event\":1,\"method\":1},{\"url\":\"https://example.com/imp-3.gif\",\"event\":1,\"method\":1}],\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"]}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\",\"https://example.com/imp-3.gif\"],\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-2.gif\"},{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-3.gif\"}]}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + }, + "type": "native" + } + ] + } + ] +} From 5b2165210f319ff01c383f7735ed9777fab8a1ec Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Tue, 29 Jun 2021 10:24:12 -0700 Subject: [PATCH 5/9] check json.marshal for errors, ignore rewrite if so --- adapters/ix/ix.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 03753c25605..7fd53cdb5f2 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -425,8 +425,9 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_1) if unmarshalExtErr == nil && bidNative1_1.Native.EventTrackers != nil && len(bidNative1_1.Native.EventTrackers) > 0 { mergeNativeImpTrackers(&bidNative1_1.Native) - json, _ := json.Marshal(bidNative1_1) - bid.AdM = string(json) + if json, marshalErr := json.Marshal(bidNative1_1); marshalErr == nil { + bid.AdM = string(json) + } } } @@ -435,8 +436,9 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_2) if unmarshalExtErr == nil && bidNative1_2.EventTrackers != nil && len(bidNative1_2.EventTrackers) > 0 { mergeNativeImpTrackers(bidNative1_2) - json, _ := json.Marshal(bidNative1_2) - bid.AdM = string(json) + if json, marshalErr := json.Marshal(bidNative1_2); marshalErr == nil { + bid.AdM = string(json) + } } } From 49a2f181b814bba543ae4f3904fa5829d6dfa46e Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Tue, 29 Jun 2021 10:24:45 -0700 Subject: [PATCH 6/9] simplify `if` by checking `len` only --- adapters/ix/ix.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 7fd53cdb5f2..4d7dfc88cd9 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -423,7 +423,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque var bidNative1_1 *Native11Wrapper if bidType == openrtb_ext.BidTypeNative { unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_1) - if unmarshalExtErr == nil && bidNative1_1.Native.EventTrackers != nil && len(bidNative1_1.Native.EventTrackers) > 0 { + if unmarshalExtErr == nil && len(bidNative1_1.Native.EventTrackers) > 0 { mergeNativeImpTrackers(&bidNative1_1.Native) if json, marshalErr := json.Marshal(bidNative1_1); marshalErr == nil { bid.AdM = string(json) @@ -434,7 +434,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque var bidNative1_2 *native1response.Response if bidType == openrtb_ext.BidTypeNative { unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_2) - if unmarshalExtErr == nil && bidNative1_2.EventTrackers != nil && len(bidNative1_2.EventTrackers) > 0 { + if unmarshalExtErr == nil && len(bidNative1_2.EventTrackers) > 0 { mergeNativeImpTrackers(bidNative1_2) if json, marshalErr := json.Marshal(bidNative1_2); marshalErr == nil { bid.AdM = string(json) From 5b9895be83b971dadc207b2392eb5d7f7f4e2d05 Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Tue, 29 Jun 2021 11:17:44 -0700 Subject: [PATCH 7/9] use map of empty structs instead of bool --- adapters/ix/ix.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 4d7dfc88cd9..8b3cc95cd0f 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -479,14 +479,14 @@ type Native11Wrapper struct { func mergeNativeImpTrackers(bidNative *native1response.Response) { // create unique list of imp pixels urls from `imptrackers` and `eventtrackers` - uniqueImpPixels := map[string]bool{} + uniqueImpPixels := map[string]struct{}{} for _, v := range bidNative.ImpTrackers { - uniqueImpPixels[v] = true + uniqueImpPixels[v] = struct{}{} } for _, v := range bidNative.EventTrackers { if v.Event == native1.EventTypeImpression && v.Method == native1.EventTrackingMethodImage { - uniqueImpPixels[v.URL] = true + uniqueImpPixels[v.URL] = struct{}{} } } From 1fa55b7cd0a0523b9403708ec07f2a54b5961654 Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Tue, 29 Jun 2021 13:25:36 -0700 Subject: [PATCH 8/9] added tests for missing native and eventtrackers objects --- adapters/ix/ix.go | 2 +- .../ix/ixtest/supplemental/bad-imp-id.json | 2 +- .../native-eventtrackers-empty.json} | 4 +- .../native-eventtrackers-missing.json | 104 ++++++++++++++++++ .../ixtest/supplemental/native-missing.json | 104 ++++++++++++++++++ 5 files changed, 212 insertions(+), 4 deletions(-) rename adapters/ix/ixtest/{exemplary/native-eventtrackers-compat-11.json => supplemental/native-eventtrackers-empty.json} (89%) create mode 100644 adapters/ix/ixtest/supplemental/native-eventtrackers-missing.json create mode 100644 adapters/ix/ixtest/supplemental/native-missing.json diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 8b3cc95cd0f..ebb99052a61 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -403,7 +403,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque for _, bid := range seatBid.Bid { bidType, ok := impMediaType[bid.ImpID] if !ok { - errs = append(errs, fmt.Errorf("Unmatched impression id: %s.", bid.ImpID)) + errs = append(errs, fmt.Errorf("unmatched impression id: %s", bid.ImpID)) } var bidExtVideo *openrtb_ext.ExtBidPrebidVideo diff --git a/adapters/ix/ixtest/supplemental/bad-imp-id.json b/adapters/ix/ixtest/supplemental/bad-imp-id.json index 0b852c85d2b..1ca053b674e 100644 --- a/adapters/ix/ixtest/supplemental/bad-imp-id.json +++ b/adapters/ix/ixtest/supplemental/bad-imp-id.json @@ -111,7 +111,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Unmatched impression id: bad-imp-id.", + "value": "unmatched impression id: bad-imp-id", "comparison": "literal" } ] diff --git a/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-11.json b/adapters/ix/ixtest/supplemental/native-eventtrackers-empty.json similarity index 89% rename from adapters/ix/ixtest/exemplary/native-eventtrackers-compat-11.json rename to adapters/ix/ixtest/supplemental/native-eventtrackers-empty.json index a7478157e3f..4cf314e742f 100644 --- a/adapters/ix/ixtest/exemplary/native-eventtrackers-compat-11.json +++ b/adapters/ix/ixtest/supplemental/native-eventtrackers-empty.json @@ -51,7 +51,7 @@ "impid": "test-imp-id", "price": 0.5, "adid": "29681110", - "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"eventtrackers\":[{\"url\":\"https://example.com/imp-2.gif\",\"event\":1,\"method\":1},{\"url\":\"https://example.com/imp-3.gif\",\"event\":1,\"method\":1}],\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"]}}", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"],\"eventtrackers\":[]}}", "adomain": [ "https://advertiser.example.com" ], @@ -83,7 +83,7 @@ "impid": "test-imp-id", "price": 0.5, "adid": "29681110", - "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\",\"https://example.com/imp-3.gif\"],\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-2.gif\"},{\"event\":1,\"method\":1,\"url\":\"https://example.com/imp-3.gif\"}]}}", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"],\"eventtrackers\":[]}}", "adomain": [ "https://advertiser.example.com" ], diff --git a/adapters/ix/ixtest/supplemental/native-eventtrackers-missing.json b/adapters/ix/ixtest/supplemental/native-eventtrackers-missing.json new file mode 100644 index 00000000000..d8c78a5cbca --- /dev/null +++ b/adapters/ix/ixtest/supplemental/native-eventtrackers-missing.json @@ -0,0 +1,104 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + }, + "httpcalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"]}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{\"assets\":[{\"id\":123,\"required\":1,\"title\":{\"text\":\"Learn about this awesome thing\"}},{\"id\":124,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/thumbnail1.png\"}},{\"id\":128,\"required\":1,\"img\":{\"url\":\"http://www.myads.com/largethumb1.png\"}},{\"id\":126,\"required\":1,\"data\":{\"value\":\"My Brand\"}},{\"id\":127,\"required\":1,\"data\":{\"value\":\"Learn all about this awesome story of someone using my product.\"}}],\"link\":{\"url\":\"http: //i.am.a/URL\"},\"imptrackers\":[\"https://example.com/imp-1.gif\",\"https://example.com/imp-2.gif\"]}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/ix/ixtest/supplemental/native-missing.json b/adapters/ix/ixtest/supplemental/native-missing.json new file mode 100644 index 00000000000..ec2108ce5d1 --- /dev/null +++ b/adapters/ix/ixtest/supplemental/native-missing.json @@ -0,0 +1,104 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + }, + "httpcalls": [ + { + "expectedRequest": { + "uri": "http://host/endpoint", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}", + "ver": "1.1" + }, + "ext": { + "bidder": { + "siteId": "569749" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "{\"native\":{}}", + "adomain": [ + "https://advertiser.example.com" + ], + "cid": "958", + "crid": "29681110", + "cat": [ + "IAB3-1" + ], + "ext": { + "ix": {} + } + }, + "type": "native" + } + ] + } + ] +} From 8ec79ba53d01f9355ff63f8e434736f7af1313bf Mon Sep 17 00:00:00 2001 From: Mani Gandham Date: Wed, 30 Jun 2021 19:25:49 -0700 Subject: [PATCH 9/9] fix variable naming --- adapters/ix/ix.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index ebb99052a61..b251ec0f736 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -420,23 +420,23 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalReque } } - var bidNative1_1 *Native11Wrapper + var bidNative1v1 *Native11Wrapper if bidType == openrtb_ext.BidTypeNative { - unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_1) - if unmarshalExtErr == nil && len(bidNative1_1.Native.EventTrackers) > 0 { - mergeNativeImpTrackers(&bidNative1_1.Native) - if json, marshalErr := json.Marshal(bidNative1_1); marshalErr == nil { + err := json.Unmarshal([]byte(bid.AdM), &bidNative1v1) + if err == nil && len(bidNative1v1.Native.EventTrackers) > 0 { + mergeNativeImpTrackers(&bidNative1v1.Native) + if json, err := json.Marshal(bidNative1v1); err == nil { bid.AdM = string(json) } } } - var bidNative1_2 *native1response.Response + var bidNative1v2 *native1response.Response if bidType == openrtb_ext.BidTypeNative { - unmarshalExtErr := json.Unmarshal([]byte(bid.AdM), &bidNative1_2) - if unmarshalExtErr == nil && len(bidNative1_2.EventTrackers) > 0 { - mergeNativeImpTrackers(bidNative1_2) - if json, marshalErr := json.Marshal(bidNative1_2); marshalErr == nil { + err := json.Unmarshal([]byte(bid.AdM), &bidNative1v2) + if err == nil && len(bidNative1v2.EventTrackers) > 0 { + mergeNativeImpTrackers(bidNative1v2) + if json, err := json.Marshal(bidNative1v2); err == nil { bid.AdM = string(json) } }