Skip to content

Commit

Permalink
add: anon metrics for when this is used
Browse files Browse the repository at this point in the history
  • Loading branch information
oreHGA committed Aug 27, 2024
1 parent 9bc2eb6 commit 2c9bce4
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import { Button, Input } from "~/components/ui";
import { activityWatchSteps } from "../data";
import dayjs from "dayjs";
import { writeDataToStore } from "~/services/storage.service";
import { appInsights } from "~/utils/appInsights";

interface IActivityWatchModalProps {
isOpen: boolean;
onCloseModal: () => void;
}

export const ActivityWatchModal: FC<IActivityWatchModalProps> = ({ isOpen, onCloseModal }) => {
const user = useSession();
const [hostList, setHostList] = useState<{ [bucketId: string]: IBucket }>({});
const [selectedHost, setSelectedHost] = useState("");

Expand Down Expand Up @@ -48,6 +50,14 @@ export const ActivityWatchModal: FC<IActivityWatchModalProps> = ({ isOpen, onClo
useEffect(() => {
if (selectedHost) {
localStorage.setItem("selectedActivityWatchHost", selectedHost);

appInsights.trackEvent({
name: "ActivityWatchHostSelected",
properties: {
userNpub: user?.data?.user?.email, // this is actually the npub, need to cast the session type so I can use the right selection
unixTimestamp: dayjs().unix(),
},
});
}
}, [selectedHost]);

Expand Down Expand Up @@ -185,6 +195,14 @@ export const ActivityWatchModal: FC<IActivityWatchModalProps> = ({ isOpen, onClo
console.log("Length of data", data.length);

writeDataToStore("activitywatch", data, endDate.unix().toString(), "download");

appInsights.trackEvent({
name: "ActivityWatchDataDownloaded",
properties: {
userNpub: user?.data?.user?.email, // this is actually the npub, need to cast the session type so I can use the right selection
unixTimestamp: dayjs().unix(),
},
});
}}
leftIcon={<Download className="mr-2 h-4 w-4" />}
disabled={!selectedHost}
Expand Down

0 comments on commit 2c9bce4

Please sign in to comment.