decord/alpha/source/modules/user_profile/UserProfileAnalyticsContext.tsx

151 lines
5.6 KiB
TypeScript
Raw Normal View History

// Module ID: 7628
// Function ID: 7629
// Name: UserProfileAnalyticsContext
// Dependencies: [19, 21, 6578, 7629, 1255, 2]
2026-07-20 16:05:17 +00:00
// Exports: UserProfileAnalyticsProvider, useCreateUserProfileAnalyticsContext, useUserProfileAnalyticsContext
// Module 7628 (UserProfileAnalyticsContext)
import v1 from "v1" /* 1255 */;
import useAnalyticsLocationsDefault from "useAnalyticsLocations" /* 6578 */;
import UserProfileAnalyticsUtils from "UserProfileAnalyticsUtils" /* 7629 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
require = fn;
const jsx = fn(21).jsx;
let context = noop.createContext(null);
const size = fn(2);
let result = size.fileFinishedImporting("modules/user_profile/UserProfileAnalyticsContext.tsx");
2026-07-20 16:05:17 +00:00
export const UserProfileAnalyticsProvider = (children) => {
({ value, openedAt } = children);
2026-07-23 10:11:24 +00:00
({ fetchStartedAt: importDefault, fetchEndedAt: dependencyMap, isLoaded } = children);
2026-07-20 16:05:17 +00:00
if (isLoaded === undefined) {
isLoaded = false;
}
let obj2;
let ref = isLoaded.useRef(undefined);
2026-07-20 16:05:17 +00:00
const ref1 = isLoaded.useRef(openedAt);
if (ref1.current !== openedAt) {
ref1.current = openedAt;
ref.current = undefined;
}
obj2 = { analyticsLocations: useAnalyticsLocationsDefault().analyticsLocations, value };
ref = obj.useRef(obj2);
2026-07-29 08:29:29 +00:00
const effect = obj.useEffect(() => {
closure_6.current = obj2;
2026-07-20 16:05:17 +00:00
});
const items = [isLoaded];
2026-07-29 08:29:29 +00:00
const effect1 = obj.useEffect(() => {
2026-07-20 16:05:17 +00:00
const timestamp = Date.now();
2026-07-29 08:29:29 +00:00
let tmp3 = null == ref.current;
if (tmp3) {
tmp3 = null != openedAt;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp3) {
tmp2.current = timestamp - openedAt;
2026-07-20 16:05:17 +00:00
}
if (isLoaded) {
({ analyticsLocations, value } = ref.current);
obj2 = { action: "VIEW", analyticsLocations };
2026-07-20 16:05:17 +00:00
const merged = Object.assign(value);
const result = UserProfileAnalyticsUtils.trackUserProfileAction(obj2);
const obj4 = { profileUi: "USER_PROFILE", timeToInteractiveMs: tmp2.current, timeToLoadMs: null, timeToFetchMs: null, viewStartedAt: null, fetchStartedAt: null, analyticsLocations: null };
2026-07-20 16:05:17 +00:00
let diff;
if (null != openedAt) {
2026-07-29 08:29:29 +00:00
diff = timestamp - tmp13;
2026-07-20 16:05:17 +00:00
}
obj4.timeToLoadMs = diff;
2026-07-20 16:05:17 +00:00
let diff1;
if (null != importDefault) {
if (null != dependencyMap) {
diff1 = dependencyMap - tmp15;
2026-07-20 16:05:17 +00:00
}
}
obj4.timeToFetchMs = diff1;
obj4.viewStartedAt = openedAt;
obj4.fetchStartedAt = importDefault;
obj4.analyticsLocations = analyticsLocations;
2026-07-20 16:05:17 +00:00
const merged1 = Object.assign(value);
const result1 = UserProfileAnalyticsUtils.maybeTrackUserProfileUiViewed(obj4);
2026-07-20 16:05:17 +00:00
}
}, items);
return ref(obj2.Provider, { value, children: children.children });
2026-07-20 16:05:17 +00:00
};
export const useCreateUserProfileAnalyticsContext = function useCreateUserProfileAnalyticsContext(layout) {
layout = layout.layout;
const userId = layout.userId;
const guildId = layout.guildId;
const channelId = layout.channelId;
const messageId = layout.messageId;
const roleId = layout.roleId;
const sourceSessionId = layout.sourceSessionId;
let flag = layout.showGuildProfile;
if (flag === undefined) {
flag = true;
}
2026-07-23 10:11:24 +00:00
const context = channelId.useContext(roleId);
let sessionId;
2026-07-29 08:29:29 +00:00
if (context != null) {
2026-07-20 16:05:17 +00:00
sessionId = context.sessionId;
}
const items = [sessionId, layout, userId, guildId, channelId, messageId, roleId, sourceSessionId, flag];
return channelId.useMemo(() => {
const obj = { sessionId: v1.v4(), sourceSessionId: null, layout: null, userId: null, guildId: null, channelId: null, messageId: null, roleId: null, showGuildProfile: null };
2026-07-29 08:29:29 +00:00
let tmp = sourceSessionId;
if (sourceSessionId == null) {
tmp = sessionId;
}
obj.sourceSessionId = tmp;
obj.layout = layout;
obj.userId = userId;
obj.guildId = guildId;
obj.channelId = channelId;
obj.messageId = messageId;
obj.roleId = roleId;
obj.showGuildProfile = flag;
2026-07-20 16:05:17 +00:00
return obj;
}, items);
};
export const useUserProfileAnalyticsContext = function useUserProfileAnalyticsContext() {
const context = noop.useContext(closure_5);
analyticsLocations = analyticsLocations(6578)().analyticsLocations;
let obj = { context, trackUserProfileAction: null, trackUserProfileEditAction: null, trackUserProfileEditSaved: null, trackUserProfileWishlistAction: null };
2026-07-20 16:05:17 +00:00
const items = [context, analyticsLocations];
obj.trackUserProfileAction = noop.useCallback((arg0) => {
if (null != context) {
const obj2 = { analyticsLocations };
const merged = Object.assign(tmp);
const merged1 = Object.assign(arg0);
const result = UserProfileAnalyticsUtils.trackUserProfileAction(obj2);
}
}, items);
2026-07-20 16:05:17 +00:00
const items1 = [context, analyticsLocations];
obj.trackUserProfileEditAction = noop.useCallback((arg0) => {
if (null != context) {
const obj2 = { analyticsLocations };
const merged = Object.assign(tmp);
const merged1 = Object.assign(arg0);
const result = UserProfileAnalyticsUtils.trackUserProfileEditAction(obj2);
}
}, items1);
2026-07-20 16:05:17 +00:00
const items2 = [context, analyticsLocations];
obj.trackUserProfileEditSaved = noop.useCallback((arg0) => {
if (null != context) {
const obj2 = { analyticsLocations };
const merged = Object.assign(tmp);
const merged1 = Object.assign(arg0);
const result = UserProfileAnalyticsUtils.trackUserProfileEditSaved(obj2);
}
}, items2);
2026-07-20 16:05:17 +00:00
const items3 = [context, analyticsLocations];
obj.trackUserProfileWishlistAction = noop.useCallback((arg0) => {
if (null != context) {
const obj2 = { analyticsLocations };
const merged = Object.assign(tmp);
const merged1 = Object.assign(arg0);
const result = UserProfileAnalyticsUtils.trackUserProfileWishlistAction(obj2);
}
}, items3);
return obj;
2026-07-20 16:05:17 +00:00
};