GithubHelp home page GithubHelp logo

qu8n / focusbeacon Goto Github PK

View Code? Open in Web Editor NEW
26.0 0.0 6.0 1.84 MB

๐Ÿ“Š Session metrics dashboard for Focusmate, a virtual co-working platform

Home Page: https://www.focusbeacon.com/

License: MIT License

CSS 0.46% JavaScript 99.54%
focusmate metrics dashboard stats

focusbeacon's Introduction


Logo

FocusBeacon

Unofficial Focusmate metrics dashboard
View Demo ยท Report Bug ยท Request Feature


FocusBeacon preview

Built with

  • Frontend: React, Tremor.so, Headless UI, TailwindCSS
  • Backend: Next.js, Supabase's Postgres database, Vercel

Getting started locally

  1. Log in to your Focusmate account
  2. Navigate to your profile settings
  3. Click on Generate API key and save the API key for a later step
  4. Clone this repo to your local machine
    git clone https://github.com/qu8n/focusbeacon.git
  5. Navigate to the project directory
    cd focusbeacon
  6. Use the Node version specified for this project
    nvm use
  7. Install packages with npm
    npm install
  8. Create an .env file in the root directory
  9. Enter the environment variables in the .env file
    DEMO_FOCUSMATE_API_KEY="YOUR_API_KEY"
    
  10. Run the app in development mode
npm run dev
  1. Open localhost:3000/dashboard/demo to view your metrics in the browser

Contributing

By default, contributors will not have access to the Focusmate OAuth login nor production database. If your contributions require access to these, please reach out to me on LinkedIn.

If you have a suggestion that would make this better, feel free to fork the repo and create a pull request. I'm also happy to chat over a Focusmate session to get you started with the codebase.

focusbeacon's People

Contributors

bennycraig avatar mahdiqaempanah avatar qu8n avatar sweep-ai[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

focusbeacon's Issues

Resolve missing Next.js plugin in ESLint config

Investigate and resolve the following warning message from the Vercel logs:

{
  "message": "warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config",
  "vercel": {
    "deploymentId": "dpl_iaAPnpxrZvBTSPT1RUBw4JDSTFMm",
    "deploymentURL": "focusbeacon-eq9rmyyhz-qu8n.vercel.app",
    "environment": "production",
    "projectId": "prj_VCvkZxdidURY3SHro23lIsiId39O",
    "projectName": "focusbeacon",
    "source": "build",
    "userName": "qu8n"
  }
}

This Next.js discussion post might be a good start.

Refactor the `Modal` component to be more generic

The Modal component is used to display a popup modal when users click on "About" or "Privacy" on the navbar.

Current state:

// _app.js
...
<NavBar
  setShowAboutModal={setShowAboutModal}
  setShowPrivacyModal={setShowPrivacyModal}
/>

{(showAboutModal || showPrivacyModal) && (
  <Modal
    modalType={showAboutModal ? "about" : "privacy"}
    setShowAboutModal={setShowAboutModal}
    setShowPrivacyModal={setShowPrivacyModal}
  />
)}
...

The mechanism to show either the About or Privacy's content is not generic. There are two setState methods for each content.

Ideal state:
There is a generic Modal component that receives two props: (1) setOpen that dictates whether the modal should open, and (2) textContent that includes the texts inside the modal.

Backend: set a global context for storing session status

When focusbeacon.com first loads, the NavBar component calls the /api/session endpoint to check whether the visitor is logged in. If they are, it will display a "Log Out" link and, otherwise, a "Log In" link.

Separately, the Dashboard component also calls this same API to decide whether to show the user's stats or redirect them to the landing page for login.

Ideally, the app should make a single call to this API endpoint.

Add tests

Add tests by using a testing framework such as Jest or Mocha that is compatible with React. Focus on more critical components such as Dashboard and its functions, especially functions that calculate metrics and asynchronous operations. At some point, we can set up CI tools to automatically run tests for new PRs.

Sweep: Create a new shared util function for filtering completed sessions

There are currently 8 instances in the codebase where sessions data are filtered to only those that are completed. (To find them, search the codebase for const completedSessions = .)

Todo: create a new generic function called getCompletedSessions() and save it in src/utils to be shared across the codebase.

Convert JavaScript code to TypeScript

All Pull Requests are welcome for this work, whether it is JS-TS conversion of a single file or multiple files. Because TS is just a superset of JS, we don't need to convert all the files at once.

The first step would include the initial setup and configurations, such as installing TS and adding the config file tsconfig.json. If you have any questions, comment below and I'll respond within 24 hours.

Recommended reading:
https://www.sitepoint.com/how-to-migrate-a-react-app-to-typescript

Frontend: add a comma separator for metrics

Right now, numeric metrics don't have a comma separator. For example: 1056 sessions (vs. 1,056 sessions). We'll go with the comma separator instead of period since most Focusmate users are based in the US.

Frontend: add a pie chart that breaks down users' sessions by time of day

Add a pie chart that breaks down users' sessions by time of day: morning, afternoon, evening, and overnight:

  • Morning: 6:00 AM to 11:59 AM
  • Afternoon: 12:00 PM (noon) to 5:59 PM
  • Evening: 6:00 PM to 8:59 PM
  • Overnight: 9:00 PM or sunset until 5:59 AM

The Focusmate API provides a user's time zone and their session times in Coordinated Universal Time (UTC). To accomplish this task, we'll need to process these two data points to discern whether their sessions fell into morning, afternoon, evening, and overnight based on their time zones.

General code clean-up and refactoring

This is an open call for implementing better programming practices (e.g. DRY) to any areas of the codebase that are lacking. Any help is welcome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.