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.5
Conviva iOS App Analytics
⭐️ 0
🕓 2 weeks ago
iOS tvOS
.package(url: "https://github.com/Conviva/conviva-ios-appanalytics.git", from: "0.2.5")

conviva-ios-appanalytics

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

Initialization

  • SPM

  • Cocoapods

    • Add below line in pods file
      • pod 'ConvivaAppAnalytics', '0.2.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.7 or above)
    • 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: "<YOUR_CUSTOMER_KEY_ADVISED_BY_Conviva>", appName: "<YOUR_APP_NAME_ADVISED_BY_Conviva>")
//ObjC

CATTracker *tracker = [CATAppAnalytics createTrackerWithCustomerKey:@"<YOUR_CUSTOMER_KEY_ADVISED_BY_Conviva>" appName:@"<YOUR_APP_NAME_ADVISED_BY_Conviva>"];

Set the user id (viewer id)

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:

let data = "{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}"
self.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.

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

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.

// Setter API

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

// Usage
NSDictionary* tags = @{
    @"Key1": @"Value1",
    @"Key2": @"Value2",
};
[self.tracker setCustomTags:tags];

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

// Usage
[self.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;

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

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.

GitHub

link
Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Release 0.2.5
2 weeks ago
  • Support to capture the playback events automatically from ConvivaSDK and reporting to AppAnalytics. If customer does not use ConvivaSDK for Experience Insights/Ad Insights, there is no impact on the event collection and everything else should work seamlessly.

Note: To enable automatic collection of playback events, ConvivaSDK 4.0.32 or above must be used. 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.4 or above

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