Skip to content

Commit 50fd083

Browse files
committed
Experiment: story auto advance and new cta button
1 parent 9b20e07 commit 50fd083

13 files changed

Lines changed: 119 additions & 16 deletions

File tree

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
randomlySelectUnsetExperiments,
4444
} from '#experiments';
4545
import {StoryAdPlacements} from '#experiments/story-ad-placements';
46+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
4647

4748
import {Services} from '#service';
4849
import {Navigation} from '#service/navigation';
@@ -243,6 +244,14 @@ export class AmpAdNetworkAdsenseImpl extends AmpA4A {
243244
if (storyAdPlacementsExpId) {
244245
addExperimentIdToElement(storyAdPlacementsExpId, this.element);
245246
}
247+
248+
const storyAdSegmentBranch = getExperimentBranch(
249+
this.win,
250+
StoryAdSegmentExp.ID
251+
);
252+
if (storyAdSegmentBranch) {
253+
addExperimentIdToElement(storyAdSegmentBranch, this.element);
254+
}
246255
}
247256

248257
/**

extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
randomlySelectUnsetExperiments,
6969
} from '#experiments';
7070
import {StoryAdPlacements} from '#experiments/story-ad-placements';
71+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
7172

7273
import {Services} from '#service';
7374
import {Navigation} from '#service/navigation';
@@ -495,6 +496,14 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
495496
if (storyAdPlacementsExpId) {
496497
addExperimentIdToElement(storyAdPlacementsExpId, this.element);
497498
}
499+
500+
const storyAdSegmentBranch = getExperimentBranch(
501+
this.win,
502+
StoryAdSegmentExp.ID
503+
);
504+
if (storyAdSegmentBranch) {
505+
addExperimentIdToElement(storyAdSegmentBranch, this.element);
506+
}
498507
}
499508

500509
/**

extensions/amp-story-auto-ads/0.1/amp-story-auto-ads.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CommonSignals_Enum} from '#core/constants/common-signals';
22

33
import {forceExperimentBranch} from '#experiments';
44
import {divertStoryAdPlacements} from '#experiments/story-ad-placements';
5+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
56

67
import {Services} from '#service';
78

@@ -43,7 +44,12 @@ const MUSTACHE_TAG = 'amp-mustache';
4344
* @const {Object<string, string>}
4445
* @visibleForTesting
4546
*/
46-
export const RELEVANT_PLAYER_EXPS = {};
47+
export const RELEVANT_PLAYER_EXPS = {
48+
[StoryAdSegmentExp.CONTROL]: StoryAdSegmentExp.ID,
49+
[StoryAdSegmentExp.AUTO_ADVANCE_OLD_CTA]: StoryAdSegmentExp.ID,
50+
[StoryAdSegmentExp.AUTO_ADVANCE_NEW_CTA]: StoryAdSegmentExp.ID,
51+
[StoryAdSegmentExp.AUTO_ADVANCE_NEW_CTA_NOT_ANIMATED]: StoryAdSegmentExp.ID,
52+
};
4753

