mirror of
https://github.com/ivabus/gui
synced 2025-06-08 00:00:27 +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 {
|
enum AnalyticsAction {
|
||||||
install = "INSTALL_ACTION",
|
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 }) => {
|
const trackAction = (action: AnalyticsAction, data?: { [key: string]: any }) => {
|
||||||
|
@ -63,3 +65,16 @@ export const trackInstallFailed = (packageFullname: string, error: string) => {
|
||||||
error
|
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 initPackagesStore from "./stores/pkgs";
|
||||||
import initNotificationStore from "./stores/notifications";
|
import initNotificationStore from "./stores/notifications";
|
||||||
import initAppUpdateStore from "./stores/update";
|
import initAppUpdateStore from "./stores/update";
|
||||||
|
import { trackSearch } from "./analytics";
|
||||||
|
|
||||||
export const featuredPackages = writable<Package[]>([]);
|
export const featuredPackages = writable<Package[]>([]);
|
||||||
|
|
||||||
|
@ -116,6 +117,7 @@ function initSearchStore() {
|
||||||
packagesStore.search(term, 5)
|
packagesStore.search(term, 5)
|
||||||
// postsStore.search(term, 10)
|
// postsStore.search(term, 10)
|
||||||
]);
|
]);
|
||||||
|
trackSearch(term, resultPkgs.length);
|
||||||
packagesSearch.set(resultPkgs);
|
packagesSearch.set(resultPkgs);
|
||||||
// postsSearch.set(resultPosts);
|
// postsSearch.set(resultPosts);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue