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

Add more props to survey created and survey edited events #27763

Open
marandaneto opened this issue Jan 22, 2025 · 0 comments
Open

Add more props to survey created and survey edited events #27763

marandaneto opened this issue Jan 22, 2025 · 0 comments

Comments

@marandaneto
Copy link
Member

posthog.capture('survey created', {
name: survey.name,
id: survey.id,
survey_type: survey.type,
questions_length: survey.questions.length,
question_types: survey.questions.map((question) => question.type),
is_duplicate: isDuplicate ?? false,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance?.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
has_branching_logic: survey.questions.some(
(question) => question.branching && Object.keys(question.branching).length > 0
),
})
},
reportSurveyViewed: ({ survey }) => {
posthog.capture('survey viewed', {
name: survey.name,
id: survey.id,
created_at: survey.created_at,
start_date: survey.start_date,
end_date: survey.end_date,
})
},
reportSurveyArchived: ({ survey }) => {
posthog.capture('survey archived', {
name: survey.name,
id: survey.id,
created_at: survey.created_at,
start_date: survey.start_date,
end_date: survey.end_date,
})
},
reportSurveyEdited: ({ survey }) => {
const questionsWithShuffledOptions = survey.questions.filter((question) => {
return question.hasOwnProperty('shuffleOptions') && (question as MultipleSurveyQuestion).shuffleOptions
})
posthog.capture('survey edited', {
name: survey.name,
id: survey.id,
created_at: survey.created_at,
start_date: survey.start_date,
events_count: survey.conditions?.events?.values.length,
recurring_survey_iteration_count: survey.iteration_count == undefined ? 0 : survey.iteration_count,
recurring_survey_iteration_interval:
survey.iteration_frequency_days == undefined ? 0 : survey.iteration_frequency_days,
shuffle_questions_enabled: !!survey.appearance?.shuffleQuestions,
shuffle_question_options_enabled_count: questionsWithShuffledOptions.length,
has_branching_logic: survey.questions.some(
(question) => question.branching && Object.keys(question.branching).length > 0
),
})
},

We should have a prop for all possible coniguration such as:

  • has_linked_flags
  • has_url_targeting
  • has_survey_wait_period
  • etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant