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

Cleans up deprecated autopromptmanager flow. #3495

Merged

Conversation

justinchou-google
Copy link
Contributor

@justinchou-google justinchou-google commented Apr 24, 2024

b/327022303

Removes all tests for deprecated features.

  • Old triggering flow
  • audienceactionflow (autoprompt vs audienceactionflow were distinct)
  • Intermediate frequency capping flow (based solely on impressions)
  • Fallback logic to old flow under certain error conditions
  • Removes unused helper functions
  • locked vs unlocked content -- all autopromptmanager behavior is solely dependent on dismissibility, not locked or unlocked status.

Refactored suites:

  • miniprompt tests
  • cta button tests

Adds tests:

  • Error tests for new flow
  • Prompt display delay
  • event handling events expanded for dismissals, completions

Fixes tests:

  • basic-runtime for subscription, contribution snippet (should allow mini prompt override)
  • added new tests for large subscription, contribution prompts
  • added new frequency capping test for when frequency cap has passed

Cleanup to follow:

  • autoPromptType var b/327022303
  • miniPrompt removal experiment b/246352036

Inventory of new tests:

  AutoPromptManager
      ● should be listening for events from the events manager
      LocalStorage timestamps via Client Event handler
        ● should ignore undefined events
        ● should not store event timestamps for a non frequency capping event
        ● should ignore irrelevant events
        ● should properly prune and fill all local storage Timestamps
        ● should not store impression timestamps for event 26 for nondismissible prompts
        ● should not store impression timestamps for event 35 for nondismissible prompts
        ● should not store impression timestamps for event 50 for nondismissible prompts
        ● should not store impression timestamps for event 34 for nondismissible prompts
        ● should not store impression timestamps for event 42 for nondismissible prompts
        ● should not store impression timestamps for event 49 for nondismissible prompts
        ● should not store impression timestamps for event 3 for nondismissible prompts
        ● for eventType=26, should set impression timestamps for action=TYPE_CONTRIBUTION
        ● for eventType=35, should set impression timestamps for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=50, should set impression timestamps for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=34, should set impression timestamps for action=TYPE_REGISTRATION_WALL
        ● for eventType=42, should set impression timestamps for action=TYPE_REWARDED_SURVEY
        ● for eventType=49, should set impression timestamps for action=TYPE_REWARDED_AD
        ● for eventType=3, should set impression timestamps for action=TYPE_SUBSCRIPTION
        ● should set impression timestamps to existing localstorage
        ● should add impression event to existing localstorage with impression timestamps
        ● should set impression timestamps for existing local storage timestamp but no impressions
        ● should set all event timestamps for a given prompt on storing impressions
        ● should not store dismissal timestamps for event 1038 for nondismissible prompts
        ● should not store dismissal timestamps for event 1059 for nondismissible prompts
        ● should not store dismissal timestamps for event 1084 for nondismissible prompts
        ● should not store dismissal timestamps for event 1058 for nondismissible prompts
        ● should not store dismissal timestamps for event 1069 for nondismissible prompts
        ● should not store dismissal timestamps for event 1079 for nondismissible prompts
        ● should not store dismissal timestamps for event 1037 for nondismissible prompts
        ● for eventType=1038, should set dismissals via local storage for action=TYPE_CONTRIBUTION
        ● for eventType=1059, should set dismissals via local storage for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=1084, should set dismissals via local storage for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=1058, should set dismissals via local storage for action=TYPE_REGISTRATION_WALL
        ● for eventType=1069, should set dismissals via local storage for action=TYPE_REWARDED_SURVEY
        ● for eventType=1079, should set dismissals via local storage for action=TYPE_REWARDED_AD
        ● for eventType=1037, should set dismissals via local storage for action=TYPE_SUBSCRIPTION
        ● should add dismissals to existing local storage timestamps
        ● should add dismissals to existing local storage timestamp but no dismissals
        ● should set all event timestamps for a given prompt on storing dismissals
        ● should not store completion timestamps for event 3051 for nondismissible prompts
        ● should not store completion timestamps for event 1056 for nondismissible prompts
        ● should not store completion timestamps for event 1085 for nondismissible prompts
        ● should not store completion timestamps for event 1054 for nondismissible prompts
        ● should not store completion timestamps for event 1068 for nondismissible prompts
        ● should not store completion timestamps for event 1078 for nondismissible prompts
        ● should not store completion timestamps for event 3050 for nondismissible prompts
        ● for eventType=3051, should set completions via local storage for action=TYPE_CONTRIBUTION
        ● for eventType=1056, should set completions via local storage for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=1085, should set completions via local storage for action=TYPE_NEWSLETTER_SIGNUP
        ● for eventType=1054, should set completions via local storage for action=TYPE_REGISTRATION_WALL
        ● for eventType=1068, should set completions via local storage for action=TYPE_REWARDED_SURVEY
        ● for eventType=1078, should set completions via local storage for action=TYPE_REWARDED_AD
        ● for eventType=3050, should set completions via local storage for action=TYPE_SUBSCRIPTION
        ● should add completions to existing local storage timestamps
        ● should add completions to existing local storage timestamps but no completions
        ● for generic eventType=2000, should set completions via local storage for autoPromptType=contribution
        ● for generic eventType=2000, should set completions via local storage for autoPromptType=contribution_large
        ● for generic eventType=2000, should set completions via local storage for autoPromptType=subscription
        ● for generic eventType=2000, should set completions via local storage for autoPromptType=subscription_large
        ● should set all event timestamps for a given prompt on storing completions
      Miniprompt
        ● should display the mini prompt, but not fetch entitlements and client config if alwaysShow is enabled
        ● should display the large prompt, but not fetch entitlements and client config if alwaysShow is enabled
        ● should not display a prompt if the autoprompttype is unknown and alwaysShow is enabled
        ● should not display a prompt if autoprompttype is NONE
        ● should not display any prompt if canDisplayAutoPrompt is false
        ● should not display the mini contribution prompt if the article is null
        ● should not display the mini contribution prompt if the article returns no actions
        ● should display the subscription mini prompt if the user has no entitlements
        ● should not display any prompt if the user has a valid entitlement
        ● should not display any monetization prompt if the article returns no actions for autoPromptType: contribution
        ● should not display any monetization prompt if the article returns no actions for autoPromptType: subscription
        ● should display the contribution mini prompt if the user has no entitlements and UI predicate is true
        ● should not store an impression for TYPE_CONTRIBUTION if a previous miniprompt impression has been stored
        ● should not store an impression for TYPE_SUBSCRIPTION if a previous miniprompt impression has been stored
        ● should not store miniprompt impression timestamps for event 25 for nondismissible prompts
        ● should not store miniprompt impression timestamps for event 24 for nondismissible prompts
        ● for miniprompt eventType=25, should set impression timestamps for action=TYPE_CONTRIBUTION
        ● for miniprompt eventType=24, should set impression timestamps for action=TYPE_SUBSCRIPTION
        ● should not store dismissal timestamps for miniprompt event 1038 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1059 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1084 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1058 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1069 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1079 for nondismissible prompts
        ● should not store dismissal timestamps for miniprompt event 1037 for nondismissible prompts
        ● for miniprompt eventType=1033, should set dismissal timestamps for action=TYPE_CONTRIBUTION
        ● for miniprompt eventType=1032, should set dismissal timestamps for action=TYPE_SUBSCRIPTION
        ● should log events when a large prompt overrides the miniprompt
        ● should replace the contribution miniprompt with a large prompt if DISABLE_DESKTOP_MINIPROMPT is enabled and viewport is wider than 480px
        ● should replace the subscription miniprompt with a large prompt if DISABLE_DESKTOP_MINIPROMPT is enabled and viewport is wider than 480px
        ● should not replace the miniprompt with a large prompt when DISABLE_DESKTOP_MINIPROMPT is enabled but the viewport is narrower than 480px
      Call to Action (CTA) Button
        ● should set promptIsFromCtaButton on cta button action: 1017
        ● should set promptIsFromCtaButton on cta button action: 1019
        ● for autoprompt eventType=26 and promptIsFromCta_ = true, should not set impressions for action=TYPE_CONTRIBUTION
        ● for autoprompt eventType=3 and promptIsFromCta_ = true, should not set impressions for action=TYPE_SUBSCRIPTION
        ● for autoprompt eventType=1038 and promptIsFromCta_ = true, should set dismissals for action=TYPE_CONTRIBUTION
        ● for autoprompt eventType=1037 and promptIsFromCta_ = true, should set dismissals for action=TYPE_SUBSCRIPTION
        ● for autoprompt eventType=3051 and promptIsFromCta_ = true, should set completion for action=TYPE_CONTRIBUTION
        ● for autoprompt eventType=3050 and promptIsFromCta_ = true, should set completion for action=TYPE_SUBSCRIPTION
      Prompt Frequency Capping Flow
        ● should not show any prompt if there are no audience actions
        ● should not show any prompt if there are no eligible audience actions
        ● survey is ineligible if there are completion timestamps
        ● should show the prompt after the specified delay
        ● should show the first prompt and log an error if the FrequencyCapConfig is invalid
        ● should show the first prompt if there are no stored impressions
        ● should show the first prompt if the frequency cap is not met
        ● should show the first prompt if the first prompt was abandoned
        ● should show the first contribution prompt if it is not dismissible
        ● should show the first prompt and log an error if the timestamps parsed from localstorage is invalid
        ● should show the first prompt if frequency cap has passed
        ● should show the second prompt if the frequency cap for contributions is met
        ● should show the second prompt if the frequency cap for contributions is met via completions
        ● should show the second prompt if the global frequency cap is undefined and prompt frequency cap for contributions is met
        ● should show the second prompt if the frequency cap for contributions is undefined and the default anyPromptFrequencyCap is met
        ● should show the second prompt if the second prompt frequency has passed
        ● should show the third prompt if the frequency cap for contributions is met and survey analytics is not configured
        ● should show the third prompt if the frequency caps for contributions and surveys are met
        ● should show the third prompt if the frequency caps for contributions and surveys are undefined and the default anyPromptFrequencyCap is met
        ● should show the third prompt if the third prompt frequency has passed
        ● should not show any prompt if the global frequency cap is met
        ● should not show any prompt if the global frequency cap is met via nanos
        ● should not show any prompt if the frequency cap is met for all prompts (but global cap is not)
        ● should not show any prompt if the frequency cap is met for all prompts via completions (but global cap is not)
        ● should not show any prompt if the frequency cap undefined for all prompts and the default anyPromptFrequencyCap is met (but global cap is not)
        ● should show the first nondismissible subscription prompt for metered flow despite past dismissals
        ● should show the second dismissible prompt if the frequency cap is met for dismissible subscription
        ● should not show any prompt if the global frequency cap is met for subscription openaccess content
        ● should display a monetization prompt for an unknown autoprompt type if the next action is a monetization prompt
        ● should display a dismissible prompt for an unknown autoprompt type if the next action is a nonmonetization prompt
      Helper Functions
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return false for invalid timestamps
        ● isValidActionsTimestamps_ should return true for valid timestamps
        ● isValidActionsTimestamps_ should return true for valid timestamps
        ● isValidActionsTimestamps_ should return true for valid timestamps
        ● isFrequencyCapped_ should return false for empty impressions
        ● isFrequencyCapped_ should return false for impressions that occurred outside of the cap duration
        ● isFrequencyCapped_ should return true if the max impression occurred within of the cap duration
        ● isFrequencyCapped_ should return true for impressions that occurred within the cap duration
        ● isFrequencyCapped_ should return true if the max impression occurred within the cap duration, including nanos
        ● isFrequencyCapped_ should return false if the max impression occurred within the cap duration, including negative nanos
        ● getPotentialAction_ returns the first action and logs error event for contribution flow with no frequencyCapConfig
      AudienceActionLocalFlow
        ● is rendered for TYPE_REWARDED_ADS
        ● is rendered for BYOP TYPE_NEWSLETTER_SIGNUP

@justinchou-google justinchou-google self-assigned this Apr 24, 2024
@justinchou-google justinchou-google marked this pull request as ready for review April 27, 2024 00:14
Copy link
Contributor

@oyj9109 oyj9109 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'm thrilled we're finally able to simplify that messy legacy code. Thank you so much for you amazing work!

src/runtime/auto-prompt-manager-test.js Outdated Show resolved Hide resolved
@justinchou-google justinchou-google merged commit f7d5197 into subscriptions-project:main Apr 30, 2024
7 checks passed
@justinchou-google justinchou-google deleted the cleanup branch April 30, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants