Skip to content

Commit

Permalink
Add and tag slippageChange event
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Nov 1, 2024
1 parent ab6ae16 commit 9cea266
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions apps/hyperdrive-trading/src/ui/analytics/Plausible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export interface PlausibleEventParamsMap {
feeAmount: string;
};
};
slippageChange: {
props: {
value: string;
// TODO: Should we add change/delta?
};
};
}

export type PlausibleEvent = keyof PlausibleEventParamsMap;
Expand Down
11 changes: 9 additions & 2 deletions apps/hyperdrive-trading/src/ui/token/SlippageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export function SlippageSettings({
onActiveOptionChange: (activeTab: "auto" | "custom") => void;
tooltip?: string;
}): JSX.Element {
function handleSlippageChange(value: string) {
window.plausible("slippageChange", {
props: { value },
});
onSlippageChange(value);
}

return (
<>
<div className="flex items-center">
Expand All @@ -34,7 +41,7 @@ export function SlippageSettings({
onClick={(e) => {
e.preventDefault();
onActiveOptionChange("auto");
onSlippageChange(DEFAULT_SLIPPAGE_AMOUNT);
handleSlippageChange(DEFAULT_SLIPPAGE_AMOUNT);
}}
className={classNames("daisy-tab text-sm", {
"font-bold": activeOption === "auto",
Expand All @@ -58,7 +65,7 @@ export function SlippageSettings({
value={slippage}
onChange={(e) => {
onActiveOptionChange("custom");
onSlippageChange(e);
handleSlippageChange(e);
}}
/>
</div>
Expand Down
11 changes: 9 additions & 2 deletions apps/hyperdrive-trading/src/ui/token/SlippageSettingsTwo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export function SlippageSettingsTwo({
}): ReactElement {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);

function handleSlippageChange(value: string) {
window.plausible("slippageChange", {
props: { value },
});
onSlippageChange(value);
}

return (
<div className="daisy-dropdown daisy-dropdown-bottom flex justify-end">
<button
Expand Down Expand Up @@ -59,7 +66,7 @@ export function SlippageSettingsTwo({
onClick={(e) => {
e.preventDefault();
onActiveOptionChange("auto");
onSlippageChange(DEFAULT_SLIPPAGE_AMOUNT);
handleSlippageChange(DEFAULT_SLIPPAGE_AMOUNT);
}}
className={classNames("daisy-tab text-sm", {
"font-bold": activeOption === "auto",
Expand All @@ -84,7 +91,7 @@ export function SlippageSettingsTwo({
value={slippage}
onChange={(e) => {
onActiveOptionChange("custom");
onSlippageChange(e);
handleSlippageChange(e);
}}
/>
</div>
Expand Down

0 comments on commit 9cea266

Please sign in to comment.