Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTT-130: Injecting Video Tracking Events in VAST #130

Merged
merged 22 commits into from
Mar 18, 2021
Merged

Conversation

ShriprasadM
Copy link
Collaborator

No description provided.

@ShriprasadM ShriprasadM marked this pull request as ready for review March 4, 2021 09:32
}
}
// replace standard macros
eventURL = replaceMacro(eventURL, VASTAdTypeMacro, "")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the value for ad type

Copy link
Collaborator Author

@ShriprasadM ShriprasadM Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Passing video type always

if "" == strings.Trim(trackerURL, " ") {
return eventURLMap
}
for _, event := range []string{"firstQuartile", "midpoint", "thirdQuartile", "complete"} {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it to global private variable

Copy link
Collaborator Author

@ShriprasadM ShriprasadM Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. introduced global private variable - trackingEvents

},
want: want{
eventURLs: map[string][]string{
"firstQuartile": []string{"http://something.com", "http://company.tracker.com?eventId=1004&appbundle=abc"},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing expectations for midpoint, thirdQuartile and complete

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. added required assertions

"complete": {"http://company.tracker.com?eventId=6&appbundle=abc"},
},
},
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add testcase when adm="" but we have nurl

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 77 to 78
fmt.Println(string(newVastXML))
fmt.Println(bid.AdM)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove println

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@pm-viral-vala pm-viral-vala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once changes are done, Please go ahead with QADrop.

creatives = append(creatives, doc.FindElements("VAST/Ad/InLine/Creatives/Creative/NonLinearAds")...)
creatives = append(creatives, doc.FindElements("VAST/Ad/Wrapper/Creatives/Creative/NonLinearAds")...)

if "" == strings.Trim(bid.AdM, " ") || strings.HasPrefix(strings.TrimLeft(strings.TrimRight(bid.AdM, "]]>"), "<![CDATA["), "http") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • use strings.TrimSpace() instead of strings.Trim()
  • bid.AdM never comes inside CDATA Tag if it is returning VAST Tag URL. check trimmed bid.AdM starts with http

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if nil != err {
err := fmt.Sprintf("Error parsing VAST XML. '%v'", err.Error())
glog.Errorf(err)
return []byte(vastXML), false, errors.New(err) // false indicates events trackers are not injected
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return err itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

doc := etree.NewDocument()
err := doc.ReadFromString(vastXML)
if nil != err {
err := fmt.Sprintf("Error parsing VAST XML. '%v'", err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf use instead Sprintf

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -302,3 +329,147 @@ func ModifyVastXmlJSON(externalUrl string, data json.RawMessage, bidid, bidder,
}
return json.RawMessage(vast)
}

//InjectVideoEventTrackers injects the video tracking events
Copy link
Collaborator

@pm-viral-vala pm-viral-vala Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write parameter single line description

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// replace standard macros
eventURL = replaceMacro(eventURL, VASTAdTypeMacro, string(openrtb_ext.BidTypeVideo))
if nil != req && nil != req.App {
eventURL = replaceMacro(eventURL, VASTAppBundleMacro, req.App.Bundle)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check Macro here, Domain or Bundle

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[DOMAIN] will be req.App.Bundle in case of Apps

}

func replaceMacro(trackerURL, macro, value string) string {
if strings.HasPrefix(macro, "[") && strings.HasSuffix(macro, "]") && len(strings.Trim(value, " ")) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it replace " [MACRO] "? Check with trimmed value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added TrimSpace

if adm == "" {
return fmt.Sprintf(wrapperVASTTemplate, bid.NURL) // set nurl as VASTAdTagURI
}
if strings.HasPrefix(adm, "<![CDATA[") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adm won't have CDATA

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the block

Copy link
Collaborator

@pm-viral-vala pm-viral-vala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ShriprasadM ShriprasadM merged commit 2b3b74a into OTT-105_VCR Mar 18, 2021
ShriprasadM added a commit that referenced this pull request Apr 20, 2021
* 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]>

Co-authored-by: Shriprasad <[email protected]>
ShriprasadM added a commit that referenced this pull request Apr 21, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants