A CocoaPods library for tracking video play and share events for Arclight Videos in iOS applications.
- iOS 12.0+
- Xcode 8.0+
- The following frameworks must be linked to your project:
libsqlite3.0.dylib
CoreLocation.framework
UIKit.framework
To install arclight-event-tracker, simply add the following line to your Podfile:
pod 'arclight-event-tracker'
If you would like to keep arclight-event-tracker updated you can simply include it like this in your podfile and "pod update" will always pull down the latest 1.20.x version.
pod 'arclight-event-tracker', '~> 1.20.0'
Objective-C:
#import "EventTracker.h"
Swift:
import arclight_event_tracker
Objective-C (AppDelegate.m):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
// Initialize tracker
[EventTracker initializeWithApiKey:@"YOUR_API_KEY"
appDomain:@"com.yourcompany.appname"
appName:@"Your App Name"
appVersion:appVersionString
isProduction:YES
trackLocation:YES];
return YES;
}
Swift (AppDelegate.swift):
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let appVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0"
// Initialize tracker
EventTracker.initialize(withApiKey: "YOUR_API_KEY",
appDomain: "com.yourcompany.appname",
appName: "Your App Name",
appVersion: appVersionString,
isProduction: true,
trackLocation: true)
return true
}
}
Parameters:
apiKey
: Your application's API keyappDomain
: Your app's bundle identifier (e.g., "com.companyname.appname")appName
: The name of your applicationappVersion
: The version of your applicationisProduction
: Set toYES
for production,NO
for stagingtrackLocation
: Set toYES
to track user location,NO
to disable
Call this method when a user plays a video:
Objective-C:
[EventTracker trackPlayEventWithRefID:@"video_id_123"
apiSessionID:@"session_id_456"
streaming:YES
mediaViewTimeInSeconds:120.0
mediaEngagementOver75Percent:YES];
Swift:
EventTracker.trackPlayEvent(withRefID: "video_id_123",
apiSessionID: "session_id_456",
streaming: true,
mediaViewTimeInSeconds: 120.0,
mediaEngagementOver75Percent: true)
Parameters:
refID
: The unique identifier of the video being playedapiSessionID
: Session ID retrieved from your server for tracking playback sessionsstreaming
:true
/YES
if video is streamed from web,false
/NO
if played from cachemediaViewTimeInSeconds
: Number of seconds the video was viewedmediaEngagementOver75Percent
:true
/YES
if video was played over 75%,false
/NO
otherwise
For more detailed tracking, you can include additional parameters:
Objective-C:
NSDictionary *extraParams = @{
@"appScreen": @"VideoPlayerScreen",
@"subtitleLanguageId": @"en",
@"mediaComponentId": @"component_123",
@"languageId": @"en"
};
[EventTracker trackPlayEventWithRefID:@"video_id_123"
apiSessionID:@"session_id_456"
streaming:YES
mediaViewTimeInSeconds:120.0
mediaEngagementOver75Percent:YES
extraParams:extraParams];
Swift:
let extraParams: [String: Any] = [
"appScreen": "VideoPlayerScreen",
"subtitleLanguageId": "en",
"mediaComponentId": "component_123",
"languageId": "en"
]
EventTracker.trackPlayEvent(withRefID: "video_id_123",
apiSessionID: "session_id_456",
streaming: true,
mediaViewTimeInSeconds: 120.0,
mediaEngagementOver75Percent: true,
extraParams: extraParams)
Track when users share videos:
Objective-C:
[EventTracker trackShareEventFromShareMethod:kShareMethodFacebook
refID:@"video_id_123"
apiSessionID:@"session_id_456"];
Swift:
EventTracker.trackShareEvent(fromShareMethod: .facebook,
refID: "video_id_123",
apiSessionID: "session_id_456")
Available Share Methods:
kShareMethodTwitter
/.twitter
- Twitter sharingkShareMethodEmail
/.email
- Email sharingkShareMethodFacebook
/.facebook
- Facebook sharingkShareMethodBlueTooth3GP
/.blueTooth3GP
- Bluetooth 3GP sharingkShareMethodEmbedURL
/.embedURL
- Embed URL copying
Call this method when your app becomes active to check for location changes:
Objective-C (AppDelegate.m):
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[EventTracker applicationDidBecomeActive];
}
Swift (AppDelegate.swift):
func applicationDidBecomeActive(_ application: UIApplication) {
EventTracker.applicationDidBecomeActive()
}
Enable logging for debugging:
Objective-C:
[EventTracker setLoggingEnabled:YES];
Swift:
EventTracker.setLoggingEnabled(true)
Set custom location coordinates:
Objective-C:
[EventTracker setLatitude:37.7749 longitude:-122.4194];
Swift:
EventTracker.setLatitude(37.7749, longitude: -122.4194)
See the Example/
directory for a complete working example of how to integrate the EventTracker into your iOS application.
To run the example project:
clone the repo, and run pod install
from the Example directory first.
This project uses automated releases via GitHub Actions. To release a new version:
Update the version in arclight-event-tracker.podspec
:
s.version = "1.20.1" # Change to your new version
Document your changes in CHANGELOG.md
file or update the release notes.
# Add your changes
git add .
# Commit with a descriptive message
git commit -m "Release v1.20.1"
# Create and push the tag
git tag 1.20.1
git push origin main
git push origin 1.20.1
Once you push the tag, GitHub Actions will automatically:
- ✅ Validate that the podspec version matches the git tag
- ✅ Run RuboCop to check code style
- ✅ Validate the podspec with
pod lib lint
- ✅ Publish to CocoaPods Trunk
Check that your release was successful:
- GitHub Actions: Check the Actions tab for successful completion
- CocoaPods: Verify the new version appears on CocoaPods.org
Before releasing, ensure you have:
- Valid Podspec: Your podspec should pass
pod lib lint
locally - Clean Code: All RuboCop checks should pass
Note: CocoaPods Trunk Token is already configured as a GitHub secret.
- Use Semantic Versioning:
MAJOR.MINOR.PATCH
- MAJOR: Breaking changes
- MINOR: New features, backward compatible
- PATCH: Bug fixes, backward compatible
If the release fails:
- Check GitHub Actions logs for specific error messages
- Verify podspec syntax by running
pod lib lint
locally - Ensure version consistency between podspec and git tag
- Check CocoaPods Trunk Token is properly configured