Swiftpack.co - reelevant-tech/analytics-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by reelevant-tech.
reelevant-tech/analytics-ios v1.0.1
📱 iOS SDK to send tracking events to Reelevant
⭐️ 0
🕓 7 weeks ago
.package(url: "https://github.com/reelevant-tech/analytics-ios.git", from: "v1.0.1")

Reelevant Analytics SDK for iOS

This Swift package could be used to send tracking events to Reelevant datasources.

How to use

You need to have a datasourceId and a companyId to be able to init the SDK and start sending events:

let config = ReelevantAnalytics.Configuration(companyId: "<company id>", datasourceId: "<datasource id>")
let sdk = ReelevantAnalytics.SDK(configuration: config)

// Generate an event
let event = ReelevantAnalytics.Event.page_view(labels: [:])
// Send it
sdk.send(event: event)

Current URL

When a user is browsing a page you should call the sdk.setCurrentURL method if you want to be able to filter on it in Reelevant.

User infos

To identify a user, you should call the sdk.setUser("<user id>") method which will store the user id in the device and send it to Reelevant.


Each event type allow you to pass additional infos via labels (Dictionary<String, String>) on which you'll be able to filter in Reelevant.

let event = ReelevantAnalytics.Event.add_cart(ids: ["my-product-id"], labels: ["lang": "en_US"])


The package is also compatible with objective-c apps:

#import "ViewController.h"
@import ReelevantAnalytics;

@interface ViewController ()


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

- (IBAction)myAction:(id)sender {
    Configuration *config = [[Configuration alloc] initWithCompanyId:@"foo" datasourceId:@"bar"];
    SDK *sdk = [[SDK alloc] initWithConfiguration:config];
    Event *event = [EventBuilder page_viewWithLabels:[[NSMutableDictionary alloc] init]];
    [sdk sendWithEvent:event];


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