Skip to content

Commit

Permalink
✨ Add trigger details to experience analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed Jul 24, 2024
1 parent 120aaaf commit 1efc751
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ extension Dictionary where Key == String, Value == Any {
"experienceInstanceId": experience.instanceID.appcuesFormatted
]

if let trigger = experience.trigger.property {
properties["trigger"] = trigger
}

switch experience.trigger {
case let .launchExperienceAction(experienceID),
let .experienceCompletionAction(experienceID):
properties["fromExperienceId"] = experienceID?.appcuesFormatted
case let .pushNotification(notificationID):
properties["pushNotificationId"] = notificationID
default:
break
}

if let localeName = experience.context?.localeName {
properties["localeName"] = localeName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal enum ExperienceTrigger: Equatable {
case qualification(reason: QualifyResponse.QualificationReason?)
case experienceCompletionAction(fromExperienceID: UUID?)
case launchExperienceAction(fromExperienceID: UUID?)
case push
case pushNotification(notificationID: String)
case showCall
case deepLink
case preview
Expand All @@ -25,8 +25,20 @@ internal enum ExperienceTrigger: Equatable {
switch self {
case .qualification:
return false
case .experienceCompletionAction, .launchExperienceAction, .push, .showCall, .deepLink, .preview:
case .experienceCompletionAction, .launchExperienceAction, .pushNotification, .showCall, .deepLink, .preview:
return true
}
}

var property: String? {
switch self {
case .qualification(let reason): return reason?.rawValue
case .experienceCompletionAction: return "experience_completion_action"
case .launchExperienceAction: return "launch_action"
case .pushNotification: return "push_notification"
case .showCall: return "show_call"
case .deepLink: return "deep_link"
case .preview: return nil
}
}
}
2 changes: 1 addition & 1 deletion Sources/AppcuesKit/Push/PushMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ internal class PushMonitor: PushMonitoring {
}

if let experienceID = parsedNotification.experienceID {
actions.append(AppcuesLaunchExperienceAction(appcues: appcues, experienceID: experienceID, trigger: .push))
actions.append(AppcuesLaunchExperienceAction(appcues: appcues, experienceID: experienceID, trigger: .pushNotification(notificationID: parsedNotification.notificationID)))
}

let actionRegistry = appcues.container.resolve(ActionRegistry.self)
Expand Down

0 comments on commit 1efc751

Please sign in to comment.