ngx-activity-log
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i ngx-activity-log

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

36.1 kB

Total Files

9

Last publish

Collaborators

  • pratheev