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

feat(Surveys): Task to update rollout percentage for Adaptive Collection #26197

Merged
merged 12 commits into from
Nov 14, 2024

Conversation

Phanatic
Copy link
Contributor

Problem

Resolves : #25722

We currently allow %-based rollouts for surveys, as well as the option to set a response limit.

For some users with high volumes, that's not enough. Here is what we've heard:

Being able to specify a response limit per time period, e.g. "250 responses per month", or "7 responses per day"
Ideally, PostHog would adapt the rollout of surveys across the time period specified by the user, e.g. when a user wants 250 responses over a one-month period, we make sure they receive approximately 8 responses per day

Changes

Celery task for daily rollout updates

Created a Celery task to update the rollout percentage of a linked targeting_feature_flag based on the calculated response_sampling_daily_limits.

  1. Ensures the feature flag's rollout_percentage aligns with the response_sampling_daily_limits for the current UTC date.
  2. Updates the feature flag daily to maintain an even distribution of response collection.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Celery task:

  1. Confirms that the feature flag's rollout_percentage is updated correctly based on the response_sampling_daily_limits for today in UTC.
  2. Ensures smooth operation for various sampling intervals and edge cases.

@Phanatic Phanatic requested a review from dmarticus November 14, 2024 16:48
@Phanatic Phanatic changed the title Survey adaptive sampling flag feat(Surveys): Task to update rollout percentage for Adaptive Collection Nov 14, 2024
Base automatically changed from survey-adaptive-sampling-1 to master November 14, 2024 18:34
@Phanatic Phanatic enabled auto-merge (squash) November 14, 2024 18:36
@Phanatic Phanatic force-pushed the survey-adaptive-sampling-flag branch from c13b8b1 to da6b8c2 Compare November 14, 2024 19:11
@Phanatic Phanatic merged commit f28cd45 into master Nov 14, 2024
89 checks passed
@Phanatic Phanatic deleted the survey-adaptive-sampling-flag branch November 14, 2024 19:58
Copy link

sentry-io bot commented Nov 21, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ CHQueryErrorNotAnAggregate: DB::Exception: Column properties is not under aggregate function and not in GROUP BY. Have colu... posthog.tasks.tasks.update_survey_adaptive_samp... View Issue

Did you find this useful? React with a 👍 or 👎

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.

Adaptive response sampling for surveys
2 participants