Skip to content

Commit

Permalink
🔀️ Merge branch 'mathieu/feature/Log-envents-with-Analytics-on-Resour…
Browse files Browse the repository at this point in the history
…ces-and-more' into develop
  • Loading branch information
ladislas committed Nov 22, 2024
2 parents 4b525f8 + 0707cbc commit af0841a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
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 @@ -172,6 +172,7 @@ struct SettingsView: View {
) {
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

0 comments on commit af0841a

Please sign in to comment.