mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
search action tracking (#507)
Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
05d0d8b8ef
commit
9fc5f62b70
2 changed files with 18 additions and 1 deletions
|
@ -27,7 +27,9 @@ mixpanel.init(pub.PUBLIC_MIXPANEL_TOKEN, { debug: true });
|
|||
|
||||
enum AnalyticsAction {
|
||||
install = "INSTALL_ACTION",
|
||||
install_failed = "INSTALL_ACTION_FAILED"
|
||||
install_failed = "INSTALL_ACTION_FAILED",
|
||||
search = "SEARCH_ACTION",
|
||||
search_failed = "SEARCH_ACTION_FAILED"
|
||||
}
|
||||
|
||||
const trackAction = (action: AnalyticsAction, data?: { [key: string]: any }) => {
|
||||
|
@ -63,3 +65,16 @@ export const trackInstallFailed = (packageFullname: string, error: string) => {
|
|||
error
|
||||
});
|
||||
};
|
||||
|
||||
export const trackSearch = (search_term: string, result_count: number) => {
|
||||
if (result_count > 0) {
|
||||
trackAction(AnalyticsAction.search, {
|
||||
search_term,
|
||||
result_count
|
||||
});
|
||||
} else {
|
||||
trackAction(AnalyticsAction.search_failed, {
|
||||
search_term
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ import initNavStore from "./stores/nav";
|
|||
import initPackagesStore from "./stores/pkgs";
|
||||
import initNotificationStore from "./stores/notifications";
|
||||
import initAppUpdateStore from "./stores/update";
|
||||
import { trackSearch } from "./analytics";
|
||||
|
||||
export const featuredPackages = writable<Package[]>([]);
|
||||
|
||||
|
@ -116,6 +117,7 @@ function initSearchStore() {
|
|||
packagesStore.search(term, 5)
|
||||
// postsStore.search(term, 10)
|
||||
]);
|
||||
trackSearch(term, resultPkgs.length);
|
||||
packagesSearch.set(resultPkgs);
|
||||
// postsSearch.set(resultPosts);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue