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

@robojs/analytics

v0.1.1

Published

Track user interactions and server activity with ease.

Downloads

60

Readme


@robojs/analytics

Instant analytics for your Robo. This plugin automatically integrates your preferred analytics service into your project, such as Google Analytics, Plausible, and more.

Use cases:

  • Know how many times a Slash Command is used.
  • Track how many times your Discord Activity is opened.
  • Monitor number of users over time.
  • Anything else you can think of. ✨

📚 Documentation: Getting started

🚀 Community: Join our Discord server

Installation 💻

To add this plugin to your Robo.js project:

npx robo add @robojs/analytics

New to Robo.js? Start your project with this plugin pre-installed:

npx create-robo <project-name> -p @robojs/analytics

Getting Started ✨

How does @robojs/analytics know which service to use? Simple! Just add your analytics service key to your .env file.

For Google Analytics, it's a tracking ID and secret:

GOOGLE_ANALYTICS_MEASURE_ID="G-123456789"
GOOGLE_ANALYTICS_SECRET="123456789"

For Plausible, it's your domain:

PLAUSIBLE_DOMAIN="example.com"

Not sure which service to use?

We recommend Plausible for its simplicity and privacy-focused analytics. If you're looking for more tracking, Google Analytics may be a better fit. You can also use both or implement your own!

Seed

This plugin can seed your project with a basic tracking setup. This includes tracking Slash Commands and Events.

JavaScript API

An Analytics object is available globally in your project.

import { Analytics } from '@robojs/analytics'
import type { ChatInputCommandInteraction } from 'discord.js'

export default (interaction: ChatInputCommandInteraction) => {
	// An event can be anything you want to track.
	Analytics.event('testing_event')

	// A view is a page view or screen view. (not really for discord bots)
	Analytics.view('Test Page')

	// Use a unique identifier per session if you can.
	// This may be more difficult for discord bots, but you can use the user id, guild id, etc.
	const sessionId = interaction.channelId ?? interaction.guildId
	Analytics.event('something_happened', { sessionId })

	// Also include a user id as well whenever possible for greater accuracy.
	Analytics.event('test_event', {
		sessionId: sessionId,
		userId: interaction.user.id
	})

	return 'I just tracked something special!'
}

Feel free to use the Analytics object anywhere in your project! It's just JavaScript, after all!

Other Services

Want to use a different analytics service? You can add your own service by extending the BaseEngine class and passing it in your config.

// config/plugins/robojs/analytics.mjs
import { BaseEngine } from '@robojs/analytics'

class MyCustomEngine extends BaseEngine {
	// Implement your custom tracking logic here
}

export default {
	engine: new MyCustomEngine()
}

We also offer a ManyEngine class that allows you to use multiple analytics services at once.

// config/plugins/robojs/analytics.mjs
import { GoogleAnalytics, Plausible, ManyEngine } from '@robojs/analytics'

export default {
	engine: new ManyEngine(new GoogleAnalytics(), new Plausible())
}

Mix and match services to your heart's content, or switch between them without needing to update code. Usage remains the same.