Skip to content

Commit

Permalink
feat: track file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed Sep 6, 2023
1 parent 212ed3d commit 5fab37a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
import { useSupabase } from "@/lib/context/SupabaseProvider";
import { useToast } from "@/lib/hooks";
import { redirectToLogin } from "@/lib/router/redirectToLogin";
import { useEventTracking } from "@/services/analytics/useEventTracking";

import { FeedItemType } from "../../../../../types";
import { SupportedFileExtensionsWithDot } from "../types";
Expand All @@ -22,6 +23,7 @@ export const useFileUploader = ({
}: UseFileUploaderProps) => {
const { publish } = useToast();
const { session } = useSupabase();
const { track } = useEventTracking();

if (session === null) {
redirectToLogin();
Expand All @@ -46,8 +48,8 @@ export const useFileUploader = ({
return;
}

for (let i = 0; i < acceptedFiles.length; i++) {
const file = acceptedFiles[i];
for (const element of acceptedFiles) {
const file = element;
const isAlreadyInFiles =
files.filter((f) => f.name === file.name && f.size === file.size)
.length > 0;
Expand All @@ -56,8 +58,8 @@ export const useFileUploader = ({
variant: "warning",
text: t("alreadyAdded", { fileName: file.name, ns: "upload" }),
});
acceptedFiles.splice(i, 1);
} else {
void track("FILE_UPLOADED");
addContent({
source: "upload",
file: file,
Expand Down

0 comments on commit 5fab37a

Please sign in to comment.