mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
track package page view (#575)
Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
d95bbb64a2
commit
ea21cc9962
4 changed files with 21 additions and 3 deletions
|
@ -183,7 +183,7 @@ app.on("open-url", (event, url) => {
|
|||
if (isPackage) {
|
||||
// /packages/github.com/pypa/twine -> /packages/github_com_pypa_twine
|
||||
const packageSlug = nameToSlug(rawPath.replace(packagesPrefix, ""));
|
||||
rawPath = [packagesPrefix, packageSlug].join("");
|
||||
rawPath = [packagesPrefix, packageSlug, "?deeplink=true"].join("");
|
||||
}
|
||||
|
||||
setProtocolPath(rawPath);
|
||||
|
|
|
@ -29,7 +29,8 @@ enum AnalyticsAction {
|
|||
install = "INSTALL_ACTION",
|
||||
install_failed = "INSTALL_ACTION_FAILED",
|
||||
search = "SEARCH_ACTION",
|
||||
search_failed = "SEARCH_ACTION_FAILED"
|
||||
search_failed = "SEARCH_ACTION_FAILED",
|
||||
view_package_page = "VIEW_PACKAGE_PAGE_ACTION"
|
||||
}
|
||||
|
||||
const trackAction = (action: AnalyticsAction, data?: { [key: string]: any }) => {
|
||||
|
@ -78,3 +79,10 @@ export const trackSearch = (search_term: string, result_count: number) => {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const trackViewPackagePage = (packageFullname: string, deeplink: boolean) => {
|
||||
trackAction(AnalyticsAction.view_package_page, {
|
||||
pkg: packageFullname,
|
||||
deeplink
|
||||
});
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
const syncPath = async () => {
|
||||
// used by the tea:// protocol to suggest a path to open
|
||||
const path = await getProtocolPath();
|
||||
|
||||
if (path) goto(path);
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
import { packagesStore } from "$libs/stores";
|
||||
import { onMount } from "svelte";
|
||||
import NotificationBar from "$components/notification-bar/notification-bar.svelte";
|
||||
import { trackViewPackagePage } from "$libs/analytics";
|
||||
|
||||
const { packageList } = packagesStore;
|
||||
|
||||
|
@ -49,10 +50,18 @@
|
|||
const url = $page.url;
|
||||
|
||||
const tab = url.searchParams.get("tab");
|
||||
|
||||
const deeplink = url.searchParams.get("deeplink");
|
||||
onMount(() => {
|
||||
packagesStore.syncPackageData(pkg);
|
||||
});
|
||||
|
||||
let lastPackage = "";
|
||||
$: {
|
||||
if (lastPackage !== pkg?.full_name && pkg) {
|
||||
lastPackage = pkg.full_name;
|
||||
trackViewPackagePage(lastPackage, !!deeplink);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="mx-16 mb-4 border border-x-0 border-t-0 py-5 text-gray">
|
||||
|
|
Loading…
Reference in a new issue