iOS Bitmovin player collector migration from API v2 to v3
Step 1 BitmovinAnalytics
is now direct dependency of BitmovinPlayer
BitmovinAnalytics
is now direct dependency of BitmovinPlayer
SPM setup: Replace dependencies
With version 3.42.0
of our Bitmovin player, Analytics comes out of the box. No need for separate setup anymore! 🌟
- Navigate to Project Settings > Package Dependencies
- Make sure you have removed the
BitmovinAnalytics
/bitmovin-analytics-collector-ios
package - Ensure you have added at least
BitmovinPlayer
version3.42.0
Once this is done you should see BitmovinAnalytics
appear again in the Package Dependency side bar
cocoapod
Setup: Update imports
cocoapod
Setup: Update importsIf you are using Cocoapods to manage your dependencies, follow these steps.
- Open your Podfile
- Remove the import of
BitmovinAnalyticsCollector
- pod 'BitmovinAnalyticsCollector/Core', '2.11.0'
- pod 'BitmovinAnalyticsCollector/BitmovinPlayer', '2.11.0'
- Make sure you use at least
BitmovinPlayer
version3.42.0
(pod 'BitmovinPlayer', '3.42.0'
)
Step 2 Remove the creation of the collector
There is no need to create a collector instance anymore. This is all handled by the player.
// change to the new config
- let config = BitmovinAnalyticsConfig(key: "<ANALYTICS_LICENSE_KEY>")
+ let config = AnalyticsConfig(licenseKey: "<ANALYTICS_LICENSE_KEY>")
// optional metadata object
+ let defaultMetadata = DefaultMetadata()
// remove collector creation
- let collector = BitmovinPlayerCollector(config: config)
// use the config to create the player
- let player = PlayerFactory.create()
+ let player = PlayerFactory.create(analyticsConfig: config, defaultMetadata: defaultMetadata)
// no need to connect the player and collector
- collector.attachPlayer(player: player)
For more information on how to configure our collector, you check out our configuration guide
Add SourceMetadata
to Source
(Optional)
SourceMetadata
to Source
(Optional)As some of the video metadata has been removed from the config, you need to provide this information via the player Source
.
let sourceMetadata = SourceMetadata(
title: "Sintel"
)
// remove old collector API calls
- collector.setSourceMetadata(sourceMetadata: sourceMetadata)
// at source creation
- let source = SourceFactory.create(from: sourceConfig)
+ let source = SourceFactory.create(from: sourceConfig, sourceMetadata: sourceMetadata)
Appendix: Player Analytics Api
The player api provides a way to access the analytics api.
Here is a quick mapping of methods.
v2 | bundle |
---|---|
collector.getUserId() | player.analytics.userId |
collector.setCustomDataOnce() | player.analytics.sendCustomDataEvent(customData:) |
collector.setSourceMetadata() | player.source.analytics.metadata |
collector.setCustomData() | removed from the collector - access now via source withplayer.source.analytics.customData |
Updated 12 months ago