Swiftpack.co - Conviva/conviva-ios-appanalytics as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Conviva.
Conviva/conviva-ios-appanalytics 0.2.22
Conviva iOS App Analytics
⭐️ 3
🕓 5 weeks ago
iOS tvOS
.package(url: "https://github.com/Conviva/conviva-ios-appanalytics.git", from: "0.2.22")


Use Application Analytics to autocollect events and track application specific events and state changes.

Supported Platforms

  • iOS(9.0 and above)
  • iPadOS(13.0 and above)
  • tvOS(9.0 and above)
  • watchOS(TBD)


NOTE: During pod installation, if you are facing any issues with FMDB, Please update your file as below and do pod installation.

  • Add below line in pods file

    • pod 'ConvivaAppAnalytics', '0.2.22'
    • pod 'FMDB', '2.7.5'
  • Manual Download

    • Download and unzip the package from Downloads. During the build phase, add ConvivaAppAnalytics.xcframework to Link Binary with Libraries section in xcode. This package contains the frameworks for both, iOS and tvOS.
  • Link the following system frameworks to Link Binary with Libraries section in xcode:

    • UIKit
    • Foundation
    • CoreTelephony (iOS only)
    • FMDB (version 2.5)
    • In Other Linker Flags section in Xcode, add "-ObjC".
    • To refer to the Conviva classes from your source code, add the following import statements:
* Swift:
import ConvivaAppAnalytics
* ObjC:
@import ConvivaAppAnalytics;

Initialize the top level object

* Swift:
var tracker = CATAppAnalytics.createTracker(customerKey: customerKey, appName: appName)
* ObjC:
id<CATTrackerController> tracker = [CATAppAnalytics createTrackerWithCustomerKey:customerKey appName:appName];

customerKey - a string to identify specific customer account. Different keys shall be used for development / debug versus production environment. Find your keys on the account info page in Pulse.

appName - a string value used to distinguish your applications. Simple values that are unique across all of your integrated platforms work best here.

Set the user id (viewer id)

* Swift:
tracker?.subject?.userId = "user_id"
* ObjC:
tracker.subject.userId = @"user_id";

Custom event tracking to track your application specific events and state changes

Use trackCustomEvent() to track all kinds of events. This API provides 2 fields to describe the tracked events.

  • eventName - Name of the custom event.
  • eventData – Any type of data in string format.

The following example shows the implementation of the 'onClick' event listener to any element:

* Swift:
let data = "{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}"
tracker?.trackCustomEvent("your-event-name", data: data)
* ObjC:
NSString *data = @"{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}";
[tracker trackCustomEvent:@"your-event-name" data:data];

Screen view tracking

When user navigates between screens, user journey is tracked by reading the class names of UIViewController classes. Name of the screens can be customized using below code as per the bussiness needs.

* Swift:
* //Add below property in view controller
* @objc var catViewId:String = "App Analytics View"
* ObjC:
* //Declare property like below
* @property(copy, nonatomic)NSString *catViewId;
* //Add below line in viewDidLoad method
* self.catViewId = @"Customizable name";

Custom Tags Support

Support is added to pass custom data as key-val pairs which are available in each event triggered by sdk and passed to backend. Below are the new api additions to support Custom Tags.

* ObjC:
// Setter API

 * Set custom tags.
 * Pass custom tags
 * @param tags Dictionary of Key-Val pairs.
- (void)setCustomTags:(NSDictionary *)tags;

NSDictionary* tags = @{
    @"Key1": @"Value1",
    @"Key2": @"Value2",
[tracker setCustomTags:tags];

// Clear API
 * Clears all custom tags.
- (void)clearCustomTags;

[tracker clearCustomTags];

 * Clears custom tags which are matching keys as passed in.
 * Keys of tags to be cleared
 * @param tagKeys tagKeys.
- (void)clearCustomTags:(NSArray *)tagKeys;

NSArray* keys = @[ @"Key1", @"Key2", @"Key3" ];
[tracker clearCustomTags:keys];

* Swift:
//Usage: Set custom tags
let tags = ["Key1": "Value1", "Key2": "Value2"]

//Usage: Clear all custom tags

//Usage: Clear custom tags
let keys = ["Key1", "Key2", "Key3"]
Auto-collected Events
Conviva provides a rich set of application performance metrics with the help of autocollected app events, such as screen_view , button_click, and network_request.
Event Occurrence
network_request after receiving the network request response
screen_view when the screen is interacted on either first launch or relaunch
application_error when an error occurrs in the application
button_click on the button click callback
application_background when the application is taken to the background
application_foreground when the application is taken to the foreground
application_install when the application is launched for the first time after it's installed. (It's not the exact installed time.)

To learn about the default metrics for analyzing the native and web applications performance, such as App Crashes, Avg Screen Load Time, and Page Loads, refer to the App Experience Metrics page in the Learning Center.

Note: If user of this sdk also uses ConvivaSDK for Experience Insights/Ad Insights, ConvivaSDK version must be 4.0.28 or above to be compatable with ConvivaAppAnalytics version 0.2.3 or above

To enable automatic collection of playback events, ConvivaSDK 4.0.32 or above must be used.


Stars: 3
Last commit: 20 hours ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Release 0.2.22
5 weeks ago
  • Enhances network request & response collection feature to capture Array type data.
  • Enhances network request feature by adding collection of query parameters as part as target url.
  • Minor fix added to the collection of content-type in network request feature.
  • Added the few extensions to default blocklist and removed remote_config.json from blocklist.
  • Enforcing to use FMDB 2.7.5 version.

NOTE: For customers who doesn't want to track remote_config.json, please update your remote config by adding remote_config.json into the blocklist

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics