From ed2343b3c69d4d4e36aac928239989c4a019c421 Mon Sep 17 00:00:00 2001 From: John Knox Date: Mon, 4 Nov 2019 09:22:18 -0800 Subject: [PATCH] Add sessionId to itsr query string Summary: This will allow rating data to be joined with version number so we can get the rating of each release. Reviewed By: mweststrate Differential Revision: D18297808 fbshipit-source-id: 00f151c64aad40632389f728ad25a565f44a2a90 --- src/chrome/RatingButton.tsx | 21 ++++++++++++++++----- src/fb-stubs/UserFeedback.tsx | 8 ++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index ee8d00aa7..a6942c918 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -21,8 +21,14 @@ import { import GK from '../fb-stubs/GK'; import * as UserFeedback from '../fb-stubs/UserFeedback'; import {FeedbackPrompt} from '../fb-stubs/UserFeedback'; +import {connect} from 'react-redux'; +import {State as Store} from 'src/reducers'; -type Props = { +type PropsFromState = { + sessionId: string | null; +}; + +type OwnProps = { onRatingChanged: (rating: number) => void; }; @@ -281,14 +287,14 @@ class FeedbackComponent extends Component< } } -export default class RatingButton extends Component { +class RatingButton extends Component { state: State = { promptData: null, isShown: false, hasTriggered: false, }; - constructor(props: Props) { + constructor(props: PropsFromState & OwnProps) { super(props); if (GK.get('flipper_rating')) { UserFeedback.getPrompt().then(prompt => { @@ -302,12 +308,12 @@ export default class RatingButton extends Component { const willBeShown = !this.state.isShown; this.setState({isShown: willBeShown, hasTriggered: true}); if (!willBeShown) { - UserFeedback.dismiss(); + UserFeedback.dismiss(this.props.sessionId); } } submitRating(rating: number) { - UserFeedback.submitRating(rating); + UserFeedback.submitRating(rating, this.props.sessionId); } submitComment( @@ -321,6 +327,7 @@ export default class RatingButton extends Component { comment, selectedPredefinedComments, allowUserInfoSharing, + this.props.sessionId, ); } @@ -370,3 +377,7 @@ export default class RatingButton extends Component { ); } } + +export default connect<{sessionId: string | null}, null, OwnProps, Store>( + ({application: {sessionId}}) => ({sessionId}), +)(RatingButton); diff --git a/src/fb-stubs/UserFeedback.tsx b/src/fb-stubs/UserFeedback.tsx index 3e4ca3171..67f265a37 100644 --- a/src/fb-stubs/UserFeedback.tsx +++ b/src/fb-stubs/UserFeedback.tsx @@ -18,7 +18,10 @@ export type FeedbackPrompt = { shouldPopup: boolean; }; -export async function submitRating(rating: number): Promise { +export async function submitRating( + rating: number, + sessionId: string | null, +): Promise { throw new Error('Method not implemented.'); } export async function submitComment( @@ -26,10 +29,11 @@ export async function submitComment( comment: string, selectedPredefinedComments: string[], allowUserInfoSharing: boolean, + sessionId: string | null, ): Promise { throw new Error('Method not implemented.'); } -export async function dismiss(): Promise { +export async function dismiss(sessionId: string | null): Promise { throw new Error('Method not implemented.'); } export async function getPrompt(): Promise {