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

Add byo cta action #3578

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 src/proto/api_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export enum AnalyticsEvent {
IMPRESSION_HOSTED_PAGE_CONTRIBUTION_OFFERS = 53,
IMPRESSION_HOSTED_PAGE_SUBSCRIPTION_OFFERS_ERROR = 54,
IMPRESSION_HOSTED_PAGE_CONTRIBUTION_OFFERS_ERROR = 55,
IMPRESSION_BYO_CTA = 56,
ACTION_SUBSCRIBE = 1000,
ACTION_PAYMENT_COMPLETE = 1001,
ACTION_ACCOUNT_CREATED = 1002,
Expand Down Expand Up @@ -188,6 +189,8 @@ export enum AnalyticsEvent {
ACTION_BYOP_NEWSLETTER_OPT_IN_CLOSE = 1084,
ACTION_BYOP_NEWSLETTER_OPT_IN_SUBMIT = 1085,
ACTION_SUBSCRIPTION_LINKING_CLOSE = 1086,
ACTION_BYO_CTA_CLOSE = 1087,
ACTION_BYO_CTA_BUTTON_CLICK = 1088,
EVENT_PAYMENT_FAILED = 2000,
EVENT_REGWALL_OPT_IN_FAILED = 2001,
EVENT_NEWSLETTER_OPT_IN_FAILED = 2002,
Expand Down
5 changes: 5 additions & 0 deletions src/runtime/audience-action-flow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
action: 'TYPE_REWARDED_SURVEY',
path: 'surveyiframe',
},
{
action: 'TYPE_BYO_CTA',
configurationId: 'byo_cta_config',
path: 'byoctaiframe',
},
].forEach(({action, configurationId, path}) => {
it(`opens an AudienceActionIframeFlow constructed with params for ${action}`, async () => {
sandbox.stub(runtime.storage(), 'get').resolves(null);
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/audience-action-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export const TYPE_REGISTRATION_WALL = 'TYPE_REGISTRATION_WALL';
export const TYPE_NEWSLETTER_SIGNUP = 'TYPE_NEWSLETTER_SIGNUP';
export const TYPE_REWARDED_SURVEY = 'TYPE_REWARDED_SURVEY';
export const TYPE_REWARDED_AD = 'TYPE_REWARDED_AD';
export const TYPE_BYO_CTA = 'TYPE_BYO_CTA';

const actionToIframeMapping: {[key: string]: string} = {
TYPE_REGISTRATION_WALL: '/regwalliframe',
TYPE_NEWSLETTER_SIGNUP: '/newsletteriframe',
TYPE_REWARDED_SURVEY: '/surveyiframe',
TYPE_BYO_CTA: '/byoctaiframe',
};

const autopromptTypeToProductTypeMapping: {
Expand Down Expand Up @@ -144,7 +146,7 @@ export class AudienceActionIframeFlow implements AudienceActionFlow {
/* shouldFadeBody */ true
);
// Disables interaction with prompt if rendering for preview.
if (!!params_.shouldRenderPreview) {
if (!!params_.shouldRenderPreview && params_.action !== TYPE_BYO_CTA) {
setImportantStyles(this.activityIframeView_.getElement(), {
'pointer-events': 'none',
});
Expand Down
16 changes: 14 additions & 2 deletions src/runtime/auto-prompt-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ describes.realWin('AutoPromptManager', (env) => {
eventType: AnalyticsEvent.IMPRESSION_REWARDED_AD,
action: 'TYPE_REWARDED_AD',
},
{
eventType: AnalyticsEvent.IMPRESSION_BYO_CTA,
action: 'TYPE_BYO_CTA',
},
{
eventType: AnalyticsEvent.IMPRESSION_OFFERS,
action: 'TYPE_SUBSCRIPTION',
Expand Down Expand Up @@ -452,6 +456,10 @@ describes.realWin('AutoPromptManager', (env) => {
eventType: AnalyticsEvent.ACTION_REWARDED_AD_CLOSE,
action: 'TYPE_REWARDED_AD',
},
{
eventType: AnalyticsEvent.ACTION_BYO_CTA_CLOSE,
action: 'TYPE_BYO_CTA',
},
{
eventType: AnalyticsEvent.ACTION_SUBSCRIPTION_OFFERS_CLOSED,
action: 'TYPE_SUBSCRIPTION',
Expand Down Expand Up @@ -588,6 +596,10 @@ describes.realWin('AutoPromptManager', (env) => {
eventType: AnalyticsEvent.ACTION_REWARDED_AD_VIEW,
action: 'TYPE_REWARDED_AD',
},
{
eventType: AnalyticsEvent.ACTION_BYO_CTA_BUTTON_CLICK,
action: 'TYPE_BYO_CTA',
},
{
eventType: AnalyticsEvent.EVENT_SUBSCRIPTION_PAYMENT_COMPLETE,
action: 'TYPE_SUBSCRIPTION',
Expand Down Expand Up @@ -3003,7 +3015,7 @@ describes.realWin('AutoPromptManager', (env) => {
actions: [
{
type: 'TYPE_BYO_CTA',
configurationId: 'rewarded_ad_config_id',
configurationId: 'byocta_config_id',
numberOfCompletions: 3,
},
],
Expand All @@ -3013,7 +3025,7 @@ describes.realWin('AutoPromptManager', (env) => {
interventionFunnel: {
interventions: [
{
configId: 'survey_config_id',
configId: 'byocta_config_id',
type: 'TYPE_BYO_CTA',
promptFrequencyCap,
closability: 'DISMISSIBLE',
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/auto-prompt-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const TYPE_NEWSLETTER_SIGNUP = 'TYPE_NEWSLETTER_SIGNUP';
const TYPE_REGISTRATION_WALL = 'TYPE_REGISTRATION_WALL';
const TYPE_REWARDED_SURVEY = 'TYPE_REWARDED_SURVEY';
const TYPE_REWARDED_AD = 'TYPE_REWARDED_AD';
const TYPE_BYO_CTA = 'TYPE_BYO_CTA';
const SECOND_IN_MILLIS = 1000;
const TWO_WEEKS_IN_MILLIS = 2 * 604800000;
const PREFERENCE_PUBLISHER_PROVIDED_PROMPT =
Expand All @@ -75,6 +76,7 @@ const DISMISSAL_EVENTS_TO_ACTION_MAP = new Map([
[AnalyticsEvent.ACTION_REGWALL_OPT_IN_CLOSE, TYPE_REGISTRATION_WALL],
[AnalyticsEvent.ACTION_SURVEY_CLOSED, TYPE_REWARDED_SURVEY],
[AnalyticsEvent.ACTION_REWARDED_AD_CLOSE, TYPE_REWARDED_AD],
[AnalyticsEvent.ACTION_BYO_CTA_CLOSE, TYPE_BYO_CTA],
[AnalyticsEvent.ACTION_SWG_SUBSCRIPTION_MINI_PROMPT_CLOSE, TYPE_SUBSCRIPTION],
[AnalyticsEvent.ACTION_SUBSCRIPTION_OFFERS_CLOSED, TYPE_SUBSCRIPTION],
]);
Expand All @@ -89,6 +91,7 @@ const COMPLETION_EVENTS_TO_ACTION_MAP = new Map([
[AnalyticsEvent.ACTION_REGWALL_OPT_IN_BUTTON_CLICK, TYPE_REGISTRATION_WALL],
[AnalyticsEvent.ACTION_SURVEY_SUBMIT_CLICK, TYPE_REWARDED_SURVEY],
[AnalyticsEvent.ACTION_REWARDED_AD_VIEW, TYPE_REWARDED_AD],
[AnalyticsEvent.ACTION_BYO_CTA_BUTTON_CLICK, TYPE_BYO_CTA],
[AnalyticsEvent.EVENT_SUBSCRIPTION_PAYMENT_COMPLETE, TYPE_SUBSCRIPTION],
]);

Expand All @@ -100,6 +103,7 @@ const IMPRESSION_EVENTS_TO_ACTION_MAP = new Map([
[AnalyticsEvent.IMPRESSION_REGWALL_OPT_IN, TYPE_REGISTRATION_WALL],
[AnalyticsEvent.IMPRESSION_SURVEY, TYPE_REWARDED_SURVEY],
[AnalyticsEvent.IMPRESSION_REWARDED_AD, TYPE_REWARDED_AD],
[AnalyticsEvent.IMPRESSION_BYO_CTA, TYPE_BYO_CTA],
[AnalyticsEvent.IMPRESSION_SWG_SUBSCRIPTION_MINI_PROMPT, TYPE_SUBSCRIPTION],
[AnalyticsEvent.IMPRESSION_OFFERS, TYPE_SUBSCRIPTION],
]);
Expand Down
Loading