Skip to content

Commit

Permalink
Merge pull request #6 from chaitanyakole/added_userid_tenantid
Browse files Browse the repository at this point in the history
Bug #236438 [telemetry] user is showing anonymous in telemetry for explore&learn and play&learn.PFA
  • Loading branch information
gouravmore authored Mar 5, 2025
2 parents 000771a + e4f2d23 commit 13ed7de
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/services/telementryService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ if (localStorage.getItem('contentSessionId') !== null) {
localStorage.setItem('allAppContentSessionId', contentSessionId);
}

const location = new URLSearchParams(window.location);
const myCurrectLanguage =
getParameter('language', location.search) || process.env.REACT_APP_LANGUAGE;

export const initialize = ({ context, config, metadata }) => {
context = context;
config = config;
playSessionId = uniqueId();
const tenantId = localStorage.getItem('tenantId');
const cohortId = localStorage.getItem('cohortId');

if (!CsTelemetryModule.instance.isInitialised) {
CsTelemetryModule.instance.init({});
const telemetryConfig = {
Expand All @@ -52,6 +59,8 @@ export const initialize = ({ context, config, metadata }) => {
cdata: [
{ id: contentSessionId, type: 'ContentSession' },
{ id: playSessionId, type: 'PlaySession' },
...(tenantId ? [{ id: tenantId, type: 'TenantId' }] : []),
...(cohortId ? [{ id: cohortId, type: 'CohortId' }] : []),
],
},
userOrgDetails: {},
Expand Down Expand Up @@ -171,15 +180,17 @@ function checkTelemetryMode(currentMode) {
);
}

const location = new URLSearchParams(window.location);
const myCurrectLanguage =
getParameter('language', location.search) || process.env.REACT_APP_LANGUAGE;

export const getEventOptions = () => {
var emis_username = 'anonymous';
var buddyUserId = '';

if (localStorage.getItem('token') !== null) {
const storedUserId = localStorage.getItem('userId');
const tenantId = localStorage.getItem('tenantId');
const cohortId = localStorage.getItem('cohortId');

if (storedUserId) {
emis_username = storedUserId;
} else if (localStorage.getItem('token') !== null) {
let jwtToken = localStorage.getItem('token');
var userDetails = jwt(jwtToken);
emis_username = userDetails.emis_username;
Expand Down Expand Up @@ -218,12 +229,16 @@ export const getEventOptions = () => {
{ id: playSessionId, type: 'PlaySession' },
{ id: userId, type: userType },
{ id: myCurrectLanguage, type: 'language' },
...(tenantId ? [{ id: tenantId, type: 'TenantId' }] : []),
...(cohortId ? [{ id: cohortId, type: 'CohortId' }] : []),
]
: [
{ id: contentSessionId, type: 'ContentSession' },
{ id: playSessionId, type: 'PlaySession' },
{ id: userId, type: userType },
{ id: myCurrectLanguage, type: 'language' },
...(tenantId ? [{ id: tenantId, type: 'TenantId' }] : []),
...(cohortId ? [{ id: cohortId, type: 'CohortId' }] : []),
{ id: userDetails?.school_name, type: 'school_name' },
{
id: userDetails?.class_studying_id,
Expand Down

0 comments on commit 13ed7de

Please sign in to comment.