Skip to content

Conversation

marandaneto
Copy link
Member

@marandaneto marandaneto commented Sep 25, 2025

💡 Motivation and Context

follow up PostHog/posthog-js#2352
Closes #323

💚 How did you test it?

Screenshot 2025-09-25 at 14 23 19

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

/// Sends a `survey dismissed` event to PostHog instance
private func sendSurveyDismissedEvent(survey: PostHogSurvey) {
let additionalProperties: [String: Any] = [
"$survey_questions": survey.questions.map(\.question),
Copy link
Member Author

Choose a reason for hiding this comment

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

survey dismissed should not have $survey_questions

Choose a reason for hiding this comment

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

in the posthog-js, it also includes the $survey_questions property.
it's useful for getting all responses up until when the user dismissed it

Copy link
Member Author

Choose a reason for hiding this comment

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

mmm i dont follow because our APIs only query for survey sent events when getting responses, how is that useful?

Copy link
Contributor

Choose a reason for hiding this comment

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

if I recall correctly, I copied over from what posthog-js ws doing, thinking that it's part of the partial response feature (was wip back then if I remember correctly), but good point on APIs above. Let's wait for @lucasheriques to comment. If we are not using this anywhere, we can drop from all sdks?

Choose a reason for hiding this comment

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

I think makes sense, we can drop it. When we implement partial responses for mobile SDKs (sometime in the future) we'll have access to all responses regardless. Will remove from the JS sdk too

@marandaneto marandaneto changed the title chore/question id format feat: iOS surveys use the new response question id format Sep 25, 2025
@marandaneto marandaneto requested a review from a team September 25, 2025 12:29
@marandaneto
Copy link
Member Author

@ioannisj we will need to check if this breaks with Flutter or not due to the missing id, the goal is to be back compatible

@marandaneto
Copy link
Member Author

@ioannisj i have found no tests for survey sent, do we assert the event somehow?

Copy link

@lucasheriques lucasheriques left a comment

Choose a reason for hiding this comment

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

code looks good, pr is still in draft though

but as mentioned, I'd also include the $survey_questions in the dismissed event, so there's a way to get the responses in case someone answers 1 question (in a 3 question survey) and then dismisses it

@marandaneto
Copy link
Member Author

code looks good, pr is still in draft though

but as mentioned, I'd also include the $survey_questions in the dismissed event, so there's a way to get the responses in case someone answers 1 question (in a 3 question survey) and then dismisses it

TIL https://github.com/PostHog/posthog-js/blob/f293275d1379327851e3c2311be59757c030c590/packages/browser/src/extensions/surveys/surveys-extension-utils.tsx#L453
The RN SDK does not.
Should I add? i'd be interested to get an answer here first though

@ioannisj
Copy link
Contributor

@ioannisj we will need to check if this breaks with Flutter or not due to the missing id, the goal is to be back compatible

Since we haven't touched the public APIs, I think we should be okay. We grab the survey id on native layer when we get a survey response. Need to run out in a bit for a while, I'll test as soon as I'm back though just to be sure

@ioannisj i have found no tests for survey sent, do we assert the event somehow?

No, sadly I forgot to add unit tests on the events back then

Copy link
Contributor

@ioannisj ioannisj left a comment

Choose a reason for hiding this comment

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

Left a couple of minor comments on public APIs. Also, since we are missing some unit tests on survey_sent event, would be cool to add them. I'm positive this won't break Flutter but I'll test soon

@marandaneto
Copy link
Member Author

Left a couple of minor comments on public APIs. Also, since we are missing some unit tests on survey_sent event, would be cool to add them. I'm positive this won't break Flutter but I'll test soon

@ioannisj would you like to add a test and finish this since our hackathon started and wont have more time this week?

@marandaneto
Copy link
Member Author

@ioannisj can we get this out?

@ioannisj
Copy link
Contributor

ioannisj commented Oct 3, 2025

@ioannisj can we get this out?

yeap on it, missed your previous comment

@ioannisj ioannisj marked this pull request as ready for review October 3, 2025 13:56
@ioannisj ioannisj requested a review from a team as a code owner October 3, 2025 13:56
@ioannisj ioannisj merged commit 2afe100 into main Oct 3, 2025
14 checks passed
@ioannisj ioannisj deleted the chore/question-id-format branch October 3, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surveys - add support for question ids

3 participants