vizhub-core / vizhub-feedback

VizHub feedback issue tracker
32 stars 3 forks source link

Public API for VizHub Stats #629

Open ghost opened 3 years ago

ghost commented 3 years ago

As a user, I want to access my usage data: number of projects, upvotes given and received, etc. tracked over time... Not a pre-built visualization, but the raw data (e.g. in JSON format) so that I can create custom visualizations of my VizHub activity.

curran commented 3 years ago

Very nice! I've been working on this actually, it's very close.

First pass is here: https://vizhub.com/stats

The API endpoint is this: https://vizhub.com/api/event/get

Example request:

  const [data, setData] = useState();

  useEffect(() => {
    const getData = async () => {
      const eventIDs = [
        'event.pageview',
        'event.pageview.home',
        'event.pageview.viz',
      ];
      const response = await fetch('/api/event/get', { 
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ eventIDs }),
      }); 
      setData(await response.json());
    };
    getData();
  }, []); 

These are the first things available, top level site stats, but we do plan to introduce more detailed per-user and per-viz stats.

It should be possible to start playing with this already now, developing a viz of this data for top level usage data.

Related issues:

curran commented 3 years ago

This is a great idea.

One concern is that if there are no API keys on it, traffic might get overwhelming over time.

That said, I could see just making it open to start, and monitoring usage of the API to see if it ever spikes or gets too high, then take action at that point like adding API keys.

Related #479 #488