diff --git a/src/__tests__/posthog-core.test.ts b/src/__tests__/posthog-core.test.ts index cdbeba835..c60a699b9 100644 --- a/src/__tests__/posthog-core.test.ts +++ b/src/__tests__/posthog-core.test.ts @@ -35,6 +35,10 @@ describe('posthog core', () => { console.error = jest.fn() }) + it('exposes the version', () => { + expect(defaultPostHog().version).toMatch(/\d+\.\d+\.\d+/) + }) + describe('capture()', () => { const eventName = 'custom_event' const eventProperties = { diff --git a/src/posthog-core.ts b/src/posthog-core.ts index 16f21e721..356457966 100644 --- a/src/posthog-core.ts +++ b/src/posthog-core.ts @@ -264,6 +264,7 @@ export class PostHog { __request_queue: QueuedRequestOptions[] decideEndpointWasHit: boolean analyticsDefaultEndpoint: string + version = Config.LIB_VERSION SentryIntegration: typeof SentryIntegration sentryIntegration: (options?: SentryIntegrationOptions) => ReturnType @@ -863,7 +864,8 @@ export class PostHog { this.on('eventCaptured', (data) => callback(data.event, data)) } - _calculate_event_properties(event_name: string, event_properties: Properties, timestamp: Date): Properties { + _calculate_event_properties(event_name: string, event_properties: Properties, timestamp?: Date): Properties { + timestamp = timestamp || new Date() if (!this.persistence || !this.sessionPersistence) { return event_properties }