Skip to content

Commit

Permalink
feat: add top browser titles to activity visualization (#631)
Browse files Browse the repository at this point in the history
* feat: add top browser titles to activity visualization

* Update src/stores/activity.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
  • Loading branch information
BelKed and ellipsis-dev[bot] authored Feb 21, 2025
1 parent 606112e commit 757f9f4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/components/SelectableVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ div
:namefunc="e => e.data.url",
:colorfunc="e => e.data.$domain",
with_limit)
div(v-if="type == 'top_browser_titles'")
aw-summary(:fields="activityStore.browser.top_titles",
:namefunc="e => e.data.title",
:colorfunc="e => e.data.$domain",
with_limit)
div(v-if="type == 'top_editor_files'")
aw-summary(:fields="activityStore.editor.top_files",
:namefunc="top_editor_files_namefunc",
Expand Down Expand Up @@ -135,6 +140,7 @@ export default {
'top_titles',
'top_domains',
'top_urls',
'top_browser_titles',
'top_categories',
'category_tree',
'category_sunburst',
Expand Down Expand Up @@ -187,6 +193,10 @@ export default {
title: 'Top Browser URLs',
available: this.activityStore.browser.available,
},
top_browser_titles: {
title: 'Top Browser Titles',
available: this.activityStore.browser.available,
},
top_editor_files: {
title: 'Top Editor Files',
available: this.activityStore.editor.available,
Expand Down
4 changes: 4 additions & 0 deletions src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ export function fullDesktopQuery(params: DesktopQueryParams): string[] {
browser_domains = merge_events_by_keys(browser_events, ["$domain"]);
browser_domains = sort_by_duration(browser_domains);
browser_domains = limit_events(browser_domains, ${default_limit});
browser_titles = merge_events_by_keys(browser_events, ["title"]);
browser_titles = sort_by_duration(browser_titles);
browser_titles = limit_events(browser_titles, ${default_limit});
browser_duration = sum_durations(browser_events);
RETURN = {
Expand All @@ -365,6 +368,7 @@ export function fullDesktopQuery(params: DesktopQueryParams): string[] {
"browser": {
"domains": browser_domains,
"urls": browser_urls,
"titles": browser_titles,
"duration": browser_duration
}
};`
Expand Down
15 changes: 14 additions & 1 deletion src/stores/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ interface State {
duration: number;
top_urls: IEvent[];
top_domains: IEvent[];
top_titles: IEvent[];
};

editor: {
Expand Down Expand Up @@ -148,6 +149,7 @@ export const useActivityStore = defineStore('activity', {
duration: 0,
top_domains: [],
top_urls: [],
top_titles: [],
},

editor: {
Expand Down Expand Up @@ -598,6 +600,11 @@ export const useActivityStore = defineStore('activity', {
const domain_events = groupSumEventsBy(window_events, '$domain', (e: any) =>
e.data.url === undefined ? '' : new URL(e.data.url).host
);
const browser_title_events = groupSumEventsBy(
window_events.filter((e: any) => e.data.url),
'title',
(e: any) => e.data.title
);

this.query_window_completed({
duration: _.sumBy(window_events, 'duration'),
Expand All @@ -618,6 +625,7 @@ export const useActivityStore = defineStore('activity', {
duration: _.sumBy(url_events, 'duration'),
domains: domain_events,
urls: url_events,
titles: browser_title_events,
});

this.buckets.editor = ['aw-watcher-vim'];
Expand Down Expand Up @@ -665,6 +673,7 @@ export const useActivityStore = defineStore('activity', {
this.browser.duration = 0;
this.browser.top_domains = null;
this.browser.top_urls = null;
this.browser.top_titles = null;

this.editor.duration = 0;
this.editor.top_files = null;
Expand Down Expand Up @@ -701,9 +710,13 @@ export const useActivityStore = defineStore('activity', {
this.active.events = data.active_events;
},

query_browser_completed(this: State, data = { domains: [], urls: [], duration: 0 }) {
query_browser_completed(
this: State,
data = { domains: [], urls: [], titles: [], duration: 0 }
) {
this.browser.top_domains = data.domains;
this.browser.top_urls = data.urls;
this.browser.top_titles = data.titles;
this.browser.duration = data.duration;
},

Expand Down
1 change: 1 addition & 0 deletions src/stores/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const desktopViews: View[] = [
elements: [
{ type: 'top_domains', size: 3 },
{ type: 'top_urls', size: 3 },
{ type: 'top_browser_titles', size: 3 },
],
},
{
Expand Down

0 comments on commit 757f9f4

Please sign in to comment.