-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Identify support (OBS + SR) #93
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 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d1ee7d8
renaming contentView
abelonogov-ld 43913e0
Working
abelonogov-ld 3232d77
renaming
abelonogov-ld f61d8a0
Merge branch 'main' into andrey/identify-support
abelonogov-ld f189ff7
payloads finished
abelonogov-ld fda0723
fix
abelonogov-ld f1ef09c
Merge branch 'main' into andrey/identify-support
abelonogov-ld ba9bc42
passing metadata
abelonogov-ld bd3c456
fix on send
abelonogov-ld 135c8b0
friendly name and user identifier hookup
abelonogov-ld 852ebf6
fix identify event logic
abelonogov-ld c103879
wip
abelonogov-ld bc5b7bf
multi, anon, single samples
abelonogov-ld 29b4a31
Merge branch 'main' into andrey/identify-support
abelonogov-ld b6cbed2
delete commented code
abelonogov-ld 929a36e
fix compilation error
abelonogov-ld 25b3016
spelling
abelonogov-ld 7b04dbc
address feedback
abelonogov-ld 5e20650
fix losing identifyPayload
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import Foundation | ||
| import UIKit | ||
|
|
||
| public class ApplicationProperties { | ||
| public static var name: String? = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String | ||
| } |
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
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
57 changes: 57 additions & 0 deletions
57
Sources/LaunchDarklySessionReplay/Exporter/IdentifyItemPayload.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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import Foundation | ||
| import LaunchDarklyObservability | ||
|
|
||
| struct IdentifyItemPayload: EventQueueItemPayload { | ||
| let attributes: [String: String] | ||
| var timestamp: TimeInterval | ||
|
|
||
| var exporterClass: AnyClass { | ||
| SessionReplayExporter.self | ||
| } | ||
|
|
||
| func cost() -> Int { | ||
| attributes.count * 100 | ||
| } | ||
| } | ||
|
|
||
| extension IdentifyItemPayload { | ||
| // Using main thread to access to ldContext | ||
| @MainActor | ||
| init(options: Options, ldContext: LDContext? = nil, timestamp: TimeInterval) { | ||
| var attributes: [String: String] = options.resourceAttributes.compactMapValues { | ||
| switch $0 { | ||
| case .array, .set, .boolArray, .intArray, .doubleArray, .stringArray: | ||
| return nil | ||
| case .string(let v): | ||
| return v | ||
| case .bool(let v): | ||
| return v.description | ||
| case .int(let v): | ||
| return String(v) | ||
| case .double(let v): | ||
| return String(v) | ||
| } | ||
| } | ||
|
|
||
| var canonicalKey = ldContext?.fullyQualifiedKey() ?? "unknown" | ||
| var ldContextMap = ldContext?.contextKeys() | ||
| if let ldContextMap { | ||
| for (k, v) in ldContextMap { | ||
| attributes[k] = v | ||
| } | ||
| } | ||
|
|
||
| var contextFriendlyName: String? = nil | ||
| if let contextFriendlyNameUnwrapped = options.contextFriendlyName, contextFriendlyNameUnwrapped.isNotEmpty { | ||
| contextFriendlyName = contextFriendlyNameUnwrapped | ||
| } else if let ldContext, ldContext.isMulti() == true, let user = ldContextMap?["user"], !user.isEmpty { | ||
abelonogov-ld marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| contextFriendlyName = user | ||
| } | ||
| attributes["key"] = contextFriendlyName ?? canonicalKey | ||
| attributes["canonicalKey"] = canonicalKey | ||
|
|
||
| self.attributes = attributes | ||
| self.timestamp = timestamp | ||
| } | ||
| } | ||
|
|
||
18 changes: 18 additions & 0 deletions
18
Sources/LaunchDarklySessionReplay/Exporter/ImageItemPayload.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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import Foundation | ||
| import LaunchDarklyObservability | ||
|
|
||
| struct ImageItemPayload: EventQueueItemPayload { | ||
| var exporterClass: AnyClass { | ||
| SessionReplayExporter.self | ||
| } | ||
|
|
||
| var timestamp: TimeInterval { | ||
| exportImage.timestamp | ||
| } | ||
|
|
||
| func cost() -> Int { | ||
| exportImage.data.count | ||
| } | ||
|
|
||
| let exportImage: ExportImage | ||
| } |
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.
Bug: Hook receives stale options without SDK metadata
The
getHooksmethod passesself.options(the original immutable options) toObservabilityHook, butOptionsis a struct. Inregister, line 19 creates a local copy withvar options = options, modifies it with SDK metadata (version, project ID, service name, etc.), and uses that copy forObservabilityClientFactory.instantiate. However, the modified copy is discarded whenregisterreturns. The hook'sbeforeEvaluationmethod usesoptions.resourceAttributeswhich will be missing all the SDK metadata that was added inregister.Additional Locations (1)
Sources/LaunchDarklyObservability/Plugin/Observability.swift#L18-L33