Skip to Content
truemetrics Docs

SDK integration

Metadata

The events your app logs with the truemetrics SDK: when to send them, every field and extra key, and the rules.

Metadata links truemetrics’ stops, parking places and entrances to your deliveries and addresses. Your app logs one event per delivery or pickup attempt with logMetadata (Flutter: logStandardMetadata). This page is the reference for its fields and keys; the agent prompt uses the same names.

When to send

  • One event per delivery attempt, whatever the outcome: successful, failed, rejected, handed to a neighbor or put in a parcel locker. The outcome goes into extra.delivery_state.
  • Send it when the driver finalizes the attempt in the app: the final scan, the confirm button, the signature or photo capture completing, or a failure reason being selected. Hook in at the single place in code where the attempt reaches its final state, not in a button that can be pressed several times.
  • Do not send on intermediate steps (opening the stop, starting a scan), and not again when the driver edits the result.
  • A later attempt at the same address, e.g. after a failed first try, is a new attempt with its own event.
  • Several parcels for the same address delivered together: one event, with all parcel IDs in extra.parcel_id.
  • Pickups follow the same rules with eventType pickup.

Log at the moment of the driver’s action, from the code that first saves it on the device, also when offline: the SDK buffers and uploads by itself. Never log from a server-sync callback. truemetrics places an event in the recording by the time logMetadata is called, and for some accounts the SDK uploads only the sensor data around that time (upload modes). If logging can only happen later, put the time of the action in eventTime.

Several events per attempt (e.g. one at the scan and one at the confirmation) only as an exception agreed with truemetrics. Each event then carries extra.type_trigger (e.g. scan_performed, job_finalized), so the events are not counted as several deliveries.

When the SDK is not ready

The SDK drops metadata logged before it is ready, e.g. right after init(). It is ready from the first Initialized, RecordingInProgress, RecordingStopped, DelayedStart, TrafficLimitReached, ReadingsDatabaseFull or AskForPermissions status after each init() (Flutter: also any onPermissionsRequired call) until deinitialize().

Build each event, eventTime included, when the driver acts. While the SDK is not ready, or while older events are still waiting, append it to a queue in local storage (a file or preferences of your own). Once the SDK is ready, send the queue in order, then log directly. Keep the newest 100 events; when trimming, never drop a planned_sequence event. Keep the queue across logout; it is sent after the next init().

Example

import io.truemetrics.truemetricssdk.TruemetricsSdk
import io.truemetrics.truemetricssdk.metadata.StandardMetadata

TruemetricsSdk.getInstance().logMetadata(
    StandardMetadata(
        eventTime = "2026-01-15T14:30:00+01:00",
        eventType = "delivery",
        deliveryId = "D-123",
        tourId = "T-456",
        waypointLatitude = "52.5200",
        waypointLongitude = "13.4050",
        referenceLatitude = "52.5201",
        referenceLongitude = "13.4051",
        address = "Pflanzstrasse 5, 10762 Berlin",
        extra = mapOf(
            "address_id" to "A-789",
            "task_id" to "T321",
            "parcel_id" to "P-1,P-2",
            "delivery_state" to "success",
            "delivered_to_neighbor" to "false",
            "eta_first" to "2026-01-15T14:10:00+01:00",
            "eta_latest" to "2026-01-15T14:25:00+01:00",
            "depot_id" to "BER-1",
            "vehicle_type" to "van",
        ),
    )
)

The Java form is on Android Native. The map-based logMetadata(Map<String, String>) is deprecated.

Standard fields

All values are strings. On Android every field is optional in code (SDK 1.6.0 and newer): an omitted field is uploaded as an empty string. In Flutter all nine are required: pass '' for unknown ones.

Field (wire key)LevelContent
eventTime (t_event)RequiredWhen the driver acted, ISO 8601 with a UTC offset or Z, e.g. 2026-01-15T14:30:00+01:00 or 2026-01-15T13:30:00Z. The SDK sends the string as it is; a time without offset cannot be placed in UTC.
eventType (type_event)Requireddelivery or pickup. Also planned_sequence (below) and integration_test (Verify).
deliveryId (id_delivery_external)RequiredYour delivery ID.
tourId (id_tour)RequiredRoute or tour ID.
waypointLatitude, waypointLongitude (lat_waypoint_external, lon_waypoint_external)RecommendedThe waypoint: the street coordinate the courier is routed to, as your routing system and the courier’s navigation use it. Typically a street projection from Google Maps or your own system.
referenceLatitude, referenceLongitude (lat_reference_external, lon_reference_external)RecommendedThe reference: where you believe the delivery is done, i.e. the destination building. Typically a rooftop coordinate from your address system or geocoder.
address (address_raw)RecommendedThe address as one string, normalized if available.
extraFurther keys, below. An extra key equal to one of the wire keys above is ignored.

