Skip to content

Commit

Permalink
feat: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaDraganJW committed Jul 5, 2023
1 parent 3895565 commit 13a1e21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 2 additions & 3 deletions public/jwpltx.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,15 @@ window.jwpltx = window.jwpltx || {};
}

// Process a player ready event
o.ready = function (aid, bun, fed, id, t, oaid, oiid) {
o.ready = function (aid, bun, fed, id, t, oaid, oiid, av) {
uri = JSON.parse(JSON.stringify(URI));
uri.aid = aid;
uri.bun = bun;
uri.fed = fed;
uri.id = id;
uri.t = t;
uri.oiid = oiid;
// eslint-disable-next-line no-undef
uri.av = APP_VERSION;
uri.av = av;

// Send oaid only for logged in users
if (oaid) {
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useOttAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const useOttAnalytics = (item?: PlaylistItem, feedId: string = '') => {
// app config id (oiid)
const oiid = config?.id;

// app version number (av)
const av = import.meta.env.APP_VERSION;

const [player, setPlayer] = useState<jwplayer.JWPlayer | null>(null);

useEffect(() => {
Expand Down Expand Up @@ -42,7 +45,7 @@ const useOttAnalytics = (item?: PlaylistItem, feedId: string = '') => {
return;
}

window.jwpltx.ready(analyticsToken, window.location.hostname, feedId, item.mediaid, item.title, oaid, oiid);
window.jwpltx.ready(analyticsToken, window.location.hostname, feedId, item.mediaid, item.title, oaid, oiid, av);
};

const completeHandler = () => {
Expand Down Expand Up @@ -70,7 +73,7 @@ const useOttAnalytics = (item?: PlaylistItem, feedId: string = '') => {
player.off('seeked', seekedHandler);
player.off('adImpression', adImpressionHandler);
};
}, [player, item, analyticsToken, feedId, oaid, oiid]);
}, [player, item, analyticsToken, feedId, oaid, oiid, av]);

return setPlayer;
};
Expand Down
11 changes: 10 additions & 1 deletion types/jwpltx.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
interface Jwpltx {
ready: (analyticsid: string, hostname: string, feedid: string, mediaid: string, title: string, accountid?: number, appid?: string) => void;
ready: (
analyticsid: string,
hostname: string,
feedid: string,
mediaid: string,
title: string,
accountid?: number,
appid?: string,
appversion?: string,
) => void;
adImpression: () => void;
seek: (offset: number, duration: number) => void;
seeked: () => void;
Expand Down

0 comments on commit 13a1e21

Please sign in to comment.