PostHog / posthog-node

Official PostHog Node library
MIT License
21 stars 19 forks source link

Correct Typescript typings to add callback as second arguments #66

Closed pxpeterxu closed 1 year ago

pxpeterxu commented 2 years ago

Changes

This change makes the Typescript typings match the underlying Javascript code for functions like capture and alias by adding a second argument (callback)

Current state: the PostHog Typescript typings indicate that functions like capture and alias take only a single argument:

e.g., for capture:

capture({ distinctId, event, properties, groups }: EventMessage): void

This is despite the code actually having an important second argument that helps report errors, etc.

/**
 * Send a capture `message`.
 *
 * @param {Object} message
 * @param {Function} [callback] (optional)
 * @return {PostHog}
 */

capture(message, callback) {
    this._validate(message, 'capture')

...

Checklist

cc @mariusandra who wrote the original types here