# nestjs-posthog

> ```shell ▶ yarn add nestjs-posthog ```

Latest version **1.1.2** (published 2022-03-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install nestjs-posthog
pnpm add nestjs-posthog
yarn add nestjs-posthog
bun add nestjs-posthog
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-03-19 |
| First published | 2022-03-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 24.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Bjerk AS |
| Maintainers | cobraz |

## Links

- npm: https://www.npmjs.com/package/nestjs-posthog
- Repository: https://github.com/bjerkio/nestjs-posthog
- npm.io page: https://npm.io/package/nestjs-posthog

## Dependencies (1)

- [posthog-node](https://npm.io/package/posthog-node.md) ^1.3.0

## Recent versions

- 1.1.2 (latest) — 2022-03-19
- 1.1.1 — 2022-03-19
- 1.1.0 — 2022-03-19
- 1.0.0 — 2022-03-19

## README

<p align="center">
    <img src="./.github/logo.svg" alt="Logo" width="150px">
</p>

<p align="center">
    <h3 align="center">nestjs-posthog</h3>
</p>

<p align="center">
    Lightweight library to use Posthog in NestJS applications.
    <br />
    <br />
    <a href="#space_invader--usage">Quick Start Guide</a>
    ·
    <a href="https://github.com/bjerkio/nestjs-posthog/issues">Request Feature</a>
    ·
    <a href="https://github.com/bjerkio/nestjs-posthog/issues">Report Bug</a>
  </p>
</p>

---

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
![Release](https://github.com/bjerkio/nestjs-posthog/workflows/Release/badge.svg)

[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/bjerkio/nestjs-posthog.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bjerkio/nestjs-posthog/context:javascript)
[![codecov](https://codecov.io/gh/bjerkio/nestjs-posthog/branch/main/graph/badge.svg)](https://codecov.io/gh/bjerkio/nestjs-posthog)

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

[nestjs]: https://github.com/nestjs/nest
[posthog]: https://posthog.com/

### :space_invader: &nbsp; Usage

```shell
▶ yarn add nestjs-posthog
```

```typescript
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.

```typescript
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][posthog-node].

[posthog-node]: https://posthog.com/docs/integrate/server/node

## Contribute & Disclaimer

We love to get help 🙏 Read more about how to get started in
[CONTRIBUTING](CONTRIBUTING.md) 🌳

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.

---
_Source: https://npm.io/package/nestjs-posthog · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
