Giter Club home page Giter Club logo

c40ddfc447f60342c6485f575efdfc24457a646932c4b74b9ba6c21ecfebf9ad's Introduction

Firefox Health backend

Firefox metrics & insights backend. For the frontend code visit the Firefox health dashboard repo.

Build Status

Requirements

  • Node
  • Yarn (recommended)

Setting project up

In your console:

yarn // To get the dependencies installed
yarn start // To start the server

Enable access to Nimbledroid's data

Nimbledroid provides us with performance data for various sites on Android. If you want to make changes to the Nimbledroid APIs on the backend you will need to have access to our corporate Nimbledroid account.

Once you have access you can fetch your personal key (keep private) under your account. You can re-generate it there if it ever gets leaked.

Once you have it you can start the backend like this:

export NIMBLEDROID_API_KEY=<API key>
export NIMBLEDROID_EMAIL=<your email address>
export REDIS_URL=redis://localhost:6379
// Change DEBUG to script:* if you also want debug output
DEBUG=script:info,script:error yarn fetchNimbledroidData
yarn start

Load this page to verify it works.

Redis

If you want to test caching with Redis (there's caching with JS as a fallback) make sure to install Redis and set the REDIS_URL env to redis://localhost:6379 before starting the server.

How the Nimbledroid data is fetched

In order to fetch the data from Nimbledroid's APIs we need an API key, thus, we need to use this backend. In order to handle the inefficient APIs we store the data in Redis.

This is how we fetch, store & serve the data:

  • We schedule a job every hour on Heroku
  • This job executes the fetchNimbledroidData.js script
  • If any of the profiles fetched are new we store them on Redis
  • When the frontend hits this backend we return data from our Redis storage

This set up above is accomplished via the "firefox-health-backend" app on Heroku.

These env variables are needed:

  • NIMBLEDROID_API_KEY
  • NIMBLEDROID_EMAIL

The addons involved are:

  • Heroku Redis
  • Heroku Scheduler

In order to report any issues with fetching the data we've also enabled the "Dead Man's snitch" (DMS) on Heroku. Ths add-on expects the Heroku scheduled job to consistently report a successful run. If DMS does not hear back from the script after a couple of hours it will send an email notifying few users. You can adjust who the recepients of the alerts are via the add-on on Heroku.

Nimbledroid data seems old

First check the APKs uploaded dates from Nimbledroid. Hover over the apps to verify the match the package IDs (e.g. org.mozilla.klar.

If everything seems fine, try to run the script as described in the section above to see if there's anything broken.

If everything works, load the Nimbledroid APKs directly and inspect the output.

Attributions

  • heartbeat icon by Creative Stall from the Noun Project

c40ddfc447f60342c6485f575efdfc24457a646932c4b74b9ba6c21ecfebf9ad's People

Contributors

armenzg avatar cpeterso avatar mozilla-github-standards avatar rvandermeulen avatar sarah-clements avatar stuartphilp avatar

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.