Skip to content

[HackWeek 2023] feat: Experimental User Feedback: Feedback button and attaching screenshot #7689

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions gatsby-browser.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import React from 'react';
import React, {useEffect} from 'react';
import {GatsbyBrowser} from 'gatsby';

import {CodeContextProvider} from 'sentry-docs/components/codeContext';
import {FeebdackWidget} from 'sentry-docs/components/feedbackWidget';
import PageContext from 'sentry-docs/components/pageContext';

export const wrapPageElement: GatsbyBrowser['wrapPageElement'] = ({
element,
props: {pageContext},
}) => <PageContext.Provider value={pageContext}>{element}</PageContext.Provider>;
}) => {
useEffect(() => {
const codeBlock = document.querySelector<HTMLDivElement>('.code-tabs-wrapper');
if (!codeBlock) {
return;
}
codeBlock.style.position = 'relative';
codeBlock.style.right = '-74px';
});
return (
<React.Fragment>
{/* FIXME: we're duplicating CodeContextProvider, which is not nice.
Ideally, FeedbackWidget is a child of the existing CodeContextProvider. */}
<CodeContextProvider>
<FeebdackWidget />
</CodeContextProvider>
<PageContext.Provider value={pageContext}>{element}</PageContext.Provider>
</React.Fragment>
);
};

// Disable prefetching altogether so our bw is not destroyed.
// If this turns out to hurt performance significantly, we can
Expand Down
5 changes: 4 additions & 1 deletion src/components/codeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ProjectCodeKeywords = {
};

type UserCodeKeywords = {
EMAIL: string;
ID: number;
NAME: string;
};
Expand Down Expand Up @@ -51,6 +52,7 @@ type ProjectApiResult = {

type UserApiResult = {
avatarUrl: string;
email: string;
id: number;
isAuthenticated: boolean;
name: string;
Expand Down Expand Up @@ -131,7 +133,7 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {

const url =
process.env.NODE_ENV === 'development'
? 'http://dev.getsentry.net:8000/docs/api/user/'
? 'http://dev.getsentry.net:8000/api/0/auth-details/'
: 'https://sentry.io/docs/api/user/';

const makeDefaults = () => {
Expand Down Expand Up @@ -185,6 +187,7 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {
? {
ID: user.id,
NAME: user.name,
EMAIL: user.email,
}
: undefined,
};
Expand Down
31 changes: 31 additions & 0 deletions src/components/feedbackButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import styled from '@emotion/styled';

const Button = styled.button`
position: fixed;
right: 0px;
bottom: 50%;
transform: translate(25%, 50%) rotate(-90deg);
background-color: #fff;
border: 1px solid #ccc;
border-radius: 4px;
color: #231c3d;
cursor: pointer;
font-size: 14px;
font-weight: 600;
padding: 6px 16px;
text-align: center;
text-decoration: none;
z-index: 9000;
&:hover {
background-color: #eee;
}
&:focus-visible {
outline: 1px solid #79628c;
background-color: #eee;
}
`;

export function FeebdackButton(props) {
return <Button {...props}>Feedback</Button>;
}
Loading