Skip to main content

realm.history

Hivekit persists every update to every object, area, or instruction. You can access this history via the realm.history API.

This makes it easy to draw routes onto a map, see events leading up to an accident or analyze bottlenecks in your operation.

Methods

realm.history.get(id, settings)

Returns the location and data history for a given object between two timestamps

  • id a unique identifier for this instruction within its realm
  • settings.startTime JavaScript Date object for the earliest time for which the history should be retrieved
  • settings.endTime JavaScript Date object for the latest time for which the history should be retrieved
  • Returns Promise array of historic object states
// Get the location history for rider 14 for the last 15 minutes
const history = await realm.history.get('rider/14', {
startTime: new Date(Date.now() - 900000),
endTime: new Date()
})

// history is now
[
{
time: '2023-03-31T09:18:41.448224Z',
location: {
longitude: 13.374626723959496,
latitude: 52.53726153283097,
accuracy: 0,
speed: 5.34,
heading: 262,
altitude: 14,
altitudeAccuracy: 0
},
data: { batteryCharge: 0.88 }
},
{
time: '2023-03-31T09:18:45.432224Z',
location: {
longitude: 13.403033576624107,
latitude: 52.54032623701426,
accuracy: 0,
speed: 5.12,
heading: 182,
altitude: 22,
altitudeAccuracy: 0
},
data: { batteryCharge: 0.86 }
},
//...
]