ngx-activity-log
v1.0.1
Published
## Installation
Downloads
3
Maintainers
Readme
ngx-activity-log
Installation
To install this library, run:
$ npm install ngx-activity-log --save
How to use
- Configure your environment at
src/environments/environment.ts
export const environment = {
logger: 'ws://localhost:8080/ws', // Socket Connection URL
logger_app_name: 'app1', // Logger App Name
// All other environments below this line
};
- Import the library into
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { NgxActivityLogModule } from 'ngx-activity-log';
// Import Environment to pass into the module
import {environment} from "../environments/environment";
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Specify your library as an import
NgxActivityLogModule.forRoot(environment)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
- Once your library is imported, you can use
LoggerService
in any component/service and emit logs and events
import { Component, OnInit } from '@angular/core';
import { LoggerService } from 'ngx-activity-log';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
constructor(public logger: LoggerService) { }
ngOnInit() {
this.logger.emit({ action: 'view', description: 'User viewed something' });
}
}
Logger Object
{
userId: Number,
action: String,
description: String,
// Captured Automatically
appName: String,
url: String,
platform: String,
os: String,
browser: String,
geoCoords: String,
publicIp: String,
localIp: String,
dateLogged: String
}
License
MIT © Pratheev