From e6f432c69dc0241bb0839b3f20abebeb608ac551 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Wed, 11 May 2022 18:42:34 +0800 Subject: [PATCH] createRecsysEntry: re-arrange for clarity (no functional change) Easier to see what's different between an entry with and without a parent. --- extras/recsys/recsys.js | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/extras/recsys/recsys.js b/extras/recsys/recsys.js index ec9f9db65..ca0a9faf6 100644 --- a/extras/recsys/recsys.js +++ b/extras/recsys/recsys.js @@ -101,28 +101,23 @@ const recsys = { const state = window.store.getState(); const user = selectUser(state); const userId = user ? user.id : null; + + // Make a stub entry that will be filled out on page load + recsys.entries[claimId] = { + uuid: uuid || Uuidv4(), + claimId: claimId, + recClickedVideoIdx: [], + pageLoadedAt: Date.now(), + events: [], + }; + if (parentUuid) { - // Make a stub entry that will be filled out on page load - recsys.entries[claimId] = { - uuid: uuid || Uuidv4(), - parentUuid: parentUuid, - uid: userId || null, // selectUser - claimId: claimId, - recClickedVideoIdx: [], - pageLoadedAt: Date.now(), - events: [], - }; + recsys.entries[claimId].uid = userId || null; + recsys.entries[claimId].parentUuid = parentUuid; } else { - recsys.entries[claimId] = { - uuid: uuid || Uuidv4(), - uid: userId, // selectUser - claimId: claimId, - pageLoadedAt: Date.now(), - recsysId: null, - recClaimIds: [], - recClickedVideoIdx: [], - events: [], - }; + recsys.entries[claimId].uid = userId; + recsys.entries[claimId].recsysId = null; + recsys.entries[claimId].recClaimIds = []; } } recsys.log('createRecsysEntry', claimId); @@ -184,6 +179,7 @@ const recsys = { recsys.entries[claimId].events.push(event); recsys.log('onRecsysPlayerEvent', claimId); }, + log: function (callName, claimId) { if (recsys.debug) { console.log(`Call: ***${callName}***, ClaimId: ${claimId}, Recsys Entries`, Object.assign({}, recsys.entries));