-
Notifications
You must be signed in to change notification settings - Fork 42
[SDK-231] Add click handling tracking #799
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
base: loren/embedded/SDK-232-ios-add-start-impression-and-pause-impression-a
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -548,6 +548,39 @@ import React | |
| EmbeddedSessionManager.shared.pauseImpression(messageId: messageId) | ||
| } | ||
|
|
||
| @objc(trackEmbeddedClick:buttonId:clickedUrl:) | ||
| public func trackEmbeddedClick( | ||
| message: NSDictionary, buttonId: String?, clickedUrl: String? | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the message be of type EmbeddedMessage instead of generic string? |
||
| ) { | ||
| ITBInfo() | ||
|
|
||
| // Extract message ID from the dictionary | ||
| guard let messageDict = message as? [AnyHashable: Any], | ||
| let metadataDict = messageDict["metadata"] as? [AnyHashable: Any], | ||
| let messageId = metadataDict["messageId"] as? String else { | ||
| ITBError("Could not extract messageId from message dictionary") | ||
| return | ||
| } | ||
|
|
||
| // Find the message in the embedded manager's cache | ||
| let messages = IterableAPI.embeddedManager.getMessages() | ||
| guard let embeddedMessage = messages.first(where: { $0.metadata.messageId == messageId }) else { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this check for embedded message be avoided by using the method's input parameter? But it can make sense if EmbeddedMessage is not guaranteed to receive everytime. |
||
| ITBError("Could not find embedded message with id: \(messageId)") | ||
| return | ||
| } | ||
|
|
||
| guard let clickedUrl = clickedUrl else { | ||
| ITBError("clickedUrl is required for trackEmbeddedClick") | ||
| return | ||
| } | ||
|
Comment on lines
+572
to
+575
|
||
|
|
||
| IterableAPI.track( | ||
| embeddedMessageClick: embeddedMessage, | ||
| buttonIdentifier: buttonId, | ||
| clickedUrl: clickedUrl | ||
| ) | ||
| } | ||
|
|
||
| // MARK: Private | ||
| private var shouldEmit = false | ||
| private let _methodQueue = DispatchQueue(label: String(describing: ReactIterableAPI.self)) | ||
|
|
||
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.
The
<string>header is imported but doesn't appear to be used in the visible code. If this import is not required by the generated RNIterableAPISpec.h header, consider removing it to keep the imports clean.