Skip to content

Commit

Permalink
OTT-105: Video Completion Rate Feature (Advertiser Changes) (#137)
Browse files Browse the repository at this point in the history
* OTT-130: Injecting Video Tracking Events in VAST  (#130)

* OTT-105_VCR: basic changes

* OTT-105: Changes for injecting Tracking Events

* OTT-130_VCR: Added framework with unit tests for injecting Video Event trackers in VAST

* OTT-130_VCR: Reverted Path replace

* OTT-130: Replaced etree dep with original repository

* OTT-130: Refactored as per latest master

* OTT-130: Refactored

* OTT-130: Refactored

* OTT-130: Reverted unwanted changes

* OTT-130: Added unit tests and refactoring

* OTT-130: InjectVideoEventTrackers will now return error if any

* OTT-130: Refactored

* OTT-130: Removed custom macro support

* OTT-130: Reverted the unwanted changes

* OTT-130: Reverted unwanted changes

* OTT-130: Added Url Query Escape Functionality

* OTT-130: Fixed test failures

* OTT-130: Refactored

* OTT-130: Addressed code review comments from Viral

Co-authored-by: Shriprasad <[email protected]>

* OTT-131: VCR Custom Macro (#132)

* OTT-131: Added support for consuming the custom macros from host company

* OTT-131: Removed unwanted comments

* OTT-131: Addressed code review comments

Co-authored-by: Shriprasad <[email protected]>

* OTT-174: Added bid ID , Ad Unit as tracking parameters and ADomain handling change (#134)

* OTT-174: Added AdUnit parameter inside video event tracker URL

* OTT-174: Added bid id, au tracker parameters. in case of advetiser_id, OW will now send only value at index 0 from bid.ADomain array by extracting the domain
Also handled the CTV/Ad Pod bid.id custom use case

* OTT-174: Ensured bidid value is replaced only in case of OW trackers. (95% reliable)
Also ensured that bidid is not getting added to other trackers, if not present

* OTT-174: Fixed code review comments

Co-authored-by: Shriprasad <[email protected]>

* OTT-105: Changes for advertiser id

Co-authored-by: Shriprasad <[email protected]>
  • Loading branch information
ShriprasadM and pm-shriprasad-marathe authored Apr 21, 2021
1 parent 025b755 commit cbbc0f8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
23 changes: 20 additions & 3 deletions endpoints/events/vtrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const (
// [ADERVERTISER_NAME] represents advertiser name
PBSAdvertiserNameMacro = "[ADVERTISER_NAME]"
// Pass imp.tagId using this macro
PBSAdUnitIDMacro = "[AD_UNIT_ID]"
PBSAdUnitIDMacro = "[AD_UNIT]"
)

var trackingEvents = []string{"firstQuartile", "midpoint", "thirdQuartile", "complete"}
Expand Down Expand Up @@ -475,9 +475,9 @@ func GetVideoEventTracking(trackerURL string, bid *openrtb.Bid, bidder string, a

if len(bid.ADomain) > 0 {
//eventURL = replaceMacro(eventURL, PBSAdvertiserNameMacro, strings.Join(bid.ADomain, ","))
url, err := url.Parse(bid.ADomain[0])
domain, err := extractDomain(bid.ADomain[0])
if nil == err {
eventURL = replaceMacro(eventURL, PBSAdvertiserNameMacro, url.Hostname())
eventURL = replaceMacro(eventURL, PBSAdvertiserNameMacro, domain)
} else {
glog.Warningf("Unable to extract domain from '%s'. [%s]", bid.ADomain[0], err.Error())
}
Expand Down Expand Up @@ -519,3 +519,20 @@ func FindCreatives(doc *etree.Document) []*etree.Element {
creatives = append(creatives, doc.FindElements("VAST/Ad/Wrapper/Creatives/Creative/NonLinearAds")...)
return creatives
}

func extractDomain(rawURL string) (string, error) {
if !strings.HasPrefix(rawURL, "http") {
rawURL = "http://" + rawURL
}
// decode rawURL
rawURL, err := url.QueryUnescape(rawURL)
if nil != err {
return "", err
}
url, err := url.Parse(rawURL)
if nil != err {
return "", err
}
// remove www if present
return strings.TrimPrefix(url.Hostname(), "www."), nil
}
26 changes: 25 additions & 1 deletion endpoints/events/vtrack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ func TestGetVideoEventTracking(t *testing.T) {
{
name: "all_macros", // expect encoding for WRAPPER_IMPRESSION_ID macro
args: args{
trackerURL: "https://company.tracker.com?operId=8&e=[EVENT_ID]&p=[PBS-ACCOUNT]&pid=[PROFILE_ID]&v=[PROFILE_VERSION]&ts=[UNIX_TIMESTAMP]&pn=[PBS-BIDDER]&advertiser_id=[ADVERTISER_NAME]&sURL=[DOMAIN]&pfi=[PLATFORM]&af=[ADTYPE]&iid=[WRAPPER_IMPRESSION_ID]&pseq=[PODSEQUENCE]&adcnt=[ADCOUNT]&cb=[CACHEBUSTING]&au=[AD_UNIT_ID]&bidid=[PBS-BIDID]",
trackerURL: "https://company.tracker.com?operId=8&e=[EVENT_ID]&p=[PBS-ACCOUNT]&pid=[PROFILE_ID]&v=[PROFILE_VERSION]&ts=[UNIX_TIMESTAMP]&pn=[PBS-BIDDER]&advertiser_id=[ADVERTISER_NAME]&sURL=[DOMAIN]&pfi=[PLATFORM]&af=[ADTYPE]&iid=[WRAPPER_IMPRESSION_ID]&pseq=[PODSEQUENCE]&adcnt=[ADCOUNT]&cb=[CACHEBUSTING]&au=[AD_UNIT]&bidid=[PBS-BIDID]",
req: &openrtb.BidRequest{
App: &openrtb.App{Bundle: "com.someapp.com", Publisher: &openrtb.Publisher{ID: "5890"}},
Ext: []byte(`{
Expand Down Expand Up @@ -1209,3 +1209,27 @@ func TestReplaceMacro(t *testing.T) {
}

}

func TestExtractDomain(t *testing.T) {
testCases := []struct {
description string
url string
expectedDomain string
expectedErr error
}{
{description: "a.com", url: "a.com", expectedDomain: "a.com", expectedErr: nil},
{description: "a.com/123", url: "a.com/123", expectedDomain: "a.com", expectedErr: nil},
{description: "http://a.com/123", url: "http://a.com/123", expectedDomain: "a.com", expectedErr: nil},
{description: "https://a.com/123", url: "https://a.com/123", expectedDomain: "a.com", expectedErr: nil},
{description: "c.b.a.com", url: "c.b.a.com", expectedDomain: "c.b.a.com", expectedErr: nil},
{description: "url_encoded_http://c.b.a.com", url: "http%3A%2F%2Fc.b.a.com", expectedDomain: "c.b.a.com", expectedErr: nil},
{description: "url_encoded_with_www_http://c.b.a.com", url: "http%3A%2F%2Fwww.c.b.a.com", expectedDomain: "c.b.a.com", expectedErr: nil},
}
for _, test := range testCases {
t.Run(test.description, func(t *testing.T) {
domain, err := extractDomain(test.url)
assert.Equal(t, test.expectedDomain, domain)
assert.Equal(t, test.expectedErr, err)
})
}
}

0 comments on commit cbbc0f8

Please sign in to comment.