Skip to content

Commit

Permalink
fix(surveys): cancel listener should be on all questions (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiy authored Oct 24, 2023
1 parent 892e444 commit 2774323
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/extensions/surveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,19 +448,19 @@ export const addCancelListeners = (
surveyId: string,
surveyEventName: string
) => {
const cancelButton = surveyPopup.getElementsByClassName('form-cancel')?.[0] as HTMLButtonElement

cancelButton.addEventListener('click', (e) => {
e.preventDefault()
Object.assign(surveyPopup.style, { display: 'none' })
localStorage.setItem(`seenSurvey_${surveyId}`, 'true')
posthog.capture('survey dismissed', {
$survey_name: surveyEventName,
$survey_id: surveyId,
sessionRecordingUrl: posthog.get_session_replay_url(),
const cancelButtons = surveyPopup.getElementsByClassName('form-cancel')
for (const button of cancelButtons) {
button.addEventListener('click', (e) => {
e.preventDefault()
closeSurveyPopup(surveyId, surveyPopup)
posthog.capture('survey dismissed', {
$survey_name: surveyEventName,
$survey_id: surveyId,
sessionRecordingUrl: posthog.get_session_replay_url?.(),
})
})
window.dispatchEvent(new Event('PHSurveyClosed'))
})
}
window.dispatchEvent(new Event('PHSurveyClosed'))
}

export const createRatingsPopup = (
Expand Down

0 comments on commit 2774323

Please sign in to comment.