From 25739aebc2494de4798847460d925d0c70462f62 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 12 Sep 2019 08:19:45 -0700 Subject: [PATCH] Only show rating button when user is eligible to rate Summary: Behind a gk. This uses a hidden webview to check if a user is eligible for star ratings. This means you can practively ask the user, and makes sure you'll get an unbiased distribution. Reviewed By: danielbuechele Differential Revision: D17343118 fbshipit-source-id: fe7471416aef947ec10f4734e4136868ab5ab3e5 --- src/chrome/RatingButton.tsx | 9 +++++++++ src/fb-stubs/UserFeedback.tsx | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index bc0dbab6f..d9210febf 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -27,6 +27,7 @@ type Props = { type State = { promptData: FeedbackPrompt | null; isShown: boolean; + userIsEligible: boolean; }; type NextAction = 'select-rating' | 'leave-comment' | 'finished'; @@ -253,6 +254,7 @@ export default class RatingButton extends Component { state = { promptData: null, isShown: false, + userIsEligible: !GK.get('flipper_use_itsr_eligibility_check'), }; constructor(props: Props) { @@ -288,6 +290,13 @@ export default class RatingButton extends Component { if (!GK.get('flipper_rating')) { return null; } + if (!this.state.userIsEligible) { + return ( + this.setState({userIsEligible: isEligible})} + /> + ); + } const promptData = this.state.promptData; if (!promptData) { return null; diff --git a/src/fb-stubs/UserFeedback.tsx b/src/fb-stubs/UserFeedback.tsx index 0dcc94b57..ee254810b 100644 --- a/src/fb-stubs/UserFeedback.tsx +++ b/src/fb-stubs/UserFeedback.tsx @@ -5,6 +5,8 @@ * @format */ +import {Component} from 'react'; + export type FeedbackPrompt = { preSubmitHeading: string; postSubmitHeading: string; @@ -28,3 +30,6 @@ export async function submitComment( export async function getPrompt(): Promise { throw new Error('Method not implemented.'); } +export class StarRatingsEligibilityChecker extends Component<{ + callback: (userIsEligible: boolean) => void; +}> {}