Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: send survey partial responses event #1788

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Mar 5, 2025

Changes

sends events after every survey question - logic to dedupe them will be done on posthog/posthog side

related issue: PostHog/posthog#19300

todo:

  • add tests

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

@lucasheriques lucasheriques added bump patch Bump patch version when this PR gets merged feature/surveys labels Mar 5, 2025
@lucasheriques lucasheriques self-assigned this Mar 5, 2025
Copy link

vercel bot commented Mar 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Mar 5, 2025 5:50am

Copy link

github-actions bot commented Mar 5, 2025

Size Change: +4.25 kB (+0.12%)

Total Size: 3.56 MB

Filename Size Change
dist/all-external-dependencies.js 220 kB +482 B (+0.22%)
dist/array.full.es5.js 274 kB +559 B (+0.2%)
dist/array.full.js 376 kB +517 B (+0.14%)
dist/array.full.no-external.js 375 kB +517 B (+0.14%)
dist/array.js 185 kB +35 B (+0.02%)
dist/array.no-external.js 183 kB +35 B (+0.02%)
dist/main.js 185 kB +35 B (+0.02%)
dist/module.full.js 376 kB +517 B (+0.14%)
dist/module.full.no-external.js 375 kB +517 B (+0.14%)
dist/module.js 185 kB +35 B (+0.02%)
dist/module.no-external.js 183 kB +35 B (+0.02%)
dist/surveys-preview.js 71.8 kB +481 B (+0.67%)
dist/surveys.js 76.5 kB +481 B (+0.63%)
ℹ️ View Unchanged
Filename Size
dist/customizations.full.js 14 kB
dist/dead-clicks-autocapture.js 14.5 kB
dist/exception-autocapture.js 9.51 kB
dist/external-scripts-loader.js 2.64 kB
dist/posthog-recorder.js 212 kB
dist/recorder-v2.js 115 kB
dist/recorder.js 115 kB
dist/tracing-headers.js 1.76 kB
dist/web-vitals.js 10.4 kB

compressed-size-action

if (!posthog) {
logger.error('[survey sent] event not captured, PostHog instance not found.')
return
}
localStorage.setItem(getSurveySeenKey(survey), 'true')

// Don't send partial response if survey is not completed and disable_survey_partial_response is true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will disable_survey_partial_response be default'ed to false? or should that be an opt in feature?

@@ -684,6 +684,10 @@ export function SurveyPopup({
onPopupSurveyDismissed = () => {},
onPopupSurveySent = () => {},
}: SurveyPopupProps) {
const surveyResponseInsertID = useMemo(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does Insert mean here?

Comment on lines +688 to +689
() => survey.id + Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
[survey.id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use an uuid instead?

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged feature/surveys stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants