Skip to content

Commit

Permalink
feat: oiid for analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaDraganJW committed Jul 4, 2023
1 parent 743af3e commit 898f94a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion public/jwpltx.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ window.jwpltx = window.jwpltx || {};
}

// Process a player ready event
o.ready = function (aid, bun, fed, id, t, oaid) {
o.ready = function (aid, bun, fed, id, t, oaid, oiid) {
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;

Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useOttAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { useAccountStore } from '#src/stores/AccountStore';
const useOttAnalytics = (item?: PlaylistItem, feedId: string = '') => {
const analyticsToken = useConfigStore((s) => s.config.analyticsToken);
const user = useAccountStore((state) => state.user);
const { config } = useConfigStore((s) => s);

// ott app user id (oaid)
const oaid: number | undefined = user?.id ? Number(user.id) : undefined;

// app config id (oiid)
const oiid = config?.id;

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

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

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

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

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

0 comments on commit 898f94a

Please sign in to comment.