0.1.2 • Published 2 years ago

nestjs-logspot v0.1.2

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

Installation

npm install --save nestjs-logspot

Getting Started

The simplest way to use nestjs-logspot is to use LogspotModule.forRoot

import { Module } from '@nestjs-common';
import { LogspotModule } from 'nestjs-stripe';

@Module({
  imports: [
    LogspotModule.forRoot({
      // Recommendation: Use env vars to store the secret key
      secretKey: 'sk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    }),
  ],
})
export class AppModule {}

You can then inject Logspot into any of your injectables by using a custom decorator

import { Injectable } from '@nestjs/common';
import { InjectLogspot, LogspotService } from 'nestjs-stripe';

@Injectable()
export class AppService {
  constructor(@InjectLogspot() private readonly logspotService: LogspotService) {}
}

After you injected Logspot, you can use the track function to send events.

import { Injectable } from '@nestjs/common';
import { InjectLogspot, LogspotService } from 'nestjs-stripe';

@Injectable()
export class AppService {
  constructor(@InjectLogspot() private readonly logspotService: LogspotService) {}

  sendEvent(account) {
    this.logspotService.track({
      event: 'account.created',
      userId: account.id,
      metadata: { email: account.email },
    });
   }
}

License

Licensed under the MIT License - see the LICENSE file for details.