Mobile SDKsConfiguration

Configuration

All Datafly mobile SDKs share the same configuration options.

Configuration options

OptionTypeDefaultDescription
pipelineKeyStringRequiredPipeline key from your source configuration
endpointStringRequiredYour Ingestion Gateway URL (e.g., https://data.example.com)
flushIntervalNumber30Seconds between automatic flushes
flushThresholdNumber20Number of events queued before automatic flush
maxQueueSizeNumber1000Maximum events stored in local SQLite queue
sessionTimeoutNumber1800Seconds of inactivity before starting a new session (30 min)
trackAppLifecycleBooleantrueAuto-track install, update, open, and background events
debugBooleanfalseEnable debug logging

iOS

let config = DataflyConfig(
    pipelineKey: "dk_live_abc123",
    endpoint: "https://data.example.com",
    flushInterval: 15,
    flushThreshold: 10,
    maxQueueSize: 5000,
    sessionTimeout: 900,          // 15 minutes
    trackAppLifecycle: true,
    debug: false
)
Datafly.shared.initialize(config: config)

Android

val config = DataflyConfig(
    pipelineKey = "dk_live_abc123",
    endpoint = "https://data.example.com",
    flushIntervalSeconds = 15,
    flushThreshold = 10,
    maxQueueSize = 5000,
    sessionTimeoutSeconds = 900,
    trackAppLifecycle = true,
    debug = false
)
Datafly.initialize(context, config)

React Native

DataflySignal.initialize({
  pipelineKey: 'dk_live_abc123',
  endpoint: 'https://data.example.com',
  flushInterval: 15,
  flushThreshold: 10,
  maxQueueSize: 5000,
  sessionTimeout: 900,
  trackAppLifecycle: true,
  debug: false,
});

Flutter

await DataflySignal.initialize(DataflyConfig(
  pipelineKey: 'dk_live_abc123',
  endpoint: 'https://data.example.com',
  flushInterval: 15,
  flushThreshold: 10,
  maxQueueSize: 5000,
  sessionTimeout: 900,
  trackAppLifecycle: true,
  debug: false,
));

.NET MAUI

DataflySignal.Initialize(new DataflyConfig
{
    PipelineKey = "dk_live_abc123",
    Endpoint = "https://data.example.com",
    FlushInterval = 15,
    FlushThreshold = 10,
    MaxQueueSize = 5000,
    SessionTimeout = 900,
    TrackAppLifecycle = true,
    Debug = false
});

Endpoint URL

The endpoint should be your Ingestion Gateway URL. This is the same endpoint used by the web SDK (Datafly.js):

https://data.example.com

The SDK appends /v1/batch for event delivery. Ensure your Ingestion Gateway is accessible from mobile networks (not just your internal network).

⚠️

Do not include a trailing slash in the endpoint URL. The SDK normalises the endpoint by stripping trailing slashes automatically.

Pipeline key

The pipeline key identifies which source this data belongs to. Create a separate source in the management UI for each mobile app (or use the same source as your web property if you want unified data).

Pipeline keys follow the format: dk_live_ or dk_test_ followed by a random string.

Debug mode

When debug is enabled:

  • iOS: Logs to the Xcode console via os.log (subsystem: com.datafly.signal)
  • Android: Logs to Logcat with tag DataflySignal

You can also attach a callback to inspect events before they are queued:

// iOS
Datafly.shared.onEvent = { event in
    print("Event: \(event)")
}
 
// Android
Datafly.onEvent = { event ->
    Log.d("Datafly", "Event: $event")
}

Disable debug mode in production builds to avoid unnecessary logging overhead.