decord/source/modules/icymi/ICYMISessionStore.tsx
github-actions ecf26fc058 chore: update source for alpha 347.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4823.js (118.4 MB)
2026-09-16 07:03:15 +00:00

610 lines
22 KiB
TypeScript

// Module ID: 14515
// Function ID: 14516
// Name: ICYMISessionStore
// Dependencies: [4553, 1235, 8483, 502, 8465, 1255, 8489, 504, 573, 2]
// Exports: resetGlobalState
// Module 14515 (ICYMISessionStore)
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import v1 from "v1" /* 1255 */;
import ICYMIAnalytics2 from "ICYMIAnalytics" /* 8489 */;
import ExperimentStore from "ExperimentStore" /* 4553 */;
import ApexExperimentStore from "ApexExperimentStore" /* 1235 */;
import LabFeatureStore from "LabFeatureStore" /* 8483 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import ICYMIStore from "ICYMIStore" /* 8465 */;
require = fn;
let c7 = 300000;
let c8 = null;
let closure_9 = [];
let c10 = 0;
let map = new Map();
class ICYMISession {
constructor() {
items = global;
if (global === undefined) {
items = [];
}
str = fn;
if (fn === undefined) {
str = "list";
}
list = str;
obj = Object.create(new.target.prototype);
closure_1 = obj;
obj2 = closure_0(closure_1[5]);
obj._sessionId = obj2.v4();
obj._startTimestamp = Date.now();
obj._endTimestamp = null;
obj._activeItems = [];
obj._dwellCount = 0;
obj._impressionCount = 0;
map = new Map();
obj._dwelledItemIdMap = map;
map1 = new Map();
obj._impressionItemIdMap = map1;
set = new Set();
obj._impressionItemTypes = set;
obj._reloadCount = 0;
obj._feedFetchCount = 0;
obj._dwelledItemsChangedCount = 0;
obj._interactionCount = 0;
obj._actionCount = 0;
obj._latestDwellStartTimeMs = 0;
obj._timeout = setTimeout(() => obj.endSession(), c7);
ICYMIAnalytics = closure_0(closure_1[6]).ICYMIAnalytics;
obj1 = { icymiSessionId: obj._sessionId, sessionStartTimeMs: obj._startTimestamp, previousIcymiSessionCount: c10, uxVariation: closure_0(closure_1[6]).DEFAULT_UX_VARIATION };
result = ICYMIAnalytics.trackFeedSessionStarted(obj1);
if (items.length > 0) {
startItemsDwellResult = obj.startItemsDwell(items.map((item) => {
obj = {};
const merged = Object.assign(item);
obj.triggerType = str;
obj.isInitiallyVisible = true;
return obj;
}));
}
return obj;
}
}
const prototype = ICYMISession.prototype;
Object.defineProperty(prototype, "sessionId", {
get: function sessionId() {
return this._sessionId;
},
set: undefined
});
Object.defineProperty(prototype, "startTimestamp", {
get: function startTimestamp() {
return this._startTimestamp;
},
set: undefined
});
Object.defineProperty(prototype, "endTimestamp", {
get: function endTimestamp() {
return this._endTimestamp;
},
set: undefined
});
Object.defineProperty(prototype, "dwellCount", {
get: function dwellCount() {
return this._dwellCount;
},
set: undefined
});
Object.defineProperty(prototype, "uniqueDwellCount", {
get: function uniqueDwellCount() {
return this._dwelledItemIdMap.size;
},
set: undefined
});
Object.defineProperty(prototype, "impressionCount", {
get: function impressionCount() {
return this._impressionCount;
},
set: undefined
});
Object.defineProperty(prototype, "uniqueImpressionCount", {
get: function uniqueImpressionCount() {
return this._impressionItemIdMap.size;
},
set: undefined
});
Object.defineProperty(prototype, "interactionCount", {
get: function interactionCount() {
return this._interactionCount;
},
set: undefined
});
Object.defineProperty(prototype, "reloadCount", {
get: function reloadCount() {
return this._reloadCount;
},
set: undefined
});
Object.defineProperty(prototype, "feedFetchCount", {
get: function feedFetchCount() {
return this._feedFetchCount;
},
set: undefined
});
Object.defineProperty(prototype, "dwelledItemsChangedCount", {
get: function dwelledItemsChangedCount() {
return this._dwelledItemsChangedCount;
},
set: undefined
});
Object.defineProperty(prototype, "impressionItemTypes", {
get: function impressionItemTypes() {
return this._impressionItemTypes;
},
set: undefined
});
prototype["getImpression"] = function getImpression(itemId) {
closure_0 = itemId;
const _activeItems = this._activeItems;
return _activeItems.find((itemId) => itemId.itemId === closure_0);
};
prototype["startItemsDwell"] = function startItemsDwell(arr) {
const self = this;
this._resetTimeout();
closure_9 = arr;
if (arr.length === this._activeItems.length) {
if (arr.every((itemId, index) => self._activeItems[index].itemId === itemId.itemId)) {
return self._activeItems;
}
}
self._dwelledItemsChangedCount = self._dwelledItemsChangedCount + 1;
const items = [];
const _activeItems = self._activeItems;
const set = new Set(_activeItems.map((itemId) => itemId.itemId));
const iter = arr[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp3 = nextResult;
let impression = self.getImpression(nextResult.itemId);
if (null != impression) {
arr = items.push(tmp5);
let deleteResult = set.delete(tmp3.itemId);
} else {
let arr2 = items.push(self._createImpression(tmp3));
}
continue;
}
const item = set.forEach((item) => self._endImpression(item));
self._activeItems = items;
return self._activeItems;
};
prototype["trackItemsLongImpression"] = function trackItemsLongImpression(items) {
const self = this;
const iter = items[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
let impression = self.getImpression(nextResult.itemId);
let result = impression;
let tmp4 = impression;
if (impression == null) {
result = self._constructImpressionFromInput(tmp2);
}
let tmp7 = result;
let sum = self._impressionCount + 1;
self._impressionCount = sum;
result.sessionImpressionIndex = sum;
let _impressionItemIdMap = self._impressionItemIdMap;
let _impressionItemIdMap2 = self._impressionItemIdMap;
let num = _impressionItemIdMap2.get(tmp2.itemId);
if (num == null) {
num = 0;
}
let result1 = _impressionItemIdMap.set(tmp2.itemId, num + 1);
let tmp11 = require;
let ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
let obj = { icymiSessionId: self._sessionId, impressionId: null, itemId: null, itemType: null, dwellStartTimeMs: null, triggerType: null, itemOccurenceCountInSession: null, itemFeedIndex: null, itemScore: null, isInitiallyVisible: null, itemChannelType: null, itemCardHeight: null, isDwelling: null, interactionActionTypes: null, interactionCount: null, uxVariation: null, sessionImpressionIndex: null };
({ impressionId: obj.impressionId, itemId: obj.itemId, itemType: obj.itemType, impressionStartTimestamp: obj.dwellStartTimeMs, triggerType: obj.triggerType } = tmp7);
let _dwelledItemIdMap = self._dwelledItemIdMap;
let num2 = _dwelledItemIdMap.get(tmp7.itemId);
if (num2 == null) {
num2 = 0;
}
obj.itemOccurenceCountInSession = num2;
({ itemFeedIndex: obj.itemFeedIndex, itemScore: obj.itemScore, isInitiallyVisible: obj.isInitiallyVisible, itemChannelType: obj.itemChannelType } = tmp7);
let itemCardHeight = map.get(tmp7.itemId);
if (itemCardHeight == null) {
itemCardHeight = tmp7.itemCardHeight;
}
if (itemCardHeight == null) {
itemCardHeight = null;
}
obj.itemCardHeight = itemCardHeight;
obj.isDwelling = null != tmp4;
({ interactionActionTypes: obj.interactionActionTypes, interactionCount: obj.interactionCount, uxVariation } = tmp7);
if (uxVariation == null) {
uxVariation = tmp11(8489).DEFAULT_UX_VARIATION;
}
obj.uxVariation = uxVariation;
obj.sessionImpressionIndex = tmp7.sessionImpressionIndex;
let trackFeedItemDwell1sResult = ICYMIAnalytics.trackFeedItemDwell1s(obj);
continue;
}
};
prototype["trackItemInteraction"] = function trackItemInteraction(id, type, actionType) {
const self = this;
const impression = this.getImpression(id);
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const obj = { id, type, actionType, impressionId: null, uxVariation: null, sessionInteractionIndex: null, icymiSessionId: null };
let impressionId;
if (impression != null) {
impressionId = impression.impressionId;
}
obj.impressionId = impressionId;
let uxVariation;
if (impression != null) {
uxVariation = impression.uxVariation;
}
if (uxVariation == null) {
uxVariation = ICYMIAnalytics2.DEFAULT_UX_VARIATION;
}
obj.uxVariation = uxVariation;
const sum = self._interactionCount + 1;
self._interactionCount = sum;
obj.sessionInteractionIndex = sum;
obj.icymiSessionId = self._sessionId;
ICYMIAnalytics.trackItemInteraction(obj);
if (null != impression) {
const prop = impression.interactionActionTypes;
prop.push(actionType);
impression.interactionCount = impression.interactionCount + 1;
}
};
prototype["trackFeedItemActioned"] = function trackFeedItemActioned(itemId) {
const self = this;
const impression = this.getImpression(itemId.itemId);
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const obj = { icymiSessionId: this._sessionId, uxVariation: null, sessionActionIndex: null, itemId: null, itemType: null, impressionId: null, actionParameters: null };
let uxVariation;
if (impression != null) {
uxVariation = impression.uxVariation;
}
if (uxVariation == null) {
uxVariation = ICYMIAnalytics2.DEFAULT_UX_VARIATION;
}
obj.uxVariation = uxVariation;
const sum = self._actionCount + 1;
self._actionCount = sum;
obj.sessionActionIndex = sum;
({ itemId: obj.itemId, itemType: obj.itemType } = itemId);
let impressionId;
if (impression != null) {
impressionId = impression.impressionId;
}
if (impressionId == null) {
impressionId = null;
}
obj.impressionId = impressionId;
obj.actionParameters = itemId.actionParameters;
const result = ICYMIAnalytics.trackFeedItemActioned(obj);
};
prototype["trackFeedFilterActioned"] = function trackFeedFilterActioned(itemId) {
const self = this;
let impression = null;
if (null != itemId.itemId) {
impression = self.getImpression(itemId.itemId);
}
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const obj = { icymiSessionId: self._sessionId, uxVariation: null, sessionActionIndex: null, filterParameters: null, itemId: null, itemType: null, impressionId: null };
let uxVariation;
if (impression != null) {
uxVariation = impression.uxVariation;
}
if (uxVariation == null) {
uxVariation = ICYMIAnalytics2.DEFAULT_UX_VARIATION;
}
obj.uxVariation = uxVariation;
const sum = self._actionCount + 1;
self._actionCount = sum;
obj.sessionActionIndex = sum;
({ filterParameters: obj.filterParameters, itemId: obj.itemId, itemType: obj.itemType } = itemId);
let impressionId;
if (impression != null) {
impressionId = impression.impressionId;
}
if (impressionId == null) {
impressionId = null;
}
obj.impressionId = impressionId;
const result = ICYMIAnalytics.trackFeedFilterActioned(obj);
};
prototype["trackFeedPageActioned"] = function trackFeedPageActioned(arg0) {
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const obj = { icymiSessionId: this._sessionId, uxVariation: ICYMIAnalytics2.DEFAULT_UX_VARIATION, sessionActionIndex: null };
const sum = this._actionCount + 1;
this._actionCount = sum;
obj.sessionActionIndex = sum;
const merged = Object.assign(arg0);
const result = ICYMIAnalytics.trackFeedPageActioned(obj);
};
prototype["incrementReloadCount"] = function incrementReloadCount() {
this._resetTimeout();
this._reloadCount = this._reloadCount + 1;
};
prototype["incrementFeedFetchCount"] = function incrementFeedFetchCount() {
this._feedFetchCount = this._feedFetchCount + 1;
};
prototype["endAllImpressions"] = function endAllImpressions() {
const self = this;
const items = [...this._activeItems];
const item = items.forEach((itemId) => self._endImpression(itemId.itemId));
};
prototype["endSession"] = function endSession() {
this.endAllImpressions();
this._endTimestamp = Date.now();
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const result = ICYMIAnalytics.trackFeedSessionCompleted({ icymiSessionId: this._sessionId, sessionDurationMs: this._endTimestamp - this._startTimestamp, sessionStartTimeMs: this._startTimestamp, sessionEndTimeMs: this._endTimestamp, impressionCount: this._impressionCount, uniqueImpressionCount: this._impressionItemIdMap.size, impressionItemTypes: Array.from(this._impressionItemTypes), feedReloadCount: this._reloadCount, feedDwelledItemsChangedCount: this._dwelledItemsChangedCount, feedFetchCount: this._feedFetchCount, latestDwellStartTimeMs: this._latestDwellStartTimeMs, previousIcyMiSessionCount, interactionCount: this._interactionCount, dwelledCount: this._dwellCount, uniqueDwelledCount: this._dwelledItemIdMap.size, uxVariation: ICYMIAnalytics2.DEFAULT_UX_VARIATION });
clearTimeout(this._timeout);
previousIcyMiSessionCount = previousIcyMiSessionCount + 1;
c8 = null;
map.clear();
return this;
};
prototype["_resetTimeout"] = function _resetTimeout() {
const self = this;
clearTimeout(this._timeout);
this._timeout = setTimeout(() => self.endSession(), c7);
};
prototype["_createImpression"] = function _createImpression(itemId) {
const self = this;
const result = this._constructImpressionFromInput(itemId);
this._dwellCount = this._dwellCount + 1;
({ _dwelledItemIdMap, _dwelledItemIdMap: _dwelledItemIdMap2 } = this);
let num = _dwelledItemIdMap2.get(itemId.itemId);
if (num == null) {
num = 0;
}
const result1 = _dwelledItemIdMap.set(itemId.itemId, num + 1);
const _impressionItemTypes = self._impressionItemTypes;
_impressionItemTypes.add(itemId.itemType);
self._latestDwellStartTimeMs = result.impressionStartTimestamp;
return result;
};
prototype["_constructImpressionFromInput"] = function _constructImpressionFromInput(itemId) {
const obj2 = { itemId: itemId.itemId, itemType: itemId.itemType, impressionId: v1.v4(), impressionStartTimestamp: Date.now(), impressionComplete: false, triggerType: itemId.triggerType, itemFeedIndex: itemId.itemFeedIndex, itemScore: itemId.itemScore, isInitiallyVisible: itemId.isInitiallyVisible, itemChannelType: itemId.itemChannelType, itemCardHeight: null, uxVariation: null, interactionActionTypes: null, interactionCount: 0, sessionImpressionIndex: null };
value = map.get(itemId.itemId);
if (value == null) {
value = null;
}
obj2.itemCardHeight = value;
obj2.uxVariation = ICYMIAnalytics2.DEFAULT_UX_VARIATION;
obj2.interactionActionTypes = [];
return obj2;
};
prototype["_endImpression"] = function _endImpression(itemId) {
const self = this;
closure_0 = itemId;
const _activeItems = this._activeItems;
const findIndexResult = _activeItems.findIndex((itemId) => itemId.itemId === closure_0);
let tmp3 = null;
if (null != this._activeItems[findIndexResult]) {
const _Date = Date;
tmp2.impressionEndTimestamp = Date.now();
tmp2.impressionComplete = true;
const ICYMIAnalytics = ICYMIAnalytics2.ICYMIAnalytics;
const obj = { icymiSessionId: self._sessionId, impressionId: tmp2.impressionId, dwellTimeMs: tmp2.impressionEndTimestamp - tmp2.impressionStartTimestamp, itemId: null, itemType: null, dwellStartTimeMs: null, dwellEndTimeMs: null, triggerType: null, itemOccurenceCountInSession: null, itemFeedIndex: null, itemScore: null, isInitiallyVisible: null, itemChannelType: null, itemCardHeight: null, uxVariation: null, interactionActionTypes: null, interactionCount: null, sessionImpressionIndex: null };
({ itemId: obj.itemId, itemType: obj.itemType, impressionStartTimestamp: obj.dwellStartTimeMs, impressionEndTimestamp: obj.dwellEndTimeMs, triggerType: obj.triggerType } = tmp2);
const _dwelledItemIdMap = self._dwelledItemIdMap;
let num = _dwelledItemIdMap.get(tmp2.itemId);
if (num == null) {
num = 0;
}
obj.itemOccurenceCountInSession = num;
({ itemFeedIndex: obj.itemFeedIndex, itemScore: obj.itemScore, isInitiallyVisible: obj.isInitiallyVisible, itemChannelType: obj.itemChannelType } = tmp2);
let itemCardHeight = map.get(tmp2.itemId);
if (itemCardHeight == null) {
itemCardHeight = tmp2.itemCardHeight;
}
if (itemCardHeight == null) {
itemCardHeight = null;
}
obj.itemCardHeight = itemCardHeight;
let DEFAULT_UX_VARIATION = tmp2.uxVariation;
if (DEFAULT_UX_VARIATION == null) {
DEFAULT_UX_VARIATION = tmp5(8489).DEFAULT_UX_VARIATION;
}
obj.uxVariation = DEFAULT_UX_VARIATION;
({ interactionActionTypes: obj.interactionActionTypes, interactionCount: obj.interactionCount, sessionImpressionIndex: obj.sessionImpressionIndex } = tmp2);
ICYMIAnalytics.trackFeedItemDwelled(obj);
const _activeItems1 = self._activeItems;
_activeItems1.splice(findIndexResult, 1);
tmp3 = tmp2;
tmp5 = require;
}
return tmp3;
};
const Store = initializeDefault.Store;
class ICYMISessionStore extends Store {
}
const prototype2 = ICYMISessionStore.prototype;
prototype2["initialize"] = function initialize() {
this.waitFor(ApexExperimentStore, AuthenticationStore, ICYMIStore, ExperimentStore, LabFeatureStore);
};
Object.defineProperty(prototype2, "currentSession", {
get: function currentSession() {
return c8;
},
set: undefined
});
Object.defineProperty(prototype2, "endedSessionCount", {
get: function endedSessionCount() {
return c10;
},
set: undefined
});
const iCYMISessionStore = new ICYMISessionStore(DispatcherDefault, {
ICYMI_TAB_OPENED: function handleTabOpened() {
let flag = null != _null;
if (flag) {
_null.endSession();
flag = true;
}
if (closure_9.length > 0) {
_null = new ICYMISession(closure_9, "focus");
flag = true;
}
return flag;
},
ICYMI_TAB_CLOSED: function handleTabClosed() {
let flag = null != _null;
if (flag) {
_null.endSession();
flag = true;
}
return flag;
},
ICYMI_SET_FOCUSED_TAB: function handleIcymiTabFocussed(focused) {
if (focused.focused) {
if (null != tmp) {
if (closure_9.length > 0) {
_null.startItemsDwell(closure_9.map((item) => {
const obj = {};
const merged = Object.assign(item);
obj.triggerType = "focus";
obj.isInitiallyVisible = true;
return obj;
}));
return true;
} else {
return false;
}
} else {
let flag2 = null != _null;
if (flag2) {
_null.endSession();
flag2 = true;
}
if (closure_9.length > 0) {
_null = new ICYMISession(closure_9, "focus");
flag2 = true;
}
return flag2;
}
} else {
let flag = null != tmp;
if (flag) {
_null.endAllImpressions();
flag = true;
}
return flag;
}
},
ICYMI_ITEMS_DWELL_START: function handleItemsDwellStart(items) {
if (null == _null) {
_null = new ICYMISession(items.items, "list");
} else {
_null.startItemsDwell(items.items);
}
return true;
},
ICYMI_ITEMS_LONG_IMPRESSION: function handleItemsLongImpression(items) {
if (null == _null) {
_null = new ICYMISession(items.items, "list");
}
const result = _null.trackItemsLongImpression(items.items);
return true;
},
RELOAD_ICYMI: function handleReloadICYMI() {
let flag = null != _null;
if (flag) {
_null.incrementReloadCount();
flag = true;
}
return flag;
},
LOAD_ICYMI_DEHYDRATED: function handleLoadICYMIDehydrated() {
let flag = null != _null;
if (flag) {
const result = _null.incrementFeedFetchCount();
flag = true;
if (null != _null) {
_null.endAllImpressions();
flag = true;
}
}
return flag;
},
APP_STATE_UPDATE: function handleAppStateUpdate(state) {
let tmp = "active" !== state.state;
if (tmp) {
tmp = null != _null;
}
if (tmp) {
let flag = null != _null;
if (flag) {
_null.endSession();
flag = true;
}
tmp = flag;
}
return tmp;
},
CHANNEL_SELECT: function handleChannelSelected() {
let tmp = null != _null;
if (tmp) {
let flag = null != _null;
if (flag) {
_null.endAllImpressions();
flag = true;
}
tmp = flag;
}
return tmp;
},
ICYMI_SET_CARD_HEIGHT: function handleSetCardHeight(itemId) {
const result = map.set(itemId.itemId, itemId.height);
return true;
},
ICYMI_ITEM_INTERACTED: function handleItemInteracted(press_comments) {
if (null == _null) {
_null = new ICYMISession(closure_9, "focus");
}
_null.trackItemInteraction(press_comments.itemId, press_comments.itemType, press_comments.actionType);
return true;
},
ICYMI_FEED_ITEM_ACTIONED: function handleFeedItemActioned(arg0) {
if (null == _null) {
_null = new ICYMISession(closure_9, "focus");
}
const result = _null.trackFeedItemActioned(arg0);
return true;
},
ICYMI_FEED_FILTER_ACTIONED: function handleFeedFilterActioned(arg0) {
if (null == _null) {
_null = new ICYMISession(closure_9, "focus");
}
const result = _null.trackFeedFilterActioned(arg0);
return true;
},
ICYMI_FEED_PAGE_ACTIONED: function handleFeedPageActioned(arg0) {
if (null == _null) {
_null = new ICYMISession(closure_9, "focus");
}
const result = _null.trackFeedPageActioned(arg0);
return true;
}
});
const size = fn(2);
let result = size.fileFinishedImporting("modules/icymi/ICYMISessionStore.tsx");
export default iCYMISessionStore;
export const resetGlobalState = function resetGlobalState() {
if (null != _null) {
const _clearTimeout = clearTimeout;
clearTimeout(_null._timeout);
}
_null = null;
closure_9 = [];
c10 = 0;
map.clear();
};
export { ICYMISession };