4.0.1 • Published 2 years ago

armut-sentinel v4.0.1

Weekly downloads
121
License
MIT
Repository
-
Last release
2 years ago

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.

4.0.1

2 years ago

4.0.0

2 years ago

3.23.23

2 years ago

3.1.4

3 years ago

3.0.9

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.6.1

4 years ago

2.6.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.891.0

4 years ago

1.89.0

4 years ago

1.881.0

4 years ago

1.88.0

4 years ago

1.874.0

4 years ago

1.873.0

4 years ago

1.872.0

4 years ago

1.871.0

4 years ago

1.87.0

4 years ago

1.84.0

5 years ago

1.74.0

5 years ago

1.73.1

5 years ago

1.72.1

5 years ago

1.71.1

5 years ago

1.70.1

5 years ago

1.69.1

5 years ago

1.68.1

5 years ago

1.67.1

5 years ago

1.64.1

5 years ago

1.63.1

5 years ago

1.62.1

5 years ago

1.61.1

5 years ago

1.6.0

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.5

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.6

6 years ago

0.0.7

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago