From 2c71502cf95961a472d528f96d5d43a6a3df70c8 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Wed, 4 May 2022 15:16:08 +0200 Subject: [PATCH] welcome screen: track actual click interaction with upload avatar button --- src/components/structures/HomePage.tsx | 6 ++---- .../views/elements/MiniAvatarUploader.tsx | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/structures/HomePage.tsx b/src/components/structures/HomePage.tsx index 6facd941030..e84d115e43d 100644 --- a/src/components/structures/HomePage.tsx +++ b/src/components/structures/HomePage.tsx @@ -74,11 +74,9 @@ const UserWelcomeTop = () => { hasAvatar={!!ownProfile.avatarUrl} hasAvatarLabel={_tDom("Great, that'll help people know it's you")} noAvatarLabel={_tDom("Add a photo so people know it's you.")} - setAvatarUrl={async url => { - PosthogTrackers.trackInteraction("WebHomeMiniAvatarUploadButton"); - await cli.setAvatarUrl(url); - }} + setAvatarUrl={url => cli.setAvatarUrl(url)} isUserAvatar + onClick={ev => PosthogTrackers.trackInteraction("WebHomeMiniAvatarUploadButton", ev)} > ; isUserAvatar?: boolean; + onClick?(ev: MouseEvent): void; } const MiniAvatarUploader: React.FC = ({ - hasAvatar, hasAvatarLabel, noAvatarLabel, setAvatarUrl, isUserAvatar, children, + hasAvatar, hasAvatarLabel, noAvatarLabel, setAvatarUrl, isUserAvatar, children, onClick, }) => { const cli = useContext(MatrixClientContext); const [busy, setBusy] = useState(false); @@ -66,7 +67,10 @@ const MiniAvatarUploader: React.FC = ({ type="file" ref={uploadRef} className="mx_MiniAvatarUploader_input" - onClick={chromeFileInputFix} + onClick={(ev) => { + chromeFileInputFix(ev); + onClick?.(ev); + }} onChange={async (ev) => { if (!ev.target.files?.length) return; setBusy(true);