Skip to content

Commit fe036b3

Browse files
authored
🚮 clean up analytics-chunks experiment (ampproject#30600)
* clean up analytics-chunks experiment * prettify * fix test * lint * fake dom postMessage
1 parent 4e6b3c9 commit fe036b3

File tree

6 files changed

+19
-23
lines changed

6 files changed

+19
-23
lines changed

‎build-system/global-configs/canary-config.json‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"allow-doc-opt-in": [
3-
"amp-next-page",
4-
"analytics-chunks",
5-
"analytics-chunks-inabox"
6-
],
2+
"allow-doc-opt-in": ["amp-next-page", "analytics-chunks-inabox"],
73
"allow-url-opt-in": ["pump-early-frame"],
84
"amp-accordion-display-locking": 0.1,
95
"canary": 1,
@@ -34,7 +30,6 @@
3430
"swg-gpay-api": 1,
3531
"swg-gpay-native": 1,
3632
"amp-ad-no-center-css": 0,
37-
"analytics-chunks": 1,
3833
"render-on-idle-fix": 1,
3934
"build-in-chunks": 1,
4035
"visibility-trigger-improvements": 1,

‎build-system/global-configs/prod-config.json‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"allow-doc-opt-in": [
3-
"amp-next-page",
4-
"analytics-chunks",
5-
"analytics-chunks-inabox"
6-
],
2+
"allow-doc-opt-in": ["amp-next-page", "analytics-chunks-inabox"],
73
"allow-url-opt-in": ["pump-early-frame"],
84
"canary": 0,
95
"a4aProfilingRate": 0.01,
@@ -33,7 +29,6 @@
3329
"swg-gpay-api": 1,
3430
"swg-gpay-native": 1,
3531
"amp-ad-no-center-css": 0,
36-
"analytics-chunks": 1,
3732
"adsense-ptt-exp": 0.1,
3833
"doubleclick-ptt-exp": 0.1
3934
}

‎extensions/amp-analytics/0.1/analytics-group.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ export function isAnalyticsChunksExperimentOn(win) {
130130
if (getMode(win).runtime == 'inabox') {
131131
return isExperimentOn(win, 'analytics-chunks-inabox');
132132
}
133-
return isExperimentOn(win, 'analytics-chunks');
133+
return true;
134134
}

‎extensions/amp-analytics/0.1/test/test-amp-analytics.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import {installCryptoService} from '../../../../src/service/crypto-impl';
3535
import {installUserNotificationManagerForTesting} from '../../../amp-user-notification/0.1/amp-user-notification';
3636
import {instrumentationServiceForDocForTesting} from '../instrumentation';
37+
import {macroTask} from '../../../../testing/yield';
3738

3839
describes.realWin(
3940
'amp-analytics',
@@ -397,7 +398,7 @@ describes.realWin(
397398
});
398399
});
399400

400-
it('fills internally provided trigger vars', function () {
401+
it('fills internally provided trigger vars', async function* () {
401402
const analytics = getAnalyticsTag({
402403
'requests': {
403404
'timer':
@@ -413,7 +414,7 @@ describes.realWin(
413414
'visibility': {'on': 'visible', 'request': 'visible'},
414415
},
415416
});
416-
417+
await macroTask();
417418
return waitForSendRequest(analytics).then(() => {
418419
requestVerifier.verifyRequestMatch(
419420
/https:\/\/e.com\/start=[0-9]+&duration=[0-9]/
@@ -455,7 +456,7 @@ describes.realWin(
455456
});
456457
});
457458

458-
it('updates requestCount on each request', () => {
459+
it('updates requestCount on each request', async function* () {
459460
const analytics = getAnalyticsTag({
460461
'host': 'example.test',
461462
'requests': {
@@ -467,6 +468,7 @@ describes.realWin(
467468
{'on': 'visible', 'request': 'pageview2'},
468469
],
469470
});
471+
await macroTask();
470472
return waitForSendRequest(analytics).then(() => {
471473
requestVerifier.verifyRequest('/test1=1');
472474
requestVerifier.verifyRequest('/test2=2');
@@ -1700,12 +1702,13 @@ describes.realWin(
17001702
analytics.getAmpDoc = () => ampdoc;
17011703
});
17021704

1703-
it('Initializes a new Linker.', () => {
1705+
it('Initializes a new Linker.', async function* () {
17041706
env.sandbox.stub(AnalyticsConfig.prototype, 'loadConfig').resolves({});
17051707

17061708
const linkerStub = env.sandbox.stub(LinkerManager.prototype, 'init');
17071709

17081710
analytics.buildCallback();
1711+
await macroTask();
17091712
return analytics.layoutCallback().then(() => {
17101713
expect(linkerStub.calledOnce).to.be.true;
17111714
});

‎testing/fake-dom.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ class EventListeners {
297297
const {
298298
addEventListener: originalAdd,
299299
removeEventListener: originalRemove,
300+
postMessage: originalPostMessage,
300301
} = target;
301302
target.addEventListener = function (type, handler, captureOrOpts) {
302303
target.eventListeners.add(type, handler, captureOrOpts);
@@ -310,6 +311,14 @@ class EventListeners {
310311
originalRemove.apply(target, arguments);
311312
}
312313
};
314+
target.postMessage = function (type) {
315+
const e = new Event('message');
316+
e.data = type;
317+
target.eventListeners.fire(e);
318+
if (originalPostMessage) {
319+
originalPostMessage.apply(target, arguments);
320+
}
321+
};
313322
}
314323

315324
/** Create empty instance. */

‎tools/experiments/experiments-config.js‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ export const EXPERIMENTS = [
243243
spec: 'https://github.com/ampproject/amphtml/issues/26823',
244244
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/26823',
245245
},
246-
{
247-
id: 'analytics-chunks',
248-
name: 'AMP Analytics Break long tasks to chunks (AMP docs only)',
249-
spec: 'https://github.com/ampproject/amphtml/issues/28435',
250-
cleanupIssue: 'https://github.com/ampproject/amphtml/issues/28435',
251-
},
252246
{
253247
id: 'analytics-chunks-inabox',
254248
name: 'AMP Analytics Break long tasks to chunks (AMP Ads only)',

0 commit comments

Comments
 (0)