From 9ee487cf43217e9ccd98e74f9bf57a1ee9e33f56 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 12 Sep 2019 08:19:45 -0700 Subject: [PATCH] Proactively ask users for feedback based on ITSREligibilityCheck Summary: Gets the rating popover to appear automatically after 30s for selected users, according to ITSR constraints. The ITSR constraints are to stop it annoying people, such as only happening once a month, and global throttling. Reviewed By: passy Differential Revision: D17343435 fbshipit-source-id: c06aa10263a64249f7e2c48b8752c37e4314ac24 --- src/chrome/RatingButton.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index 4811f2bde..7df98fe5c 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -30,6 +30,7 @@ type State = { promptData: FeedbackPrompt | null; isShown: boolean; userIsEligible: boolean; + hasTriggered: boolean; }; type NextAction = 'select-rating' | 'leave-comment' | 'finished'; @@ -257,6 +258,7 @@ export default class RatingButton extends Component { promptData: null, isShown: false, userIsEligible: !useEligibilityCheck, + hasTriggered: false, }; constructor(props: Props) { @@ -268,7 +270,7 @@ export default class RatingButton extends Component { onClick() { const willBeShown = !this.state.isShown; - this.setState({isShown: willBeShown}); + this.setState({isShown: willBeShown, hasTriggered: true}); if (!willBeShown && useEligibilityCheck) { UserFeedback.dismiss(); } @@ -292,6 +294,19 @@ export default class RatingButton extends Component { ); } + triggerPopover() { + if (!this.state.hasTriggered) { + this.setState({isShown: true, hasTriggered: true}); + } + } + + setIsEligible(isEligible: boolean) { + this.setState({userIsEligible: isEligible}); + if (isEligible) { + setTimeout(this.triggerPopover.bind(this), 30000); + } + } + render() { if (!GK.get('flipper_rating')) { return null; @@ -299,7 +314,7 @@ export default class RatingButton extends Component { if (!this.state.userIsEligible) { return ( this.setState({userIsEligible: isEligible})} + callback={this.setIsEligible.bind(this)} /> ); }