Skip to content

Commit 08de088

Browse files
committed
Remove attribution reporting api from ads
1 parent c309cc0 commit 08de088

12 files changed

Lines changed: 14 additions & 588 deletions

File tree

extensions/amp-a4a/0.1/amp-a4a.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {triggerAnalyticsEvent} from '#utils/analytics';
2828
import {DomTransformStream} from '#utils/dom-transform-stream';
2929
import {listenOnce} from '#utils/event-helper';
3030
import {dev, devAssert, logHashParam, user, userAssert} from '#utils/log';
31-
import {isAttributionReportingAllowed} from '#utils/privacy-sandbox-utils';
3231

3332
import {canSetCookie, getCookie} from 'src/cookies';
3433

@@ -2071,11 +2070,7 @@ export class AmpA4A extends AMP.BaseElement {
20712070
// Block synchronous XHR in ad. These are very rare, but super bad for UX
20722071
// as they block the UI thread for the arbitrary amount of time until the
20732072
// request completes.
2074-
let featurePolicies = "sync-xhr 'none';";
2075-
2076-
if (isAttributionReportingAllowed(this.win.document)) {
2077-
featurePolicies += "attribution-reporting 'src';";
2078-
}
2073+
const featurePolicies = "sync-xhr 'none';";
20792074

20802075
mergedAttributes['allow'] = featurePolicies;
20812076

extensions/amp-a4a/0.1/secure-frame.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {createElementWithAttributes, escapeHtml} from '#core/dom';
22

3-
import {isAttributionReportingAllowed} from '#utils/privacy-sandbox-utils';
4-
53
import {getFieSafeScriptSrcs} from '../../../src/friendly-iframe-embed';
64

75
// If making changes also change ALLOWED_FONT_REGEX in head-validation.js
@@ -85,9 +83,5 @@ export function createSecureFrame(win, title, height, width) {
8583
})
8684
);
8785

88-
if (isAttributionReportingAllowed(document)) {
89-
iframe.setAttribute('allow', `attribution-reporting 'src'`);
90-
}
91-
9286
return iframe;
9387
}

extensions/amp-a4a/0.1/test/test-amp-a4a.js

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {installRealTimeConfigServiceForDoc} from '#service/real-time-config/real
2020

2121
import * as analytics from '#utils/analytics';
2222
import {dev, user} from '#utils/log';
23-
import * as privacySandboxUtils from '#utils/privacy-sandbox-utils';
2423

2524
import {macroTask} from '#testing/helpers';
2625
import {createIframePromise} from '#testing/iframe';
@@ -921,34 +920,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
921920
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
922921
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
923922
});
924-
925-
it('should set feature policy for attribution-reporting when supported', async () => {
926-
env.sandbox
927-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
928-
.returns(true);
929-
a4a.sandboxHTMLCreativeFrame = () => true;
930-
a4a.onLayoutMeasure();
931-
await a4a.layoutCallback();
932-
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
933-
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
934-
expect(a4a.iframe.getAttribute('allow')).to.include(
935-
"attribution-reporting 'src';"
936-
);
937-
});
938-
939-
it('should not set feature policy for attribution-reporting when not supported', async () => {
940-
env.sandbox
941-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
942-
.returns(false);
943-
a4a.sandboxHTMLCreativeFrame = () => true;
944-
a4a.onLayoutMeasure();
945-
await a4a.layoutCallback();
946-
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
947-
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
948-
expect(a4a.iframe.getAttribute('allow')).to.not.include(
949-
"attribution-reporting 'src';"
950-
);
951-
});
952923
});
953924

954925
describe('illegal render mode value', () => {
@@ -1038,30 +1009,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
10381009
expect(fetchMock.called('ad')).to.be.true;
10391010
});
10401011

