Skip to content

Commit 463cc18

Browse files
fix: set survey properties before sending the event (#1997)
1 parent 3466889 commit 463cc18

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/posthog-core.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -931,13 +931,6 @@ export class PostHog {
931931
data.properties['$event_time_override_system_time'] = systemTime
932932
}
933933

934-
// Top-level $set overriding values from the one from properties is taken from the plugin-server normalizeEvent
935-
// This doesn't handle $set_once, because posthog-people doesn't either
936-
const finalSet = { ...data.properties['$set'], ...data['$set'] }
937-
if (!isEmptyObject(finalSet)) {
938-
this.setPersonPropertiesForFlags(finalSet)
939-
}
940-
941934
if (event_name === SurveyEventName.DISMISSED || event_name === SurveyEventName.SENT) {
942935
const surveyId = properties?.[SurveyEventProperties.SURVEY_ID]
943936
const surveyIteration = properties?.[SurveyEventProperties.SURVEY_ITERATION]
@@ -951,6 +944,13 @@ export class PostHog {
951944
}
952945
}
953946

947+
// Top-level $set overriding values from the one from properties is taken from the plugin-server normalizeEvent
948+
// This doesn't handle $set_once, because posthog-people doesn't either
949+
const finalSet = { ...data.properties['$set'], ...data['$set'] }
950+
if (!isEmptyObject(finalSet)) {
951+
this.setPersonPropertiesForFlags(finalSet)
952+
}
953+
954954
if (!isNullish(this.config.before_send)) {
955955
const beforeSendResult = this._runBeforeSend(data)
956956
if (!beforeSendResult) {

0 commit comments

Comments
 (0)