npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ima-worldhealth/sunfish

v4.4.0

Published

A webapp for configuring DHIS2 email reports

Downloads

14

Readme

Sunfish

Sunfish is an application to screenshot DHIS2 dashboards into PDFs and email them to members of user groups on a set schedule.

This application is used internally at IMA World Health to deliver monthly dashboards to users of DHIS2 in various programs.

How It Works

Sunfish relies on three other projects of IMA World Health:

  1. dhis2-api
  2. dhis2-crawler
  3. coral

In brief, dhis2-api is a nodejs abstraction for the DHIS2 Web API, and provides authentication for users and downloads lists of dashboards, user groups, and users. dhis2-crawler is a puppeteer wrapper for logging into and accessing DHIS2 dashbaords. coral is a rendering engine also using puppeteer to turn HTML templates into PDFs before emailing them.

Authentication is managed by DHIS2 - if a user has an account with DHIS2, they automatically have an account with Sunfish. Sunfish forwards on their username/password to DHIS2 for authentication.

A user sets up a schedule by specifying an email to deliver (subject and body), a user group to send it to, and a frequency (daily, weekly, monthly). The frequency is represented in standard unix cron syntax. Schedules are not namespaced, so all users see all schedules and can manipulate them.

Schedules are stored in SQLite3 database for portability and use cron-scheduler to manage when they are run.

When a schedule is run, the following events take place:

  1. The schedule is loaded from the database.
  2. The dhis2-crawler spins up a headless browser and logs into DHIS2
  3. The dhi2-crawler navigates to each dashboard specified in the schedule using the dashboard id. DHIS2 embeds these in the DOM, so it is able to navigate to these dashboards using CSS selectors.
  4. The dashboards are downloaded by converting each graph or table into a PNG Data URI.
  5. The DHIS2 API is queried to find out what users are in the user group specified. Their email addresses are retrieved.
  6. Using coral, the dashboards are templated into an HTML template and converted into PDFs. Each dashboard is a separate PDF.
  7. The PDFs are added as attachments to the email message.
  8. MailGun sends the email to all addresses as a BCC list.
  9. Everything is shut down and cleaned up.

LICENSE

MIT