Custom metadata
If your use case requires it, it is possible to add your own data in the trip analysis request. For example, it can be data that is specific to your trip, application or user identification system.
Metadata is persisted, so if you want to send it only for one trip, you need to remove it at the end of the trip, on the sdkStateChanged(state: State)callback, by checking if state is INACTIVE.

Set metadata

You can add additional metadata to your trip by calling the following method:
Kotlin
Java
1
val metaData = hashMapOf<String, String>()
2
metaData["yourKey"] = "yourValue"
3
DriveKitTripAnalysis.setTripMetaData(metaData)
Copied!
1
final HashMap<String, String> metaData = new HashMap<>();
2
metaData.put("yourKey", "yourValue");
3
DriveKitTripAnalysis.INSTANCE.setTripMetaData(metaData);
Copied!
The metadata must be represented as a key/value object where the key and value have a String type.
The metadata can be set any time before the end of a trip.
If metadata is sent, it will also be added to the push data request in the metaData field.

Get metadata

It is possible to get a copy of configured metadata thanks to the following method on DriveKitTripAnalysis:
Kotlin
Java
1
DriveKitTripAnalysis.getTripMetaData()
Copied!
DriveKitTripAnalysis.INSTANCE.getTripMetaData();
Note: Any modification on the returned object has no effect on the metadata sent with a trip.

Update metadata

To update a value in metadata, call the following method:
Kotlin
Java
1
DriveKitTripAnalysis.updateTripMetadata(“yourKey”, “newValue”)
Copied!
DriveKitTripAnalysis.INSTANCE.updateTripMetadata(“yourKey”, “newValue”);

Delete a specific metadata

To delete a specific value in metadata, call the following method:
Kotlin
Java
1
DriveKitTripAnalysis.deleteTripMetadata(“yourKey”)
Copied!
1
DriveKitTripAnalysis.INSTANCE.deleteTripMetadata(“yourKey”)
Copied!

Delete all metadata

To delete all values in metadata, call this method:
Kotlin
Java
1
DriveKitTripAnalysis.deleteTripMetadata()
Copied!
1
DriveKitTripAnalysis.INSTANCE.deleteTripMetadata();
Copied!