Skip to content
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

[Feat] #408 - Amplitude 설치 #462

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Prev Previous commit
fix: amplitude - 푸시 알림 클릭했을 때
  • Loading branch information
seungchan2 committed Dec 12, 2024
commit 6a551f1b60357930fe44690ad6eac845387d5b30
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
public enum AmplitudeEventType: String {
// 푸시 이벤트
case receivedPush = "received_push"
case clickPush = "click_push"
// 클릭 이벤트
case clickAlarm = "click_alarm"
case clickMyPage = "click_mypage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public final class NotificationHandler: NSObject, UNUserNotificationCenterDelega
public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
let userInfo = notification.request.content.userInfo
print("APNs 푸시 알림 페이로드: \(userInfo)")
AmplitudeInstance.shared.track(eventType: .receivedPush, eventProperties: ["notificationId": payload.id,
"send_timeStamp": payload.sendAt,
"title": payload.title,
"contents": payload.content,
"admin_category": payload.category ?? "없음"])
return([.badge, .banner, .list, .sound])
}

Expand All @@ -36,11 +41,11 @@ public final class NotificationHandler: NSObject, UNUserNotificationCenterDelega
print("APNs 푸시 알림 페이로드: \(userInfo)")
guard let payload = NotificationPayload(dictionary: userInfo) else { return }

AmplitudeInstance.shared.track(eventType: .receivedPush, eventProperties: ["notificationId": payload.id,
"send_timeStamp": payload.sendAt,
"title": payload.title,
"contents": payload.content,
"admin_category": payload.category ?? "없음"])
AmplitudeInstance.shared.track(eventType: .clickPush, eventProperties: ["notificationId": payload.id,
"send_timeStamp": payload.sendAt,
"leadtime": "",
"contain_deeplink": payload.hasDeepLink,
"deeplink_url": payload.deepLink ?? "없음"])
guard payload.hasLink else {
self.deepLink.send(makeComponentsForEmptyLink(notificationId: payload.id))
return
Expand Down