Extra keys

KeyLevelContent
address_idRequiredHighest priority. Your stable identifier of the address. truemetrics returns parking places and entrances keyed by this ID.
delivery_stateRequiredsuccess, failed or special (e.g. delivered to neighbor, customer not home, parcel locker), plus your raw internal code.
delivered_to_neighborRequiredtrue if handed to a neighbor or to any address other than the recipient’s, else false. See Neighbor deliveries.
eta_first, eta_latestRequiredThe first planned ETA and the most recent updated ETA, ISO 8601. With only one ETA, send it in both.
depot_idRequiredThe depot or hub the route starts from, as your systems name it. On every event, also on planned_sequence.
Stop identifier, e.g. task_id, stop_id or parcel_idRequiredThe one identifier used per stop in the planned sequence, same key name and value.
parcel_idRecommendedParcel ID(s), comma-separated for several parcels.
neighbor_address, neighbor_address_idRecommendedFor a neighbor delivery, if known: the street address where it was handed over (not the neighbor’s name) and its ID.
service_typeRecommendedYour raw service code as it is, e.g. signature required, age check.
street, house_number, postal_code, cityRecommendedAddress parts, if your app has them separately.
vehicle_typeOptionalE.g. car, van, bike. Lets parking places be told apart by vehicle.
driver_id, driver_experience, …OptionalOther fields your systems use, e.g. for later analysis by category.
type_triggerExceptionOnly where agreed with truemetrics, see When to send.

Do not send recipient names, phone numbers or free-text notes.

Neighbor deliveries

Every delivery handed to a neighbor, or to any other address than the recipient’s (e.g. a nearby shop), must be marked with delivered_to_neighbor true. The courier stopped at a different building than the recipient’s, so truemetrics has to filter these events out; otherwise a wrong parking place or entrance is linked to the recipient’s address_id. If your app only has a status code for this, still send the flag and keep the code in delivery_state.

Planned sequence

Exactly once per route, when the route is actually started, log one dedicated event with the planned stops. It is never combined with a delivery event.

  • eventType planned_sequence, eventTime and tourId set, the other standard fields empty.
  • extra.planned_sequence: the planned stops in order, as a JSON array string, e.g. [{"seq":1,"task_id":"T321","eta":"2026-10-15T08:12:00Z"}, ...]. Per stop only seq, the one stop identifier and the planned eta (ISO 8601). The identifier uses the same key name and value as in the delivery events.
  • extra.stop_count and extra.depot_id.

Keep the event under 50 KB; a route of 100 to 200 stops is far below that. Metadata logged close together is uploaded as one piece, the upload limit is set per account and can be as low as 200 KB, and a piece above the limit is never uploaded. Do not split the sequence into several events.

Do not send it again on re-plans, app restarts or re-logins for the same route: keep a sent flag per tourId, set in the same step that logs or queues the event.

Templates and tags

The SDK can also build metadata step by step from templates and tags. The result is a plain map like the deprecated logMetadata(Map); for delivery events use StandardMetadata.

import io.truemetrics.truemetricssdk.TruemetricsSdk

val sdk = TruemetricsSdk.getInstance()

sdk.createMetadataTemplate("stop", mapOf("vehicle_type" to "van"))
sdk.createMetadataFromTemplate("current_stop", "stop")
sdk.appendToMetadataTag("current_stop", "address_id", "A-789")
sdk.logMetadataByTag("current_stop")
sdk.removeMetadataTag("current_stop")
MethodReturnsDescription
createMetadataTemplate(name, data)UnitCreate a template
getMetadataTemplate(name)Map<String, String>?A template by name
getMetadataTemplateNames()Set<String>All template names
removeMetadataTemplate(name)BooleanRemove a template
createMetadataFromTemplate(tag, template)BooleanCreate a tag from a template
appendToMetadataTag(tag, data)UnitAdd a map to a tag
appendToMetadataTag(tag, key, value)UnitAdd one key and value to a tag
getMetadataByTag(tag)Map<String, String>?The metadata of a tag
getMetadataTags()Set<String>All tags
logMetadataByTag(tag)BooleanLog a tag’s metadata
removeMetadataTag(tag)BooleanRemove a tag
removeFromMetadataTag(tag, key)BooleanRemove a key from a tag
clearAllMetadata()UnitRemove all templates and tags

On this page