NEUROFUSIONInc / fusion

Record changes in health, behavior and brain activity locally on your browser or mobile phone. Discord: https://discord.gg/sqsuzXWE3K
https://usefusion.ai/research
Other
35 stars 8 forks source link

include activitywatch as a data source for screentime data #42

Open oreHGA opened 1 year ago

oreHGA commented 1 year ago
ErikBjare commented 11 months ago

@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).

oreHGA commented 10 months ago

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.

oreHGA commented 8 months ago

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);
    });
  };
Screenshot 2023-12-05 at 6 56 13 PM
ErikBjare commented 8 months ago

@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.

oreHGA commented 8 months ago

Thanks @ErikBjare this worked (had to restart activitywatch for it to take effect)

We'll add the steps for this in the integration instructions:

macOS: ~/Library/Application\ Support/activitywatch/

Linux: ~/.config/activitywatch, or the path defined by the $XDG_CONFIG_HOME environment variable.


- File `aw-server/aw-server.toml`

`cors_origins = "https://localhost:3000"`

(in prod it'll be https://usefusion.app)

- Restart ActivityWatch app  (they'll only have to do this once)

<img width="1170" alt="Screenshot 2023-12-06 at 6 06 51 PM" src="https://github.com/NEUROFUSIONInc/fusion/assets/13490968/3fd969ed-578e-4173-babd-8c3c50fd84f9">
oreHGA commented 8 months ago

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

oreHGA commented 2 months ago

@abena07 here's where we're tracking activity watch integrations in the web client

abena07 commented 2 months ago

@oreHGA okay! will like to be more clear on a few things so will schedule a call for this weekend.

oreHGA commented 2 weeks ago

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