4854
/** @enum {string} */
4955
export const Attributes = {

extensions/amp-story-auto-ads/0.1/story-ad-page.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {setStyle} from '#core/dom/style';
99
import {map} from '#core/types/object';
1010
import {parseJson} from '#core/types/object/json';
1111

12-
import {isExperimentOn} from '#experiments';
12+
import {getExperimentBranch} from '#experiments';
13+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
1314

1415
import {getData, listen} from '#utils/event-helper';
1516
import {dev, devAssert, userAssert} from '#utils/log';
@@ -313,7 +314,14 @@ export class StoryAdPage {
313314
'id': this.id_,
314315
};
315316

316-
if (isExperimentOn(this.win_, 'story-ad-auto-advance')) {
317+
const storyAdSegmentBranch = getExperimentBranch(
318+
this.win_,
319+
StoryAdSegmentExp.ID
320+
);
321+
if (
322+
storyAdSegmentBranch &&
323+
storyAdSegmentBranch != StoryAdSegmentExp.CONTROL
324+
) {
317325
attributes['auto-advance-after'] = '10s';
318326
}
319327

extensions/amp-story-auto-ads/0.1/story-ad-ui.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {createElementWithAttributes} from '#core/dom';
22
import {map} from '#core/types/object';
33
import {getWin} from '#core/window';
44

5-
import {isExperimentOn} from '#experiments';
5+
import {getExperimentBranch} from '#experiments';
6+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
67

78
import {Services} from '#service';
89

@@ -309,7 +310,15 @@ export function createCta(doc, buttonFitter, container, uiMetadata) {
309310
return null;
310311
}
311312

312-
if (isExperimentOn(doc.defaultView, 'story-ad-auto-advance')) {
313+
const storyAdSegmentBranch = getExperimentBranch(
314+
doc.defaultView,
315+
StoryAdSegmentExp.ID
316+
);
317+
if (
318+
storyAdSegmentBranch == StoryAdSegmentExp.AUTO_ADVANCE_NEW_CTA ||
319+
storyAdSegmentBranch ==
320+
StoryAdSegmentExp.AUTO_ADVANCE_NEW_CTA_NOT_ANIMATED
321+
) {
313322
return createPageOutlink_(doc, uiMetadata, container);
314323
} else {
315324
return createCtaLayer_(a, doc, container);

extensions/amp-story-auto-ads/0.1/test/test-story-ad-ui.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {toggleExperiment} from '#experiments';
1+
import {forceExperimentBranch} from '#experiments';
2+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
23

34
import {ButtonTextFitter} from '../story-ad-button-text-fitter';
45
import {
@@ -248,7 +249,11 @@ describes.realWin('story-ad-ui', {amp: true}, (env) => {
248249

249250
beforeEach(() => {
250251
buttonFitter = new ButtonTextFitter(env.ampdoc);
251-
toggleExperiment(win, 'story-ad-auto-advance', true);
252+
forceExperimentBranch(
253+
win,
254+
StoryAdSegmentExp.ID,
255+
StoryAdSegmentExp.AUTO_ADVANCE_NEW_CTA
256+
);
252257
});
253258

254259
it('createCta page outlink custom theme element', () => {

extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@
168168
animation: i-amphtml-tap-scale var(--i-amphtml-page-attachment-ui-animation-duration) var(--i-amphtml-page-attachment-ui-animation-delay) both !important;
169169
}
170170

171+
.i-amphtml-story-page-open-attachment-outlink-no-animation-exp.i-amphtml-story-page-open-attachment-outlink-no-animation-exp[active] {
172+
animation: none !important;
173+
}
174+
171175
.i-amphtml-story-outlink-page-attachment-arrow {
172176
display: block !important;
173177
cursor: pointer !important;
@@ -180,6 +184,10 @@
180184
animation: i-amphtml-move-up-arrow var(--i-amphtml-page-attachment-ui-animation-duration) var(--i-amphtml-page-attachment-ui-animation-delay) both !important;
181185
}
182186

187+
.i-amphtml-story-page-open-attachment.i-amphtml-story-page-open-attachment-outlink-no-animation-exp[active] .i-amphtml-story-outlink-page-attachment-arrow {
188+
animation: none !important;
189+
}
190+
183191
@keyframes i-amphtml-move-up-arrow {
184192
0%, 100% {
185193
opacity: 1;

extensions/amp-story-page-attachment/0.1/amp-story-open-page-attachment.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/**
22
* @fileoverview Helper for amp-story rendering of page-attachment UI.
33
*/
4+
import objStr from 'obj-str';
5+
46
import * as Preact from '#core/dom/jsx';
57
import {scopedQuerySelector} from '#core/dom/query';
68
import {computedStyle, setImportantStyles} from '#core/dom/style';
79
import {getWin} from '#core/window';
810

11+
import {getExperimentBranch} from '#experiments';
12+
913
import {Services} from '#service';
1014
import {LocalizedStringId_Enum} from '#service/localization/strings';
1115

@@ -128,13 +132,21 @@ const renderOutlinkUI = (pageEl, attachmentEl) => {
128132
// Set image.
129133
const openImgAttr = attachmentEl.getAttribute('cta-image');
130134

135+
const noAnimation =
136+
getExperimentBranch(getWin(pageEl), 'story-ad-auto-advance') == 'c';
137+
131138
return openLabelOrFallback(
132139
pageEl,
133140
anchorChild?.textContent || ctaLabelFromAttr(attachmentEl)
134141
).then((openLabel) => {
135142
const openAttachmentEl = (
136143
<a
137-
class="i-amphtml-story-page-open-attachment i-amphtml-story-page-open-attachment-outlink"
144+
class={objStr({
145+
'i-amphtml-story-page-open-attachment': true,
146+
'i-amphtml-story-page-open-attachment-outlink': true,
147+
'i-amphtml-story-page-open-attachment-outlink-no-animation-exp':
148+
noAnimation,
149+
})}
138150
role="button"
139151
target="_top"
140152
title={attachmentTitle}

extensions/amp-story/1.0/amp-story-page.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {isAutoplaySupported, tryPlay} from '#core/dom/video';
2424
import {toArray} from '#core/types/array';
2525
import {debounce, once} from '#core/types/function';
2626

27-
import {isExperimentOn} from '#experiments';
27+
import {getExperimentBranch, isExperimentOn} from '#experiments';
28+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
2829

2930
import {Services} from '#service';
3031
import {LocalizedStringId_Enum} from '#service/localization/strings';
@@ -1105,8 +1106,15 @@ export class AmpStoryPage extends AMP.BaseElement {
11051106
emitProgress_(progress) {
11061107
// Don't emit progress for ads, since the progress bar is hidden.
11071108
// Don't emit progress for inactive pages, because race conditions.
1109+
const storyAdSegmentBranch = getExperimentBranch(
1110+
this.win,
1111+
StoryAdSegmentExp.ID
1112+
);
1113+
const progressBarExpDisabled =
1114+
!storyAdSegmentBranch ||
1115+
storyAdSegmentBranch == StoryAdSegmentExp.CONTROL;
11081116
if (
1109-
(!isExperimentOn(this.win, 'story-ad-auto-advance') && this.isAd()) ||
1117+
(progressBarExpDisabled && this.isAd()) ||
11101118
this.state_ === PageState.NOT_ACTIVE
11111119
) {
11121120
return;

extensions/amp-story/1.0/amp-story.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ import {endsWith} from '#core/types/string';
5252
import {parseQueryString} from '#core/types/string/url';
5353
import {getHistoryState as getWindowHistoryState} from '#core/window/history';
5454

55-
import {isExperimentOn} from '#experiments';
55+
import {getExperimentBranch, isExperimentOn} from '#experiments';
56+
import {StoryAdSegmentExp} from '#experiments/story-ad-progress-segment';
5657

5758
import {Services} from '#service';
5859
import {calculateExtensionFileUrl} from '#service/extension-script';
@@ -655,9 +656,14 @@ export class AmpStory extends AMP.BaseElement {
655656
return;
656657
}
657658

659+
const storyAdSegmentBranch = getExperimentBranch(
660+
this.win,
661+
StoryAdSegmentExp.ID
662+
);
658663
if (
659664
!this.activePage_.isAd() ||
660-
isExperimentOn(this.win, 'story-ad-auto-advance')
665+
(storyAdSegmentBranch &&
666+
storyAdSegmentBranch != StoryAdSegmentExp.CONTROL)
661667
) {
662668
this.systemLayer_.updateProgress(pageId, progress);
663669
}

0 commit comments

Comments
 (0)