@shopana/ga
Version:
Type-safe Google Analytics 4 (GA4) tracking library for React and Next.js with ecommerce support, event batching, and SSR compatibility
56 lines • 1.9 kB
JavaScript
import {} from '../types/common';
import {} from '../types/events';
export function buildVideoStartEvent(params) {
if (!params.measurementId) {
throw new Error('measurementId is required for video_start events');
}
return {
name: 'video_start',
measurementId: params.measurementId,
params: {
video_title: params.video_title,
video_url: params.video_url,
video_duration: params.video_duration,
video_provider: params.video_provider,
visible: params.visible,
...(params.extraParams ?? {}),
},
};
}
export function buildVideoProgressEvent(params) {
if (!params.measurementId) {
throw new Error('measurementId is required for video_progress events');
}
return {
name: 'video_progress',
measurementId: params.measurementId,
params: {
video_title: params.video_title,
video_url: params.video_url,
video_current_time: params.video_current_time,
video_duration: params.video_duration,
video_percent: params.video_percent,
video_provider: params.video_provider,
visible: params.visible,
...(params.extraParams ?? {}),
},
};
}
export function buildVideoCompleteEvent(params) {
if (!params.measurementId) {
throw new Error('measurementId is required for video_complete events');
}
return {
name: 'video_complete',
measurementId: params.measurementId,
params: {
video_title: params.video_title,
video_url: params.video_url,
video_duration: params.video_duration,
video_provider: params.video_provider,
visible: params.visible,
...(params.extraParams ?? {}),
},
};
}
//# sourceMappingURL=videoTracking.js.map