1041-
it('should set feature policy for attribution-reporting when supported', async () => {
1042-
env.sandbox
1043-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
1044-
.returns(true);
1045-
a4a.sandboxHTMLCreativeFrame = () => false;
1046-
a4a.onLayoutMeasure();
1047-
await a4a.layoutCallback();
1048-
verifyNameFrameRender(a4aElement, false /* shouldSandbox */);
1049-
expect(a4a.iframe.getAttribute('allow')).to.equal(
1050-
"sync-xhr 'none';attribution-reporting 'src';"
1051-
);
1052-
});
1053-
1054-
it('should not set feature policy for attribution-reporting when not supported', async () => {
1055-
env.sandbox
1056-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
1057-
.returns(false);
1058-
a4a.sandboxHTMLCreativeFrame = () => false;
1059-
a4a.onLayoutMeasure();
1060-
await a4a.layoutCallback();
1061-
verifyNameFrameRender(a4aElement, false /* shouldSandbox */);
1062-
expect(a4a.iframe.getAttribute('allow')).to.equal("sync-xhr 'none';");
1063-
});
1064-
10651012
['', 'client_cache', 'safeframe', 'some_random_thing'].forEach(
10661013
(headerVal) => {
10671014
it(`should not attach a NameFrame when header is ${headerVal}`, async () => {
@@ -1171,38 +1118,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
11711118
expect(fetchMock.called('ad')).to.be.true;
11721119
});
11731120

1174-
it('should set feature policy for attribution-reporting when supported', async () => {
1175-
env.sandbox
1176-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
1177-
.returns(true);
1178-
a4a.sandboxHTMLCreativeFrame = () => false;
1179-
a4a.onLayoutMeasure();
1180-
await a4a.layoutCallback();
1181-
verifySafeFrameRender(
1182-
a4aElement,
1183-
DEFAULT_SAFEFRAME_VERSION,
1184-
false /* shouldSandbox */
1185-
);
1186-
expect(a4a.iframe.getAttribute('allow')).to.equal(
1187-
"sync-xhr 'none';attribution-reporting 'src';"
1188-
);
1189-
});
1190-
1191-
it('should not set feature policy for attribution-reporting when not supported', async () => {
1192-
env.sandbox
1193-
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
1194-
.returns(false);
1195-
a4a.sandboxHTMLCreativeFrame = () => false;
1196-
a4a.onLayoutMeasure();
1197-
await a4a.layoutCallback();
1198-
verifySafeFrameRender(
1199-
a4aElement,
1200-
DEFAULT_SAFEFRAME_VERSION,
1201-
false /* shouldSandbox */
1202-
);
1203-
expect(a4a.iframe.getAttribute('allow')).to.equal("sync-xhr 'none';");
1204-
});
1205-
12061121
['', 'client_cache', 'nameframe', 'some_random_thing'].forEach(
12071122
(headerVal) => {
12081123
it(`should not attach a SafeFrame when header is ${headerVal}`, async () => {

extensions/amp-ad-exit/0.1/amp-ad-exit.js

Lines changed: 4 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import {Services} from '#service';
1414

1515
import {getData} from '#utils/event-helper';
1616
import {dev, devAssert, user, userAssert} from '#utils/log';
17-
import {
18-
AttributionReportingStatus,
19-
isAttributionReportingAllowed,
20-
} from '#utils/privacy-sandbox-utils';
2117

2218
import {TransportMode, assertConfig, assertVendor} from './config';
2319
import {makeClickDelaySpec} from './filters/click-delay';
@@ -93,8 +89,7 @@ export class AmpAdExit extends AMP.BaseElement {
9389
this.expectedOriginToVendor_ = {};
9490

9591
/** @private @const {boolean} */
96-
this.isAttributionReportingSupported_ =
97-
this.detectAttributionReportingSupport();
92+
this.isAttributionReportingSupported_ = false;
9893
}
9994

10095
/**
@@ -191,10 +186,8 @@ export class AmpAdExit extends AMP.BaseElement {
191186
getUrlVariableRewriter_(args, event, target) {
192187
const substitutionFunctions = {
193188
'ATTRIBUTION_REPORTING_STATUS': () =>
194-
getAttributionReportingStatus(
195-
this.isAttributionReportingSupported_,
196-
target
197-
),
189+
// ARA removed
190+
this.isAttributionReportingSupported_,
198191
'CLICK_X': () => event.clientX,
199192
'CLICK_Y': () => event.clientY,
200193
};
@@ -389,17 +382,7 @@ export class AmpAdExit extends AMP.BaseElement {
389382
.filter(Boolean),
390383
behaviors: target['behaviors'] || {},
391384
};
392-
if (
393-
this.isAttributionReportingSupported_ &&
394-
target?.behaviors?.browserAdConversion
395-
) {
396-
this.targets_[name]['windowFeatures'] =
397-
this.getAttributionReportingValues_(
398-
target?.behaviors?.browserAdConversion
399-
);
400-
} else {
401-
this.targets_[name]['trackingUrls'] = target['trackingUrls'] || [];
402-
}
385+
this.targets_[name]['trackingUrls'] = target['trackingUrls'] || [];
403386

404387
// Build a map of {vendor, origin} for 3p custom variables in the config
405388
for (const customVar in target['vars']) {
@@ -430,37 +413,6 @@ export class AmpAdExit extends AMP.BaseElement {
430413
this.init3pResponseListener_();
431414
}
432415

433-
/**
434-
* Determine if `attribution-reporting` is supported by user-agent. Should only return
435-
* true for Chrome 92+.
436-
* @visibleForTesting
437-
* @return {boolean}
438-
*/
439-
detectAttributionReportingSupport() {
440-
return isAttributionReportingAllowed(this.win.document);
441-
}
442-
443-
/**
444-
* Extracts the keys from the `browserAdConversion` data creates a
445-
* string to be used as the `features` param for the `window.open()` call.
446-
* @param {JsonObject} adConversionData
447-
* @return {?string}
448-
*/
449-
getAttributionReportingValues_(adConversionData) {
450-
if (!adConversionData || !Object.keys(adConversionData)) {
451-
return;
452-
}
453-
454-
// `noopener` is probably redundant here but left as defense in depth.
455-
// https://groups.google.com/a/chromium.org/g/blink-dev/c/FFX6VkvladY/m/QgaWHK6ZBAAJ
456-
const parts = ['noopener'];
457-
for (const key of Object.keys(adConversionData)) {
458-
const encoded = encodeURIComponent(adConversionData[key]);
459-
parts.push(`${key.toLowerCase()}=${encoded}`);
460-
}
461-
return parts.join(',');
462-
}
463-
464416
/**
465417
* Gets the resource ID of the amp-ad element containing this amp-ad-exit tag.
466418
* This is a pass-through for the version in service.js, solely because
@@ -580,26 +532,3 @@ export class AmpAdExit extends AMP.BaseElement {
580532
AMP.extension(TAG, '0.1', (AMP) => {
581533
AMP.registerElement(TAG, AmpAdExit);
582534
});
583-
584-
/**
585-
* Resolves the ATTRIBUTION_REPORTING_STATUS macro to the appropriate value
586-
* based on the given config and browser support.
587-
* @param {boolean} isAttributionReportingSupported
588-
* @param {!NavigationTargetDef} target
589-
* @return {AttributionReportingStatus}
590-
* @visibleForTesting
591-
*/
592-
export function getAttributionReportingStatus(
593-
isAttributionReportingSupported,
594-
target
595-
) {
596-
if (
597-
target?.behaviors?.browserAdConversion &&
598-
isAttributionReportingSupported
599-
) {
600-
return AttributionReportingStatus.ATTRIBUTION_DATA_PRESENT_AND_POLICY_ENABLED;
601-
} else if (target?.behaviors?.browserAdConversion?.attributionsrc) {
602-
return AttributionReportingStatus.ATTRIBUTION_DATA_PRESENT;
603-
}
604-
return AttributionReportingStatus.ATTRIBUTION_MACRO_PRESENT;
605-
}

0 commit comments

Comments
 (0)