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/CHANGELOG.md +6 -0
- package/lib/index.cjs.js +7 -3
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.esm.js +7 -3
- package/lib/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/posthog-node.ts +6 -1
- package/test/posthog-node.spec.ts +21 -1
package/package.json
CHANGED
package/src/posthog-node.ts
CHANGED
|
@@ -117,7 +117,12 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
identify({ distinctId, properties }: IdentifyMessageV1): void {
|
|
120
|
-
|
|
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
|
-
|
|
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
|
])
|