mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: plausible for feedback (#5763)
This commit is contained in:
parent
b24471c1b4
commit
182901aab6
@ -19,6 +19,7 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|||||||
import { IToast } from 'interfaces/toast';
|
import { IToast } from 'interfaces/toast';
|
||||||
import { useTheme } from '@mui/material/styles';
|
import { useTheme } from '@mui/material/styles';
|
||||||
import { FeedbackData, FeedbackMode } from './FeedbackContext';
|
import { FeedbackData, FeedbackMode } from './FeedbackContext';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
export const ParentContainer = styled('div')(({ theme }) => ({
|
export const ParentContainer = styled('div')(({ theme }) => ({
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
@ -198,6 +199,7 @@ export const FeedbackComponent = ({
|
|||||||
feedbackMode,
|
feedbackMode,
|
||||||
}: IFeedbackComponent) => {
|
}: IFeedbackComponent) => {
|
||||||
const { setToastData } = useToast();
|
const { setToastData } = useToast();
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { isPro, isOss, isEnterprise } = useUiConfig();
|
const { isPro, isOss, isEnterprise } = useUiConfig();
|
||||||
const { addFeedback } = useUserFeedbackApi();
|
const { addFeedback } = useUserFeedbackApi();
|
||||||
@ -221,6 +223,12 @@ export const FeedbackComponent = ({
|
|||||||
const dontAskAgain = () => {
|
const dontAskAgain = () => {
|
||||||
closeFeedback();
|
closeFeedback();
|
||||||
setHasSubmittedFeedback(true);
|
setHasSubmittedFeedback(true);
|
||||||
|
trackEvent('feedback', {
|
||||||
|
props: {
|
||||||
|
eventType: `dont ask again`,
|
||||||
|
category: feedbackData.category,
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmission = async (event: React.FormEvent<HTMLFormElement>) => {
|
const onSubmission = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { FeedbackComponentWrapper } from './FeedbackComponent';
|
import { FeedbackComponentWrapper } from './FeedbackComponent';
|
||||||
import { FeedbackContext, FeedbackData, FeedbackMode } from './FeedbackContext';
|
import { FeedbackContext, FeedbackData, FeedbackMode } from './FeedbackContext';
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from 'react';
|
||||||
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
|
|
||||||
export const FeedbackProvider: FC = ({ children }) => {
|
export const FeedbackProvider: FC = ({ children }) => {
|
||||||
const [feedbackData, setFeedbackData] = useState<
|
const [feedbackData, setFeedbackData] = useState<
|
||||||
FeedbackData | undefined
|
FeedbackData | undefined
|
||||||
>();
|
>();
|
||||||
|
const { trackEvent } = usePlausibleTracker();
|
||||||
|
|
||||||
const [showFeedback, setShowFeedback] = useState(false);
|
const [showFeedback, setShowFeedback] = useState(false);
|
||||||
const [feedbackMode, setFeedbackMode] = useState<
|
const [feedbackMode, setFeedbackMode] = useState<
|
||||||
@ -15,6 +17,13 @@ export const FeedbackProvider: FC = ({ children }) => {
|
|||||||
setFeedbackData(data);
|
setFeedbackData(data);
|
||||||
setShowFeedback(true);
|
setShowFeedback(true);
|
||||||
setFeedbackMode(mode);
|
setFeedbackMode(mode);
|
||||||
|
|
||||||
|
trackEvent('feedback', {
|
||||||
|
props: {
|
||||||
|
eventType: `feedback opened`,
|
||||||
|
category: data.category,
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeFeedback = () => {
|
const closeFeedback = () => {
|
||||||
|
@ -54,7 +54,8 @@ export type CustomEvents =
|
|||||||
| 'search-filter'
|
| 'search-filter'
|
||||||
| 'scheduled-configuration-changes'
|
| 'scheduled-configuration-changes'
|
||||||
| 'search-feature-buttons'
|
| 'search-feature-buttons'
|
||||||
| 'new-strategy-form';
|
| 'new-strategy-form'
|
||||||
|
| 'feedback';
|
||||||
|
|
||||||
export const usePlausibleTracker = () => {
|
export const usePlausibleTracker = () => {
|
||||||
const plausible = useContext(PlausibleContext);
|
const plausible = useContext(PlausibleContext);
|
||||||
|
Loading…
Reference in New Issue
Block a user