Skip to content

Commit

Permalink
Merge pull request #209 from Sunbird-ALL/all-1.3-tn-dev-hotfix
Browse files Browse the repository at this point in the history
All 1.3 tn dev hotfix
  • Loading branch information
gouravmore authored Nov 11, 2024
2 parents 37709b6 + 4673973 commit af84ec8
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 81 deletions.
167 changes: 93 additions & 74 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,104 @@
import React, { useEffect, useRef } from 'react';
import { ThemeProvider } from '@mui/material';
import { BrowserRouter as Router } from 'react-router-dom';
import { StyledEngineProvider } from '@mui/material/styles';
import FingerprintJS from '@fingerprintjs/fingerprintjs';
import routes from './routes';
import { AppContent } from './views';
import theme from './assets/styles/theme';
import { initialize } from './services/telementryService';
import { startEvent } from './services/callTelemetryIntract';
import '@project-sunbird/telemetry-sdk/index.js';
import React, { useEffect, useRef } from "react";
import { ThemeProvider } from "@mui/material";
import { BrowserRouter as Router } from "react-router-dom";
import { StyledEngineProvider } from "@mui/material/styles";
import FingerprintJS from "@fingerprintjs/fingerprintjs";
import routes from "./routes";
import { AppContent } from "./views";
import theme from "./assets/styles/theme";
import { initialize } from "./services/telementryService";
import { startEvent } from "./services/callTelemetryIntract";
import "@project-sunbird/telemetry-sdk/index.js";

const App = () => {
const ranonce = useRef(false);
useEffect(() => {
const initService = async () => {
var did;
if (localStorage.getItem('fpDetails_v2') !== null) {
let fpDetails_v2 = localStorage.getItem('fpDetails_v2');
did = fpDetails_v2.result;
} else {
did = localStorage.getItem('did');
}
const ranonce = useRef(false);
useEffect(() => {
const initService = async () => {
var did;
if (localStorage.getItem("fpDetails_v2") !== null) {
let fpDetails_v2 = localStorage.getItem("fpDetails_v2");
did = fpDetails_v2.result;
} else {
did = localStorage.getItem("did");
}

await initialize({
context: {
mode: process.env.REACT_APP_MODE, // To identify preview used by the user to play/edit/preview
authToken: '', // Auth key to make api calls
did: did, // Unique id to identify the device or browser
uid: 'anonymous',
channel: process.env.REACT_APP_CHANNEL, // Unique id of the channel(Channel ID)
env: process.env.REACT_APP_ENV,
await initialize({
context: {
mode: process.env.REACT_APP_MODE, // To identify preview used by the user to play/edit/preview
authToken: "", // Auth key to make api calls
did: did, // Unique id to identify the device or browser
uid: "anonymous",
channel: process.env.REACT_APP_CHANNEL, // Unique id of the channel(Channel ID)
env: process.env.REACT_APP_ENV,

pdata: {
// optional
id: process.env.REACT_APP_ID, // Producer ID. For ex: For sunbird it would be "portal" or "genie"
ver: process.env.REACT_APP_VER, // Version of the App
pid: process.env.REACT_APP_PID, // Optional. In case the component is distributed, then which instance of that component
},
tags: [
// Defines the tags data
'',
],
timeDiff: 0, // Defines the time difference// Defines the object roll up data
host: process.env.REACT_APP_HOST, // Defines the from which domain content should be load
endpoint: process.env.REACT_APP_ENDPOINT,
apislug: process.env.REACT_APP_APISLUG,
},
config: {},
// tslint:disable-next-line:max-line-length
metadata: {},
});
if (!ranonce.current) {
if (localStorage.getItem('contentSessionId') === null) {
startEvent();
}
ranonce.current = true;
}
};
pdata: {
// optional
id: process.env.REACT_APP_ID, // Producer ID. For ex: For sunbird it would be "portal" or "genie"
ver: process.env.REACT_APP_VER, // Version of the App
pid: process.env.REACT_APP_PID, // Optional. In case the component is distributed, then which instance of that component
},
tags: [
// Defines the tags data
"",
],
timeDiff: 0, // Defines the time difference// Defines the object roll up data
host: process.env.REACT_APP_HOST, // Defines the from which domain content should be load
endpoint: process.env.REACT_APP_ENDPOINT,
apislug: process.env.REACT_APP_APISLUG,
},
config: {},
// tslint:disable-next-line:max-line-length
metadata: {},
});
if (!ranonce.current) {
if (localStorage.getItem("contentSessionId") === null) {
startEvent();
}
ranonce.current = true;
}
};

const setFp = async () => {
const fp = await FingerprintJS.load();
const setFp = async () => {
const fp = await FingerprintJS.load();

const { visitorId } = await fp.get();
if (!localStorage.getItem('did')) {
localStorage.setItem('did', visitorId);
}
initService();
};
const { visitorId } = await fp.get();
if (!localStorage.getItem("did")) {
localStorage.setItem("did", visitorId);
}
initService();
};

setFp();
}, []);
setFp();
}, []);

return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<Router>
<AppContent routes={routes} />
</Router>
</ThemeProvider>
</StyledEngineProvider>
);
useEffect(() => {
const handleMessage = (event) => {
// Destructure the message data
const { messageType, localStorageKeyValue } = event.data;
if (messageType === "customData") {
for (const item of localStorageKeyValue) {
const key = item.key;
const value = item.value;

localStorage.setItem(key, value);
}
}
};
window.addEventListener("message", handleMessage);
return () => {
window.removeEventListener("message", handleMessage);
};
}, []);

