Socket
Socket
Sign inDemoInstall

posthog-node

Package Overview
Dependencies
Maintainers
6
Versions
66
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 2.3.1 to 2.4.0

10

CHANGELOG.md

@@ -0,4 +1,8 @@

# 2.4.0 - 2023-02-02
1. Adds support for overriding timestamp of capture events
# 2.3.0 - 2022-1-26
1. uses v3 decide endpoint
1. uses v3 decide endpoint
2. JSON payloads will be returned with feature flags

@@ -8,7 +12,11 @@ 3. Feature flags will gracefully fail and optimistically save evaluated flags if server is down

# 2.2.3 - 2022-12-01
1. Fix issues with timeouts for local evaluation requests
# 2.2.2 - 2022-11-28
1. Fix issues with timeout
# 2.2.1 - 2022-11-24
1. Add standard 10 second timeout

@@ -15,0 +23,0 @@

3

lib/index.d.ts

@@ -71,2 +71,3 @@ /// <reference types="node" />

sendFeatureFlags?: boolean;
timestamp?: Date;
}

@@ -215,3 +216,3 @@ interface GroupIdentifyMessage {

disable(): void;
capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void;
capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp }: EventMessageV1): void;
identify({ distinctId, properties }: IdentifyMessageV1): void;

@@ -218,0 +219,0 @@ alias(data: {

@@ -1,2 +0,2 @@

import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, JsonType } from './types';
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PosthogCaptureOptions, JsonType } from './types';
import { RetriableOptions } from './utils';

@@ -53,8 +53,8 @@ export * as utils from './utils';

***/
identify(distinctId?: string, properties?: PostHogEventProperties): this;
identify(distinctId?: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
capture(event: string, properties?: {
[key: string]: any;
}, forceSendFeatureFlags?: boolean): this;
}, options?: PosthogCaptureOptions): this;
alias(alias: string): this;
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties): this;
autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
/***

@@ -66,4 +66,4 @@ *** GROUPS

}): this;
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties): this;
group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
/***

@@ -99,5 +99,2 @@ * PROPERTIES

overrideFeatureFlag(flags: PostHogDecideResponse['featureFlags'] | null): void;
_sendFeatureFlags(event: string, properties?: {
[key: string]: any;
}): void;
/***

@@ -104,0 +101,0 @@ *** QUEUEING AND FLUSHING

@@ -45,2 +45,5 @@ /// <reference types="node" />

};
export declare type PosthogCaptureOptions = {
timestamp?: Date;
};
export declare type PostHogFetchResponse = {

@@ -47,0 +50,0 @@ status: number;

@@ -20,3 +20,3 @@ import { JsonType, PosthogCoreOptions, PostHogFetchOptions, PostHogFetchResponse, PosthogFlagsAndPayloadsResponse } from '../../posthog-core/src';

disable(): void;
capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void;
capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp }: EventMessageV1): void;
identify({ distinctId, properties }: IdentifyMessageV1): void;

@@ -23,0 +23,0 @@ alias(data: {

@@ -10,2 +10,3 @@ import { JsonType } from '../../posthog-core/src';

sendFeatureFlags?: boolean;
timestamp?: Date;
}

@@ -12,0 +13,0 @@ export interface GroupIdentifyMessage {

{
"name": "posthog-node",
"version": "2.3.1",
"version": "2.4.0",
"description": "PostHog Node.js integration",

@@ -5,0 +5,0 @@ "repository": "PostHog/posthog-node",

@@ -112,3 +112,3 @@ import { version } from '../package.json'

capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void {
capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp }: EventMessageV1): void {
this.reInit(distinctId)

@@ -118,3 +118,14 @@ if (groups) {

}
this._sharedClient.capture(event, properties, sendFeatureFlags || false)
const _capture = (): void => {
this._sharedClient.capture(event, properties, { timestamp })
}
if (sendFeatureFlags) {
this._sharedClient.reloadFeatureFlagsAsync(false).finally(() => {
_capture()
})
} else {
_capture()
}
}

@@ -121,0 +132,0 @@

@@ -12,2 +12,3 @@ import { JsonType } from '../../posthog-core/src'

sendFeatureFlags?: boolean
timestamp?: Date
}

@@ -14,0 +15,0 @@

@@ -139,2 +139,16 @@ // import { PostHog } from '../'

})
it('should allow overriding timestamp', async () => {
expect(mockedFetch).toHaveBeenCalledTimes(0)
posthog.capture({ event: 'custom-time', distinctId: '123', timestamp: new Date('2021-02-03') })
jest.runOnlyPendingTimers()
const batchEvents = getLastBatchEvents()
expect(batchEvents).toMatchObject([
{
distinct_id: '123',
timestamp: '2021-02-03T00:00:00.000Z',
event: 'custom-time',
},
])
})
})

@@ -141,0 +155,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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