Skip to content

Commit

Permalink
♻️ Add new push analytics properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 6, 2024
1 parent 0ced779 commit 6ba60ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Sources/AppcuesKit/Push/ParsedNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ internal struct ParsedNotification {
let applicationID: String
let userID: String
let notificationID: String
let notificationVersion: Int?
let workflowID: String?
let workflowVersion: Int?
let workflowTaskID: String?
let deepLinkURL: URL?
let experienceID: String?
Expand All @@ -34,7 +36,9 @@ internal struct ParsedNotification {
self.userID = userID
self.notificationID = notificationID

self.notificationVersion = userInfo["appcues_notification_version"] as? Int
self.workflowID = userInfo["appcues_workflow_id"] as? String
self.workflowVersion = userInfo["appcues_workflow_version"] as? Int
self.workflowTaskID = userInfo["appcues_workflow_task_id"] as? String
self.deepLinkURL = (userInfo["appcues_deep_link_url"] as? String)
.flatMap { URL(string: $0) }
Expand Down
15 changes: 9 additions & 6 deletions Sources/AppcuesKit/Push/PushMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@ internal class PushMonitor: PushMonitoring {
completionHandler: @escaping () -> Void
) {
if !parsedNotification.isTest {
let properties: [String: Any?] = [
"notification_id": parsedNotification.notificationID,
"notification_version": parsedNotification.notificationVersion,
"workflow_id": parsedNotification.workflowID,
"workflow_version": parsedNotification.workflowVersion,
"workflow_task_id": parsedNotification.workflowTaskID,
"device_id": storage.deviceID
]
analyticsPublisher.publish(TrackingUpdate(
type: .event(name: Events.Push.pushOpened.rawValue, interactive: false),
properties: [
"notification_id": parsedNotification.notificationID,
"workflow_id": parsedNotification.workflowID,
"workflow_task_id": parsedNotification.workflowTaskID,
"device_id": storage.deviceID
].compactMapValues { $0 },
properties: properties.compactMapValues { $0 },
isInternal: true
))
}
Expand Down

0 comments on commit 6ba60ed

Please sign in to comment.