fusion
fusion copied to clipboard
include activitywatch as a data source for screentime data
- [ ] add fusion to allowed urls that can fetch from local activitywatch
- [ ] enable CORS
- [ ] make fetch calls from browser using https://github.com/ActivityWatch/aw-client-js
@oreHGA Can you point me to where the resulting data from the API calls would go?
If using aw-client-js, there might be some work I need to do first since aw-client-js doesn't have the same handy built-in queries as aw-client-python (same ones as in aw-webui) which do most the heavy lifting (AFK filtering, categorization, etc).
Hey! Sorry I'm just getting back to this.
The api calls will go specifically in this file - neurofusion/next-client/src/components/features/integrations/modals/activitywatch-modal.tsx
The integrations folder contains all the logic for other connectors.
Re: aw-client-js: I looked through the docs and I was that I had to provide my hostname and bucket information... @ErikBjare , I'll give it a shot & try to input from my browser.
Hey @ErikBjare , I tried using the aw-client-js to list the active buckets but I'm getting a CORS error as the response. Is there somewhere I need to set Fusion's domain was an an allowed origin from ActivityWatch?
Code snippet I used after installing the library:
const awClient = new AWClient("fusionClient");
awClient.getBuckets().then((buckets) => {
console.log(buckets);
});
};
@oreHGA Yes, see: https://github.com/ActivityWatch/aw-webui#cors
Basically you can add allowed CORS origins in the config files. Not the most user-friendly experience, but somewhat easy to do.
Thanks @ErikBjare this worked (had to restart activitywatch for it to take effect)
We'll add the steps for this in the integration instructions:
- Find the folder in on your computer based on your device type
Windows: %LocalAppData%\activitywatch\activitywatch
macOS: ~/Library/Application\ Support/activitywatch/
Linux: ~/.config/activitywatch, or the path defined by the $XDG_CONFIG_HOME environment variable.
- File to open is
aw-server/aw-server.toml
Make sure you have the cors_origins line under [server] looking like below
[server]
cors_origins = "https://usefusion.ai"`
(for devs, use this instead)
cors_origins = "https://localhost:3000;https://usefusion.ai;https://usefusion.app"
- Restart ActivityWatch app (they'll only have to do this once)
This is what we want to call afterwards to fetch screentime history - https://github.com/ActivityWatch/aw-client-js/blob/39868c71e48a23193aed77167894917ea423f812/src/aw-client.ts#L316
@abena07 here's where we're tracking activity watch integrations in the web client
@oreHGA okay! will like to be more clear on a few things so will schedule a call for this weekend.
eventually, we'd want to eventually make a PR to activitywatch settings page that allows the user to update the allowed domains from here: http://localhost:5600/#/settings