feat: manual start/stop session recording#276
Merged
Conversation
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
ioannisj
commented
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
marandaneto
reviewed
Dec 19, 2024
11 tasks
marandaneto
reviewed
Jan 7, 2025
marandaneto
reviewed
Jan 7, 2025
marandaneto
reviewed
Jan 7, 2025
marandaneto
reviewed
Jan 7, 2025
4 tasks
ioannisj
commented
Jan 8, 2025
marandaneto
approved these changes
Jan 8, 2025
marandaneto
approved these changes
Jan 8, 2025
# Conflicts: # CHANGELOG.md # PostHog.xcodeproj/project.pbxproj # PostHogTests/PostHogAutocaptureEventTrackerSpec.swift # PostHogTests/PostHogAutocaptureIntegrationSpec.swift
Contributor
Instructions and example for changelogPlease add an entry to ## Next
- manual start/stop session recording ([#276](https://github.com/PostHog/posthog-ios/pull/276))If none of the above apply, you can opt out of this check by adding |
eakurnikov
pushed a commit
to trustwallet/posthog-ios
that referenced
this pull request
Feb 6, 2025
* chore: add swiftformat config * fix: avoid registering for notifications multiple times * feat: add session replay automatic start config * fix: capture timestamp along with snapshot events * feat: add start/stop session recording and refactor session manager * fix(ci): use Xcode 16 for unit testing * fix(ci): switch to macos-14 for tests * fix(ci): tests * fix: remove start mode from session replay config * fix: use timestamp at time of checking as the new session timestamp * feat: capture session id on network request start * fix: get session id only after snapshot is generated * fix: don't process $snapshot if session id is missing * fix: remove todo * chore: update CHANGELOG * fix(ci): use latest-stable Xcode version * feat: additional checks on react native * fix: lint * fix: remove didFinishLaunching notification * fix: tests * chore(ci): build examples on latest macos
Open
4 tasks
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
Closes #262, #227
Docs PR: PostHog/posthog.com#10235
Added the following:
startSessionRecording(resumeCurrent: Bool)stopSessionRecording()Session Management
Related discussion: https://posthog.slack.com/archives/C03PB072FMJ/p1733146678787689?thread_ts=1732810962.491699&cid=C03PB072FMJ
Based on the discussion above, I refactored how we manager and rotate replay sessions. Quite a big change but the main points of the change are:
getSessionIdchanges form and is now responsible on running validation rules and rotates or clears the session if needed before returninggetSessionIdcan be called withreadOnlyto skip validation and just return current session id. In both cases, a new id will be created if it doesn't exist but only when the app is foregrounded.nowis used. For replay, we capture the timestamp of the event as soon as possible, so we need to run session validation checks on that timestamp to account for delayed captures$snapshotevents add their own$session_idproperty which is acquired as early as possible andcapture()method will respect that $session_id$snapshotevents always callcapture()with a given timestamp, acquired as early as possiblereasonon hedgeLog messages related to session id changes for debugging purposesTODO:
💚 How did you test it?
📝 Checklist