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
Move extractSize to a separate hook #10127
Conversation
.then(adResponse => { | ||
expect(adResponse).to.deep.equal( | ||
{creative, signature: base64UrlDecodeToBytes('AQAB')}); | ||
expect(impl.extractSize(headers)).to.deep.equal(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent is off here.
extensions/amp-a4a/0.1/amp-a4a.js
Outdated
@@ -649,20 +654,23 @@ export class AmpA4A extends AMP.BaseElement { | |||
// This block returns the ad creative and signature, if available; null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update these comments to reflect that size will also be passed down through here.
expect(loadExtensionSpy.withArgs('amp-analytics')).to.be.called; | ||
signature: base64UrlDecodeToBytes('AQAB'), | ||
}); | ||
expect(impl.extractSize(headers)).to.deep.equal(size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent here as well.
extensions/amp-a4a/0.1/amp-a4a.js
Outdated
if (!headerValue) { | ||
return null; | ||
} | ||
if (!(/[0-9]+x[0-9]+/.test(headerValue))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to do a RegExp, why not just capture the values out of the regexp and save the split?
if (size) { | ||
this.size_ = size; | ||
} else { | ||
size = this.size_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This always felt odd to me. Why not have this return null if its not in the headers and move the logic to when we apply sizing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be honest, I don't really understand how this code works. Do you mean the call to setStyles
in onCreativeRender
? Where would that code get the information about what size to use, if it wasn't set here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK no need to address in this PR.
if (size) { | ||
this.size_ = size; | ||
} else { | ||
size = this.size_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK no need to address in this PR.
Determining the size of a Fast Fetch creative is now done through its own overridable method in
AmpA4A
. This will facilitate the deprecation ofextractCreativeAndSignature
, which in turn will facilitate having two different signature schemes controlled by a client-side experiment.One of the PRs that #9040 is being split into. Related to #7618.