GithubHelp home page GithubHelp logo

nestjs-posthog's Introduction

Logo

nestjs-posthog

Lightweight library to use Posthog in NestJS applications.

Quick Start Guide · Request Feature · Report Bug


code style: prettier Commitizen friendly Release

Language grade: JavaScript codecov

Posthog for Nestjs makes it easier to implement analytics with Posthog into your Nestjs application.

👾   Usage

▶ yarn add nestjs-posthog
import { Module } from '@nestjs/common';
import { PosthogModule } from 'nestjs-posthog';

@Module({
  imports: [
    PosthogModule.forRoot({
      apiKey: '<ph_project_api_key>',
      options: {
        host: '<ph_instance_address>',
      },
    }),
  ],
})
export class AppModule {}

Example

You can easily inject PosthogService to be used in your services, controllers, etc.

import { Injectable } from '@nestjs/common';
import { PosthogService } from 'nestjs-posthog';

@Injectable()
export class AuthService {
  constructor(private service: PosthogService) {}

  helloWorldMethod() {
    this.service.capture({
      distinctId: 'distinct id',
      event: 'movie played',
      properties: {
        movieId: '123',
        category: 'romcom',
      },
    });
    return 'hello world';
  }
}

Read more about the methods in Posthogs Node.js client documentation.

Contribute & Disclaimer

We love to get help 🙏 Read more about how to get started in CONTRIBUTING 🌳

This is a community-driven Open Source project with no ties with Posthog. It's supported on a volunteer-basis, but frequently used in commerical projects.

nestjs-posthog's People

Contributors

simenandre avatar dependabot[bot] avatar github-actions[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.