Skip to content

rnr/openedx-app-firebase-analytics-ios

 
 

Repository files navigation

OEXFirebaseAnalytics

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.

Overview

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

Requirements

  • iOS 16.0+
  • Swift 6.0+
  • OEXFoundation 1.0.0
  • Firebase iOS SDK 11.3.0+

Installation

Step 1: Add Package Dependency

Screenshot 2024-10-29 at 17 33 06
  1. Open your OpenEdX iOS project in Xcode
  2. Navigate to project settings > Package Dependencies
  3. Click the '+' button to add a new package dependency
  4. Enter the package URL: https://github.com/openedx/openedx-app-firebase-analytics-ios
  5. Set the Dependency Rule to "Exact Version" and version to "1.0.0"
  6. Click "Add Package"

Step 2: Add Framework to Your Target

Screenshot 2024-10-29 at 17 33 26

If you don't see OEXFirebaseAnalytics in the list:

  1. Click the '+' button
  2. Click "Add Other..."
  3. Choose "Add Package Dependency..."
  4. Select OEXFirebaseAnalytics from the list
  5. Click "Add"

Setup

  1. Ensure Firebase is properly configured in your OpenEdX iOS app by following the Firebase iOS setup guide

  2. 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())
    }
}

Features

User Identification

func identify(id: String, username: String?, email: String?)

Sets the Firebase user ID for user-scoped analytics in the OpenEdX app.

Event Logging

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

Screen View Tracking

func logScreenEvent(_ event: String, parameters: [String: Any]?)

Logs screen view events with optional parameters.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%