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

rocketmetrics

v0.1.0

Published

Javascript package for RocketMetrics. RocketMetrics is a simplest and fastest way to track the performance of your acquisition channels, and track the AARRR metrics (acquisition, activation, retention, revenue, referral) of each of your channels. Get star

Downloads

13

Readme

RocketMetrics

RocketMetrics is a simplest and fastest way to track the performance of your acquisition channels, and track the AARRR metrics (acquisition, activation, retention, revenue, referral) of each of your channels. Get started in 2 minutes !

It works both for frontend and backend.

Create an account

If you don't already have an account, go to https://metrics.rocketchart.co and create an account.

Install the library

npm i rocketmetrics

Set up the library

You have to set up RocketMetrics once for your whole project.

Example for plain Javascript or Node.js:

const rocketmetrics = require('rocketmetrics');

const rmetrics = Rocketmetrics();
rmetrics.configure({
  apiKey: "abcdefghijklmnopqrstuvwxyz",
  metrics: {"Landing page":"2K-LRknrQ","Create account":"FsX-TTjaI","Account created":"Ofi4fyEjb","Arrived on dashboard":"PfdAYsT4m"},
  domain: "yourwebsite.com",
  defaultFunnelId: "jTFXLfz24"
});

module.exports = rmetrics;

// OR

import Rocketmetrics from "rocketmetrics";

const rmetrics = Rocketmetrics();
rmetrics.configure({
  apiKey: "abcdefghijklmnopqrstuvwxyz",
  metrics: {"Landing page":"2K-LRknrQ","Create account":"FsX-TTjaI","Account created":"Ofi4fyEjb","Arrived on dashboard":"PfdAYsT4m"},
  domain: "yourwebsite.com",
  defaultFunnelId: "jTFXLfz24"
});

export default rmetrics;

Example for Vue.js (in the main.js file):

import Rocketmetrics from "rocketmetrics";

const rmetrics = Rocketmetrics();
rmetrics.configure({
  apiKey: "abcdefghijklmnopqrstuvwxyz",
  metrics: {"Landing page":"2K-LRknrQ","Create account":"FsX-TTjaI","Account created":"Ofi4fyEjb","Arrived on dashboard":"PfdAYsT4m"},
  domain: "yourwebsite.com",
  defaultFunnelId: "jTFXLfz24"
});

Vue.mixin({
  data: function() {
    return {
      get rmetrics() {
        return rmetrics;
      }
    }
  }
})

// And anywhere in your code, rmetrics is available under the global scope

await this.rmetrics.triggerEvent(...);

Use the library

Once RocketMetrics is set up, you can require it from any file in your project and use it:

const rmetrics = require('path/to/the/file/where/you/set/up/RocketMetrics').default;

// OR

import rmetrics from './path/to/the/file/where/you/set/up/RocketMetrics';

// AND THEN (examples)

await rmetrics.listen(); //listens for query parameter "rm" in URL, sets up the cookie and creates the lead
await rmetrics.triggerEvent("newValue", {metricName: "Landing page"}); //Sends an event when the lead arrives on the landing page (automatically using his cookie id)
await rmetrics.triggerEvent("newValue", {metricName: "Create account"}); //Sends an event when the lead arrives on the create an account page (automatically using his cookie id)
await rmetrics.triggerEvent("newUser", {userId: "123", userName: "Marc", userCompanyName: "RocketChart", userEmail: "[email protected]"}); //Sends an event to notify that the lead became a user with a certain userId (automatically using his cookie id), along with user's details
await rmetrics.triggerEvent("newValue", {metricName: "Account created", userId: "123"}); //Sends an event when the lead has successfully created his account, using his userId (here the cookie is not used then)
await rmetrics.triggerEvent("newValue", {metricName: "Arrived on dashboard"}); //Sends an event when the user arrived on the dashboard, without specifying his userId (by default the cookie id is used then)
await rmetrics.triggerEvent("newValue", {metricName: "Subscribed to a paid plan", userId: "123", amount: 99}); //Sends an event when the user subscribes to a paid plan, with the amount of MRR/ARR or one time payment the user is bringing you
await rmetrics.triggerEvent("newUsage", {userId: "123"}); //Sends an event when a user is active on the app, to track usage statistics on RocketMetrics website

