Skip to content

Commit

Permalink
Add a player version (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
waliid authored Jul 27, 2023
1 parent 61090de commit f720c89
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Demo/Sources/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import Analytics
import AVFoundation
import Player
import SwiftUI

struct SettingsView: View {
Expand Down Expand Up @@ -115,7 +116,7 @@ struct SettingsView: View {
@ViewBuilder
private func debuggingFooter() -> some View {
VStack {
Text("Version \(version) Build \(buildVersion)")
Text("Version \(version) Build \(buildVersion), Player \(Player.version)")
HStack(spacing: 0) {
Text("Made with ")
Image(systemName: "heart.fill")
Expand Down
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ let package = Package(
.target(name: "Core"),
.product(name: "DequeModule", package: "swift-collections"),
.product(name: "TimelaneCombine", package: "TimelaneCombine")
],
plugins: [
.plugin(name: "PackageInfoPlugin")
]
),
.target(
Expand Down
5 changes: 5 additions & 0 deletions Sources/Analytics/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public class Analytics {
/// The singleton instance.
public static var shared = Analytics()

/// The analytics version.
public static var version: String {
PackageInfo.version
}

private var configuration: Configuration?

private let comScoreService = ComScoreService()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Analytics/ComScore/ComScoreTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class ComScoreTracker: PlayerItemTracker {
public func enable(for player: Player) {
streamingAnalytics.createPlaybackSession()
streamingAnalytics.setMediaPlayerName("Pillarbox")
streamingAnalytics.setMediaPlayerVersion(PackageInfo.version)
streamingAnalytics.setMediaPlayerVersion(Player.version)

$metadata.sink { [weak self] metadata in
self?.updateMetadata(with: metadata)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Analytics/CommandersAct/CommandersActService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class CommandersActService {
func start(with configuration: Analytics.Configuration) {
vendor = configuration.vendor
guard let serverSide = ServerSide(siteID: 3666, andSourceKey: configuration.sourceKey) else { return }
serverSide.addPermanentData("app_library_version", withValue: PackageInfo.version)
serverSide.addPermanentData("app_library_version", withValue: Analytics.version)
serverSide.addPermanentData("navigation_app_site_name", withValue: configuration.appSiteName)
serverSide.addPermanentData("navigation_device", withValue: Self.device())
serverSide.enableRunningInBackground()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Analytics/CommandersAct/CommandersActTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private extension CommandersActTracker {
func labels(for player: Player) -> [String: String] {
metadata.labels.merging([
"media_player_display": "Pillarbox",
"media_player_version": PackageInfo.version,
"media_player_version": Player.version,
"media_volume": "\(volume(for: player))"
]) { _, new in new }
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/Player/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import TimelaneCombine
public final class Player: ObservableObject, Equatable {
private static weak var currentPlayer: Player?

/// The player version.
public static var version: String {
PackageInfo.version
}

/// The current playback state.
@Published public private(set) var playbackState: PlaybackState = .idle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class CommandersActPageViewTests: CommandersActTestCase {
expect(labels.navigation_level_8).to(equal("level_8"))
expect(labels.navigation_level_9).to(beNil())
expect(["phone", "tablet", "tvbox", "phone"]).to(contain([labels.navigation_device]))
expect(labels.app_library_version).to(equal(PackageInfo.version))
expect(labels.app_library_version).to(equal(Analytics.version))
expect(labels.navigation_app_site_name).to(equal("site"))
expect(labels.navigation_property_type).to(equal("app"))
expect(labels.navigation_bu_distributer).to(equal("SRG"))
Expand Down

0 comments on commit f720c89

Please sign in to comment.