fusion icon indicating copy to clipboard operation
fusion copied to clipboard

include activitywatch as a data source for screentime data

Open oreHGA opened this issue 2 years ago • 9 comments

  • [ ] 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 avatar Feb 15 '23 20:02 oreHGA

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

ErikBjare avatar Sep 05 '23 17:09 ErikBjare

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 avatar Oct 16 '23 15:10 oreHGA

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

oreHGA avatar Dec 06 '23 03:12 oreHGA

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

ErikBjare avatar Dec 06 '23 07:12 ErikBjare

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)
Screenshot 2023-12-06 at 6 06 51 PM

oreHGA avatar Dec 06 '23 23:12 oreHGA

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 avatar Dec 07 '23 02:12 oreHGA

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

oreHGA avatar Jun 17 '24 23:06 oreHGA

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

abena07 avatar Jun 17 '24 23:06 abena07

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

oreHGA avatar Aug 11 '24 18:08 oreHGA