Repository navigation
Run Open Measurement verification scripts declared in VAST wrappers - #1067
postindustria-code wants to merge 2 commits into
Conversation
AdVerifications were read from the InLine ad only, so a verification vendor added by a Wrapper was never measured. Scripts are now collected along the whole wrapper chain and deduplicated. A video ad without verification scripts skips the OM session with a debug log instead of an error on every event, and a script without a vendor or parameters is loaded without parameters rather than failing the session for all vendors.
The "no scripts" check ran before unusable scripts were dropped, so an ad whose every script was invalid still got an OM session with no scripts, and its later OM calls logged errors. The scripts are now converted first and the session is skipped when none is left. An empty <AdVerifications/> node also hid an Extension that had scripts; empty nodes and extensions are now ignored. "Using jsResource" is logged only for the scripts that are used. OmAdSessionManagerTest was an empty placeholder. It now checks how verification scripts become OM resources (with and without vendor or parameters, malformed or missing URLs), that an ad with no usable scripts skips the session with debug logs only, that a missing session without that skip still logs an error, and that the next ad with scripts clears the skip flag.
|
This PR might solve the issue #1066 |
YuriyVelichkoPI
left a comment
There was a problem hiding this comment.
Thanks, this closes #1066 nicely. Wrapper <AdVerifications> and wrapper Extensions are now read, the chain is merged and deduplicated, and the OM changes are a real improvement: one bad script no longer disables every vendor, and scripts without parameters still load. For InLine-only responses with valid scripts the OM script list is unchanged. CI is green, and the new tests plus the video/loading suites pass locally.
Please apply the changes below once #1034 is merged, and rebase onto it. #1034 changes how the played ad is selected (adIndex can now be greater than 0) and adds getAdIndex(parser, index), which returns the followed Wrapper ad for wrapper responses and the played ad for the last response. This PR has to build on that. Without it, the two PRs merge without a git conflict in AdResponseParserVast.java, but the wrapper scripts get dropped again (see 1).
-
Use the right ad at each level of the chain (inline on
AdResponseParserVast.java). The loop reads adindexin every response, not the Wrapper ad thatgetVastUrl()actually followed.- On its own, a multi-ad wrapper response runs a script from an ad that's never shown and skips the followed Wrapper's script.
- On top of #1034,
adIndex = 1makes a single-ad wrapper response returnnull, so the wrapper vendor is silently dropped. That's #1066 again.
After rebasing, use #1034's
getAdIndex(parser, index)in the loop and passadIndexfromCreativeModelsMakerVast, as #1066 suggested. -
Add a test for the wiring in
CreativeModelsMakerVast(inline). If line 116 is reverted to master, every test still passes. Please add a test throughmakeModelsthat asserts both the wrapper and the InLine vendor, plus a case where the played ad isn't ad 0 (and the followed Wrapper isn't ad 0).
|
|
||
| Ad ad = parserVast.vast.getAds().get(index); | ||
| for (AdResponseParserVast parser = parserVast; parser != null; parser = parser.wrappedVASTXml) { | ||
| AdVerifications adVerifications = getOwnAdVerifications(parser, index); |
There was a problem hiding this comment.
This uses the same index in every response of the chain. In a wrapper response, though, the ad that matters is the Wrapper that getVastUrl() followed (the first one with a VASTAdTagURI), not ad index.
- Today: a root response
[InLine "sib" (vendor siblingInline), Wrapper "w" (vendor followedWrapper)]givessiblingInline, inline. The followed wrapper's vendor is missing, and a script from an ad that isn't rendered runs. - With Render the first playable Linear creative of a VAST response #1034:
indexbecomes theadIndexof the last response. For a single-ad root Wrapper over[unplayable InLine, playable InLine],adIndex = 1, the root level returnsnull, and the wrapper vendor is dropped (adIndex=1 verifications=playedInline). This file auto-merges with Render the first playable Linear creative of a VAST response #1034, so git won't flag it.
Once #1034 is merged, please rebase and use its lookup here:
AdVerifications adVerifications = getOwnAdVerifications(parser, getAdIndex(parser, index));With that on #1034 + this PR, both cases give followedWrapper, …, and the existing suites (including #1034's tests) stay green.
| final String videoDuration = latestVastWrapperParser.getVideoDuration(latestVastWrapperParser, 0); | ||
| final String skipOffset = latestVastWrapperParser.getSkipOffset(latestVastWrapperParser, 0); | ||
| final AdVerifications adVerifications = rootVastParser.getAdVerification(latestVastWrapperParser, 0); | ||
| final AdVerifications adVerifications = rootVastParser.getAdVerification(rootVastParser, 0); |
There was a problem hiding this comment.
This line is what actually turns the feature on, but no test covers it. With it reverted to master's getAdVerification(latestVastWrapperParser, 0), all rendering.* tests and OmAdSessionManagerTest still pass (282 green).
After rebasing on #1034 this becomes rootVastParser.getAdVerification(rootVastParser, adIndex). Please add tests in CreativeModelsMakerVastTest that go through makeModels:
- A wrapper chain with a wrapper-level
<AdVerifications>(for example, extend thetestMakeModelsWrapperfixture or a copy of it). Assert thatmodel.getAdVerifications()contains both the wrapper vendor and the InLine vendor. - A case where the played ad isn't ad 0 (
adIndex > 0) and the followed Wrapper isn't ad 0. Assert that only the followed Wrapper's and the played InLine's vendors are present.
mdanylov-sigma
left a comment
There was a problem hiding this comment.
I agree with Yuriy's review (the per-level ad index after rebasing on #1034, and the makeModels wiring test), so I won't repeat those. There's one more issue this PR introduces, inline below.
Older gaps in the OM verification handling are tracked in #1068, so they don't block this PR. Wrapper scripts now reach them too: non-OMID resources, Extensions ignored next to a non-empty node, parameters dropped without a log when vendor is missing, and verificationNotExecuted.
| } | ||
| for (Verification verification : adVerifications.getVerifications()) { | ||
| // The same script is often repeated along the chain; running it twice would double count. | ||
| String key = verification.getVendor() + '|' + verification.getJsResource() |
There was a problem hiding this comment.
The key is built from the raw fields, but createVerificationScriptResources maps every entry with an empty vendor or empty parameters to createVerificationScriptResourceWithoutParameters(url). So entries that OM will receive as the same resource can still have different keys:
- a missing
<VerificationParameters>(null) and an empty<VerificationParameters/>("", sincereadTextreturns an empty string) - the same script with and without a
vendorattribute, when it has no parameters
Example: Wrapper <Verification vendor="dv"><JavaScriptResource>https://x/omid.js</JavaScriptResource></Verification>, and InLine with the same entry plus <VerificationParameters/>. The keys dv|https://x/omid.js|null and dv|https://x/omid.js| differ, so both become WithoutParameters(https://x/omid.js). The OM service script gives every resource its own iframe (omid-verification-script-frame-<id> in omsdk.js), so the script really runs twice. That's the double count the comment above says this prevents.
Could the key be built from what OM gets? For example, dedupe in createVerificationScriptResources after the mapping:
boolean withParameters = !TextUtils.isEmpty(vendorKey) && !TextUtils.isEmpty(params);
String key = url + "|" + (withParameters ? vendorKey + "|" + params : "");
if (!seen.add(key)) {
continue;
}Or keep it in the parser, but treat null and "" the same and leave the vendor out of the key when there are no parameters. A test with the null/empty pair would cover it.
Why:
AdVerificationswere read from the InLine ad only, so a verification vendor added by a VAST Wrapper was never measured.What changed
<AdVerifications/>nodes and extensions are ignored, so they no longer hide an extension that has scripts.Tested:
:PrebidMobile-core:testDebugUnitTest, with new cases inAdResponseParserVastTestandOmAdSessionManagerTest(previously an empty placeholder).MraidInternalBrowserActionTestfails onmasterwithout this change as well.iOS counterpart: prebid/prebid-mobile-ios#1457