Skip to content

MihaiVoinea/nestjs-logspot

Repository files navigation

nestjs-logspot

Injectable Logspot wrapper for NestJS

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.

About

NestJS wrapper module for logspot.io

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published