Skip to content

Commit

Permalink
Merge pull request #16 from iamkentleom/feature/analytics
Browse files Browse the repository at this point in the history
initial upload & download ga events
  • Loading branch information
iamkentleom authored Jul 29, 2023
2 parents 5283b18 + 6a13567 commit 904b075
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import About from "./components/About.svelte";
import Footer from "./components/Footer.svelte";
import { auth, signInAnonymously } from "./firebase/auth";
import { analytics } from "./firebase/analytics";
export let url = "";
Expand All @@ -19,8 +18,6 @@
if (loggedIn) {
console.log("Logged in anonymously");
}
analytics();
} catch (error) {
console.log("Code: ", error.code);
console.log("Message: ", error.message);
Expand Down
2 changes: 2 additions & 0 deletions src/components/CardDropzoneFile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { files, values, folder } from "../stores";
import { Icon, X } from "svelte-hero-icons";
import { scale, slide } from "svelte/transition";
import { analytics, logEvent } from "../firebase/analytics";
import { getFileIcon, getFileId, prettyFileSize } from "../utils/files";
import { status as STATUS } from "../utils/constants";
import { nanoid } from "nanoid";
Expand Down Expand Up @@ -54,6 +55,7 @@
},
() => {
status = STATUS.DONE;
logEvent(analytics, "upload_file");
console.log(`${file.name} uploaded.`);
}
);
Expand Down
4 changes: 4 additions & 0 deletions src/components/DownloadFilesFile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
getMetadata,
getDownloadURL,
} from "../firebase/storage";
import { analytics, logEvent } from "../firebase/analytics";
import { Icon, Download, Document } from "svelte-hero-icons";
export let file;
Expand All @@ -31,6 +32,8 @@
console.log(error);
}
});
const logDownload = () => logEvent(analytics, "download_file");
</script>
<a
Expand All @@ -39,6 +42,7 @@
title={`Download ${file.name}`}
href={url}
target="_blank"
on:click={logDownload}
download
>
<div class="grid grid-cols-5 md:grid-cols-6 content-center grow">
Expand Down
2 changes: 1 addition & 1 deletion src/firebase/analytics.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getAnalytics, logEvent } from "firebase/analytics";
import app from "./index";

const analytics = () => getAnalytics(app);
const analytics = getAnalytics(app);

export { analytics, logEvent };

0 comments on commit 904b075

Please sign in to comment.