diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index 90dfc2612..4b6fb28c5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -17,12 +17,11 @@ import Views if let item = item { pdfItem = PDFItem.make(item: item) self.item = item + trackReadEvent(reader: item.isPDF ? "PDF" : "WEB") } - - trackReadEvent() } - private func trackReadEvent() { + private func trackReadEvent(reader: String) { guard let itemID = item?.unwrappedID ?? pdfItem?.itemID else { return } guard let slug = item?.unwrappedSlug ?? pdfItem?.slug else { return } guard let originalArticleURL = item?.unwrappedPageURLString ?? pdfItem?.downloadURL else { return } @@ -31,6 +30,7 @@ import Views .linkRead( linkID: itemID, slug: slug, + reader: reader, originalArticleURL: originalArticleURL ) ) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift index 48e5f7631..8c1194425 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderLoadingContainer.swift @@ -25,6 +25,7 @@ import Views .linkRead( linkID: item.unwrappedID, slug: item.unwrappedSlug, + reader: "WEB", originalArticleURL: item.unwrappedPageURLString ) ) diff --git a/apple/OmnivoreKit/Sources/Utils/EventTracking/TrackableEvents.swift b/apple/OmnivoreKit/Sources/Utils/EventTracking/TrackableEvents.swift index e4bdc7840..65d12d9b6 100644 --- a/apple/OmnivoreKit/Sources/Utils/EventTracking/TrackableEvents.swift +++ b/apple/OmnivoreKit/Sources/Utils/EventTracking/TrackableEvents.swift @@ -1,7 +1,7 @@ import Foundation public enum TrackableEvent { - case linkRead(linkID: String, slug: String, originalArticleURL: String) + case linkRead(linkID: String, slug: String, reader: String, originalArticleURL: String) case debugMessage(message: String) case backgroundFetch(jobStatus: BackgroundFetchJobStatus, itemCount: Int, secondsElapsed: Int) case audioSessionStart(linkID: String) @@ -33,10 +33,11 @@ public extension TrackableEvent { var properties: [String: String]? { switch self { - case let .linkRead(linkID: linkID, slug: slug, originalArticleURL: originalArticleURL): + case let .linkRead(linkID: linkID, slug: slug, reader: reader, originalArticleURL: originalArticleURL): return [ "link": linkID, "slug": slug, + "reader": reader, "url": originalArticleURL ] case let .debugMessage(message: message): diff --git a/packages/web/pages/[username]/[slug]/index.tsx b/packages/web/pages/[username]/[slug]/index.tsx index f6ab12ece..0293a3da0 100644 --- a/packages/web/pages/[username]/[slug]/index.tsx +++ b/packages/web/pages/[username]/[slug]/index.tsx @@ -243,6 +243,7 @@ export default function Home(): JSX.Element { posthog.capture('link_read', { link: article.id, slug: article.slug, + reader: article.contentReader, url: article.originalArticleUrl, }) }