open-index/open-npm huggingface dataset:
npm package: @posthog/plugin-globals
Description: Types for globals exposed to PostHog plugins
Latest version: 0.0.1

## PostHog Plugin Globals

[![npm package](https://img.shields.io/npm/v/@posthog/plugin-scaffold?style=flat-square)](https://www.npmjs.com/package/@posthog/plugin-globals)
[![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT)

This package contains types for globals exposed to PostHog plugins.

To use, install via yarn or npm:

```shell
yarn add --dev @posthog/plugin-globals
npm install --save-dev @posthog/plugin-globals
```

Then add the following to your `tsconfig.json`:

```json5
{
    "include": [
      /* keep exisitng entries like "src" or "**.ts" and add: */
      "./node_modules/@posthog/plugin-globals/globals.d.ts"
    ]
}
```

Alternatively (only if the previous step is not suitable), add the following to the top of your `index.ts`:

```typescript
import '@posthog/plugin-globals'
```

Enjoy an improved plugin authoring experience!

## Questions?

### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)
npm package: @posthog/plugin-scaffold
Description: Types and utilities for PostHog Plugins
Author: PostHog
Latest version: 1.7.1
Deprecated: compromised

## PostHog Plugin Scaffold

[![npm package](https://img.shields.io/npm/v/@posthog/plugin-scaffold?style=flat-square)](https://www.npmjs.com/package/@posthog/plugin-scaffold)
[![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT)

This project contains shared typescript types that PostHog plugin
authors can use.

```bash
# if using yarn
yarn add --dev @posthog/plugin-scaffold

# if using npm
npm install --save-dev @posthog/plugin-scaffold
``` 

Then in your plugins:

```typescript
import { PluginEvent, PluginInput, PluginMeta } from "@posthog/plugin-scaffold";

export function processEvent(event: PluginEvent, meta: PluginMeta<PluginInput>) {
    if (event.properties) {
        event.properties['hello'] = 'world'
    }
    return event
}
```

## Releasing a new version

It's magic! Just bump up `version` in `package.json` on the main branch and the new version will be published automatically, on GitHub and on npm. Courtesy of GitHub Actions.

## Questions?

### [Join our Slack community.](https://join.slack.com/t/posthogusers/shared_invite/enQtOTY0MzU5NjAwMDY3LTc2MWQ0OTZlNjhkODk3ZDI3NDVjMDE1YjgxY2I4ZjI4MzJhZmVmNjJkN2NmMGJmMzc2N2U3Yjc3ZjI5NGFlZDQ)
npm package: @posthog/plugin-utils
Description: Shared CLI and sourcemap utilities for PostHog build plugins
Latest version: 1.0.1

# @posthog/plugin-utils

Shared CLI and sourcemap utilities used by PostHog build plugins (`@posthog/webpack-plugin`, `@posthog/rollup-plugin`, `@posthog/nextjs-config`, `@posthog/nuxt`).

This package is an internal dependency and not intended for direct use.
npm package: @posthog/posthog-ai
Description: PostHog Node.js AI integrations
Author: PostHog
Latest version: 1.0.1
Deprecated: This project has been renamed. Install using @posthog/ai instead.

# PostHog Node AI

Initial Typescript SDK for LLM Observability

## Installation

```bash
yarn add @posthog/posthog-ai
```

## Usage

### Before

```typescript
import { OpenAI } from 'openai'

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY || '',
})

await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello, world!' }],
})
```

### After

```typescript
import { OpenAI } from 'posthog-node-ai'
import { PostHog } from 'posthog-node'

const phClient = new PostHog(
  process.env.POSTHOG_API_KEY, {
    host: process.env.POSTHOG_HOST || 'https://us.posthog.com',
  }
})

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY || '',
  posthog: phClient,
})

await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello, world!' }],
  posthog_distinct_id: 'test-user-id',
  posthog_properties: {
    test_property: 'test_value',
  }
})

// YOU HAVE TO HAVE THIS OR THE CLIENT MAY NOT SEND EVENTS
await phClient.shutdown()
```

Please see the main [PostHog docs](https://www.posthog.com/docs).

## Questions?

### [Check out our community page.](https://posthog.com/posts)
npm package: @posthog/property-filter-plugin
Description: Filter a list of properties from the event data.
Latest version: 0.0.7

# Property Filter Plugin

## Important!

This plugin will only work on events ingested **after** the plugin was enabled. This means it **will** register events as being the first if there were events that occured **before** it was enabled. To mitigate this, you could consider renaming the relevant events and creating an [action](https://posthog.com/docs/features/actions) that matches both the old event name and the new one.

## Usage

This plugin will set all configured properties to null inside an ingested event. Usually it makes sense to place this plugin at the *end* of the plugin chain.

Note when specifying `$ip`, additionally `event.ip` will be removed.

## Credits

Heavily inspired by https://github.com/PostHog/first-time-event-tracker
npm package: @posthog/property-flattener-plugin
Description: Flatten event properties to easily access them in filters.
Author: Yakko Majuri
Latest version: 0.0.7

# Property Flattener Plugin

Flatten nested properties in PostHog events to easily access them in filters.

## Example

For example, if you're an online retailer, and have `purchase` events with the following property structure:

```json
{
    "event": "purchase",
    "properties": {
        "product": {
            "name": "AZ12 shoes",
            "type": "footwear",
            "size": {
                "number": 12,
                "gender": "M"
            }
        }
    }
}
```

This plugin will keep the nested properties unchanged, but also add any nested properties at the first depth, like so:

```json
{
    "event": "purchase",
    "properties": {
        "product": {
            "name": "AZ12 shoes",
            "type": "footwear",
            "size": {
                "number": 12,
                "gender": "M"
            }
        },
        "product__name": "AZ12 shoes",
        "product__type": "footwear",
        "product__size__number": 12,
        "product__size__gender": "M"
    }
}
```

As such, you can now filter your purchase events based on `product__size__number` for example. 

The default separator for nested properties is two subsequent underscores (`__`), but you can also change this to:

* `.`
* `>`
* `/`

When picking your separator, make sure it will not clash with your property naming patterns.