mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
track link read events
This commit is contained in:
parent
b317e1b96b
commit
d7acfe69f8
6 changed files with 30 additions and 27 deletions
|
|
@ -67,6 +67,16 @@ enum PDFProvider {
|
|||
}
|
||||
}
|
||||
|
||||
func trackReadEvent() {
|
||||
EventTracker.track(
|
||||
.linkRead(
|
||||
linkID: item.unwrappedID,
|
||||
slug: item.unwrappedSlug,
|
||||
originalArticleURL: item.unwrappedPageURLString
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private func createWebAppWrapperViewModel(username: String, dataService: DataService, rawAuthCookie: String?) {
|
||||
let baseURL = dataService.appEnvironment.webAppBaseURL
|
||||
|
||||
|
|
@ -130,11 +140,14 @@ struct LinkItemDetailView: View {
|
|||
#if os(iOS)
|
||||
if viewModel.item.isPDF {
|
||||
fixedNavBarReader
|
||||
.task { viewModel.trackReadEvent() }
|
||||
} else {
|
||||
WebReaderContainerView(item: viewModel.item, homeFeedViewModel: viewModel.homeFeedViewModel)
|
||||
.task { viewModel.trackReadEvent() }
|
||||
}
|
||||
#else
|
||||
fixedNavBarReader
|
||||
.task { viewModel.trackReadEvent() }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public final class RootViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
func configurePDFProvider(pdfViewerProvider: @escaping (URL, PDFViewerViewModel) -> AnyView) {
|
||||
EventTracker.track(TestEvent.testEventTwo(extraData: "invoked #configurePDFprovider function"))
|
||||
guard PDFProvider.pdfViewerProvider == nil else { return }
|
||||
|
||||
PDFProvider.pdfViewerProvider = { [weak self] url, linkedItem in
|
||||
|
|
|
|||
|
|
@ -46,11 +46,7 @@ public extension UserProfile {
|
|||
}
|
||||
|
||||
public extension Viewer {
|
||||
var unwrappedUsername: String {
|
||||
username ?? ""
|
||||
}
|
||||
|
||||
var unwrappedName: String {
|
||||
name ?? ""
|
||||
}
|
||||
var unwrappedUsername: String { username ?? "" }
|
||||
var unwrappedName: String { name ?? "" }
|
||||
var unwrappedUserID: String { userID ?? "" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ private struct ViewerInternal {
|
|||
try context.save()
|
||||
logger.debug("Viewer saved succesfully")
|
||||
objectID = viewer.objectID
|
||||
EventTracker.registerUser(userID: viewer.unwrappedUserID)
|
||||
} catch {
|
||||
context.rollback()
|
||||
logger.debug("Failed to save Viewer: \(error.localizedDescription)")
|
||||
|
|
|
|||
|
|
@ -34,8 +34,3 @@ private let segment: Analytics? = {
|
|||
|
||||
return Analytics(configuration: config)
|
||||
}()
|
||||
|
||||
public protocol TrackableEvent {
|
||||
var name: String { get }
|
||||
var properties: [String: String]? { get }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,25 @@
|
|||
import Foundation
|
||||
|
||||
public enum TestEvent {
|
||||
case testEventOne
|
||||
case testEventTwo(extraData: String)
|
||||
public enum TrackableEvent {
|
||||
case linkRead(linkID: String, slug: String, originalArticleURL: String)
|
||||
}
|
||||
|
||||
extension TestEvent: TrackableEvent {
|
||||
public var name: String {
|
||||
public extension TrackableEvent {
|
||||
var name: String {
|
||||
switch self {
|
||||
case .testEventOne:
|
||||
return "testEventOne"
|
||||
case .testEventTwo:
|
||||
return "testEventTwo"
|
||||
case .linkRead:
|
||||
return "link_read"
|
||||
}
|
||||
}
|
||||
|
||||
public var properties: [String: String]? {
|
||||
var properties: [String: String]? {
|
||||
switch self {
|
||||
case .testEventOne:
|
||||
return nil
|
||||
case let .testEventTwo(extraData: extraData):
|
||||
return ["extraData": extraData]
|
||||
case let .linkRead(linkID: linkID, slug: slug, originalArticleURL: originalArticleURL):
|
||||
return [
|
||||
"link": linkID,
|
||||
"slug": slug,
|
||||
"url": originalArticleURL
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue