Git Product home page Git Product logo

suryatmodulus / rudder-sdk-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isabella232/rudder-sdk-swift

0.0 1.0 0.0 93 KB

Repo for RudderStack's iOS/tvOS SDK. RudderStack is an open-source, warehouse-first Customer Data Pipeline and Segment-alternative. It collects and routes clickstream data and builds your customer data lake on your data warehouse.

License: MIT License

Swift 97.20% Ruby 0.78% Objective-C 0.83% Shell 1.19%

rudder-sdk-swift's Introduction

The Customer Data Platform for Developers

Website · Documentation · Community Slack


RudderStack iOS SDK

RudderStack's iOS SDK lets you track event data from your iOS, tvOS, watchOS and macOS applications. After integrating the SDK, you will also be able to send these events to your preferred destinations such as Google Analytics, Amplitude, and more.

For detailed documentation on the iOS SDK, click here.

Installing the iOS SDK

The iOS SDK is available through CocoaPods, Carthage, and Swift Package Manager (SPM).

CocoaPods

To install the SDK, simply add the following line to your Podfile:

pod 'RudderStack', '1.0.0-beta.3'

Carthage

For Carthage support, add the following line to your Cartfile:

github "rudderlabs/rudder-sdk-swift" "v1.0.0-beta.3"

Remember to include the following code where you want to refer to or use the RudderStack SDK classes, as shown:

Objective C
@import RudderStack;
Swift
import RudderStack

Swift Package Manager (SPM)

You can also add the RudderStack iOS SDK via Swift Package Mangaer, via one of the following two ways:

Xcode

  • Go to File - Add Package, as shown:

Adding a package

  • Enter the package repository ([email protected]:rudderlabs/rudder-sdk-swift.git) in the search bar.

  • In Dependency Rule, select Up to Next Major Version and enter 1.0.0-beta.3 as the value, as shown:

Setting dependency

  • Select the project to which you want to add the package.

  • Finally, click on Add Package.

Swift

To leverage package.swift, use the following snippet in your project:

// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "RudderStack",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "RudderStack",
            targets: ["RudderStack"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "[email protected]:rudderlabs/rudder-sdk-swift.git", from: "1.0.0-beta.3")
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "RudderStack",
            dependencies: [
                .product(name: "RudderStack", package: "rudder-sdk-swift")
            ]),
        .testTarget(
            name: "RudderStackTests",
            dependencies: ["RudderStack"]),
    ]
)

Initializing the RudderStack client

To the initialize RSClient, place the following code in your AppDelegate file under the method didFinishLaunchingWithOptions:

Objective C

RSConfig *config = [[RSConfig alloc] initWithWriteKey:WRITE_KEY];
[config dataPlaneURL:DATA_PLANE_URL];
[config recordScreenViews:YES];
RSClient *client = [[RSClient alloc] initWithConfig:config];

Swift

let config: RSConfig = RSConfig(writeKey: WRITE_KEY)
            .dataPlaneURL(DATA_PLANE_URL)
            .loglevel(.debug)
            .trackLifecycleEvents(true)
            .recordScreenViews(true)
let client = RSClient(config: config)

Sending Events

Track

Objective C
[client track:@"sample_track_call" properties:NULL option:NULL];
[client track:@"sample_track_call" properties:@{
    @"key_1" : @"value_1",
    @"key_2" : @"value_2"
} option:NULL];

Swift

client.track("sample_track_call")
client.track("sample_track_call", properties:[
    "key_1" : "value_1",
    "key_2" : "value_2"
])

Screen

Objective C
[client screen:@"Main" properties:@{@"prop_key" : @"prop_value"} option:NULL];

Swift

client.screen("Main", properties:["prop_key" : "prop_value"]);

Identify

Objective C
[client identify:@"test_user_id" traits:@{
    @"foo": @"bar",
    @"foo1": @"bar1",
    @"email": @"[email protected]"
} option:NULL];

Swift

client.identify("test_user_id", traits:[
    "foo": "bar",
    "foo1": "bar1",
    "email": "[email protected]"
])

Group

Objective C
[client group:@"sample_group_id" traits:@{
    @"foo": @"bar", 
    @"foo1": @"bar1", 
    @"email": @"[email protected]"
} option:NULL];

Swift

client.group("sample_group_id" traits:[
    "foo": "bar", 
    "foo1": "bar1", 
    "email": "[email protected]"
])

Alias

Objective C
[client alias:@"new_user_id" option:NULL];

Swift

client.alias("new_user_id")

Reset

Objective C
[client reset];

Swift

client.reset()

For detailed documentation on the iOS SDK, click here.

Contribute

We would love to see you contribute to this project. Get more information on how to contribute here.

About RudderStack

RudderStack is a customer data platform for developers. Our tooling makes it easy to deploy pipelines that collect customer data from every app, website and SaaS platform, then activate it in your warehouse and business tools.

More information on RudderStack can be found here.

Contact us

For more information on using the RudderStack iOS SDK, you can contact us or start a conversation on our Slack channel.

rudder-sdk-swift's People

Contributors

pallabmaiti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.