Skip to content

Commit

Permalink
Apply feedback, fix location to get full path
Browse files Browse the repository at this point in the history
  • Loading branch information
briandoyle81 committed Dec 19, 2024
1 parent 8c319ee commit e160366
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
33 changes: 6 additions & 27 deletions src/components/feedbackFaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,27 @@ export default function FeedbackFaces() {
const handleFeedbackClick = (feedbackType: string) => {
setClickedFace(feedbackType);

const pagePath = window.location.pathname;
const label = `${feedbackType} - ${pagePath}`;
const label = `${feedbackType}`;

event({
action: "feedback_click",
category: "Feedback",
category: "feedback",
label: label,
location: pagePath,
location: true,
});

// Reset the clicked state after a brief delay
setTimeout(() => setClickedFace(null), 300);
};

return (
<div style={styles.container}>
<div className="flex justify-left items-center gap-1">
{faces.map((face) => (
<button
key={face.label}
onClick={() => handleFeedbackClick(face.label)}
style={{
...styles.button,
transform: clickedFace === face.label ? "scale(1.2)" : "scale(1)",
opacity: clickedFace === face.label ? 0.7 : 1,
}}
className={`text-4xl cursor-pointer p-2 bg-transparent border-none transition-transform duration-200 focus:outline-none ${clickedFace === face.label ? "scale-110 opacity-70" : "scale-100 opacity-100"
}`}
aria-label={face.label}
>
{face.emoji}
Expand All @@ -47,20 +43,3 @@ export default function FeedbackFaces() {
</div>
);
}

// Inline CSS styles
const styles = {
container: {
display: "flex",
justifyContent: "center",
alignItems: "center",
} as React.CSSProperties,
button: {
fontSize: "30px",
background: "none",
border: "none",
cursor: "pointer",
transition: "transform 0.2s, opacity 0.2s",
padding: "10px",
} as React.CSSProperties,
};
6 changes: 3 additions & 3 deletions src/utils/gtags.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export const event = ({
category?: string;
label?: string;
value?: number | string;
location?: string;
location?: boolean;
}) => {
if (process.env.NODE_ENV !== "production") return

if (!window.gtag) {
console.warn(
"window.gtag is not defined. This could mean your google anylatics script has not loaded on the page yet."
"window.gtag is not defined. This could mean your google analytics script has not loaded on the page yet."
)
return
}
Expand All @@ -61,7 +61,7 @@ export const event = ({
};

if (location) {
eventPayload.page_location = location;
eventPayload.page_location = window.location.href;
}

window.gtag("event", action, eventPayload);
Expand Down

0 comments on commit e160366

Please sign in to comment.