Skip to content

Commit

Permalink
fix(surveys): Send responded property with every type of survey (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar authored Nov 9, 2023
1 parent b2fc9e5 commit b0007f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/extensions/surveys.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ describe('survey display logic', () => {
$survey_question: 'How satisfied are you with our newest product?',
$survey_response: 1,
sessionRecordingUrl: undefined,
$set: {
'$survey_responded/testSurvey1': true,
},
})
expect(localStorage.getItem(`seenSurvey_${mockSurveys[0].id}`)).toBe('true')

Expand Down
9 changes: 9 additions & 0 deletions src/extensions/surveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ export const createRatingsPopup = (
// @ts-ignore // TODO: Fix this, error because it doesn't know that the target is a button
$survey_response: parseInt(activeRatingEl?.value),
sessionRecordingUrl: posthog.get_session_replay_url?.(),
$set: {
[`$survey_responded/${survey.id}`]: true,
},
})
window.setTimeout(() => {
window.dispatchEvent(new Event('PHSurveySent'))
Expand Down Expand Up @@ -644,6 +647,9 @@ export const createMultipleChoicePopup = (
$survey_question: survey.questions[0].question,
$survey_response: selectedChoices,
sessionRecordingUrl: posthog.get_session_replay_url?.(),
$set: {
[`$survey_responded/${survey.id}`]: true,
},
})
window.setTimeout(() => {
window.dispatchEvent(new Event('PHSurveySent'))
Expand Down Expand Up @@ -810,6 +816,9 @@ export const createMultipleQuestionSurvey = (posthog: PostHog, survey: Survey) =
$survey_questions: survey.questions.map((question) => question.question),
sessionRecordingUrl: posthog.get_session_replay_url?.(),
...multipleQuestionResponses,
$set: {
[`$survey_responded/${survey.id}`]: true,
},
})
window.setTimeout(() => {
window.dispatchEvent(new Event('PHSurveySent'))
Expand Down

0 comments on commit b0007f3

Please sign in to comment.