Skip to content

Commit

Permalink
Removed geoOverride flag (#26724)
Browse files Browse the repository at this point in the history
  • Loading branch information
Micajuine Ho authored Feb 11, 2020
1 parent 15b60a3 commit 7c483dd
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 98 deletions.
1 change: 0 additions & 1 deletion build-system/global-configs/canary-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"amp-ad-ff-adx-ady": 0.01,
"amp-auto-ads-adsense-holdout": 0.1,
"amp-auto-ads-no-op-experiment": 0.05,
"amp-consent-geo-override": 1,
"amp-consent-v2": 1,
"amp-mega-menu": 1,
"amp-nested-menu": 1,
Expand Down
1 change: 0 additions & 1 deletion build-system/global-configs/prod-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"amp-ad-ff-adx-ady": 0.01,
"amp-auto-ads-adsense-holdout": 0.1,
"amp-auto-ads-no-op-experiment": 0.05,
"amp-consent-geo-override": 1,
"amp-consent-v2": 1,
"amp-mega-menu": 1,
"amp-nested-menu": 1,
Expand Down
71 changes: 2 additions & 69 deletions extensions/amp-consent/0.1/amp-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {ConsentPolicyManager} from './consent-policy-manager';
import {ConsentStateManager} from './consent-state-manager';
import {ConsentUI} from './consent-ui';
import {Deferred} from '../../../src/utils/promise';
import {GEO_IN_GROUP} from '../../amp-geo/0.1/amp-geo-in-group';
import {
NOTIFICATION_UI_MANAGER,
NotificationUiManager,
Expand All @@ -38,7 +37,7 @@ import {
resolveRelativeUrl,
} from '../../../src/url';
import {dev, devAssert, user, userAssert} from '../../../src/log';
import {dict, hasOwn} from '../../../src/utils/object';
import {dict} from '../../../src/utils/object';
import {getData} from '../../../src/event-helper';
import {getServicePromiseForDoc} from '../../../src/service';
import {isEnumValue} from '../../../src/types';
Expand Down Expand Up @@ -425,11 +424,7 @@ export class AmpConsent extends AMP.BaseElement {
*/
init_() {
this.passSharedData_();
if (isExperimentOn(this.win, 'amp-consent-geo-override')) {
this.syncRemoteConsentState_();
} else {
this.maybeSetDirtyBit_();
}
this.syncRemoteConsentState_();

this.getConsentRequiredPromise_()
.then(isConsentRequired => {
Expand All @@ -454,9 +449,6 @@ export class AmpConsent extends AMP.BaseElement {
* @return {!Promise<boolean>}
*/
getConsentRequiredPromise_() {
if (!isExperimentOn(this.win, 'amp-consent-geo-override')) {
return this.getConsentRequiredPromiseLegacy_();
}
return this.consentStateManager_
.getConsentInstanceInfo()
.then(storedInfo => {
Expand All @@ -476,41 +468,6 @@ export class AmpConsent extends AMP.BaseElement {
});
}

/**
* Returns a promise that resolve when amp-consent knows
* if the consent is required.
* @return {!Promise<boolean>}
*/
getConsentRequiredPromiseLegacy_() {
let consentRequiredPromise = null;
if (this.consentConfig_['promptIfUnknownForGeoGroup']) {
const geoGroup = this.consentConfig_['promptIfUnknownForGeoGroup'];
consentRequiredPromise = this.isConsentRequiredGeo_(geoGroup);
} else {
consentRequiredPromise = this.getConsentRemote_().then(
remoteConfigResponse => {
if (
!remoteConfigResponse ||
!hasOwn(remoteConfigResponse, 'promptIfUnknown')
) {
this.user().error(
TAG,
'Expecting promptIfUnknown from ' +
'checkConsentHref when promptIfUnknownForGeoGroup is not ' +
'specified'
);
// Set to false if not defined
return false;
}
return !!remoteConfigResponse['promptIfUnknown'];
}
);
}
return consentRequiredPromise.then(required => {
return !!required;
});
}

/**
* Blindly pass sharedData
*/
Expand All @@ -526,18 +483,6 @@ export class AmpConsent extends AMP.BaseElement {
this.consentStateManager_.setConsentInstanceSharedData(sharedDataPromise);
}

/**
* Set dirtyBit of the local consent value based on server response
*/
maybeSetDirtyBit_() {
const responsePromise = this.getConsentRemote_();
responsePromise.then(response => {
if (response && !!response['forcePromptOnNext']) {
this.consentStateManager_.setDirtyBit();
}
});
}

/**
* Clear cache for server side decision and then sync.
*/
Expand Down Expand Up @@ -582,18 +527,6 @@ export class AmpConsent extends AMP.BaseElement {
}
}

/**
* Returns a promise that if user is in the given geoGroup
* @param {string} geoGroup
* @return {Promise<boolean>}
*/
isConsentRequiredGeo_(geoGroup) {
return Services.geoForDocOrNull(this.element).then(geo => {
userAssert(geo, 'requires <amp-geo> to use promptIfUnknownForGeoGroup');
return geo.isInCountryGroup(geoGroup) == GEO_IN_GROUP.IN;
});
}

/**
* Get localStored consent info, and send request to get consent from endpoint
* if there is checkConsentHref specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describes.endtoend(
{
testUrl:
'http://localhost:8000/test/manual/amp-consent/amp-consent-basic-uses.amp.html#amp-geo=de',
experiments: ['amp-consent-geo-override'],
// TODO (micajuineho): Add shadow-demo after #25985 is fixed and viewer-demo when...
environments: ['single'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describes.endtoend(
{
testUrl:
'http://localhost:8000/test/manual/amp-consent/amp-consent-basic-uses.amp.html#amp-geo=mx',
experiments: ['amp-consent-geo-override'],
// TODO (micajuineho): Add shadow-demo after #25985 is fixed, and viewer-demo when...
environments: ['single'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describes.endtoend(
{
testUrl:
'http://localhost:8000/test/manual/amp-consent/amp-consent-basic-uses.amp.html#amp-geo=us',
experiments: ['amp-consent-geo-override'],
// TODO (micajuineho): Add shadow-demo after #25985 is fixed and viewer-demo when...
environments: ['single'],
},
Expand Down
17 changes: 0 additions & 17 deletions extensions/amp-consent/0.1/test/test-amp-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,6 @@ describes.realWin(

describe('geo-override server communication', () => {
let ampConsent;
beforeEach(() => {
toggleExperiment(win, 'amp-consent-geo-override', true);
});

afterEach(() => {
toggleExperiment(win, 'amp-consent-geo-override', false);
});

it('checks local storage before making sever request', async () => {
const config = {
Expand Down Expand Up @@ -825,12 +818,7 @@ describes.realWin(
});
});

afterEach(() => {
toggleExperiment(win, 'amp-consent-geo-override', false);
});

it('should not show promptUI if local storage has decision', async () => {
toggleExperiment(win, 'amp-consent-geo-override', true);
const config = {
'consentInstanceId': 'abc',
'consentRequired': 'remote',
Expand Down Expand Up @@ -945,7 +933,6 @@ describes.realWin(

describe('hide/show postPromptUI with local storage', () => {
beforeEach(() => {
toggleExperiment(win, 'amp-consent-geo-override', true);
defaultConfig = dict({
'consentInstanceId': 'ABC',
'consentRequired': true,
Expand All @@ -959,10 +946,6 @@ describes.realWin(
ampConsent = new AmpConsent(consentElement);
});

afterEach(() => {
toggleExperiment(win, 'amp-consent-geo-override', false);
});

it('hides postPromptUI with no local storage decision', async () => {
await ampConsent.buildCallback();
expect(postPromptUI).to.have.display('none');
Expand Down
7 changes: 0 additions & 7 deletions tools/experiments/experiments-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ export const EXPERIMENTS = [
spec: 'https://github.com/ampproject/amphtml/issues/26432',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/26432',
},
{
id: 'amp-consent-geo-override',
name: 'AMP consent modified to support CCPA',
spec:
'https://github.com/ampproject/amphtml/blob/lannka-consent-design/extensions/amp-consent/amp-consent.md',
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/25623',
},
{
id: 'amp-sidebar-v2',
name: 'Updated sidebar component with nested menu and animations',
Expand Down

0 comments on commit 7c483dd

Please sign in to comment.