fix(surveys): include dismissal responses on Android#497
Conversation
| } | ||
|
|
||
| private fun surveyHasResponses(responses: Map<String, PostHogSurveyResponse>): Boolean { | ||
| return responses.values.any { it.toResponseValue() != null } |
There was a problem hiding this comment.
Given how Rating accepts a nullable integer, and how it's converted to a response value, it looks like it could return the string "null" and cause this function to return true.
Seems like a weird edge case, though, and given the way we're tracking responses, it looks unlikely? I'll leave it up to you.
There was a problem hiding this comment.
I'm not 100% sure if this will generate "null" string either, but doesn't hurt to be covered in a test?
There was a problem hiding this comment.
Yeah looks like it will generate "null"
We should probably change this from is Rating -> rating.toString() to is Rating -> rating?.toString()
There was a problem hiding this comment.
Yep, fixed this. Rating(null) now returns null instead of the string "null", and I added both a core response test and a dismissed payload test for that case.
|
|
||
| // Store the response for survey completion tracking | ||
| currentSurveyResponses[getResponseKey(questionIndex)] = response | ||
| currentSurveyResponses[getLegacyResponseKey(questionIndex)] = response |
There was a problem hiding this comment.
This was pre-existing but I think currentSurveyResponses should be synchronized with activeSurveyLock
There was a problem hiding this comment.
Good call, fixed. I wrapped the active survey response/completion reads and writes with activeSurveyLock and snapshot the responses before sending the event.
| } | ||
|
|
||
| private fun surveyHasResponses(responses: Map<String, PostHogSurveyResponse>): Boolean { | ||
| return responses.values.any { it.toResponseValue() != null } |
There was a problem hiding this comment.
I'm not 100% sure if this will generate "null" string either, but doesn't hurt to be covered in a test?
posthog-android Compliance ReportDate: 2026-04-27 22:06:14 UTC
|
| Test | Status | Duration |
|---|---|---|
| Request Payload.Request With Person Properties Device Id | ❌ | 300ms |
Failures
request_payload.request_with_person_properties_device_id
404, message='Not Found', url='http://sdk-adapter:8080/get_feature_flag'
💡 Motivation and Context
survey dismissedevents$survey_partially_completedfor dismissed surveys$survey_response_<questionId>keys on Android$survey_questionswith RN/iOS so it contains{ id, question, response }objects instead of only question stringsCompanion PRs
💚 How did you test it?
PostHogSurveysEventPayloadTestsurvey sentpayload coverage for legacy keys, question-id keys, and richer$survey_questionsANDROID_HOME/local.propertiesmissing)📝 Checklist
pnpm changesetto generate a changeset file