-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(project): OWA-56 add DRM check for CDN analytics #469
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,12 @@ import type { PlaylistItem, Source } from '../../types/playlist'; | |
|
||
export const attachAnalyticsParams = (item: PlaylistItem) => { | ||
// @todo pass these as params instead of reading the stores | ||
const { config } = useConfigStore.getState(); | ||
const { config, settings } = useConfigStore.getState(); | ||
const { user } = useAccountStore.getState(); | ||
const { profile } = useProfileStore.getState(); | ||
|
||
const vendorId = settings.vendorId; | ||
|
||
const { sources, mediaid } = item; | ||
|
||
const userId = user?.id; | ||
|
@@ -17,22 +19,31 @@ export const attachAnalyticsParams = (item: PlaylistItem) => { | |
|
||
sources.map((source: Source) => { | ||
const url = new URL(source.file); | ||
const urlSearchParams = url.searchParams; | ||
|
||
const mediaId = mediaid.toLowerCase(); | ||
const sourceUrl = url.href.toLowerCase(); | ||
|
||
// Attach user_id and profile_id only for VOD and BCL SaaS Live Streams | ||
const isVOD = sourceUrl === `https://cdn.jwplayer.com/manifests/${mediaId}.m3u8`; | ||
const isBCL = sourceUrl === `https://content.jwplatform.com/live/broadcast/${mediaId}.m3u8`; | ||
const cdnUrlVOD = `https://cdn.jwplayer.com/manifests/${mediaId}.m3u8`; | ||
const cdnUrlBCL = `https://content.jwplatform.com/live/broadcast/${mediaId}.m3u8`; | ||
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think we should remove the extension check? The sources could also contain MPEG-DASH or MP4 files that won't have the analytic parameters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey Christiaan, that is a good catch. I was referring to Marco's previous notes while working on this task. |
||
|
||
// Attach user_id, profile_id and vendor_id only for VOD, BCL SaaS Live Streams and DRM | ||
const isVOD = sourceUrl === cdnUrlVOD; | ||
const isBCL = sourceUrl === cdnUrlBCL; | ||
const isDRM = sourceUrl.startsWith(cdnUrlVOD) && urlSearchParams.has('exp') && urlSearchParams.has('sig'); | ||
|
||
if ((isVOD || isBCL) && userId) { | ||
url.searchParams.set('user_id', userId); | ||
if ((isVOD || isBCL || isDRM) && userId) { | ||
urlSearchParams.set('user_id', userId); | ||
|
||
if (isJwIntegration && profileId) { | ||
url.searchParams.set('profile_id', profileId); | ||
urlSearchParams.set('profile_id', profileId); | ||
} | ||
} | ||
|
||
if (vendorId) { | ||
urlSearchParams.set('vendor_id', vendorId); | ||
} | ||
|
||
source.file = url.toString(); | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to your change, but this function mutates the given item, should we create a new object instead?