Skip to content

Commit

Permalink
feat: opt-out of automatic error tracking if using FairPlay
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Aug 28, 2024
1 parent 011363a commit 4a37436
Showing 1 changed file with 49 additions and 61 deletions.
110 changes: 49 additions & 61 deletions Sources/MuxPlayerSwift/Monitoring/Monitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,55 @@ class Monitor: ErrorDispatcher {
usingDRM: Bool = false
) {

let monitoredPlayer: MonitoredPlayer
let customerData: MUXSDKCustomerData

if let customerData = options.customerData {
if let externallySpecifiedCustomerData = options.customerData {

let customerDataCopy = MUXSDKCustomerData()
let modifiedCustomerData = MUXSDKCustomerData()

if let customerVideoData = customerData.customerVideoData {
if let customerVideoData = externallySpecifiedCustomerData.customerVideoData {
let customerVideoDataCopy = MUXSDKCustomerVideoData()
customerVideoDataCopy.setQuery(customerVideoData.toQuery())
customerDataCopy.customerVideoData = customerVideoData
modifiedCustomerData.customerVideoData = customerVideoData
}

if let customerViewData = customerData.customerViewData {
if let customerViewData = externallySpecifiedCustomerData.customerViewData {
let customerViewDataCopy = MUXSDKCustomerViewData()
customerViewDataCopy.setQuery(customerViewData.toQuery())
customerDataCopy.customerViewData = customerViewData
modifiedCustomerData.customerViewData = customerViewData
}

if let customerViewerData = customerData.customerViewerData {
if let customerViewerData = externallySpecifiedCustomerData.customerViewerData {
let customerViewerDataCopy = MUXSDKCustomerViewerData()
customerViewerDataCopy.viewerApplicationName = customerViewerData.viewerApplicationName
customerViewerDataCopy.viewerDeviceCategory = customerViewerData.viewerDeviceCategory
customerViewerDataCopy.viewerDeviceManufacturer = customerViewerData.viewerDeviceManufacturer
customerViewerDataCopy.viewerDeviceModel = customerViewerData.viewerDeviceModel
customerViewerDataCopy.viewerOsFamily = customerViewerData.viewerOsFamily
customerViewerDataCopy.viewerOsVersion = customerViewerData.viewerOsVersion
customerDataCopy.customerViewerData = customerViewerData
modifiedCustomerData.customerViewerData = customerViewerData
}

if let customerPlayerData = customerData.customerPlayerData {
if let customerPlayerData = externallySpecifiedCustomerData.customerPlayerData {
let customerPlayerDataCopy = MUXSDKCustomerPlayerData()
customerPlayerDataCopy.setQuery(
customerPlayerData.toQuery()
)
customerPlayerDataCopy.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerDataCopy.playerSoftwareName = "MuxPlayerSwiftAVPlayerViewController"
customerDataCopy.customerPlayerData = customerPlayerDataCopy
modifiedCustomerData.customerPlayerData = customerPlayerDataCopy
} else {
let customerPlayerData = MUXSDKCustomerPlayerData()
customerPlayerData.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerData.playerSoftwareName = "MuxPlayerSwiftAVPlayerViewController"
customerDataCopy.customerPlayerData = customerPlayerData
modifiedCustomerData.customerPlayerData = customerPlayerData
}

let binding = MUXSDKStats.monitorAVPlayerViewController(
playerViewController,
withPlayerName: options.playerName,
customerData: customerDataCopy
)

monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)

customerData = modifiedCustomerData

} else {

let customerData = MUXSDKCustomerData()
customerData = MUXSDKCustomerData()
let customerPlayerData = MUXSDKCustomerPlayerData()
customerPlayerData.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerData.playerSoftwareName = "MuxPlayerSwiftAVPlayerViewController"
Expand All @@ -97,18 +88,21 @@ class Monitor: ErrorDispatcher {
customerViewData.viewDrmType = "fairplay"
customerData.customerViewData = customerViewData
}
}

let binding = MUXSDKStats.monitorAVPlayerViewController(
playerViewController,
withPlayerName: options.playerName,
customerData: customerData
)
let shouldTrackErrorsAutomatically = !usingDRM

monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)
}
let binding = MUXSDKStats.monitorAVPlayerViewController(
playerViewController,
withPlayerName: options.playerName,
customerData: customerData,
automaticErrorTracking: shouldTrackErrorsAutomatically
)

let monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)

let objectIdentifier = ObjectIdentifier(playerViewController)

Expand All @@ -121,41 +115,32 @@ class Monitor: ErrorDispatcher {
options: MonitoringOptions,
usingDRM: Bool = false
) {
let monitoredPlayer: MonitoredPlayer
let customerData: MUXSDKCustomerData

if let customerData = options.customerData {
if let externallySpecifiedCustomerData = options.customerData {

let customerDataCopy = MUXSDKCustomerData()
let modifiedCustomerData = MUXSDKCustomerData()

if let customerPlayerData = customerData.customerPlayerData {
if let customerPlayerData = externallySpecifiedCustomerData.customerPlayerData {
let customerPlayerDataCopy = MUXSDKCustomerPlayerData()
customerPlayerDataCopy.setQuery(
customerPlayerData.toQuery()
)
customerPlayerDataCopy.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerData.playerSoftwareName = "MuxPlayerSwiftAVPlayerLayer"
customerDataCopy.customerPlayerData = customerPlayerDataCopy
modifiedCustomerData.customerPlayerData = customerPlayerDataCopy
} else {
let customerPlayerData = MUXSDKCustomerPlayerData()
customerPlayerData.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerData.playerSoftwareName = "MuxPlayerSwiftAVPlayerLayer"
customerDataCopy.customerPlayerData = customerPlayerData
modifiedCustomerData.customerPlayerData = customerPlayerData
}

let binding = MUXSDKStats.monitorAVPlayerLayer(
playerLayer,
withPlayerName: options.playerName,
customerData: customerDataCopy
)

monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)
customerData = modifiedCustomerData

} else {

let customerData = MUXSDKCustomerData()
customerData = MUXSDKCustomerData()
let customerPlayerData = MUXSDKCustomerPlayerData()
customerPlayerData.playerSoftwareVersion = SemanticVersion.versionString
customerPlayerData.playerSoftwareName = "MuxPlayerSwiftAVPlayerLayer"
Expand All @@ -170,18 +155,21 @@ class Monitor: ErrorDispatcher {
customerViewData.viewDrmType = "fairplay"
customerData.customerViewData = customerViewData
}
}

let binding = MUXSDKStats.monitorAVPlayerLayer(
playerLayer,
withPlayerName: options.playerName,
customerData: customerData
)
let shouldTrackErrorsAutomatically = !usingDRM

monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)
}
let binding = MUXSDKStats.monitorAVPlayerLayer(
playerLayer,
withPlayerName: options.playerName,
customerData: customerData,
automaticErrorTracking: shouldTrackErrorsAutomatically
)

let monitoredPlayer = MonitoredPlayer(
name: options.playerName,
binding: binding!
)

let objectIdentifier = ObjectIdentifier(playerLayer)

Expand Down

0 comments on commit 4a37436

Please sign in to comment.