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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change means that all iOS/tvOS consumers receive a warning unless we're only calling into PostHog from the main thread. If a client's logging system runs off of
main
, accessingUIApplication.shared
will cause warnings in Xcode. Not sure if that's a priority for y'all, but figured I'd raise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @dfed, yeah that is indeed true. Hopping and blocking to main thread for every single event is not realistic so we should probably promote these to static properties.
NSScreen.main
will probably need to stay as dynamic context since it represents the screen of the currently focused window which can change, but I think for iOS/tvOS it's probably safe to calculate this once. Let me think about it a bit and I'll get back soonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can check if the captured event is on the main thread and only do the thread jumping if needed to reduce the perf impact as well.
UIApplication.shared.windows
is also deprecated so the change from A to B didn't make sense IMO.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostHogReplayIntegration.getCurrentWindow()
is likely the correct way right now, we should movegetCurrentWindow()
out ofPostHogReplayIntegration
and reuse across the SDK, I see more places usingUIApplication.shared
that is just trying to find the activewindow
, egUIViewController.activeController
andUIApplication.ph_currentWindow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. For capturing events we probably want to skip scene state checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#247