return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<Router>
<AppContent routes={routes} />
</Router>
</ThemeProvider>
</StyledEngineProvider>
);
};

export default App;
2 changes: 1 addition & 1 deletion src/components/Practice/Mechanics3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const Mechanics2 = ({
left: {
xs: 0, // For extra small screens
sm: 0, // For small screens
md: "-40px", // Adjust position for medium screens
md: "0px", // Adjust position for medium screens
lg: "0px",
xl: "0px",
},
Expand Down
36 changes: 33 additions & 3 deletions src/utils/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,12 @@ const Practice = () => {
(currentGetContent?.competency
? `&level_competency=${currentGetContent?.competency}`
: "") +
(currentGetContent?.tags ? `&tags=${currentGetContent?.tags}` : "")
(currentGetContent?.tags
? `&tags=${currentGetContent?.tags}`
: "") +
(currentGetContent?.storyMode
? `&story_mode=${currentGetContent?.storyMode}`
: "")
);

//TODO: required only for S1 and S2
Expand Down Expand Up @@ -480,7 +485,10 @@ const Practice = () => {
(currentGetContent?.competency
? `&level_competency=${currentGetContent?.competency}`
: "") +
(currentGetContent?.tags ? `&tags=${currentGetContent?.tags}` : "")
(currentGetContent?.tags ? `&tags=${currentGetContent?.tags}` : "") +
(currentGetContent?.storyMode
? `&story_mode=${currentGetContent?.storyMode}`
: "")
);

// TODO: handle error if resWord is empty
Expand Down Expand Up @@ -583,7 +591,10 @@ const Practice = () => {
(currentGetContent?.competency
? `&level_competency=${currentGetContent?.competency}`
: "") +
(currentGetContent?.tags ? `&tags=${currentGetContent?.tags}` : "")
(currentGetContent?.tags ? `&tags=${currentGetContent?.tags}` : "") +
(currentGetContent?.storyMode
? `&story_mode=${currentGetContent?.storyMode}`
: "")
);
setTotalSyllableCount(resWord?.data?.totalSyllableCount);
setLivesData({
Expand Down

0 comments on commit af84ec8

Please sign in to comment.