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

@beakyn/activity-tracker

v2.4.2

Published

<img src="https://static1.squarespace.com/static/5897ae3d1b10e38edfec3e32/t/58986a0dcd0f689b985fb123/1532278715866/?format=1500w" height="30" />

Downloads

48

Readme

Beakyn Activity Tracker

This is a custom redux-beacon integration that allows us to have our very own User Activity tracking API as a target.

Table of Contents

Usage

First of all, you must add both redux-beacon and @beakyn/activity-tracker as dependencies.

Then, you should have a config object with the following properties:

  • appName (string): The application which is being tracked
  • tenant (string): The current tenant
  • token (string): The logged user jwt token
  • url (string): The Activity API instance url
  • resourceId (string): Either the user email or their ID, depending on resourceType
  • resourceType (ResourceType): Either .email or .user, depending on resourceId

For example:

import { ResourceType } from '@beakyn/activity-tracker';

const config = {
  appName: 'My Applictation',
  tenant: 'My tenant',
  token: '...',
  url: '...',
  resourceId: '...',
  resourceType: ResourceType.email,
};

Note: This module detects if it's running in localhost and does nothing there to avoid polluting your analytics with local data. In order to allow traking while on development – and debug sent requests or similar – you may want to add a devMode: true property to your config object.

Next step is to define a custom event map like the following:

import { actions as bknAuthActions } from 'bkn-auth';
import { ActivityService } from '@beakyn/activity-tracker';

const { trackEvent } = ActivityService.getInstance(config);

const eventsMap = {
  [bknAuthActions.logout.getType()]: trackEvent(action => {
    return {
      feature: 'App',
      action: 'Logged out',
    };
  }),
};

Last but not least, head over to your Redux store:

import { applyMiddleware, compose, createStore } from 'redux';
import { createMiddleware } from 'redux-beacon';

import { ActivityMiddleware, ResourceType } from '@beakyn/activity-tracker';

import { rootReducer, RootState } from './rootReducer';

import { config, eventsMap } from './utils/activity'; // Or somewhere else you have both

const activityInstance = ActivityMiddleware(config);

const activityMiddleware = createMiddleware(eventsMap, activityInstance);

const middlewares = [activityMiddleware];

const storeEnhancers = [applyMiddleware(...middlewares)];

export const store = createStore<RootState>(
  rootReducer,
  compose(...storeEnhancers)
);

Then you're done! 🚀

License

This project is licensed under the terms of the MIT license.