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

ci-trap-web

v1.0.14

Published

Lightweight mouse and touch event tracker library for browsers.

Downloads

324

Readme

ci-trap-web test

Lightweight mouse movement tracker library for browsers.

Quickstart

In order to collect mouse, pointer, touch and various other browser events from a website do the following in your ES6 or CommonJS compatible project:

1. Install:

$ npm install ci-trap-web

2. Import trap client using ES6 module syntax:

import trap from 'ci-trap-web';

... or using CommonJS syntax:

const { trap } = require('ci-trap-web');

3. Set up data collection server and start collecting events:

trap.url('https://your.server.com');
trap.mount(document.body);

4. Check for Trap submissions in your network communications, e.g. using your browser's development tools.

Examples

There are working examples in the examples/ directory:

  • ES6 (in examples/es6/) provides a fully configured ES6 compatible example to start integrating Trap into a modern Javascript framework, e.g. React.

  • Vanilla (in examples/vanilla/) contains a precompiled Javascript bundle and the necessary steps to integrate Trap into a bare-bone HTML document -- without the need to set up a complex build framework.

  • Sandbox (in examples/sandbox/) is our experimental sandbox to test and validate new features, execute various research tasks, e.g., saving collected chunks to files into a configurable directory.

Develop

You may want to develop new features or reproduce bugs in a working environment, for this we recommend using our "Sandbox" example in the examples/sandbox/ directory.

Examples are set up. They can be installed and started with these simple commands:

  1. Install the root project's dependencies (in the project's root):

    $ make install-deps
  2. Go into the example you want to start -- e.g. "Sandbox" in this case -- and install its dependencies:

    $ cd examples/sandbox/
    $ make install-deps
  3. Start the web server to start the example application:

    $ make server

The UI of the example is available at http://localhost:3000/.

Configuration

You can configure ci-trap-web by specifying environment variables during build time. These environment variables act as configuration parameters.

You can find the configuration parameters in src/constants.js. Each configuration parameter has a process.env.<name> reference in constants.js.

See the How to generate gt.min.js section for an example that overrides the APP_DEFAULT_TRAP_API_KEY_VALUE configuration parameter.

How to generate gt.min.js

  1. Install the root project's dependencies (in the project's root):

    $ make install-deps
  2. Generate a UUID that you will use as the API key (optional):

    $ uuidgen
    aa34677e-a3ee-445c-8483-a30924ebc5d9
  3. Build a release (replace the API key):

    $ APP_DEFAULT_TRAP_API_KEY_VALUE=aa34677e-a3ee-445c-8483-a30924ebc5d9 \
          make release
  4. You can find your customized gt.min.js as dist/gt.min.js.

How to generate gt.min.js with Docker

You can build assets in a dockerized environment, without the need to install Node.js and its dependencies.

  1. Generate a UUID that you will use as the API key (optional):

    $ uuidgen
    aa34677e-a3ee-445c-8483-a30924ebc5d9
  2. Build JavaScript asset files with the Docker environment provided:

    $ docker build --ssh default --build-arg GIT_USER=${GIT_USER} . \
        -t ci-trap-web

    Replace ${GIT_USER} with your Gerrit/Git user.

  3. Resulting assets are put into the container's /opt/app/ directory which can be easily accessed after starting the container and using curl or directly copy the files out of it:

    • Start the container:

      $ docker run --rm -p 8080:80 --name ci-trap-web ci-trap-web
    • In a separate shell, use curl to fetch the asset:

      $ curl -O http://your-docker-server:8080/gt.min.js
    • Or directly copy the file out of it:

      $ docker cp ci-trap-web:/opt/app/gt.min.js ./gt.min.js

License

ci-trap-web is released under the MIT license.