Back to Open Saas

Admin Dashboard

opensaas-sh/blog/src/content/docs/general/admin-dashboard.mdx

latest3.7 KB
Original Source

import adminDashboard from '@assets/admin/admin-dashboard.png'; import dbStudio from '@assets/stripe/db-studio.png'; import { Image } from 'astro:assets';

This is a reference on how the Admin dashboard, available at /admin, is set up.

<Image src={adminDashboard} alt="admin dashboard" loading="eager" />

Permissions

The Admin dashboard is only accessible to users with the isAdmin field set to true.

tsx
model User {
  id                        Int             @id @default(autoincrement())
  email                     String?         @unique
  username                  String?
  isAdmin                   Boolean         @default(false)
  //...

To give yourself administrator priveledges, make sure you add your email addresses to the ADMIN_EMAILS environment variable in .env.server file before registering/logging in with that email address:

sh
[email protected]

// or add many admins with a comma-separated list

[email protected],[email protected],[email protected]

Or if you've already logged in with an email address that you want to give admin priveledges to, you can run the following command in a separate terminal window to update the user's isAdmin field manually:

sh
wasp db studio
<Image src={dbStudio} alt="db studio" loading="lazy" />

:::tip[Star our Repo on GitHub! 🌟] We've packed in a ton of features and love into this SaaS starter, and offer it all to you for free!

If you're finding this template and its guides useful, consider giving us a star on GitHub :::

Admin Dashboard Pages

Analytics Dashboard

The Admin analytics dashboard is a single place for you to view your most important metrics and perform some admin tasks. At the moment, it pulls data from:

  • Payment Processor:
    • total revenue
    • revenue for each day of the past week
  • Google or Plausible:
    • total number of page views (non-unique)
    • percentage change in page views from the previous day
    • top sources/referrers with unique visitor count (i.e. how many people came from that source to your app)
  • Database:
    • total number of registered users
    • daily change in number of registered users
    • total number of paying users
    • daily change in number of paying users

These metrics are aggregated within the background job dailyStatsJob, which by default is run every hour. You can change the frequency of this job by modifying its cron field:

ts
job dailyStatsJob {
  executor: PgBoss,
  perform: {
    fn: import { calculateDailyStats } from "@src/analytics/stats"
  },
  schedule: {
    cron: "0 * * * *" // every hour. useful in production
    // cron: "* * * * *" // every minute. useful for debugging
  },
  entities: [User, DailyStats, Logs, PageViewSource]
}

For more info on Wasp's recurring background jobs, check out the Wasp Jobs docs.

For a guide on how to integrate these services so that you can view your analytics via the dashboard, check out the Payment Integrations and Analytics guide of the docs.

:::note[Help us improve] We're always looking to improve the Admin dashboard. If you feel something is missing or could be improved, consider opening an issue or submitting a pull request :::

Users

The Users page is where you can view all your users and their most important details. You can also search and filter users by:

  • email address
  • subscription/payment status
  • admin status