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

🐛Check for window null before creating tracking pixel #26749

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions builtins/amp-pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export class AmpPixel extends BaseElement {
return Services.urlReplacementsForDoc(this.element)
.expandUrlAsync(this.assertSource_(src))
.then(src => {
if (!this.win) {
return;
}
const pixel = createPixel(this.win, src, this.referrerPolicy_);
dev().info(TAG, 'pixel triggered: ', src);
return pixel;
Expand Down
3 changes: 3 additions & 0 deletions extensions/amp-analytics/0.1/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ export class Transport {
* @param {string|undefined} referrerPolicy
*/
static sendRequestUsingImage(win, request, suppressWarnings, referrerPolicy) {
if (!win) {
return;
}
const image = createPixel(win, request.url, referrerPolicy);
loadPromise(image)
.then(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const TAG = 'pixel';
* @return {!Element}
*/
export function createPixel(win, src, referrerPolicy) {
// Caller need to verify window is not destoried when creating pixel
Copy link
Contributor

@Enriqe Enriqe Feb 12, 2020

Choose a reason for hiding this comment

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

nit: s/destoried/destroyed

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't let STAMP folk see this :)

Copy link
Contributor

Choose a reason for hiding this comment

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

LOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL!

if (referrerPolicy && referrerPolicy !== 'no-referrer') {
user().error(TAG, 'Unsupported referrerPolicy: %s', referrerPolicy);
}
Expand Down