Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

posthog-node

Package Overview
Dependencies
Maintainers
5
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthog-node - npm Package Compare versions

Comparing version 1.1.7 to 1.2.0

11

event-validation.js

@@ -25,2 +25,4 @@ var type = require('component-type')

return validateAliasEvent(event)
case 'groupIdentify':
return validateGroupIdentifyEvent(event)
default:

@@ -58,2 +60,11 @@ assert(0, 'Invalid event type: "' + type + '"')

/**
* Validate an "groupIdentify" event.
*/
function validateGroupIdentifyEvent(event) {
assert(event.groupType, 'You must pass a "groupType".')
assert(event.groupKey, 'You must pass a "groupKey".')
}
/**
* Validation rules.

@@ -60,0 +71,0 @@ */

28

index.d.ts

@@ -20,4 +20,11 @@ // Type definitions for posthog-node

event: string
groups?: Record<string, string | number> // Mapping of group type to group id
}
interface GroupIdentifyMessage {
groupType: string
groupKey: string // Unique identifier for the group
properties?: Record<string | number, any>
}
export default class PostHog {

@@ -32,5 +39,6 @@ constructor(apiKey: string, options?: Option)

* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
* @param properties OPTIONAL | which can be a dict with any information you'd like to add
* @param properties OPTIONAL | which can be a object with any information you'd like to add
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
*/
capture({ distinctId, event, properties }: EventMessage): void
capture({ distinctId, event, properties, groups }: EventMessage): void

@@ -61,5 +69,5 @@ /**

/**
* @description PostHog feature flags (https://posthog.com/docs/features/feature-flags)
* @description PostHog feature flags (https://posthog.com/docs/features/feature-flags)
* allow you to safely deploy and roll back new features. Once you've created a feature flag in PostHog,
* you can use this method to check if the flag is on for a given user, allowing you to create logic to turn
* you can use this method to check if the flag is on for a given user, allowing you to create logic to turn
* features on and off for different user groups or individual users.

@@ -75,3 +83,13 @@ * IMPORTANT: To use this method, you need to specify `personalApiKey` in your config! More info: https://posthog.com/docs/api/overview

/**
* @description Force an immediate reload of the polled feature flags. Please note that they are
* @description Sets a groups properties, which allows asking questions like "Who are the most active companies"
* using my product in PostHog.
*
* @param groupType Type of group (ex: 'company'). Limited to 5 per project
* @param groupKey Unique identifier for that type of group (ex: 'id:5')
* @param properties OPTIONAL | which can be a object with any information you'd like to add
*/
groupIdentify({ groupType, groupKey, properties }: GroupIdentifyMessage): void
/**
* @description Force an immediate reload of the polled feature flags. Please note that they are
* already polled automatically at a regular interval.

@@ -78,0 +96,0 @@ */

@@ -134,9 +134,14 @@ 'use strict'

const apiMessage = Object.assign({}, message, {
properties: Object.assign({}, message.properties, {
$lib: 'posthog-node',
$lib_version: version,
}),
const properties = Object.assign({}, message.properties, {
$lib: 'posthog-node',
$lib_version: version,
})
if ('groups' in message) {
properties.$groups = message.groups
delete message.groups
}
const apiMessage = Object.assign({}, message, { properties })
this.enqueue('capture', apiMessage, callback)

@@ -175,2 +180,26 @@ return this

/**
* @description Sets a groups properties, which allows asking questions like "Who are the most active companies"
* using my product in PostHog.
*
* @param groupType Type of group (ex: 'company'). Limited to 5 per project
* @param groupKey Unique identifier for that type of group (ex: 'id:5')
* @param properties OPTIONAL | which can be a object with any information you'd like to add
*/
groupIdentify(message, callback) {
this._validate(message, 'groupIdentify')
const captureMessage = {
event: '$groupidentify',
distinctId: `\$${message.groupType}_${message.groupKey}`,
properties: {
$group_type: message.groupType,
$group_key: message.groupKey,
$group_set: message.properties || {}
}
}
return this.capture(captureMessage, callback)
}
/**
* Add a `message` of type `type` to the queue and

@@ -177,0 +206,0 @@ * check whether it should be flushed.

2

package.json
{
"name": "posthog-node",
"version": "1.1.7",
"version": "1.2.0",
"description": "PostHog Node.js integration",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc