Docs

Events

Report sign ups, purchases and other conversions with Lander.trackEvent, backed by an offline queue.

App user IDs

Setting an app user ID with Lander.setUserId is currently supported in Flutter 0.4.0 and later. This SDK version does not expose that method; its events continue to use the SDK installation ID.

Installs and opens are recorded for you. Use Lander.trackEvent for the things that happen after: a sign up, a purchase, a completed onboarding. Pass the linkId of the link that brought the user in, and the conversion is attributed to that link.

Track an event

Lander.trackEvent(
  "purchase",
  properties: ["productId": "123", "amount": 49.99, "currency": "USD"],
  linkId: link?.linkId // optional: the LanderLink that opened this screen
)
static func trackEvent(
  _ name: String,
  properties: [String: any Sendable] = [:],
  linkId: String? = nil
)

Prop

Type

trackEvent is fire and forget: it is not async, does not throw, and returns at once. The event is validated on the spot, given an ID and a timestamp, and handed to the on device queue. You can call it before Lander.initialize; such events are queued once the SDK starts.

What Lander records without you

EventWhenSent by
InstallThe first launch report of a new install IDLander.initialize (POST /v1/sdk/init)
OpenEach time a link opens the app and the SDK resolves itThe resolve call (POST /v1/sdk/resolve)
Handoff openA successful claimHandoffThe claim call

Do not track these yourself, or they will be counted twice.

linkId is only known while you have the LanderLink. Pass the link along to the screen it opened and use it there:

ProductView.swift
struct ProductView: View {
  let id: String
  let link: LanderLink?

  var body: some View {
    Button("Buy") {
      Lander.trackEvent(
        "purchase",
        properties: ["productId": id, "amount": 49.99, "currency": "USD"],
        // Attribute the purchase to the link that opened this screen, if any.
        linkId: link?.linkId
      )
    }
  }
}

If the conversion happens later (a sign up a few screens or days after the link), keep the linkId yourself, for example in your app state or UserDefaults, and pass it when the event happens. Unresolved links have no linkId; passing nil simply records the event without a link.

How the queue works

Events go to a queue on the device first, then to POST /v1/sdk/events in batches:

  • Batched. A flush runs about 2 seconds after an event (so bursts go out together), when the app goes to the background, and on the next launch. Each request carries up to 100 events.
  • Finishes in the background. When the app moves to the background, the SDK starts a UIKit background task so the flush can complete, and ends it as soon as the flush is done.
  • Survives offline and restarts. The queue is stored in a file in Application Support, excluded from backups. Up to 1000 events are kept; beyond that the oldest are dropped.
  • Waits for the install. Lander rejects events from installs it does not know, so events wait until the first launch report has succeeded, then go out.
  • Retries with backoff. A failed batch is retried after 1 second, doubling up to 5 minutes, with jitter. A longer Retry-After from the API is honored.
  • Counted once. Every event carries a client generated UUID, so a batch sent twice (for example after a lost response) is deduplicated by Lander.
  • Never stuck. A batch the API rejects as invalid is dropped so it cannot block the queue. An auth error (401 or 403) pauses sending until the next launch and keeps the events.

Each event is stored with the time it happened (occurredAt, UTC with milliseconds), so a purchase made offline on Monday and sent on Tuesday is still dated Monday.

Invalid events

Because trackEvent does not throw, an invalid event is dropped and never sent, with a warning in the log (written even when enableLogging is off, so you see it in the Xcode console). One bad event would otherwise make the API reject its whole batch. An event is invalid when:

  • name is empty or longer than 100 characters.
  • linkId is not a UUID.
  • properties contains something that cannot be sent as JSON, such as a Date, a URL or a custom type. Convert those first, for example ISO8601DateFormatter().string(from: date) or url.absoluteString.

The warning looks like [Lander] Dropped event "purchase": trackEvent: linkId must be a Lander link ID (UUID).

Network and server errors never surface from trackEvent; the queue deals with those.

See your events

Open Live events in the dashboard to watch app events arrive as you test. It refreshes every 5 seconds.

Next steps

On this page