Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feedback modal #857

Merged
merged 14 commits into from
Dec 20, 2024
Merged

Add feedback modal #857

merged 14 commits into from
Dec 20, 2024

Conversation

kacperkapusciak
Copy link
Member

@kacperkapusciak kacperkapusciak commented Dec 16, 2024

This PR implements feedback functionality by gathering sentiment:positive, sentiment:negative telemetry events.

Screen.Recording.2024-12-16.at.16.15.25.mov
Screen.Recording.2024-12-16.at.16.15.49.mov

Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 5:16pm

@kmagiera
Copy link
Member

I'd perhaps add some note that when sending the form we won't include any details about the project, user's setup or the logs

@filip131311
Copy link
Collaborator

Building on what @kmagiera has commented, maybe we could add an "opt-in" check box for attaching radon logs?

@kmagiera
Copy link
Member

getting the logs is not as straightforward, also this would fit better in bug/issue reporting flow rather than feedback, so I'd leave it out. Just wanted to make sure it is clear the feedback form doesn't include any potentially sensitive info

@kacperkapusciak
Copy link
Member Author

@kmagiera added in 3a4d1ab

@maciekstosio
Copy link
Contributor

image

Those paddings look odd.

@kacperkapusciak
Copy link
Member Author

@maciekstosio fixed in 0947f14

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this uses telemetry reporter it may be that some users have it disabled in which case we won't receive their reports. We can perhaps setup it in a way that we ignore telemetry settings but don't think this is the right way to do this.

@kacperkapusciak
Copy link
Member Author

alternatively i can gather the feedback in our customer portal database

@kmagiera
Copy link
Member

I guess this should be fine for now. One simple workaround we can add is to check if user have telemetry on and only then show this button

…tate to the top component to allow better state menagment
Copy link
Contributor

@maciekstosio maciekstosio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this should stay selected

Screen.Recording.2024-12-20.at.15.09.07.mov

return <UtilsContext.Provider value={utils}>{children}</UtilsContext.Provider>;
const [telemetryEnabled, setTelemetryEnabled] = useState(false);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be in a separate hook, as a change to the state will cause unnecessary rerenders in all useUtils occurrences

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this will be better imo.

const useTelemntry = () => {
  const utils = useUtils();
  const [telemetryEnabled, setTelemetryEnabled] = useState(false);

  useEffect(() => {
    utils.isTelemetryEnabled().then(setTelemetryEnabled);
    utils.addListener("telemetryEnabledChanged", setTelemetryEnabled);

    return () => {
      utils.removeListener("telemetryEnabledChanged", setTelemetryEnabled);
    };
  }, []);

  return telemetryEnabled;
}

return <UtilsContext.Provider value={utils}>{children}</UtilsContext.Provider>;
const [telemetryEnabled, setTelemetryEnabled] = useState(false);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this will be better imo.

const useTelemntry = () => {
  const utils = useUtils();
  const [telemetryEnabled, setTelemetryEnabled] = useState(false);

  useEffect(() => {
    utils.isTelemetryEnabled().then(setTelemetryEnabled);
    utils.addListener("telemetryEnabledChanged", setTelemetryEnabled);

    return () => {
      utils.removeListener("telemetryEnabledChanged", setTelemetryEnabled);
    };
  }, []);

  return telemetryEnabled;
}

const utils = makeProxy<Utils>("Utils");

const UtilsContext = createContext<UtilsInterface>(utils);
const UtilsContext = createContext<UtilsContextProps>(utils);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why type rename?

}, []);

return (
<TelemetryContext.Provider value={{ telemetryEnabled }}>{children}</TelemetryContext.Provider>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{telemetryEnabled} is useMemo -> if the value doesn't change, we'll rerender descend components anyway, cause the object will be recreated.

const context = useContext(TelemetryContext);

if (context === undefined) {
throw new Error("useUtils must be used within a TelemetryContextProvider");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error("useUtils must be used within a TelemetryContextProvider");
throw new Error("useTelemetry must be used within a TelemetryContextProvider");

};

export function Feedback({ sentiment, setSentiment }: FeedbackProps) {
const { sendTelemetry } = useUtils();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a separate telemetry hook, it sounds like sendTelemetry should be there

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be on Utils interface anyway since i have no means of removing it, so it seems pointless to add it a second tim in useTelemetry


const TelemetryContext = createContext<TelemetryContextProps>({ telemetryEnabled: false });

export function TelemetryProvider({ children }: PropsWithChildren) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it should be in a separate file. I am not sure why we need to pass utils through the context, but if we cannot just import it in a separate file, you can always use useUtils in TelemetryProvider. Just remember to order providers properly (imo this is why it would be better to have it just in hook instead of context, especially since we don't use it anywhere else).

}, []);

return (
<TelemetryContext.Provider value={{ telemetryEnabled }}>{children}</TelemetryContext.Provider>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return just telemetryEnabled or wrap with useMemo

@filip131311 filip131311 merged commit 3838dc8 into main Dec 20, 2024
4 checks passed
@filip131311 filip131311 deleted the @kacperkapusciak/gather-feedback branch December 20, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants