Analytics
The PSPDFKit Analytics API allows you to easily collect usage data based on a user’s activity taking place in PSPDFKit components.
The PSPDFKit Analytics API consists of:
-
An
Analytics
object containing all constants that are related to the Analytics API -
An
AnalyticsClient
interface that you need to implement to capture analytics events
Integration
The PSPDFKit Analytics API comes bundled with PSPDFKitUI.xcframework
, so you don’t need to add any external packages. Just ensure you’re importing the PSPDFKitUI
module in your file wherever you’re using this API.
Enable Analytics
To collect analytics data, you need to implement the AnalyticsClient
interface. This interface will be notified of all events emitted by PSPDFKit, and it’s where you pass them to the analytics service of your choice.
Be aware that events are delivered on a background thread.
Create an instance of your AnalyticsClient
when the app launches (preferably at the same time you’re initializing PSPDFKit) and register it with PSPDFKit.addAnalyticsClient()
:
val analyticsClient = MyAnalyticsClient()
PSPDFKit.addAnalyticsClient(analyticsClient)
AnalyticsClient analyticsClient = new MyAnalyticsClient();
PSPDFKit.addAnalyticsClient(analyticsClient);