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

mathieu/feature/Log envents with Analytics on Resources and more #1578

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Apps/LekaApp/Sources/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// MARK: - SettingsView

struct SettingsView: View {

Check warning on line 14 in Apps/LekaApp/Sources/Views/Settings/SettingsView.swift

View workflow job for this annotation

GitHub Actions / swiftlint

Type body should span 250 lines or less excluding comments and whitespace: currently spans 251 lines (type_body_length)
@Environment(\.openURL) private var openURL
@Environment(\.dismiss) var dismiss

Expand Down Expand Up @@ -172,6 +172,7 @@
) {
self.dismiss()
self.authManager.deleteCurrentUser()
AnalyticsManager.logEventAccountDelete()
}
} message: {
Text(l10n.SettingsView.AccountSection.DeleteAccount.alertMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ public extension AnalyticsManager {

Self.logEvent(name: "skip_authentication", parameters: params)
}

static func logEventAccountDelete(parameters: [String: Any] = [:]) {
let params: [String: Any] = [:].merging(parameters) { _, new in new }

Self.logEvent(name: "account_delete", parameters: params)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ public extension AnalyticsManager {
case educationalGame = "educational_game"
case story
case gamepad
case resource
case resourceFile
case resourceVideo
}

enum ContentOrigin: String {
case generalLibrary = "general_library"
case personalLibrary = "personal_library"
case searchResults = "search_results"
case resourcesFirstSteps = "resources_first_steps"
case resourcesVideos = "resources_videos"
case resourcesDeepDive = "resources_deep_dive"
case resources
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public extension Category {
enum ResourceType: String, Codable {
case file
case video
case link
}

struct ResourcePayload: Codable {
Expand Down
7 changes: 7 additions & 0 deletions Modules/ContentKit/Sources/Views/ResourceFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AnalyticsKit
import QuickLook
import SwiftUI

Expand Down Expand Up @@ -37,6 +38,12 @@ public struct ResourceFileView: View {
}
.onTapGesture {
self.url = ContentKitResources.bundle.url(forResource: self.resource.value, withExtension: "resource.pdf")
AnalyticsManager.logEventSelectContent(
type: .resourceFile,
id: self.resource.id.uuidString,
name: self.resource.title,
origin: .resources
)
}
.quickLookPreview(self.$url)
.padding()
Expand Down
26 changes: 25 additions & 1 deletion Modules/ContentKit/Sources/Views/ResourceVideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AnalyticsKit
import Combine
import DesignKit
import LocalizationKit
import SwiftUI
Expand All @@ -20,16 +22,38 @@ public struct ResourceVideoView: View {

public var body: some View {
GroupBox(label: Label(self.resource.title, systemImage: self.resource.icon)) {
YouTubePlayerView(YouTubePlayer(stringLiteral: self.resource.value))
let player = YouTubePlayer(stringLiteral: self.resource.value)

YouTubePlayerView(player)
.aspectRatio(16 / 9, contentMode: .fit)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onAppear {
self.cancellable = player.playbackStatePublisher
.sink { state in
if state == .playing {
AnalyticsManager.logEventSelectContent(
type: .resourceVideo,
id: self.resource.id.uuidString,
name: self.resource.title,
origin: .resources
)
}
}
}
.onDisappear {
self.cancellable?.cancel()
}
}
.padding()
}

// MARK: Internal

let resource: Category.Resource

// MARK: Private

@State private var cancellable: AnyCancellable?
}

#Preview {
Expand Down
Loading