OEXFirebaseAnalytics is a Firebase Analytics integration plugin for the OpenEdX iOS application. This package provides seamless integration with Firebase Analytics while conforming to the analytics protocols defined in OEXFoundation.
This analytics service allows OpenEdX iOS app to:
- Track user interactions
- Log custom events
- Monitor screen views
- Identify users
- Format analytics data according to Firebase requirements
- iOS 16.0+
- Swift 6.0+
- OEXFoundation 1.0.0
- Firebase iOS SDK 11.3.0+
- Open your OpenEdX iOS project in Xcode
- Navigate to project settings > Package Dependencies
- Click the '+' button to add a new package dependency
- Enter the package URL:
https://github.com/openedx/openedx-app-firebase-analytics-ios
- Set the Dependency Rule to "Exact Version" and version to "1.0.0"
- Click "Add Package"
If you don't see OEXFirebaseAnalytics in the list:
- Click the '+' button
- Click "Add Other..."
- Choose "Add Package Dependency..."
- Select OEXFirebaseAnalytics from the list
- Click "Add"
-
Ensure Firebase is properly configured in your OpenEdX iOS app by following the Firebase iOS setup guide
-
Initialize the Firebase Analytics service in your OpenEdX application:
import OEXFirebaseAnalytics
import OEXFoundation
class AppDelegate: UIResponder, UIApplicationDelegate {
private let pluginManager = PluginManager()
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
initPlugins()
return true
}
private func initPlugins() {
pluginManager.addPlugin(analyticsService: FirebaseAnalyticsService())
}
}
func identify(id: String, username: String?, email: String?)
Sets the Firebase user ID for user-scoped analytics in the OpenEdX app.
func logEvent(_ event: String, parameters: [String: Any]?)
Logs custom events with optional parameters. The service automatically formats event names and parameters to comply with Firebase Analytics requirements:
- Event names are limited to 40 characters
- Parameter values are limited to 100 characters
- Special characters are replaced with underscores
- Double underscores are consolidated
func logScreenEvent(_ event: String, parameters: [String: Any]?)
Logs screen view events with optional parameters.