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

armut-sentinel

v4.0.1

Published

Armut logger tool

Downloads

26

Readme

npm

armut-sentinel is a JavaScript library for saving mouse events sending it to a custom API for further analysis. You can use armut-sentinel with any framework you want since it's framework agnostic.

Installation

To install the latest version of the library you can use npm:

npm install armut-sentinel 

Getting a build

So there are two build commands in the package.json.

  1. npm run build: Use this one if you want to get a quick build without deciding whether unit tests are succeeded or not. Not recommended for publish. However, can be useful for build in development environment.
  2. npm run build:safe: As the name suggests, this one generates a build but first it runs all the unit tests so if any of these tests fail, your build will fail too. This commands is very useful for publishing since it guarentees that there is no problem with the current version.

Let's talk about the build process. First we compile Typescript code into JavaScript(npm run compile) after removing dist directory. Then we transpile the compiled JavaScript code using babel into dist directory.(npm run transpile). Lastly, we run webpack for getting a bundle. In dist directory, two files will be generated: index.bundle.js minified and bundled version of source code, and index.d.ts which is a declaration file for our source code to infer types.

Documentation

ArmutSentinel.getExperimentAndVariantId(cookie: Cookie): ExperimentIdType

Gets a special id from the input cookie that is used for Google Analytics.

ArmutSentinel.checkCookie(cookieName: string): MaybeEmptyString<Cookie>

A recursive function that tries to get the cookie running with predefined retry times. If cannot find the cookie after limited attempts it returns to an empty string.

ArmutSentinel.xhrSend(): void

A recursive function that checks if is there any requests waiting in the queue and if there is any initiates the request. Terminates when there is no request left.

ArmutSentinel.collect(event: MouseEvent, sessionId?: string, screenName?: string): void

Upon getting a new event, it gathers all the necessary information and pushes it to the items array to be send in the request body.

ArmutSentinel.send(
    apiUrl: string,
    apiName: string,
    sentinelData: EnhancedSentinelDataModel,
    onSuccess?: VoidFunction<void>,
    onError?: VoidFunction<void>
  ): void

Bread and butter of the library. Enhances sentinelData with apt fields. Detects environment using window object. Adds given event listeners to xhr request and sets the headers for it. Then adds adds the request to the queue and consumes it using xhrSend.

License

This project is licensed under MIT.