feat(surveys): collect partial responses and resume unfinished surveys - #807
Open
lucasheriques wants to merge 7 commits into
Open
feat(surveys): collect partial responses and resume unfinished surveys#807lucasheriques wants to merge 7 commits into
lucasheriques wants to merge 7 commits into
Conversation
Honor enable_partial_responses and emit cumulative survey sent events after each submitted question. Reuse a submission UUID through completion or dismissal, and report $survey_completed using the existing branching result. Retain legacy response properties and completion-only behavior by default. Verified red/green survey tests; make test (169 XCTest + 781 Swift Testing tests); make lint; make apiCheck; iOS, macOS and Mac Catalyst builds. Other platform builds require SDKs absent from this machine. CodeScene passed.
Contributor
|
Reviews (1): Last reviewed commit: "feat(surveys): collect partial responses..." | Re-trigger Greptile |
2 tasks
CI exposed a race between forced survey loading and the remote-config listener's flag refresh. Seed survey data separately and await flag loading, matching the neighboring feature-flag eligibility test. The matching suite passes (10 tests), and the previously failing test passes 10 consecutive runs. CodeScene gate passed with stable test-file health.
Contributor
posthog-ios Compliance ReportDate: 2026-09-09 18:35:48 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
Save progress after nonterminal answers and restore the submission ID, answers, answer-time text/language and next branching destination. Clear state on completion, dismissal, reset or incompatible survey updates. Keep resumable surveys eligible and start built-in UI at the restored index; document the additive initialQuestionIndex contract for custom delegates. Verified: make test (169 XCTest + 789 Swift Testing), make testOniOSSimulator (190 XCTest + 911 Swift Testing), make format, make lint, make apiCheck. CodeScene safeguard passed. make build passed iOS/macOS/Catalyst SDKs but stopped at missing tvOS SDK; watchOS/visionOS and full example builds remain unverified locally.
Serialize progress read/modify/write operations with SDK identity reset, reject snapshots invalidated by reset, and bind renderer callbacks to an attempt token and reset generation. Capture events outside state locks with an explicit identity so client callbacks can reset safely. Merge seen history from storage when resuming, including completion and dismissal, and document invalidated renderer callbacks. Validation: focused regression tests, full SPM and iOS simulator suites, formatting, lint, public API checks and CodeScene passed. Available iOS, macOS and Catalyst SDK builds passed; tvOS/watchOS/visionOS SDKs are unavailable locally, so those builds could not be validated here.
The following custom-distinct-ID test could receive the preceding test's asynchronous identify upload after its batch recorder was reset. Wait for and assert that upload before the preceding fixture ends. Validation: all 25 identity tests and the full SPM suite passed.
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
Bind progress and callbacks to a durable reset epoch and serialize survey transactions with identity reset using a retained app-group file lock. Reject stale and ownerless records, revoke a write-protected epoch across processes, and recover when another process repairs the epoch. Refresh event identity from shared storage and materialize missing identity outside the file lock before validating the epoch again. Add isolated shared-storage regressions and register them in the Xcode test target. Verification: make test (169 XCTest, 805 Swift Testing); simulator tests (190 XCTest, 927 Swift Testing); final focused event/shared-storage tests; format, lint, API snapshot and CodeScene safeguard. A subprocess probe also verified lock contention. Stable SDK size/function-count penalties remain. The broad suites precede the final focused recovery/fixture adjustment.
Keep saved survey progress when remote configuration is unavailable, while authoritative empty lists still reconcile removals. Retain the configured survey delegate until SDK close has uninstalled its integrations. Replace weaker restart checks with a fresh SDK/default-delegate/controller journey covering restored branching, cumulative answers, submission IDs, and answer-time wording and language. Consolidate duplicate cases and move codec validation into a server-free suite. Verify reset recovery remains usable. Validation: make format, make lint apiCheck, and CodeScene passed. make test passed 169 XCTest and 804 Swift Testing tests. make testOniOSSimulator passed 190 XCTest and 926 Swift Testing tests, without retries. A restored-index mutation failed all four restart scenarios and was restored before final validation. Nil-config deletion and configured-delegate cleanup were reproduced before their fixes. The renderer journey uses the real display controller rather than mounted touch UI or OS process death. Existing timing-based lock tests remain; the full Apple platform/example-app build matrix was not rerun.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Add partial responses and persistent resume to iOS surveys, moving toward survey feature parity across all PostHog SDKs, with posthog-js as the reference. Closes #447. Auto-submit is separate in #808.
After submitting an answer, users can restart and resume at the next branching destination with saved answers and the same
$survey_submission_id. Withenable_partial_responses=true, each answer emits a cumulativesurvey sentevent; false/absent emits only on completion. Resume works in both modes.Key behavior:
initialQuestionIndex.Review path
💚 How did you test it?
Passed:
make test,make testOniOSSimulator(no retries),make format,make lint,make apiCheck, and CodeScene. Regression tests cover restart, branching, payloads, reset and stale callbacks; forcing the wrong resume index made the restart test fail.Local validation covers macOS and iOS. Restart tests recreate SDKs through the real delegate/controller; OS process death and the full Apple-platform/example-app matrix were not exercised.
📝 Checklist
🤖 Agent context
Autonomy: Human-driven (agent-assisted). Codex implemented the changes with independent QA agents; human review is required.