posthog-node 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "PostHog Node.js integration",
5
5
  "repository": "PostHog/posthog-node",
6
6
  "scripts": {
@@ -117,7 +117,12 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
117
117
  }
118
118
 
119
119
  identify({ distinctId, properties }: IdentifyMessageV1): void {
120
- super.identifyStateless(distinctId, properties)
120
+ // Catch properties passed as $set and move them to the top level
121
+ const personProperties = properties?.$set || properties
122
+
123
+ super.identifyStateless(distinctId, {
124
+ $set: personProperties,
125
+ })
121
126
  }
122
127
 
123
128
  alias(data: { distinctId: string; alias: string }): void {
@@ -114,7 +114,27 @@ describe('PostHog Node.js', () => {
114
114
  distinct_id: '123',
115
115
  event: '$identify',
116
116
  properties: {
117
- foo: 'bar',
117
+ $set: {
118
+ foo: 'bar',
119
+ },
120
+ },
121
+ },
122
+ ])
123
+ })
124
+
125
+ it('should handle identify mistakenly using $set', async () => {
126
+ expect(mockedFetch).toHaveBeenCalledTimes(0)
127
+ posthog.identify({ distinctId: '123', properties: { foo: 'bar', $set: { foo: 'other' } } })
128
+ jest.runOnlyPendingTimers()
129
+ const batchEvents = getLastBatchEvents()
130
+ expect(batchEvents).toMatchObject([
131
+ {
132
+ distinct_id: '123',
133
+ event: '$identify',
134
+ properties: {
135
+ $set: {
136
+ foo: 'other',
137
+ },
118
138
  },
119
139
  },
120
140
  ])