B2Metric Analytics · v1.0.0

Behavioral analytics for your iOS app, in minutes.

A lightweight Swift SDK that captures every event, screen and session — then streams it into B2Metric IQ for funnels, retention and churn prediction.

iOS 13.0+Swift 5.0+Xcode 12.0+
AppDelegate.swift
import UIKit
import B2MetricAnalyticsSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions:
      [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    B2MetricAnalytics.shared.logLevel = .debug

    B2MetricAnalytics.shared.start(
      apiKey: "YOUR_API_KEY",
      batchSize: 20,
      flushInterval: 30
    )
    return true
  }
}
SDK initialized — events start flowing
LIVE · B2Metric SDK

Event stream

app_opened
AUTO
screen_viewed
Home
AUTO
product_viewed
SKU-123
LOG
add_to_cart
$299.99
LOG
purchase_completed
ORD-789
LOG

Quick start

From zero to first event in three steps

Install with Swift Package Manager, initialize on launch, and log your first event.

Package.swift
// Xcode → File → Add Packages…
// Paste the repository URL, pick a version,
// then add B2MetricAnalyticsSDK to your app target.

dependencies: [
  .package(
    url: "https://github.com/b2metric",
    from: "1.0.0"
  )
]
Add via Swift Package Manager

Capabilities

Everything you need to understand mobile behavior

One install captures the full picture — automatic baselines plus precise, typed events you control.

Core

Track Events

Capture how users interact with your app.

Log custom events with a single call. Attach typed properties — strings, numbers, booleans, dates — through AnyCodable for full context.

Automatic Event Tracking

Sessions and lifecycle, instrumented for you.

App opens, sessions and lifecycle moments are captured out of the box — no manual instrumentation required to get a baseline of behavior.

Screen Tracking

See the path users take, screen by screen.

Record screen views to reconstruct navigation flows and feed funnel, retention and user-flow reports inside B2Metric IQ.

Push Notification Tracking

Measure delivery, opens and impact.

Attribute notification deliveries and opens to downstream behavior so campaign performance is measurable end to end.

Performance

Event Batching & Flushing

Battery- and network-friendly by design.

Events are buffered and sent in batches on a configurable interval. Tune batchSize and flushInterval to balance freshness against efficiency.

Debug Mode

Verify your integration in real time.

Switch logLevel to .debug to stream every event and network call to the console, then flip to .off for production builds.

Configuration

Tuned for development. Hardened for production.

Three parameters control everything. Send events instantly while debugging, then batch for battery and network efficiency in release builds.

ParameterDefaultType
apiKeyREQUIRED
Your B2Metric API key. Must be non-empty.
String
batchSize
Number of events to batch before sending.
20Int
flushInterval
Time in seconds between automatic flushes.
30TimeInterval
String "value"Int, Double 42, 3.14Bool true, falseDate Date()
Development · AppDelegate.swift
B2MetricAnalytics.shared.logLevel = .debug
B2MetricAnalytics.shared.start(
  apiKey: "YOUR_DEV_API_KEY",
  batchSize: 1,       // send immediately
  flushInterval: 5
)

Event payload

Rich context, attached automatically

Call logEvent with a name and typed properties — the SDK enriches every payload before it leaves the device.

  • Each event carries a unique id and ISO timestamp.
  • Your properties pass through with full type fidelity via AnyCodable.
  • user_properties — device, OS, app version, locale — are added for you.
product_viewed · payload.json
{
  "api_key": "sdk_xxxxxxxxxxxxxxxx",
  "body": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "type": "product_viewed",
    "timestamp": "2026-02-18T07:45:02.552Z",
    "properties": {
      "product_id": "SKU-123",
      "product_name": "Running Shoes",
      "category": "Footwear",
      "price": 299.90
    },
    "user_properties": {
      "app_version": "1.0.0",
      "device_model": "iPhone 15 Pro",
      "os_version": "17.2",
      "platform": "iOS",
      "country_code": "TR",
      "timezone": "Europe/Istanbul"
    }
  }
}
$ swift package resolvelogEvent("purchase_completed")

Ship your first insight today.

Add the package, paste your API key, and watch events arrive in B2Metric IQ in real time.