Skip to content

Mobore/mobore-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Mobore iOS SDK -- Example App

A simple ecommerce demo app that showcases every feature of the Mobore iOS SDK.

Mobore docs

Getting Started

1. Get Your Client Token

  1. Sign up or log in at mobore.com
  2. Create a new project (or select an existing one)
  3. Navigate to Settings > Client Tokens
  4. Copy your client token

2. Configure the Token

Open mobore-example/mobore_exampleApp.swift and replace the placeholder token:

let agentConfig = MoboreAgentConfigBuilder()
    .withClientToken("YOUR_CLIENT_TOKEN_HERE")  // <-- paste your token
    .withEnvironment("development")
    .withSessionSampleRate(1.0)
    .build()

3. Build and Run

  1. Open mobore-example.xcodeproj in Xcode
  2. Wait for Swift packages to resolve (the SDK is linked as a local package from ../mobore-ios-sdk)
  3. Select a simulator or device and press Run

Telemetry will start flowing to your Mobore dashboard immediately.

What This App Demonstrates

App Entry (mobore_exampleApp.swift)

SDK Feature How It's Used
MoboreAgentConfigBuilder Full agent configuration with token, environment, sample rate, and span filters
MoboreInstrumentationConfigBuilder All 13 auto-instrumentations enabled with custom URL filtering
MoboreIosSdkAgent.start() SDK initialization -- one call activates everything
addGlobalAttribute() Sets app.demo=true on every span and log for the session

Shop Tab (ProductListView.swift)

SDK Feature How It's Used
.reportName("ProductList") Names the SwiftUI screen for view tracking
addLog() Logs "Product catalog loaded" with product count
addTiming() Measures catalog load time in milliseconds
addAction() Tracks quick_add_to_cart with product ID, name, and price
Auto: Tap Instrumentation Every "Add to Cart" button tap is captured with target and action

Product Detail (ProductDetailView.swift)

SDK Feature How It's Used
startView() / endCurrentView() Manual view tracking with custom URL mobore-example://products/<id>
setViewAttributes() Sets product.id, product.name, product.category on the view span
setViewAttribute() Sets product.price on the view span
addViewEvent() Records item_added event when user adds to cart
addAction() Tracks add_to_cart with quantity, total, category, and source
addTiming() Measures cart operation duration
addLog() Logs navigation to web content

Cart (CartView.swift)

SDK Feature How It's Used
.reportName("Cart") Names the screen for view tracking
addError() Reports error when user attempts checkout with empty cart
addAction() Tracks remove_from_cart on swipe-to-delete
addLog() Logs checkout initiation with cart total and item count

Checkout (CheckoutView.swift)

SDK Feature How It's Used
startView() / endCurrentView() Manual view tracking for the checkout flow
setViewAttribute() Sets checkout.cart_total on the view span
addLog(level: "debug") Debug log when checkout opens
addLog(level: "info") Logs payment processing start and order completion
addLog(level: "warn") Warns on payment failure
addError() Reports payment error with source and stack trace (toggle "Simulate payment error")
addAction() Tracks purchase_complete with order total and duration
addTiming() Measures total checkout duration from open to purchase
forceFlush() Immediately exports all telemetry after successful purchase

Profile (ProfileView.swift)

SDK Feature How It's Used
.reportName("Profile") Names the screen for view tracking
setUser() Sets user identity (user.id, user.name, user.email)
addGlobalAttribute() Sets app.theme attribute
addGlobalAttributes() Sets locale, timezone, and screen scale in one call
removeGlobalAttribute() Removes the app.theme attribute
addAction() Tracks login action
addLog() Logs sign-in and attribute changes
Auto: Network Instrumentation "Fetch Sample Data" makes a real HTTP request to httpbin.org/json -- automatically traced
addError() Reports network fetch errors
forceFlush() Manual flush button for immediate export

Web Content (WebContentView.swift)

SDK Feature How It's Used
startView() / endCurrentView() Manual view tracking for the web content sheet
addLog() Logs WebView open event
Auto: WebView Instrumentation WKWebView navigation to example.com is automatically traced (request, start, finish, error)

Always Running (Auto-Instrumentation)

These features require zero code and run in the background:

Feature What It Captures
Crash Reporting Native crashes with symbolicated stack traces (PLCrashReporter)
App Hang Detection Main thread blocks >2 seconds
Lifecycle Events App state transitions: active, inactive, background, foreground, terminate
System Metrics CPU usage and memory footprint gauges
App Metrics MetricKit launch times, hang histograms, and exit counters
Low Power Mode Power state changes
App Exit Handling Flushes all telemetry on termination/background
Session Usage Active screen time with 90-second inactivity threshold
Session Management 30-minute session timeout with automatic rotation
NTP Clock Sync Accurate timestamps via Kronos NTP

Project Structure

mobore-example/
  mobore_exampleApp.swift   -- SDK init with full config
  ContentView.swift         -- Tab navigation (Shop / Cart / Profile)
  Models.swift              -- Product and CartItem data models
  AppStore.swift            -- Observable cart state
  ProductListView.swift     -- Product grid with quick-add
  ProductDetailView.swift   -- Product detail with manual view tracking
  CartView.swift            -- Shopping cart with error reporting
  CheckoutView.swift        -- Checkout flow with timing and flush
  ProfileView.swift         -- User identity and network demo
  WebContentView.swift      -- WKWebView instrumentation demo

Requirements

  • Xcode 15.0+
  • iOS 16.0+

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages