Coder Social home page Coder Social logo

muhammetsahin / aptabase-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aptabase/aptabase-swift

0.0 0.0 0.0 11.51 MB

Swift SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps

Home Page: https://aptabase.com

License: MIT License

Ruby 3.59% Swift 96.41%

aptabase-swift's Introduction

Aptabase

Swift SDK for Aptabase

Instrument your apps with Aptabase, an Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps.

Install

Option 1: Swift Package Manager

Add the following lines to your Package.swift file:

let package = Package(
    ...
    dependencies: [
        ...
        .package(name: "Aptabase", url: "https://github.com/aptabase/aptabase-swift.git", from: "0.3.4"),
    ],
    targets: [
        .target(
            name: "MyApp",
            dependencies: ["Aptabase"] // Add as a dependency
        )
    ]
)

Option 2: Adding package dependencies with Xcode

Use this guide to add aptabase-swift to your project. Use https://github.com/aptabase/aptabase-swift for the URL when Xcode asks.

Option 3: CocoaPods

Aptabase is also available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Aptabase', :git => 'https://github.com/aptabase/aptabase-swift.git', :tag => '0.3.4'

Usage

If you're targeting macOS, you must first enable the Outgoing Connections (Client) checkbox under the App Sandbox section.

First, you need to get your App Key from Aptabase, you can find it in the Instructions menu on the left side menu.

Initialized the SDK as early as possible in your app, for example:

import SwiftUI
import Aptabase

@main
struct ExampleApp: App {
    init() {
        Aptabase.shared.initialize(appKey: "<YOUR_APP_KEY>") // ๐Ÿ‘ˆ this is where you enter your App Key
    }
    
    var body: some Scene {
        WindowGroup {
            MainView()
        }
    }
}

Afterward, you can start tracking events with trackEvent:

import Aptabase

Aptabase.shared.trackEvent("app_started") // An event with no properties
Aptabase.shared.trackEvent("screen_view", with: ["name": "Settings"]) // An event with a custom property

A few important notes:

  1. The SDK will automatically enhance the event with some useful information, like the OS, the app version, and other things.
  2. You're in control of what gets sent to Aptabase. This SDK does not automatically track any events, you need to call trackEvent manually.
    • Because of this, it's generally recommended to at least track an event at startup
  3. The trackEvent function is a non-blocking operation as it runs in the background.
  4. Only strings and numbers values are allowed on custom properties

Preparing for Submission to Apple App Store

When submitting your app to the Apple App Store, you'll need to fill out the App Privacy form. You can find all the answers on our How to fill out the Apple App Privacy when using Aptabase guide.

aptabase-swift's People

Contributors

ast3r10n avatar goenning avatar manucheri avatar mladjan 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.