Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/app/components/ATIAnalytics/atiUrl/index.client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,40 @@ describe('atiUrl', () => {
});
});

it('should include skip-rate fields when provided on itemTracker', () => {
const componentSpecificTrack = buildReverbEventModel({
...input,
itemTracker: {
type: 'portrait-video',
text: 'Example title',
duration: 9000,
totalDuration: 12000,
completionRate: 0.75,
skipRate: 0.25,
navigationMethod: 'swipe',
exitReason: 'navigation',
versionId: 'p1234567',
resourceId: 'urn:bbc:pips:pid:p1234567',
},
});

expect(componentSpecificTrack.eventDetails.item).toEqual({
attribution: 'advertiserID',
duration: 9000,
exit_reason: 'navigation',
link: 'http://localhost',
name: 'top-stories',
navigation_method: 'swipe',
resource_id: 'urn:bbc:pips:pid:p1234567',
skip_rate: 0.25,
text: 'Example title',
total_duration: 12000,
type: 'portrait-video',
completion_rate: 0.75,
version_id: 'p1234567',
});
});

it('should return the correct Reverb group event model', () => {
const blockSpecificTrack = buildReverbEventModel({
...input,
Expand Down
14 changes: 14 additions & 0 deletions src/app/components/ATIAnalytics/atiUrl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,18 @@ export const buildReverbEventModel = ({
groupTracker = {},
eventGroupingName,
}: ATIEventTrackingProps): ReverbBeaconConfig => {
// these optional fields are emitted by the portrait video skip-rate spike
const {
type: itemType,
text,
position,
duration,
totalDuration,
completionRate,
skipRate,
navigationMethod,
exitReason,
versionId,
label,
mediaType,
resourceId: itemResourceId,
Expand Down Expand Up @@ -156,6 +163,13 @@ export const buildReverbEventModel = ({
...(text && { text }),
...(position && { position }),
...(duration && { duration }),
// these are mapped to snake_case so the payload matches existing reverb conventions
...(totalDuration && { total_duration: totalDuration }),
...(completionRate != null && { completion_rate: completionRate }),
...(skipRate != null && { skip_rate: skipRate }),
...(navigationMethod && { navigation_method: navigationMethod }),
...(exitReason && { exit_reason: exitReason }),
...(versionId && { version_id: versionId }),
...(mediaType && { media_type: mediaType }),
...(label && { label }),
...(itemResourceId && { resource_id: itemResourceId }),
Expand Down
7 changes: 7 additions & 0 deletions src/app/components/ATIAnalytics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export interface ItemTracker {
text?: string;
position?: number;
duration?: number;
// these fields support portrait video skip-rate analysis in reverb/piano
totalDuration?: number;
completionRate?: number;
skipRate?: number;
navigationMethod?: string;
exitReason?: string;
versionId?: string;
resourceId?: string;
label?: string;
mediaType?: string;
Expand Down
Loading
Loading