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

fix: modify trigger for query_authoring survey #1400

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions querybook/webapp/components/DataDocQueryCell/DataDocQueryCell.tsx
Expand Up @@ -102,6 +102,7 @@ interface IState {
query: string;
meta: IDataQueryCellMeta;

modifiedAt: number;
focused: boolean;
selectedRange: ISelectedRange;
queryCollapsedOverride: boolean;
Expand All @@ -126,6 +127,7 @@ class DataDocQueryCellComponent extends React.PureComponent<IProps, IState> {
this.state = {
query: props.query,
meta: props.meta,
modifiedAt: 0,
focused: false,
selectedRange: null,
queryCollapsedOverride: null,
Expand Down Expand Up @@ -347,6 +349,7 @@ class DataDocQueryCellComponent extends React.PureComponent<IProps, IState> {
this.setState(
{
query,
modifiedAt: Date.now(),
},
() => {
this.onChangeDebounced({ context: query });
Expand Down Expand Up @@ -429,10 +432,13 @@ class DataDocQueryCellComponent extends React.PureComponent<IProps, IState> {
)
).id;

triggerSurvey(SurveySurfaceType.QUERY_AUTHORING, {
query_execution_id: queryId,
cell_id: this.props.cellId,
});
// Only trigger survey if the query is modified within 5 minutes
if (Date.now() - this.state.modifiedAt < 5 * 60 * 1000) {
triggerSurvey(SurveySurfaceType.QUERY_AUTHORING, {
query_execution_id: queryId,
cell_id: this.props.cellId,
});
}

return queryId;
}
Expand Down