1.0.0 • Published 5 years ago

nes-analytics v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Installation:

npm install --save @daymon-nes/nes-logging
npm install --save @daymon-nes/nes-analytics

A implementation using @daymon-nes/nes-analytics for collecting events and sending to analytics server

Example:

import { EventFeedBack } from '@daymon-nes/nes-analytics';
// create an instance with a specific classification
// loggingConf is a configuration for @daymon-nes/nes-logging
const feedbackService = new EventFeedBack('classification_analytics', loggingConf);

// a default logging configuration
defaultconfig {
  appenders: {
		console: { "type":"console" },
       	kinesis: {"type":"kinesis", "identityPoolId":"us-east-1:a1a30fa6-dda8-44ba-bfd9-d7ddc7fc8a40", "region":"us-east-1"}
	},
    // you can specify different categories
	categories: {
		default: { "appenders": [ "console" ], "level": "all" },
        custom: { "appenders":[ "console", "kinesis ], "level": "error"}
	},
	// geoTracking: toggle ON/OFF geodata
	geoTracking: true
}

// Record a 'Like' event
feedbackService.like(name, attributes, metrics)

// Record a 'Dislike' event
feedbackService.dislike(name, attributes, metric)

// Record a 'Report' event
feedbackService.report(name, attributes, metric)

Result

{
  "evenId": "6ea472c0-f1f6-11e8-bf31-81ac446fcb35",
  "logDate": "2018-11-27T03:42:15.532Z",
  "data": {
    "classification": {
      "service": "ANALYTICS",
      "eventType": "EVENT_FEEDBACK",
      "actionType": "LIKE"
    },
    "metrics": 97.801304214271
  },
  "geoData": {
    "geometry": {
      "type": "Point",
      "coordinates": [ 47.5, 19.0833 ]
    },
    "properties": {
      "ipAddress": "188.6.104.57",
      "name": "Budapest",
      "country": "Hungary"
    }
  }
}

A brief description about configuration of @daymon-nes/nes-logging

appenders (object) - a map of named appenders (string) to appender definitions (object). Appender definitions must have a property type (string) - other properties depend on the appender type.
categories (object) - a map of named categories (string) to category definitions (object). 

You must define the default category which is used for all log events that do not match a specific category.
Category definitions have two properties:
- appenders (array of strings) - the list of appender names to be used for this category. A category must have at least one appender.
- level (string, case insensitive) - the minimum log level that this category will send to the appenders. For example, if set to ‘error’ then the appenders will only receive log events of level ‘error’, ‘fatal’, ‘mark’ - log events of ‘info’, ‘warn’, ‘debug’, or ‘trace’ will be ignored.

Currently support 2 appenders:

Console

Kinesis comes with these settings:

identityPoolId: required,

region: required,

bufferSize: (optional), default = 1000,

flushSize: (optional), default = 100,

flushInterval: (optional), default = 5000,

resendLimit: (optional), default = 5,

Issues:

For Angular 6, you need to include code below in polyfill.ts

(window as any).global = window;

Doesn't support pm2