-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR implements feedback functionality by gathering `sentiment:positive`, `sentiment:negative` telemetry events. https://github.com/user-attachments/assets/a0fb9e4a-1ae5-4224-a0e0-0ad9f90c9c0b https://github.com/user-attachments/assets/739526e8-3885-4126-b953-b5e355a36ce0 --------- Co-authored-by: filip131311 <[email protected]>
- Loading branch information
1 parent
1fa81b9
commit 3838dc8
Showing
10 changed files
with
458 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/vscode-extension/src/webview/components/Feedback.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
.feedback { | ||
display: flex; | ||
gap: 4px; | ||
} | ||
|
||
.feedback-button { | ||
width: 26px; | ||
height: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 3px; | ||
transition: all 250ms 0ms ease-in-out; | ||
} | ||
|
||
.feedback-button:active { | ||
transform: scale(0.94); | ||
} | ||
|
||
.feedback-button-large:active { | ||
transform: scale(0.96); | ||
} | ||
|
||
.feedback-button:hover span, | ||
.feedback-button-positive-active span, | ||
.feedback-button-negative-active span { | ||
color: var(--swm-popover-background) !important; | ||
} | ||
|
||
.feedback-button:hover { | ||
cursor: pointer; | ||
} | ||
|
||
.feedback-button-large { | ||
width: 64px; | ||
height: 46px; | ||
} | ||
|
||
.feedback-button-large span { | ||
font-size: 24px !important; | ||
} | ||
|
||
.feedback-button-positive { | ||
color: var(--green-light-80); | ||
border: 1px solid var(--green-light-80); | ||
} | ||
|
||
.feedback-button-positive span { | ||
color: var(--green-light-80); | ||
} | ||
|
||
.feedback-button-positive:hover, | ||
.feedback-button-positive-active { | ||
background-color: var(--green-light-80); | ||
} | ||
|
||
.feedback-button-negative { | ||
border: 1px solid var(--red-light-80); | ||
} | ||
|
||
.feedback-button-negative span { | ||
color: var(--red-light-80); | ||
} | ||
|
||
.feedback-button-negative:hover, | ||
.feedback-button-negative-active { | ||
background-color: var(--red-light-80); | ||
} | ||
|
||
.feedback-prompt { | ||
cursor: pointer; | ||
font-size: 12px; | ||
} | ||
.feedback-prompt:hover { | ||
text-decoration: underline; | ||
} |
77 changes: 77 additions & 0 deletions
77
packages/vscode-extension/src/webview/components/Feedback.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Dispatch, MouseEvent, SetStateAction } from "react"; | ||
import "./Feedback.css"; | ||
import classNames from "classnames"; | ||
import { useUtils } from "../providers/UtilsProvider"; | ||
import { Sentiment } from "./SendFeedbackItem"; | ||
|
||
type FeedbackProps = { | ||
sentiment: Sentiment | undefined; | ||
setSentiment: Dispatch<SetStateAction<Sentiment | undefined>>; | ||
}; | ||
|
||
export function Feedback({ sentiment, setSentiment }: FeedbackProps) { | ||
const { sendTelemetry } = useUtils(); | ||
|
||
const handleFeedback = (event: MouseEvent<HTMLButtonElement>, pickedSentiment: Sentiment) => { | ||
event.preventDefault(); | ||
sendTelemetry(`feedback:${pickedSentiment}`); | ||
setSentiment(pickedSentiment); | ||
}; | ||
|
||
return ( | ||
<div className="feedback"> | ||
{Boolean(sentiment) ? ( | ||
<p className="feedback-prompt"> | ||
{sentiment === "positive" ? "What went well?" : "Tell us more"} | ||
</p> | ||
) : ( | ||
<> | ||
<FeedbackButton sentiment="positive" onClick={(e) => handleFeedback(e, "positive")} /> | ||
<FeedbackButton sentiment="negative" onClick={(e) => handleFeedback(e, "negative")} /> | ||
</> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
type FeedbackButtonProps = { | ||
sentiment: Sentiment; | ||
onClick?: (event: MouseEvent<HTMLButtonElement>) => void; | ||
type?: "small" | "large"; | ||
isActive?: boolean; | ||
}; | ||
|
||
export function FeedbackButton({ | ||
sentiment, | ||
onClick, | ||
type = "small", | ||
isActive, | ||
}: FeedbackButtonProps) { | ||
if (sentiment === "positive") { | ||
return ( | ||
<button | ||
className={classNames( | ||
"feedback-button feedback-button-positive", | ||
isActive && "feedback-button-positive-active", | ||
type === "large" && "feedback-button-large" | ||
)} | ||
type="button" | ||
onClick={onClick}> | ||
<span className="codicon codicon-thumbsup" /> | ||
</button> | ||
); | ||
} | ||
|
||
return ( | ||
<button | ||
className={classNames( | ||
"feedback-button feedback-button-negative", | ||
isActive && "feedback-button-negative-active", | ||
type === "large" && "feedback-button-large" | ||
)} | ||
type="button" | ||
onClick={onClick}> | ||
<span className="codicon codicon-thumbsdown" /> | ||
</button> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/vscode-extension/src/webview/components/SendFeedbackItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useState } from "react"; | ||
import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; | ||
|
||
import { useModal } from "../providers/ModalProvider"; | ||
import FeedbackView from "../views/FeedbackView"; | ||
import { Feedback } from "./Feedback"; | ||
|
||
export type Sentiment = "positive" | "negative"; | ||
|
||
export function SendFeedbackItem() { | ||
const { openModal } = useModal(); | ||
|
||
const [sentiment, setSentiment] = useState<Sentiment | undefined>(); | ||
|
||
return ( | ||
<DropdownMenu.Item | ||
className="dropdown-menu-item" | ||
onSelect={() => { | ||
openModal( | ||
"Do you enjoy using Radon IDE today?", | ||
<FeedbackView initialSentiment={sentiment} /> | ||
); | ||
}}> | ||
<span className="codicon codicon-feedback" /> | ||
<div className="dropdown-menu-item-content"> | ||
Send feedback | ||
<Feedback sentiment={sentiment} setSentiment={setSentiment} /> | ||
</div> | ||
</DropdownMenu.Item> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/vscode-extension/src/webview/providers/TelemetryProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createContext, PropsWithChildren, useContext, useEffect, useMemo, useState } from "react"; | ||
import { useUtils } from "./UtilsProvider"; | ||
|
||
type TelemetryContextProps = { telemetryEnabled: boolean }; | ||
|
||
const TelemetryContext = createContext<TelemetryContextProps>({ telemetryEnabled: false }); | ||
|
||
export function TelemetryProvider({ children }: PropsWithChildren) { | ||
const utils = useUtils(); | ||
const [telemetryEnabled, setTelemetryEnabled] = useState(false); | ||
|
||
useEffect(() => { | ||
utils.isTelemetryEnabled().then(setTelemetryEnabled); | ||
utils.addListener("telemetryEnabledChanged", setTelemetryEnabled); | ||
|
||
return () => { | ||
utils.removeListener("telemetryEnabledChanged", setTelemetryEnabled); | ||
}; | ||
}, []); | ||
|
||
const contextValue = useMemo(() => ({ telemetryEnabled }), [telemetryEnabled]); | ||
|
||
return <TelemetryContext.Provider value={contextValue}>{children}</TelemetryContext.Provider>; | ||
} | ||
|
||
export function useTelemetry() { | ||
const context = useContext(TelemetryContext); | ||
|
||
if (context === undefined) { | ||
throw new Error("useTelemetry must be used within a TelemetryContextProvider"); | ||
} | ||
return context; | ||
} |
Oops, something went wrong.