Documentation

.configure()

frontend and backend

rmetrics.configure({
  apiKey: "abcdefghijklmnopqrstuvwxyz",
  metrics: {"Landing page":"2K-LRknrQ","Create account":"FsX-TTjaI","Account created":"Ofi4fyEjb","Arrived on dashboard":"PfdAYsT4m"},
  domain: "yourwebsite.com",
  defaultFunnelId: "jTFXLfz24"
});

Use this method to set up your API Key, the metrics your will track and the domain on which your website/app is hosted (without subdomain or http). You can generate an API Key on the RocketMetrics dashboard, under Settings -> Integration. You can also copy the whole metrics object and paste it in your code. You can also set a defaultFunnelId which is the default funnel that will be used if the lead does not come from any of your funnels (thus no 'rm' query parameter set up).

.listen()

frontend only

await rmetrics.listen(); //listens for query parameter "rm" in URL, sets up the cookie and creates the lead

Use this method on the page where the lead is first landing on. Usually it is the landing page / homepage of your website. This method sets up a cookie in the lead's browser with a automatically generated leadId, and sends an event to RocketMetrics including the funnelId it came from and the leadId. The funnelId is automatically retrieved from the query parameter "rm" (example: https://yourwebsite.com?rm=funnelId).

.triggerEvent()

frontend and backend

await rmetrics.triggerEvent("newValue", {metricName: "Landing page"}); //Sends an event when the lead arrives on the landing page (automatically using his cookie id)
await rmetrics.triggerEvent("newValue", {metricName: "Create account"}); //Sends an event when the lead arrives on the create an account page (automatically using his cookie id)
await rmetrics.triggerEvent("newUser", {userId: "123", userName: "Marc", userCompanyName: "RocketChart", userEmail: "[email protected]"}); //Sends an event to notify that the lead became a user with a certain userId (automatically using his cookie id), along with user's details
await rmetrics.triggerEvent("newValue", {metricName: "Account created", userId: user.id}); //Sends an event when the lead has successfully created his account, using his userId (here the cookie is not used then)
await rmetrics.triggerEvent("newValue", {metricName: "Arrived on dashboard"}); //Sends an event when the user arrived on the dashboard, without specifying his userId (by default the cookie id is used then)
await rmetrics.triggerEvent("newValue", {metricName: "Subscribed to a paid plan", userId: "123", amount: 99}); //Sends an event when the user subscribes to a paid plan, with the amount of MRR/ARR or one time payment the user is bringing you
await rmetrics.triggerEvent("newUsage", {userId: "123"}); //Sends an event when a user is active on the app, to track usage statistics on RocketMetrics website

Use this method anywhere in your code, frontend and backend, where you wish to track events. There are three possible events: "newValue", "newUser" and "newUsage". The usual way is to track all events on the frontend until the lead becomes a user using the "newValue" event along with the metricName (the leadId is automatically retrieved from the lead's browser cookies). Once the lead becomes a user, you send a "newUser" event along with the userId. Afterwards, you can choose to send further events using the "newValue" event with either the userId, or nothing and the leadId will automatically be used instead (retrieved from the browser's cookies). In the backend, you have no choice then always using the userId. You can also track the revenue each lead/user is bringing. You just have to add the price (MRR/ARR or one time payment) under "amount" along with the metricName. When you want to track when your users were last active, you can send a "newUsage" event along with either the userId (frontend and backend) or nothing (frontend only, the leadId will be retrieved from cookies) and see the stats under the Usage page on RocketMetrics website