0.3.32
This commit is contained in:
@@ -20,6 +20,11 @@ const maxAnalyticsBatch = 200
|
||||
// nothing about what anyone was looking at.
|
||||
const maxDwellMs = 30 * 60 * 1000
|
||||
|
||||
// maxPositionMs clamps a pause/resume step's reported position. A title that long does
|
||||
// not exist, so a wilder value says the field was misread rather than that playback was
|
||||
// genuinely there.
|
||||
const maxPositionMs = 24 * 60 * 60 * 1000
|
||||
|
||||
type rowEventPayload struct {
|
||||
RowID string `json:"rowId"`
|
||||
RowKind string `json:"rowKind"`
|
||||
@@ -52,6 +57,9 @@ type journeyEventPayload struct {
|
||||
PlaySessionID string `json:"playSessionId"`
|
||||
Outcome string `json:"outcome"`
|
||||
OccurredAt string `json:"occurredAt"`
|
||||
// PositionMs is where playback was, in the title, on a pause or resume step. Absent
|
||||
// (zero) on every other kind of step.
|
||||
PositionMs int64 `json:"positionMs"`
|
||||
}
|
||||
|
||||
type journeyAnalyticsRequest struct {
|
||||
@@ -63,7 +71,7 @@ var journeyActions = allowedAnalyticsValues(
|
||||
"journey_start", "home_open", "journey_end", "screen_view", "open", "close", "select",
|
||||
"submit", "request", "start", "stop", "complete", "abandon", "change",
|
||||
"toggle", "follow", "unfollow", "favourite", "unfavourite", "mark_played",
|
||||
"mark_unplayed", "retry", "dismiss", "switch",
|
||||
"mark_unplayed", "retry", "dismiss", "switch", "pause", "resume",
|
||||
)
|
||||
var journeyOutcomes = allowedAnalyticsValues("", "success", "failure", "cancelled", "completed", "abandoned")
|
||||
|
||||
@@ -122,7 +130,18 @@ func toJourneyEvent(payload journeyEventPayload, userID string, now time.Time) (
|
||||
Screen: payload.Screen, Feature: payload.Feature, Source: payload.Source,
|
||||
Target: payload.Target, ItemID: payload.ItemID,
|
||||
ItemName: strings.TrimSpace(payload.ItemName), ItemType: payload.ItemType,
|
||||
PlaySessionID: payload.PlaySessionID, Outcome: payload.Outcome}, true
|
||||
PlaySessionID: payload.PlaySessionID, Outcome: payload.Outcome,
|
||||
PositionMs: clampPositionMs(payload.PositionMs)}, true
|
||||
}
|
||||
|
||||
func clampPositionMs(value int64) int64 {
|
||||
if value < 0 {
|
||||
return 0
|
||||
}
|
||||
if value > maxPositionMs {
|
||||
return maxPositionMs
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func safeAnalyticsValue(value string, max int) bool {
|
||||
|
||||
Reference in New Issue
Block a user