Skip to content

Commit

Permalink
[PBI-1824c] CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dchauOoyala committed Jun 29, 2016
1 parent 24587fa commit e7474ef
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 28 deletions.
14 changes: 7 additions & 7 deletions js/ssai_pulse.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ OO.Ads.manager(function(_, $)
// Denotes that an ad request is waiting for a response
WAITING: "waiting",

// Denotes that a response has returned for an ad request and the ad has "played"
PLAYED: "played"
// Denotes that a response has returned for an ad request and the ad is "playing"
PLAYING: "playing"
};

// variable to store the timeout used to keep track of how long an SSAI ad plays
Expand Down Expand Up @@ -182,6 +182,7 @@ OO.Ads.manager(function(_, $)
if (this.currentAd.ad)
{
this.currentAd.ad.id3AdId = this.currentId3Object.adId;
_handleTrackingUrls(this.currentAd, ["impression", "start"]);
amc.notifyLinearAdStarted(this.currentAd.id,
{
name: this.currentAd.ad.name,
Expand All @@ -191,7 +192,6 @@ OO.Ads.manager(function(_, $)
isLive: this.currentAd.ad.isLive
}
);
_handleTrackingUrls(this.currentAd, ["impression", "start"]);
}
}
};
Expand Down Expand Up @@ -281,8 +281,8 @@ OO.Ads.manager(function(_, $)
{
if (amcAd && amcAd.ad)
{
window.open(amcAd.ad.clickthrough);
_handleTrackingUrls(amcAd, ["linearClickTracking"]);
window.open(amcAd.ad.clickthrough);
}
};

Expand Down Expand Up @@ -386,8 +386,8 @@ OO.Ads.manager(function(_, $)
* Called if the ajax call succeeds
* @public
* @method SsaiPulse#onResponse
* @param {XMLDocument} xml The xml returned from loading the ad
* @param {object} id3Object The ID3 object
* @param {XMLDocument} xml The xml returned from loading the ad
*/
this.onResponse = function(id3Object, xml)
{
Expand All @@ -413,7 +413,7 @@ OO.Ads.manager(function(_, $)
ssaiAd.name = _getTitle(adObject);
}

this.adIdDictionary[id3Object.adId] = STATE.PLAYED;
this.adIdDictionary[id3Object.adId] = STATE.PLAYING;
amc.forceAdToPlay(this.name, ssaiAd, amc.ADTYPE.LINEAR_VIDEO, {}, id3Object.duration);

//_forceMockAd(id3Object);
Expand Down Expand Up @@ -798,7 +798,7 @@ OO.Ads.manager(function(_, $)
/**
* Helper function to retrieve the ad object's tracking urls under a specific event name.
* @private
* @method SsaiPulse#_getTrackingEventUrls
* @method SsaiPulse#_getLinearTrackingEventUrls
* @param {object} adObject The ad metadata
* @param {string} trackingEventName The name of the tracking event
* @returns {string[]|null} The array of tracking urls associated with the event name. Returns null if no URLs exist.
Expand Down
133 changes: 133 additions & 0 deletions test/unit-test-helpers/mock_responses/ssai.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<VAST version="3.0">
<Ad id="11de5230-ff5c-4d36-ad77-c0c7644d28e9" sequence="1">
<InLine>
<AdSystem>Videoplaza Karbon</AdSystem>
<AdTitle>FE_Sports</AdTitle>
<Error>errorUrl</Error>
<Impression>impressionUrl</Impression>
<Impression>impressionUrl2</Impression>
<Creatives>
<Creative id="video">
<Linear>
<Duration>00:00:15</Duration>
<TrackingEvents>
<Tracking event="start">startUrl</Tracking>
<Tracking event="start">startUrl2</Tracking>
<Tracking event="firstQuartile">firstQuartileUrl</Tracking>
<Tracking event="firstQuartile">firstQuartileUrl2</Tracking>
<Tracking event="midpoint">midpointUrl</Tracking>
<Tracking event="midpoint">midpointUrl2</Tracking>
<Tracking event="thirdQuartile">thirdQuartileUrl</Tracking>
<Tracking event="thirdQuartile">thirdQuartileUrl2</Tracking>
<Tracking event="complete">completeUrl</Tracking>
<Tracking event="complete">completeUrl2</Tracking>
<Tracking event="mute">muteUrl</Tracking>
<Tracking event="unmute">unmuteUrl</Tracking>
<Tracking event="fullscreen">fullscreenUrl</Tracking>
</TrackingEvents>
<MediaFiles>
<MediaFile delivery="progressive" type="video/mp4" bitrate="597" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/7393daba-b562-4f94-a6b3-db2dc478a43d.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="552" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/6e8205fd-a09d-4a72-bfd4-a86b1ad646f5.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="550" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/67c57287-cb37-4b04-a90b-443234f99920.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="550" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/c167d153-a4b9-4cd9-8c28-5091dd41a037.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="550" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/631ff826-78e7-4d98-8618-20c4ad66e4a0.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="547" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/4e61c4ce-15b1-48dd-93a4-b6bd41c97702.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="442" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/cf288119-e879-49bb-a183-edf5f9245b28.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="432" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/e17e2ae1-2be3-4e39-bf8f-ed948c40c824.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="432" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/b2d46765-20bb-446a-a484-ede1674b2166.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="281" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/cac55ab7-b88f-431b-a7e6-718ec2882641.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="278" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/7d8abf3e-8cf7-461c-af7c-829195562a11.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="278" width="512" height="288" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/75ee6522-0b08-4b76-bf2f-38f503093829.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="176" width="480" height="270" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/9beade48-97f0-4c69-991b-d60ad042e246.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="176" width="480" height="270" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/8856681d-a772-4de0-9843-139210ae3c83.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="174" width="480" height="270" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/df7135f7-e89e-4c98-b260-aa6a5293ef4b.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="145" width="320" height="180" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/64d04bff-9d0b-4af3-9d5a-38ca6eca7b5f.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="143" width="320" height="180" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/6d1e6726-dbbf-4d59-b22c-33e488e8dfac.mp4
]]>
</MediaFile>
<MediaFile delivery="progressive" type="video/mp4" bitrate="143" width="320" height="180" scalable="true">
<![CDATA[
http://d2weccgdf287ps.cloudfront.net/creatives/assets/139e6858-1417-43ba-ad40-fa2b330c5af6/8d737203-ca10-466a-819b-6599cc81a5ff.mp4
]]>
</MediaFile>
</MediaFiles>
<VideoClicks>
<ClickTracking>linearClickTrackingUrl</ClickTracking>
</VideoClicks>
</Linear>
</Creative>
</Creatives>
<Extensions>
<Extension xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="VPAdServerExtension_type" type="AdServer" name="Videoplaza">
<AdInfo showSkipButton="never" lastImpression="1467148272365" skipReset="24:00:00.0" requestType="lazy" gid="acb92938-be2a-4f82-96b2-d46f4a004819" cid="50261830-7fa4-43d8-9427-6d4db33502f2" format="spot_standard" variant="NORMAL" exclusive="false"/>
</Extension>
</Extensions>
</InLine>
</Ad>
</VAST>
42 changes: 21 additions & 21 deletions utils/VastParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
// there could be an <Error> element in the vast response
var noAdsErrorURL = $(vastXML).find("Error").text();
if (noAdsErrorURL) {
this.pingURL(this.ERROR_CODES.WRAPPER_NO_ADS, noAdsErrorURL);
this.pingErrorURL(this.ERROR_CODES.WRAPPER_NO_ADS, noAdsErrorURL);
}
// if the ad response came from a wrapper, then go up the chain and ping those error urls
//this.trackError(this.ERROR_CODES.WRAPPER_NO_ADS, this.wrapperParentId);
Expand All @@ -255,25 +255,25 @@
/**
* Helper function to ping error URL. Replaces error macro if it exists.
* @public
* @method VastParser#pingURL
* @method VastParser#pingErrorURL
* @param {number} code Error code
* @param {string} url URL to ping
*/
this.pingURL = function(code, url) {
this.pingErrorURL = function(code, url) {
url = url.replace(/\[ERRORCODE\]/, code);
OO.pixelPing(url);
};

/**
* Helper function to ping error URLs.
* @public
* @method VastParser#pingURLs
* @method VastParser#pingErrorURLs
* @param {number} code Error code
* @param {string[]} urls URLs to ping
*/
this.pingURLs = function(code, urls) {
this.pingErrorURLs = function(code, urls) {
_.each(urls, function() {
pingURL(code, url);
this.pingErrorURL(code, url);
}, this);
};

Expand All @@ -283,7 +283,7 @@
* Note: <Error> can only live in three places: directly under <VAST>, <Ad>, or <Wrapper> elements.
* <Error> tags are also optional so they may not always exist.
* @public
* @method Vast#getErrorTrackingInfo
* @method VastParser#getErrorTrackingInfo
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @param {object} ads A jQuery object which contains the collection of ad elements found
*/
Expand All @@ -306,7 +306,7 @@
/**
* Helper function to verify that XML is valid
* @public
* @method Vast#isValidVastXML
* @method VastParser#isValidVastXML
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @returns {boolean} Returns true if the xml is valid otherwise it returns false.
*/
Expand All @@ -317,7 +317,7 @@
/**
* Helper function to verify XML has valid VAST root tag.
* @public
* @method Vast#isValidRootTagName
* @method VastParser#isValidRootTagName
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @returns {boolean} Returns true if the root tag is valid otherwise it returns false.
*/
Expand All @@ -333,7 +333,7 @@
/**
* Helper function to verify XML is a valid VAST version.
* @public
* @method Vast#isValidVastVersion
* @method VastParser#isValidVastVersion
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @returns {boolean} Returns true if the VAST version is valid otherwise it returns false.
*/
Expand All @@ -350,7 +350,7 @@
/**
* Returns the Vast version of the provided XML.
* @private
* @method Vast#getVastVersion
* @method VastParser#getVastVersion
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @returns {string} The Vast version.
*/
Expand All @@ -362,7 +362,7 @@
/**
* Helper function to get the VAST root element.
* @private
* @method Vast#getVastRoot
* @method VastParser#getVastRoot
* @param {XMLDocument} vastXML Contains the vast ad data to be parsed
* @returns {object} null if a VAST tag is absent, or if there are multiple VAST tags. Otherwise,
* returns the VAST root element.
Expand All @@ -383,7 +383,7 @@
/**
* Returns the Vast major version. For example, the '3' in 3.0.
* @private
* @method Vast#getMajorVersion
* @method VastParser#getMajorVersion
* @param {string} version The Vast version as parsed from the XML
* @returns {string} The major version.
*/
Expand All @@ -396,7 +396,7 @@
/**
* Checks to see if this ad manager supports a given Vast version.
* @private
* @method Vast#supportsVersion
* @method VastParser#supportsVersion
* @param {string} version The Vast version as parsed from the XML
* @returns {boolean} true if the version is supported by this ad manager, false otherwise.
*/
Expand All @@ -408,7 +408,7 @@
* Checks to see if the given Vast version supports the podded ads functionality, as per Vast specs
* for different versions.
* @private
* @method Vast#supportsPoddedAds
* @method VastParser#supportsPoddedAds
* @returns {boolean} true if the podded ads functionality is supported in the specified Vast version,
* false otherwise
*/
Expand All @@ -420,7 +420,7 @@
* Checks to see if the given Vast version supports the ad fallback functionality, as per Vast specs
* for different versions.
* @private
* @method Vast#supportsAdFallback
* @method VastParser#supportsAdFallback
* @returns {boolean} true if the ad fallback functionality is supported in the specified Vast version,
* false otherwise
*/
Expand All @@ -431,7 +431,7 @@
/**
* Default template to use when creating the vast ad object.
* @private
* @method Vast#getVastTemplate
* @method VastParser#getVastTemplate
* @returns {object} The ad object that is formated to what we expect vast to look like.
*/
var getVastTemplate = _.bind(function() {
Expand All @@ -448,7 +448,7 @@
/**
* Helper function to remove empty items.
* @private
* @method Vast#filterEmpty
* @method VastParser#filterEmpty
* @param {Array} array An array that is the be checked if it is empty
* @returns {Array} The filtered array.
*/
Expand All @@ -459,7 +459,7 @@
/**
* While getting the ad data the manager needs to parse the companion ad data as well and add it to the object.
* @private
* @method Vast#parseCompanionAd
* @method VastParser#parseCompanionAd
* @param {XMLDocument} companionAdXML XML that contains the companion ad data
* @returns {object} The ad object with companion ad.
*/
Expand Down Expand Up @@ -495,7 +495,7 @@
* Checks if there is any companion ads associated with the ad and if one is found, it will call the Ad Manager
* Controller to show it.
* @public
* @method Vast#checkCompanionAds
* @method VastParser#checkCompanionAds
* @param {object} adInfo The Ad metadata
*/
this.checkCompanionAds = function(adInfo) {
Expand All @@ -517,7 +517,7 @@
/**
* The xml is parsed to find any tracking events and then returned as part of an object.
* @private
* @method Vast#parseTrackingEvents
* @method VastParser#parseTrackingEvents
* @param {object} tracking The tracking object to be mutated
* @param {XMLDocument} xml The data of the ad with tracking info
* @param {string[]} trackingEvents List of events that are tracked, if null then it uses the global one
Expand Down

0 comments on commit e7474ef

Please sign in to comment.