From 9d0e95fa707fe1ef32802fc53810ef0b96c9fdac Mon Sep 17 00:00:00 2001 From: suvarnakale Date: Fri, 29 Nov 2024 15:41:37 +0530 Subject: [PATCH 1/2] Issue #000 chore: username set in playerconfg --- src/data/player-config.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/data/player-config.ts b/src/data/player-config.ts index 45c28e6e..fe482603 100644 --- a/src/data/player-config.ts +++ b/src/data/player-config.ts @@ -1,5 +1,9 @@ import { PlayerConfig } from "@/utils/Interfaces"; +let name = ""; +if (typeof window !== "undefined" && window.localStorage) { + name = localStorage.getItem("userName") || ""; +} export const V2PlayerConfig: PlayerConfig = { context: { mode: "play", @@ -18,7 +22,7 @@ export const V2PlayerConfig: PlayerConfig = { did: "", contextRollup: { l1: "test-k12-channel" }, objectRollup: {}, - userData: { firstName: "Guest", lastName: "User" }, + userData: { firstName: name, lastName: "" }, host: "https://telemetry.prathamdigital.org", endpoint: "/v1/telemetry", }, @@ -122,9 +126,9 @@ export const V1PlayerConfig: PlayerConfig = { app: ["test-k12-channel"], cdata: [], userData: { - firstName: "Guest", - lastName: "User", + firstName: name, + lastName: "", }, }, - data: {} + data: {}, }; From 8ef6ff46987539b86a5605497a1a2cee91722c19 Mon Sep 17 00:00:00 2001 From: suvarnakale Date: Fri, 29 Nov 2024 17:31:28 +0530 Subject: [PATCH 2/2] Issue #000 chore: playerconfg hard coded variables change --- src/data/player-config.ts | 31 +++++++++++++++---------- src/pages/play/content/[identifier].tsx | 21 ++++++++++------- src/utils/Interfaces.ts | 8 +++---- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/data/player-config.ts b/src/data/player-config.ts index fe482603..fffc0882 100644 --- a/src/data/player-config.ts +++ b/src/data/player-config.ts @@ -1,9 +1,15 @@ +import { getDeviceId } from "@/utils/Helper"; import { PlayerConfig } from "@/utils/Interfaces"; let name = ""; if (typeof window !== "undefined" && window.localStorage) { name = localStorage.getItem("userName") || ""; } + +const DeviceId = getDeviceId().then((deviceId) => { + return deviceId; +}); + export const V2PlayerConfig: PlayerConfig = { context: { mode: "play", @@ -13,17 +19,17 @@ export const V2PlayerConfig: PlayerConfig = { ver: "1.0.0", pid: "admin-portal", }, - contentId: "do_12345", + contentId: "", sid: "", uid: "", timeDiff: -0.089, - channel: "test-k12-channel", - tags: ["test-k12-channel"], - did: "", - contextRollup: { l1: "test-k12-channel" }, + channel: process.env.NEXT_PUBLIC_CHANNEL_ID || "", + tags: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""], + did: DeviceId, + contextRollup: { l1: process.env.NEXT_PUBLIC_CHANNEL_ID || "" }, objectRollup: {}, userData: { firstName: name, lastName: "" }, - host: "https://telemetry.prathamdigital.org", + host: "", endpoint: "/v1/telemetry", }, config: { @@ -33,7 +39,7 @@ export const V2PlayerConfig: PlayerConfig = { host: "", overlay: { showUser: false }, splash: { - text: "", + text: "Powered by Pratham", icon: "", bgImage: "assets/icons/splacebackground_1.png", webLink: "", @@ -54,6 +60,7 @@ export const V2PlayerConfig: PlayerConfig = { }, data: {}, }; + export const V1PlayerConfig: PlayerConfig = { config: { whiteListUrl: [], @@ -114,16 +121,16 @@ export const V1PlayerConfig: PlayerConfig = { ver: "1.0.0", pid: "admin-portal", }, - contentId: "do_12345", + contentId: "", sid: "", uid: "", timeDiff: -1.129, contextRollup: {}, - channel: "test-k12-channel", - did: "", + channel: process.env.NEXT_PUBLIC_CHANNEL_ID || "", + did: DeviceId, dims: [], - tags: ["test-k12-channel"], - app: ["test-k12-channel"], + tags: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""], + app: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""], cdata: [], userData: { firstName: name, diff --git a/src/pages/play/content/[identifier].tsx b/src/pages/play/content/[identifier].tsx index ceb3e7cd..90770a91 100644 --- a/src/pages/play/content/[identifier].tsx +++ b/src/pages/play/content/[identifier].tsx @@ -57,9 +57,11 @@ const Players: React.FC = () => { } else if (INTERACTIVE_MIME_TYPE.includes(data?.mimeType)) { playerConfig = V1PlayerConfig; playerConfig.metadata = data; + playerConfig.context["contentId"] = identifier; } else { playerConfig = V2PlayerConfig; playerConfig.metadata = data; + playerConfig.context["contentId"] = identifier; } setLoading(false); } @@ -74,15 +76,14 @@ const Players: React.FC = () => { return ( - router.back()}> + router.back()} + > - - {t("COMMON.BACK")} - + {t("COMMON.BACK")} {loading && ( = () => { )} - {playerConfig?.metadata?.name} + + {playerConfig?.metadata?.name} + {!loading ? : null} {/* {t('COMMON.DESCRIPTION')} */} - ); }; diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index 41968b72..4bc89e2f 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -145,7 +145,7 @@ export interface Context { mode?: string; authToken?: string; sid?: string; - did?: string; + did?: any; uid?: string; channel: string; pdata: Pdata; @@ -158,7 +158,7 @@ export interface Context { endpoint?: string; dispatcher?: object; partner?: any[]; - contentId: string; + contentId?: any; dims?: any[]; app?: string[]; userData?: { @@ -198,7 +198,7 @@ export interface Metadata { baseDir?: string; } export interface PlayerConfig { - context?: Context; + context: Context; config?: Config; metadata?: Metadata; data?: any; @@ -218,4 +218,4 @@ export interface CentralizedModalProps { handlePrimaryButton?: () => void; handleSkipButton?: () => void; icon?: boolean; -} \ No newline at end of file +}