Add video playback analytics events (#11629)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import {type EmbedPlayerType, getEmbedPlayerMediaType} from './embed-player'
|
||||
|
||||
describe('getEmbedPlayerMediaType', () => {
|
||||
it.each<
|
||||
readonly [EmbedPlayerType, ReturnType<typeof getEmbedPlayerMediaType>]
|
||||
>([
|
||||
['youtube_video', 'video'],
|
||||
['youtube_short', 'video'],
|
||||
['twitch_video', 'video'],
|
||||
['vimeo_video', 'video'],
|
||||
['spotify_song', 'audio'],
|
||||
['soundcloud_set', 'audio'],
|
||||
['apple_music_album', 'audio'],
|
||||
['bandcamp_track', 'audio'],
|
||||
['giphy_gif', 'gif'],
|
||||
['flickr_album', 'other'],
|
||||
])('classifies %s as %s', (type, expected) => {
|
||||
expect(getEmbedPlayerMediaType(type)).toBe(expected)
|
||||
})
|
||||
})
|
||||
@@ -49,6 +49,29 @@ export type EmbedPlayerType =
|
||||
| 'bandcamp_album'
|
||||
| 'bandcamp_track'
|
||||
|
||||
export function getEmbedPlayerMediaType(
|
||||
type: EmbedPlayerType,
|
||||
): 'video' | 'audio' | 'gif' | 'other' {
|
||||
if (
|
||||
type === 'youtube_video' ||
|
||||
type === 'youtube_short' ||
|
||||
type === 'twitch_video' ||
|
||||
type === 'vimeo_video'
|
||||
) {
|
||||
return 'video'
|
||||
}
|
||||
if (type.endsWith('_gif')) return 'gif'
|
||||
if (
|
||||
type.startsWith('spotify_') ||
|
||||
type.startsWith('soundcloud_') ||
|
||||
type.startsWith('apple_music_') ||
|
||||
type.startsWith('bandcamp_')
|
||||
) {
|
||||
return 'audio'
|
||||
}
|
||||
return 'other'
|
||||
}
|
||||
|
||||
export const externalEmbedLabels: Record<EmbedPlayerSource, string> = {
|
||||
youtube: 'YouTube',
|
||||
youtubeShorts: 'YouTube Shorts',
|
||||
|
||||
Reference in New Issue
Block a user