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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@main12/payload-hyros-widget

v0.1.7

Published

Payload CMS plugin that adds Hyros analytics dashboard widgets with configurable themes and a server-side data proxy.

Readme

Payload Plugin Hyros Widget

Payload plugin that adds Hyros analytics widgets to the admin dashboard.

Current implementation includes:

  • Individual drag-and-drop metric widgets (not one monolithic card)
  • Chart-first widget visuals for trends, mix, and funnel snapshots
  • Server-side Hyros API proxy endpoint (API key stays on server)

Features

Widget Collection

  • Total Revenue
  • Qualified Sales
  • Refunds & Discounts
  • Revenue Trend
  • Product Mix
  • Total Leads
  • Leads Trend
  • Lead Funnel
  • Top Lead Tags

Installation

pnpm add @main12/payload-hyros-widget

Required Environment Variables

HYROS_API_KEY=your_hyros_api_key

For local development in this repository, configure dev/.env from dev/.env.example.

If you want to use a different environment variable name, pass hyrosApiKeyEnvVarName in the plugin options.

Usage

Add the plugin in your Payload config:

import { buildConfig } from 'payload'
import { payloadPluginHyrosWidget } from '@main12/payload-hyros-widget'

export default buildConfig({
  plugins: [
    payloadPluginHyrosWidget({
      defaultDateRangeDays: 30,
      collections: {
        posts: true,
      },
    }),
  ],
})

Plugin Options

type PayloadPluginHyrosWidgetConfig = {
  collections?: Partial<Record<CollectionSlug, true>>
  defaultDateRangeDays?: number
  hyrosApiKeyEnvVarName?: string
  widgetStyle?: 'default' | 'minimal'
  disabled?: boolean
}
  • collections: optionally adds the addedByPlugin field to selected collections.
  • defaultDateRangeDays: fallback date range when dashboard query params are absent.
  • hyrosApiKeyEnvVarName: custom environment variable name used to read the Hyros API key.
  • widgetStyle: controls the widget theme. Supported values are default and minimal.
  • disabled: disables runtime plugin behavior while preserving schema changes.

Widget Themes

This plugin supports multiple widget themes through the widgetStyle option.

Theme behavior:

  • default: Payload-like card styling with neutral background, border, and no extra gradients.
  • minimal: lighter/transparent look that keeps a visible border.

If you do not set widgetStyle, the plugin uses default.

Theme Configuration Examples

Use default theme explicitly:

import { buildConfig } from 'payload'
import { payloadPluginHyrosWidget } from '@main12/payload-hyros-widget'

export default buildConfig({
  plugins: [
    payloadPluginHyrosWidget({
      widgetStyle: 'default',
    }),
  ],
})

Use minimal theme:

import { buildConfig } from 'payload'
import { payloadPluginHyrosWidget } from '@main12/payload-hyros-widget'

export default buildConfig({
  plugins: [
    payloadPluginHyrosWidget({
      widgetStyle: 'minimal',
    }),
  ],
})

Combined configuration example:

import { buildConfig } from 'payload'
import { payloadPluginHyrosWidget } from '@main12/payload-hyros-widget'

export default buildConfig({
  plugins: [
    payloadPluginHyrosWidget({
      widgetStyle: 'default',
      defaultDateRangeDays: 30,
      hyrosApiKeyEnvVarName: 'HYROS_API_KEY',
    }),
  ],
})

Dashboard Setup

This plugin registers real Payload dashboard widgets through config.admin.dashboard.widgets and also seeds a default dashboard layout so the widgets can be rearranged in the Payload dashboard editor.

Registered widgets:

  • Hyros Total Revenue
  • Hyros Qualified Sales
  • Hyros Refunds & Discounts
  • Hyros Revenue Trend
  • Hyros Product Mix
  • Hyros Total Leads
  • Hyros Leads Trend
  • Hyros Lead Funnel
  • Hyros Top Tags

API Endpoint

The plugin registers the Payload endpoint:

  • GET /api/{apiRoute}/hyros/dashboard

Query params:

  • fromDate (optional, ISO day)
  • toDate (optional, ISO day)

If omitted, the plugin uses defaultDateRangeDays ending at today.

Architecture

The implementation follows a clean architecture orientation:

  • Interface layer:
    • src/endpoints/hyrosDashboardHandler.ts
    • src/widgets/HyrosMetricWidget/Component.client.tsx
    • src/widgets/*Widget/Component.client.tsx
  • Domain layer:
    • src/hyros/analytics.ts
  • Infrastructure layer:
    • src/hyros/client.ts
    • src/hyros/types.ts
    • src/hyros/options.ts

Widget registration:

  • src/widgets/index.ts
  • src/widgets/useHyrosDashboardData.ts
  • src/widgets/HyrosWidget.module.css

This keeps business rules independent from transport and UI details.

Development

pnpm install
pnpm dev

Useful scripts:

  • pnpm lint
  • pnpm test:int
  • pnpm test:e2e
  • pnpm build

Notes

  • The Hyros API key is never exposed in browser requests.
  • Dashboard widgets fetch from the Payload endpoint, not directly from Hyros.