- Defined in:
Creates timestamps for events. Timestamps are counted in milliseconds since
the Unix epoch (
(Time.now.to_f * 1000).to_i).
Snowplow events accrue timestamps as they are processed. When an event is
first generated by a
dvce_created_tstamp in the processed event)
ttm ("true timestamp";
true_tstamp in the processed event). These two
timestamps are set using the Timestamp subclasses and
. The adds a
stm ("sent timestamp";
dvce_sent_tstamp) property to the event just before sending it to the
collector. These timestamps are all processed into UTC time.
Events can have either a device timestamp or a true timestamp, not both. By
#track_x_event methods create a DeviceTimestamp. In some
circumstances, the device timestamp may be inaccurate. There are three
methods to override the default device timestamp value when the event is
- Provide your own calculated timestamp, as a Num (e.g.
1633596554978), to the
#track_x_eventmethod. This will be converted into a DeviceTimestamp by the Tracker, and will still be recorded as
dtmin the event.
- Manually create a DeviceTimestamp (e.g.
SnowplowTracker::DeviceTimestamp.new(1633596554978)), and provide this to the
#track_x_eventmethod. This will still be recorded as
dtmin the event.
- Provide a TrueTimestamp object to the
SnowplowTracker::TrueTimestamp.new(1633596554978)). This will result in a
ttmfield in the event.
The timestamps that are added to the event once it has been emitted are not
the responsibility of this class. The collector receives the event and adds a
collector_tstamp. A later part of the pipeline adds the
the event enrichment has finished.
When DeviceTimestamp is used, a
derived_tstamp is also calculated and
added to the event. This timestamp attempts to take latency and possible
inaccuracy of the device clock into account. It is calculated by
collector_tstamp - (dvce_sent_tstamp - dvce_created_tstamp). When
TrueTimestamp is used, the
derived_stamp will be the same as
Direct Known Subclasses