Skip to content

Commit

Permalink
chore: make the survey duration configable (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
jczhong84 authored Aug 14, 2024
1 parent 9df5170 commit c7b5c3e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
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

0 comments on commit c7b5c3e

Please sign in to comment.