You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/spec/common.md
+24-30Lines changed: 24 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ title: 'Spec: Common Fields'
4
4
5
5
In the Segment [Spec](/docs/connections/spec/) all the [API calls](/docs/connections/spec#api-calls) have a common structure, and a few common fields.
6
6
7
-
However, not all destinations accept all fields included in the Spec. Not sure which fields an destination accepts? Refer to the destination's documentation page, or check out the [open-source destination code on Github](https://github.com/segment-integrations).
7
+
However, not all destinations accept all fields included in the Spec. Not sure which fields a destination accepts? Refer to the destination's documentation page, or check out the [open-source destination code on Github](https://github.com/segment-integrations).
8
8
9
9
## Structure
10
10
Every API call has the same core structure and fields. These fields describe user identity, timestamping and mechanical aides like API version.
@@ -129,23 +129,23 @@ Context is a dictionary of extra information that provides useful context about
129
129
<td>`active`</td>
130
130
<td>Boolean</td>
131
131
<td>Whether a user is active
132
-
132
+
<br><br>
133
133
This is usually used to flag an `.identify()` call to just update the traits but not "last seen."
134
134
</td>
135
135
</tr>
136
136
<tr>
137
137
<td>`app`</td>
138
138
<td>Object</td>
139
139
<td>dictionary of information about the current application, containing `name`, `version` and `build`.
140
-
140
+
<br><br>
141
141
This is collected automatically from our mobile libraries when possible.
142
142
</td>
143
143
</tr>
144
144
<tr>
145
145
<td>`campaign`</td>
146
146
<td>Object</td>
147
147
<td>Dictionary of information about the campaign that resulted in the API call, containing `name`, `source`, `medium`, `term` and `content`.
148
-
148
+
<br><br>
149
149
This maps directly to the common UTM campaign parameters.
150
150
</td>
151
151
</tr>
@@ -187,9 +187,7 @@ Context is a dictionary of extra information that provides useful context about
187
187
<tr>
188
188
<td>`page`</td>
189
189
<td>Object</td>
190
-
<td>Dictionary of information about the current page in the browser, containing `hash`, `path`, `referrer`, `search`, `title` and `url`
191
-
192
-
Automatically collected by Analytics.js.
190
+
<td>Dictionary of information about the current page in the browser, containing `hash`, `path`, `referrer`, `search`, `title` and `url`. This is automatically collected by Analytics.js.
193
191
</td>
194
192
</tr>
195
193
<tr>
@@ -212,14 +210,14 @@ Context is a dictionary of extra information that provides useful context about
212
210
<td>`groupId`</td>
213
211
<td>String</td>
214
212
<td>Group / Account ID.
215
-
213
+
<br><br>
216
214
This is useful in B2B use cases where you need to attribute your non-group calls to a company or account. It is relied on by several Customer Success and CRM tools.</td>
217
215
</tr>
218
216
<tr>
219
217
<td>`traits`</td>
220
218
<td>Object</td>
221
219
<td>Dictionary of `traits` of the current user
222
-
220
+
<br><br>
223
221
This is useful in cases where you need to `track` an event, but also associate information from a previous `identify` call. You should fill this object the same way you would fill traits in an [identify call](/docs/connections/spec/identify/#traits).</td>
224
222
</tr>
225
223
<tr>
@@ -307,63 +305,59 @@ Every API call has four timestamps, `originalTimestamp`, `timestamp`, `sentAt` a
307
305
### Timestamp Overview
308
306
309
307
<table>
310
-
<colwidth="20%">
311
-
<colwidth="40%">
312
-
<colwidth="40%">
313
308
<tr>
314
309
<td>**Timestamp**</td>
315
310
<td>**Calculated**</td>
316
311
<td>**Description**</td>
317
312
</tr>
318
313
<tr>
319
-
<td>originalTimestamp</td>
314
+
<td>`originalTimestamp`</td>
320
315
<td>
321
316
Time on the client device when call was invoked
322
-
317
+
<br>
323
318
**OR**
324
-
319
+
<br>
325
320
The `timestamp` value manually passed in through server-side libraries.
326
321
</td>
327
322
<td>
328
323
Used by Segment to calculate `timestamp`.
329
-
330
-
**Note:** `originalTimestamp` is not useful for analysis since it's not always trustworthy as it can be easily adjusted and affected by clock skew.
331
-
</td>
324
+
<br><br>
325
+
**Note:** `originalTimestamp` is not useful for analysis since it's not always trustworthy as it can be easily adjusted and affected by clock skew.</td>
332
326
</tr>
333
327
<tr>
334
-
<td>sentAt</td>
328
+
<td>`sentAt`</td>
335
329
<td>
336
330
Time on client device when call was sent
337
-
331
+
<br>
338
332
**OR**
339
-
340
-
`sentAt` value manually passed in.
333
+
<br>
334
+
`sentAt` value manually passed in.
341
335
</td>
342
336
<td>
343
337
Used by Segment to calculate `timestamp`.
344
-
345
-
**Note:** `sentAt` is not useful for analysis since it's not always trustworthy as it can be easily adjusted and affected by clock skew</p>
338
+
<br><br>
339
+
**Note:** `sentAt` is not useful for analysis since it's not always trustworthy as it can be easily adjusted and affected by clock skew.
346
340
</td>
347
341
</tr>
348
342
<tr>
349
-
<td>receivedAt</td>
343
+
<td>`receivedAt`</td>
350
344
<td>time on Segment server clock when call was received</td>
351
345
<td>
352
346
Used by Segment to calculate `timestamp`, and used as sort key in Warehouses.
353
-
347
+
<br><br>
354
348
**Note:** For max query speed, `receivedAt` is the recommended timestamp for analysis when chronology does not matter as chronology is not ensured.
355
349
</td>
356
350
</tr>
357
351
<tr>
358
-
<td>timestamp</td>
352
+
<td>`timestamp`</td>
359
353
<td>
360
354
Calculated by Segment to correct client-device clock skew using the following formula:
361
-
355
+
<br>
362
356
`receivedAt` - (`sentAt` - `originalTimestamp`)
363
357
</td>
364
358
<td>
365
359
Used by Segment to send to downstream destinations, and used for historical replays.
366
-
360
+
<br><br>
367
361
**Note:** Recommended timestamp for analysis when chronology does matter.
368
362
</td>
369
363
</tr>
@@ -377,7 +371,7 @@ The `originalTimestamp` tells you when call was invoked on the client device or
377
371
**Note:** The `originalTimestamp` timestamp is not useful for any analysis since it's not always trustworthy as it can be easily adjusted and affected by clock skew.
378
372
379
373
380
-
### `sentAt`
374
+
### sentAt
381
375
382
376
The `sentAt` timestamp specifies the clock time for the client's device when the network request was made to the Segment API. For libraries and systems that send batched requests, there can be a long gap between a datapoint's `timestamp` and `sentAt`. Combined with `receivedAt`, we can use `sentAt` to correct the original `timestamp` in situations where a user's device clock cannot be trusted (mobile phones and browsers). The `sentAt` and `receivedAt` timestamps are assumed to occur at the same time (maximum a few hundred milliseconds), and therefore the difference is the user's device clock skew, which can be applied back to correct the `timestamp`.
0 commit comments