Skip to content
Nuxie
Esc
navigateopen⌘Jpreview
On this page

Configuration

Initialize the SDK with your API key and environment settings

Initialize the SDK at app launch with your API key and configuration options. Call setup(with:) once, as early as possible – typically in your AppDelegate.application(_:didFinishLaunchingWithOptions:) or your SwiftUI App.init().

Minimal setup

import Nuxie

let config = NuxieConfiguration(apiKey: "your_api_key")
try NuxieSDK.shared.setup(with: config)

Find your API key in the Nuxie dashboard under Settings > API Keys.

The SDK is ready to use after setup(with:) returns. Behind the scenes, it starts asynchronous tasks to fetch your profile, initialize the event system, and begin listening for StoreKit transactions.

Full setup example

import Nuxie

let config = NuxieConfiguration(apiKey: "your_api_key")

// Environment
config.environment = .production

// Logging
config.logLevel = .debug
config.enableConsoleLogging = true
config.redactSensitiveData = true

// Event batching
config.flushAt = 20
config.flushInterval = 30
config.maxQueueSize = 1000

// Identity
config.eventLinkingPolicy = .migrateOnIdentify

// Locale override
config.localeIdentifier = "es_ES"

// Privacy
config.propertiesSanitizer = DefaultPropertiesSanitizers.privacy
config.beforeSend = { event in
    // Drop internal debug events
    if event.name.hasPrefix("debug_") { return nil }
    return event
}

// Purchases
config.purchaseDelegate = MyPurchaseDelegate()

try NuxieSDK.shared.setup(with: config)

Configuration options

Core

Property Type Default Description
apiKey String Required Your Nuxie API key.
environment Environment .production Target environment. Changing this updates apiEndpoint automatically unless you set a custom endpoint.
apiEndpoint URL https://i.nuxie.ai Override the API endpoint for custom deployments.
isDebugMode Bool false Bypass caches for flow and profile fetches during development.

Environments

Environment Endpoint
.production https://i.nuxie.ai
.staging https://staging-i.nuxie.io
.development https://dev-i.nuxie.io
.custom Set apiEndpoint manually.

Logging

Property Type Default Description
logLevel LogLevel .warning Minimum log level. Options: .verbose, .debug, .info, .warning, .error, .none.
enableConsoleLogging Bool true Print log output to the console.
enableFileLogging Bool false Write logs to a file on disk.
redactSensitiveData Bool true Mask API keys and distinct IDs in log output.

Event batching

Property Type Default Description
eventBatchSize Int 50 Maximum events per network batch.
flushAt Int 20 Number of queued events that triggers an automatic flush.
flushInterval TimeInterval 30 Seconds between automatic flushes.
maxQueueSize Int 1000 Maximum events held in the network queue. Oldest events are dropped when full.

Identity

Property Type Default Description
eventLinkingPolicy EventLinkingPolicy .migrateOnIdentify Controls whether locally stored events are reassigned from the anonymous ID to the identified ID on identify(). Options: .migrateOnIdentify, .keepSeparate.

Locale

Property Type Default Description
localeIdentifier String? nil Override the device locale for profile requests (e.g., "es_ES"). When nil, the SDK uses Locale.current.identifier. Call refreshProfile() after changing this value.

Privacy

Property Type Default Description
propertiesSanitizer NuxiePropertiesSanitizer? nil A custom sanitizer applied to event properties before storage and delivery. The SDK includes built-in sanitizers: DefaultPropertiesSanitizers.privacy, .compliance, and .debug.
beforeSend ((NuxieEvent) -> NuxieEvent?)? nil A hook called before each event is stored and sent. Return nil to drop the event entirely, or return a modified event.

Purchases

Property Type Default Description
purchaseDelegate NuxiePurchaseDelegate? nil Handles purchase and restore requests from flows. Required if your flows contain purchase actions. See Purchases.

Plugins

Property Type Default Description
enablePlugins Bool true Enable the plugin system.
plugins [NuxiePlugin] [AppLifecyclePlugin()] Plugins installed during setup. The AppLifecyclePlugin is included by default and tracks $app_installed, $app_updated, $app_opened, and $app_backgrounded.

Setup behavior

When you call setup(with:), the SDK performs these steps synchronously:

  1. Validates the API key.
  2. Registers the configuration.
  3. Configures the logger.
  4. Starts the app lifecycle coordinator.
  5. Installs and starts plugins (if enabled).

It also launches background tasks for:

  • Initializing the event storage and network queue.
  • Restoring persisted campaign journeys.
  • Fetching the initial profile from the edge.
  • Syncing feature access to the SwiftUI observable.
  • Listening for StoreKit 2 transaction updates.

Tip: setup(with:) is intentionally one-shot. Calling it a second time logs a warning and returns without reconfiguring. If you need to change configuration, restart the app with the new settings.

Next steps

Last updated on July 23, 2026

Was this page helpful?