Skip to content

Commit 5894556

Browse files
TheTradeDesk: Resolve burl if not resolved (#4481)
1 parent 6c86074 commit 5894556

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

adapters/thetradedesk/thetradedesk.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ func resolveAuctionPriceMacros(bid *openrtb2.Bid) {
241241
return
242242
}
243243
price := strconv.FormatFloat(bid.Price, 'f', -1, 64)
244-
bid.NURL = strings.Replace(bid.NURL, "${AUCTION_PRICE}", price, -1)
245-
bid.AdM = strings.Replace(bid.AdM, "${AUCTION_PRICE}", price, -1)
244+
bid.NURL = strings.ReplaceAll(bid.NURL, "${AUCTION_PRICE}", price)
245+
bid.AdM = strings.ReplaceAll(bid.AdM, "${AUCTION_PRICE}", price)
246+
bid.BURL = strings.ReplaceAll(bid.BURL, "${AUCTION_PRICE}", price)
246247
}

adapters/thetradedesk/thetradedesk_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ func TestResolveAuctionPriceMacros(t *testing.T) {
458458
bid *openrtb2.Bid
459459
expectedNURL string
460460
expectedAdM string
461+
expectedBURL string
461462
}{
462463
{
463464
name: "nil_bid",
@@ -469,19 +470,23 @@ func TestResolveAuctionPriceMacros(t *testing.T) {
469470
Price: 1.23,
470471
NURL: "http://example.com/nurl",
471472
AdM: "<div>Ad content</div>",
473+
BURL: "http://adsrvr.org/feedback/xxxx?wp=1.23&param2=abc",
472474
},
473475
expectedNURL: "http://example.com/nurl",
474476
expectedAdM: "<div>Ad content</div>",
477+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=1.23&param2=abc",
475478
},
476479
{
477480
name: "macros_in_both_nurl_and_adm",
478481
bid: &openrtb2.Bid{
479482
Price: 1.50,
480483
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}",
481484
AdM: "<div>Ad content with price ${AUCTION_PRICE}</div>",
485+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
482486
},
483487
expectedNURL: "http://example.com/nurl?price=1.5",
484488
expectedAdM: "<div>Ad content with price 1.5</div>",
489+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=1.5&param2=abc",
485490
},
486491
{
487492
name: "macro_only_in_nurl",
@@ -503,75 +508,97 @@ func TestResolveAuctionPriceMacros(t *testing.T) {
503508
expectedNURL: "http://example.com/nurl",
504509
expectedAdM: "<div>Price: 0.99</div>",
505510
},
511+
{
512+
name: "macro_only_in_burl",
513+
bid: &openrtb2.Bid{
514+
Price: 0.99,
515+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
516+
},
517+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=0.99&param2=abc",
518+
},
506519
{
507520
name: "multiple_macros_in_same_field",
508521
bid: &openrtb2.Bid{
509522
Price: 3.14,
510523
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}&backup_price=${AUCTION_PRICE}",
511524
AdM: "<div>Price: ${AUCTION_PRICE}, Backup: ${AUCTION_PRICE}</div>",
525+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=${AUCTION_PRICE}",
512526
},
513527
expectedNURL: "http://example.com/nurl?price=3.14&backup_price=3.14",
514528
expectedAdM: "<div>Price: 3.14, Backup: 3.14</div>",
529+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=3.14&param2=3.14",
515530
},
516531
{
517532
name: "zero_price",
518533
bid: &openrtb2.Bid{
519534
Price: 0.0,
520535
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}",
521536
AdM: "<div>Price: ${AUCTION_PRICE}</div>",
537+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
522538
},
523539
expectedNURL: "http://example.com/nurl?price=0",
524540
expectedAdM: "<div>Price: 0</div>",
541+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=0&param2=abc",
525542
},
526543
{
527544
name: "very_small_price",
528545
bid: &openrtb2.Bid{
529546
Price: 0.001,
530547
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}",
531548
AdM: "<div>Price: ${AUCTION_PRICE}</div>",
549+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
532550
},
533551
expectedNURL: "http://example.com/nurl?price=0.001",
534552
expectedAdM: "<div>Price: 0.001</div>",
553+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=0.001&param2=abc",
535554
},
536555
{
537556
name: "large_price",
538557
bid: &openrtb2.Bid{
539558
Price: 999.999,
540559
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}",
541560
AdM: "<div>Price: ${AUCTION_PRICE}</div>",
561+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
542562
},
543563
expectedNURL: "http://example.com/nurl?price=999.999",
544564
expectedAdM: "<div>Price: 999.999</div>",
565+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=999.999&param2=abc",
545566
},
546567
{
547568
name: "integer_price",
548569
bid: &openrtb2.Bid{
549570
Price: 5.0,
550571
NURL: "http://example.com/nurl?price=${AUCTION_PRICE}",
551572
AdM: "<div>Price: ${AUCTION_PRICE}</div>",
573+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${AUCTION_PRICE}&param2=abc",
552574
},
553575
expectedNURL: "http://example.com/nurl?price=5",
554576
expectedAdM: "<div>Price: 5</div>",
577+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=5&param2=abc",
555578
},
556579
{
557580
name: "empty_nurl_and_adm",
558581
bid: &openrtb2.Bid{
559582
Price: 1.23,
560583
NURL: "",
561584
AdM: "",
585+
BURL: "",
562586
},
563587
expectedNURL: "",
564588
expectedAdM: "",
589+
expectedBURL: "",
565590
},
566591
{
567592
name: "case_sensitive_macro_not_replaced",
568593
bid: &openrtb2.Bid{
569594
Price: 1.50,
570595
NURL: "http://example.com/nurl?price=${auction_price}",
571596
AdM: "<div>Price: ${Auction_Price}</div>",
597+
BURL: "http://adsrvr.org/feedback/xxxx?wp=${Auction_Price}&param2=abc",
572598
},
573599
expectedNURL: "http://example.com/nurl?price=${auction_price}",
574600
expectedAdM: "<div>Price: ${Auction_Price}</div>",
601+
expectedBURL: "http://adsrvr.org/feedback/xxxx?wp=${Auction_Price}&param2=abc",
575602
},
576603
}
577604

@@ -592,6 +619,7 @@ func TestResolveAuctionPriceMacros(t *testing.T) {
592619

593620
assert.Equal(t, tt.expectedNURL, testBid.NURL, "NURL should match expected value")
594621
assert.Equal(t, tt.expectedAdM, testBid.AdM, "AdM should match expected value")
622+
assert.Equal(t, tt.expectedBURL, testBid.BURL, "BRUL should match expected value")
595623
})
596624
}
597625
}

0 commit comments

Comments
 (0)