Skip to content

Commit

Permalink
fix: modify trigger for query_authoring survey (#1400)
Browse files Browse the repository at this point in the history
* fix: modify trigger for query_authoring survey

* comments
  • Loading branch information
jczhong84 authored Jan 26, 2024
1 parent 0e1917c commit 8c87e3e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions querybook/webapp/components/DataDocQueryCell/DataDocQueryCell.tsx
Original file line number Diff line number Diff line change
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

0 comments on commit 8c87e3e

Please sign in to comment.