-
Notifications
You must be signed in to change notification settings - Fork 0
chore: Identify API for MAUI refactor #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
12c3998
recordLogs and Metrics (+1 squashed commit)
abelonogov-ld 6270236
Debug
abelonogov-ld f0a0bb1
use in664
abelonogov-ld ce241f6
remove duplicate logic
abelonogov-ld 117aec7
Merge branch 'main' into andrey/sr-hookproxy
abelonogov-ld 161a09b
Merge branch 'main' into andrey/sr-hookproxy
abelonogov-ld 090984d
Hook changes
abelonogov-ld 38d97d0
Merge branch 'main' into andrey/sr-hookproxy
abelonogov-ld b548c71
crashReporting: .enabled
abelonogov-ld 9124a3b
Merge branch 'main' into andrey/sr-hookproxy
abelonogov-ld fd4e870
refactor to service
abelonogov-ld 8ec3e01
remove assert
abelonogov-ld 01a088d
delete empty file
abelonogov-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
32 changes: 11 additions & 21 deletions
32
Sources/LaunchDarklySessionReplay/SessionReplayHookProxy.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,29 @@ | ||
| import Foundation | ||
| import LaunchDarklyObservability | ||
| #if LD_COCOAPODS | ||
| import LaunchDarklyObservability | ||
| #else | ||
| import Common | ||
| #endif | ||
|
|
||
| /// @objc adapter for the C# / MAUI bridge. | ||
| /// Converts Foundation types (NSObject, NSDictionary) to Swift types | ||
| /// and delegates to SessionReplay so the replay identify logic is accessible | ||
| /// from the Xamarin.iOS binding. | ||
| /// Converts Foundation types to Swift types | ||
| /// and delegates to SessionReplayHookExporter. | ||
| @objc(SessionReplayHookProxy) | ||
| public final class SessionReplayHookProxy: NSObject { | ||
| private let plugin: SessionReplay | ||
| private let sessionReplayService: SessionReplayServicing | ||
|
|
||
| init(plugin: SessionReplay) { | ||
| self.plugin = plugin | ||
| init(sessionReplayService: SessionReplayServicing) { | ||
| self.sessionReplayService = sessionReplayService | ||
| super.init() | ||
| } | ||
|
|
||
| @objc(afterIdentifyWithContextKeys:canonicalKey:completed:) | ||
| public func afterIdentify(contextKeys: NSDictionary, canonicalKey: String, completed: Bool) { | ||
| guard completed else { return } | ||
| guard let options = plugin.observabilityContext?.options else { return } | ||
|
|
||
| var keys = [String: String]() | ||
| for (k, v) in contextKeys { | ||
| if let key = k as? String, let val = v as? String { keys[key] = val } | ||
| } | ||
|
|
||
| let sessionAttributes = plugin.observabilityContext?.sessionAttributes | ||
| Task { | ||
| let identifyPayload = IdentifyItemPayload( | ||
| options: options, | ||
| sessionAttributes: sessionAttributes, | ||
| contextKeys: keys, | ||
| canonicalKey: canonicalKey, | ||
| timestamp: Date().timeIntervalSince1970 | ||
| ) | ||
| await plugin.sessionReplayService?.scheduleIdentifySession(identifyPayload: identifyPayload) | ||
| } | ||
| sessionReplayService.afterIdentify(contextKeys: keys, canonicalKey: canonicalKey, completed: completed) | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
Computed
hookProxycreates new instance on every accessMedium Severity
The
hookProxyproperty changed from a stored property to a computed property, meaning every access allocates a newSessionReplayHookProxy(anNSObjectsubclass) instead of returning a cached instance. This is particularly wasteful for the C#/MAUI bridge, where each call likeLDReplay.shared.hookProxy?.afterIdentify(...)creates a throwaway object. The siblingLDObserve.shared.hookProxyremains a stored property set once ingetHooks(), making this inconsistent across the two plugins.