diff --git a/cypress/e2e/surveys.cy.ts b/cypress/e2e/surveys.cy.ts index ef40abc32..116390b3b 100644 --- a/cypress/e2e/surveys.cy.ts +++ b/cypress/e2e/surveys.cy.ts @@ -581,11 +581,12 @@ describe('Surveys', () => { // first capture is $pageview cy.wait('@capture-assertion') cy.get('.PostHogSurvey123').shadow().find('.cancel-btn-wrapper').click() + cy.wait(500) cy.wait('@capture-assertion').then(async ({ request }) => { const captures = await getBase64EncodedPayload(request) expect(captures.map(({ event }) => event)).to.deep.equal([ - // 'survey shown', - // 'survey dismissed', + 'survey shown', + 'survey dismissed', '$pageleave', ]) }) diff --git a/src/extensions/surveys.tsx b/src/extensions/surveys.tsx index 81a3bda4a..28cabe601 100644 --- a/src/extensions/surveys.tsx +++ b/src/extensions/surveys.tsx @@ -230,7 +230,6 @@ export function Surveys({ posthog, survey, style }: { posthog: PostHog; survey: localStorage.setItem(`lastSeenSurveyDate`, new Date().toISOString()) window.addEventListener('PHSurveyClosed', () => { - localStorage.setItem(`seenSurvey_${survey.id}`, 'true') posthog.capture('survey dismissed', { $survey_name: survey.name, $survey_id: survey.id, @@ -240,6 +239,7 @@ export function Surveys({ posthog, survey, style }: { posthog: PostHog; survey: }, }) setShowSurveyQuestion(false) + localStorage.setItem(`seenSurvey_${survey.id}`, 'true') }) window.addEventListener('PHSurveySent', () => {