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

chore: make the survey duration configurable #1487

Merged
merged 1 commit into from
Aug 14, 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
2 changes: 2 additions & 0 deletions docs_website/docs/integrations/add_surveys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Below is an example of a setting that enables all surveys:
survey:
global_response_cooldown: 2592000 # 30 days
global_trigger_cooldown: 600 # 10 minutes
global_trigger_duration: 60 # 1 minute
global_max_per_week: 6
global_max_per_day: 3

Expand All @@ -40,5 +41,6 @@ There are 4 variables that you can configure either for eaceh individual surface

- **response_cooldown**: Time (in seconds) the system waits before showing the same survey to a user who has already responded.
- **trigger_cooldown**: Waiting period before the same survey is shown to the same user.
- **trigger_duration**: The duration (in seconds) for which the survey is displayed before being dismissed.
- **max_per_week**: Maximum number of surveys shown to a user per week (per surface type).
- **max_per_day**: Daily limit for the number of surveys shown to a user (per surface type).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "querybook",
"version": "3.34.1",
"version": "3.34.2",
"description": "A Big Data Webapp",
"private": true,
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions querybook/config/querybook_public_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ai_assistant:
survey:
global_response_cooldown: 2592000 # 30 days
global_trigger_cooldown: 600 # 10 minutes
global_trigger_duration: 60 # 1 minute
global_max_per_week: 6
global_max_per_day: 3

Expand Down
2 changes: 2 additions & 0 deletions querybook/webapp/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ declare module 'config/querybook_public_config.yaml' {
survey?: {
global_response_cooldown?: number;
global_trigger_cooldown?: number;
global_trigger_duration?: number;
global_max_per_week?: number;
global_max_per_day?: number;

surfaces?: Array<{
surface: string;
response_cooldown?: number;
trigger_cooldown?: number;
trigger_duration?: number;
max_per_week?: number;
max_per_day?: number;
}>;
Expand Down
3 changes: 2 additions & 1 deletion querybook/webapp/hooks/ui/useSurveyTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
shouldTriggerSurvey,
} from 'lib/survey/triggerLogic';
import { useDebouncedFn } from 'hooks/useDebouncedFn';
import { SURVEY_CONFIG } from 'lib/survey/config';

export async function triggerSurvey(
surface: SurveySurfaceType,
Expand All @@ -28,7 +29,7 @@ export async function triggerSurvey(
/>
),
{
duration: 1 * 60 * 1000, // 1 minute
duration: SURVEY_CONFIG[surface].triggerDuration * 1000,
}
);

Expand Down
4 changes: 4 additions & 0 deletions querybook/webapp/lib/survey/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ surveyConfig?.surfaces?.forEach((surface) => {
surface.trigger_cooldown ??
surveyConfig.global_trigger_cooldown ??
600, // 10 minutes
triggerDuration:
surface.trigger_duration ??
surveyConfig.global_trigger_duration ??
60, // 1 minute
maxPerWeek:
surface.max_per_week ?? surveyConfig.global_max_per_week ?? 3,
maxPerDay: surface.max_per_day ?? surveyConfig.global_max_per_day ?? 1,
Expand Down
1 change: 1 addition & 0 deletions querybook/webapp/lib/survey/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface ISurveyConfig {
surface: string;
responseCooldown: number;
triggerCooldown: number;
triggerDuration: number;
maxPerWeek: number;
maxPerDay: number;
}
Expand Down
Loading