Skip to content

Commit

Permalink
chore: make disclaimer optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rihp committed Aug 31, 2023
1 parent 8ae65dc commit 2ce35e4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
14 changes: 13 additions & 1 deletion apps/browser/src/components/Chat/Chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,29 @@
border-radius: 10px 10px 0 0;
border: 2px solid red;
display: flex;
justify-content: space-between;
justify-content: space-around;
align-items: center;
}

.ButtonWrapper {
display: flex;
gap: 10px;
}

.CloseDisclaimer {
cursor: pointer;
padding: 10px 20px;
font-weight: bold;
color: red;
}

.CloseWithoutTracking {
cursor: pointer;
padding: 10px 20px;
font-weight: bold;
color: white;
}

.Chat__Export {
cursor: pointer;
font-size: 24px;
Expand Down
23 changes: 18 additions & 5 deletions apps/browser/src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Chat: React.FC<ChatProps> = ({ evo, onMessage, messages, goalEnded }: Chat
);
const [stopped, setStopped] = useState<boolean>(false);
const [showDisclaimer, setShowDisclaimer] = useState<boolean>(true);
const [trackUser, setTrackUser] = useState<boolean>(false);


const pausedRef = useRef(paused);
Expand Down Expand Up @@ -104,8 +105,15 @@ const Chat: React.FC<ChatProps> = ({ evo, onMessage, messages, goalEnded }: Chat
return () => clearTimeout(timer);
}, [evoRunning, evoItr]);


const handleCloseDisclaimer = () => {
setShowDisclaimer(false);
setTrackUser(true); // User accepted disclaimer, enable tracking
};

const handleCloseWithoutTracking = () => {
setShowDisclaimer(false);
setTrackUser(false); // User did not accept disclaimer, disable tracking
};

const handleSend = async () => {
Expand All @@ -116,7 +124,10 @@ const Chat: React.FC<ChatProps> = ({ evo, onMessage, messages, goalEnded }: Chat
setSending(true);
setMessage("");
setEvoRunning(true);
trackMessageSent(message); // Google Analytics Event tracker

if (trackUser) { // Only track if user accepted the disclaimer
trackMessageSent(message);
}
};

const handlePause = async () => {
Expand Down Expand Up @@ -178,12 +189,14 @@ const Chat: React.FC<ChatProps> = ({ evo, onMessage, messages, goalEnded }: Chat

<div className="Chat__Container">
{showDisclaimer && (
<div className="DisclaimerRibbon">
🧠 Disclaimer: In order to improve Evo, all inputs to the agent through this UI will be tracked so don't share any sensitive information or private keys.
<span className="CloseDisclaimer" onClick={handleCloseDisclaimer}>Agree and Continue</span>
<div className="DisclaimerRibbon">
🧠 Disclaimer: In order to improve Evo, all inputs to the agent through this UI will be tracked, so don't share any sensitive information or private keys.
<div className="ButtonWrapper">
<span className="CloseDisclaimer" onClick={handleCloseDisclaimer}>Agree</span>
<span className="CloseWithoutTracking" onClick={handleCloseWithoutTracking}>Disagree</span>
</div>
</div>
)}

<input
type="text"
value={message}
Expand Down

0 comments on commit 2ce35e4

Please sign in to comment.