430 lines
14 KiB
TypeScript
430 lines
14 KiB
TypeScript
// Metro module 10498 (f10499).
|
|
import { QuestTaskPlatform } from "../QuestConstants";
|
|
import { PlatformTypes, ComponentActions, UserSettingsSections } from "../../../Constants";
|
|
import * as _QuestTaskUtils from "./QuestTaskUtils";
|
|
import { hasPlayOnDesktopTask, hasStreamOnDesktopTask, hasAchievementInGameTask, hasWatchVideoTasks } from "./QuestTaskUtils";
|
|
import { FirstPartyQuestTaskTypes } from "../../../_bundle/Module5040";
|
|
import { shouldMigrateToAdAnalyticsInterface, AdAnalyticsInterfaceExperimentStep } from "../experiments/AdAnalyticsInterfaceExperiment";
|
|
import { captureAdUserAction } from "../../ads/analytics/captureAdUserAction";
|
|
import { AdUserActionType } from "../../ads/analytics/captureAdUserActionTypes";
|
|
import { AdCreativeType } from "../../../_bundle/Module6013";
|
|
import { trackQuestContentClicked, trackAppStoreOverlayEvent, trackAdContentClicked, trackAdContentAppStoreOverlayEvent } from "../lib/analytics/AnalyticsActions";
|
|
import authorizeConnection_native from "../../connections/authorizeConnection.native";
|
|
import { t } from "../../../intl/index.native";
|
|
import { isIOS, getOS, isAndroid } from "../../../utils/PlatformUtils";
|
|
import { getCtaLink } from "./QuestCopyUtils";
|
|
import { openPlayStoreInlineInstall } from "../../links/native/BrowserManager";
|
|
import { clearAppStoreOverlayOpen, setAppStoreOverlayOpen } from "../native/AppStoreOverlayTelemetryManager";
|
|
import { ComponentDispatch } from "../../../utils/ComponentDispatchUtils";
|
|
import { v4 } from "../../../_bundle/Module514";
|
|
import { AppStoreBottomSheetOverlayFeatureGate } from "../experiments/index";
|
|
import openURL from "../../../lib/openURL";
|
|
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
function $mk84944($env) {
|
|
return (a0) => {
|
|
const r2 = $env;
|
|
(0, r2[1])();
|
|
const r5 = r2[0];
|
|
const r7 = $env.$parent;
|
|
r5(r7[4].QUEST_APP_STORE_OVERLAY_CLOSED, r2[3], a0);
|
|
(0, r7[0])(r7[2][15]).ComponentDispatch.dispatch(r7[5].QUEST_APP_STORE_OVERLAY_FINISHED);
|
|
};
|
|
}
|
|
function $mk84945($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
if (a0) {
|
|
(0, r1[2])({
|
|
trackOverlayEvent: $mk107240(r1)
|
|
});
|
|
(0, r1[0])($env.$parent[4].QUEST_APP_STORE_OVERLAY_OPEN_SUCCEEDED, r1[3]);
|
|
} else {
|
|
(0, r1[1])();
|
|
const r5 = r1[0];
|
|
const r8 = $env.$parent;
|
|
r5(r8[4].QUEST_APP_STORE_OVERLAY_OPEN_FAILED, r1[3]);
|
|
(0, r8[0])(r8[2][15]).ComponentDispatch.dispatch(r8[5].QUEST_APP_STORE_OVERLAY_FINISHED);
|
|
}
|
|
};
|
|
}
|
|
function $mk84946($env) {
|
|
return () => {
|
|
const r2 = $env;
|
|
(0, r2[1])();
|
|
const r4 = r2[0];
|
|
const r6 = $env.$parent;
|
|
r4(r6[4].QUEST_APP_STORE_OVERLAY_OPEN_FAILED, r2[3]);
|
|
(0, r6[0])(r6[2][15]).ComponentDispatch.dispatch(r6[5].QUEST_APP_STORE_OVERLAY_FINISHED);
|
|
};
|
|
}
|
|
function $mk107240($env) {
|
|
return (a0, a1) => {
|
|
const r1 = $env;
|
|
return (0, r1[0])(a0, r1[3], a1);
|
|
};
|
|
}
|
|
let getDirectAppStoreLinkFromCta, getInlineStoreParamsFromCta;
|
|
let env7043 = {};
|
|
export function supportedConsoles(a0) {
|
|
const r24 = Object.keys(a0.config.taskConfigV2.tasks);
|
|
const r25 = [];
|
|
for (const item of r24) {
|
|
if (FirstPartyQuestTaskTypes.PLAY_ON_XBOX === item) {
|
|
r25.push(PlatformTypes.XBOX);
|
|
} else if (FirstPartyQuestTaskTypes.PLAY_ON_PLAYSTATION === item) {
|
|
r25.push(PlatformTypes.PLAYSTATION);
|
|
}
|
|
}
|
|
return r25;
|
|
}
|
|
getDirectAppStoreLinkFromCta = function getDirectAppStoreLinkFromCta(a0) {
|
|
let r33, r43, android;
|
|
L16: {
|
|
if (!(!isIOS() && getOS() !== "ios")) {
|
|
if (a0.ios?.iosAppId != null) {
|
|
const r22 = a0.ios.iosAppId.startsWith("id");
|
|
const iosAppId = a0.ios.iosAppId;
|
|
r33 = `https://apps.apple.com/app/${r22 ? iosAppId : `id${iosAppId}`}`;
|
|
break L16;
|
|
}
|
|
}
|
|
if (!isAndroid()) {
|
|
const oS = getOS();
|
|
r43 = null;
|
|
if (oS === "android") {
|
|
android = a0.android;
|
|
r43 = android?.androidAppId == null ? null : `https://play.google.com/store/apps/details?id=${a0.android.androidAppId}`;
|
|
}
|
|
} else {
|
|
android = a0.android;
|
|
r43 = android?.androidAppId == null ? null : `https://play.google.com/store/apps/details?id=${a0.android.androidAppId}`;
|
|
}
|
|
r33 = r43;
|
|
}
|
|
return r33;
|
|
};
|
|
getInlineStoreParamsFromCta = function getInlineStoreParamsFromCta(a0) {
|
|
let r21;
|
|
L11: {
|
|
if (isAndroid()) {
|
|
if (a0.android?.androidAppId != null) {
|
|
r21 = {
|
|
url: `https://play.google.com/d?id=${a0.android.androidAppId}`,
|
|
appId: null
|
|
};
|
|
break L11;
|
|
}
|
|
}
|
|
r21 = isIOS() ? a0.ios?.iosAppId != null ? {
|
|
url: `https://apps.apple.com/app/id${a0.ios.iosAppId}`,
|
|
appId: parseInt(a0.ios.iosAppId, 10)
|
|
} : null : null;
|
|
}
|
|
return r21;
|
|
};
|
|
const r24 = {
|
|
DESKTOP: "desktop",
|
|
XBOX: "xbox",
|
|
PLAYSTATION: "playstation"
|
|
};
|
|
export function supportedTaskPlatforms(a0) {
|
|
const r10 = hasPlayOnDesktopTask({
|
|
quest: a0
|
|
}) || hasStreamOnDesktopTask({
|
|
quest: a0
|
|
}) || hasAchievementInGameTask(a0);
|
|
const hasSomeConsoleTasks = _QuestTaskUtils.hasSomeConsoleTasks(a0);
|
|
const r21 = [];
|
|
if (r10) {
|
|
r21.push(QuestTaskPlatform.DESKTOP);
|
|
}
|
|
if (hasSomeConsoleTasks) {
|
|
r21.push(QuestTaskPlatform.CONSOLE);
|
|
}
|
|
return r21;
|
|
}
|
|
export function isQuestSupportedOnWeb(a0) {
|
|
let r8 = hasWatchVideoTasks(a0);
|
|
const hasPlayActivityTask = _QuestTaskUtils.hasPlayActivityTask(a0);
|
|
if (!r8) {
|
|
r8 = hasPlayActivityTask;
|
|
}
|
|
return r8;
|
|
}
|
|
export { r24 as PlayQuestPlatform };
|
|
export function getPlatformTypeForHintMessage(a0) {
|
|
return a0.connected_account_type === "xbox" ? PlatformTypes.XBOX : PlatformTypes.PLAYSTATION;
|
|
}
|
|
export function openAuthorizationConnectionModal({ platformType, quest }, a1) {
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_2_CLICKED_INTERNAL, "open_authorization_connection_modal")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_INTERNAL,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: quest.id,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
impressionId: a1.impressionId
|
|
});
|
|
} else {
|
|
trackQuestContentClicked({
|
|
questId: quest.id,
|
|
questContent: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
questContentCTA: a1.ctaContent,
|
|
impressionId: a1.impressionId
|
|
});
|
|
}
|
|
authorizeConnection_native({
|
|
platformType,
|
|
location: a1.ctaContent
|
|
});
|
|
}
|
|
export function getExpiredCredentialsHintMessage(a0) {
|
|
let PlatformTypes2, XBOX;
|
|
if (a0.connected_account_type === "xbox") {
|
|
XBOX = PlatformTypes.XBOX;
|
|
PlatformTypes2 = PlatformTypes;
|
|
} else {
|
|
PlatformTypes2 = PlatformTypes;
|
|
XBOX = PlatformTypes2.PLAYSTATION;
|
|
}
|
|
return XBOX === PlatformTypes2.XBOX ? t["mytEv+"] : t.iDiwby;
|
|
}
|
|
export function openGameLinkDirectly(a0, a1) {
|
|
let c18076_0 = a0;
|
|
let c18076_1 = a1;
|
|
let r19 = getCtaLink(a0.config);
|
|
const ctaConfig = a0.config.ctaConfig;
|
|
const r21 = ctaConfig == null ? null : getDirectAppStoreLinkFromCta({
|
|
url: getCtaLink(a0.config),
|
|
android: ctaConfig.android,
|
|
ios: ctaConfig.ios
|
|
});
|
|
if (r21 != null) {
|
|
r19 = r21;
|
|
}
|
|
const r29 = (function urlHasClickId(a0) {
|
|
let r10;
|
|
try {
|
|
r10 = new URL(a0).searchParams.has("dclid");
|
|
} catch ($e) {
|
|
return false;
|
|
}
|
|
return r10;
|
|
})(r19);
|
|
const r30 = r19;
|
|
let r31 = r30;
|
|
let clickId = void 0;
|
|
if (r29) {
|
|
const r36 = v4();
|
|
r31 = (function setClickIdOnUrl(a0, a1) {
|
|
let r15;
|
|
try {
|
|
const uRL = new URL(a0);
|
|
uRL.searchParams.set("dclid", a1);
|
|
r15 = uRL.toString();
|
|
} catch ($e) {
|
|
return a0;
|
|
}
|
|
return r15;
|
|
})(r30, r36);
|
|
clickId = r36;
|
|
}
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_3_CLICKED_EXTERNAL, "open_game_link_directly")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_EXTERNAL_ADVERTISER_CTA,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: a0.id,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
questContentPosition: a1.position,
|
|
impressionId: a1.impressionId,
|
|
clickId
|
|
});
|
|
} else {
|
|
trackQuestContentClicked({
|
|
questId: a0.id,
|
|
questContent: a1.content,
|
|
questContentCTA: a1.ctaContent,
|
|
questContentPosition: a1.position,
|
|
impressionId: a1.impressionId,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
clickId
|
|
});
|
|
}
|
|
ComponentDispatch.dispatch(ComponentActions.QUEST_GAME_LINK_OPENED);
|
|
if (!AppStoreBottomSheetOverlayFeatureGate.getConfig({
|
|
location: "quest_open_game_link"
|
|
}).enabled && r21 != null) {
|
|
const ctaConfig2 = a0.config.ctaConfig;
|
|
const r94 = ctaConfig2 == null ? null : getInlineStoreParamsFromCta({
|
|
url: getCtaLink(a0.config),
|
|
android: ctaConfig2.android,
|
|
ios: ctaConfig2.ios
|
|
});
|
|
if (r94 != null) {
|
|
let env18077;
|
|
const r104 = env18077 = {
|
|
$parent: env7043
|
|
};
|
|
env18077[0] = (a0, a1, a2) => trackAppStoreOverlayEvent(c18076_0, c18076_1, a1, a0, a2);
|
|
env18077[1] = clearAppStoreOverlayOpen;
|
|
env18077[2] = setAppStoreOverlayOpen;
|
|
const { url, appId } = r94;
|
|
env18077[3] = appId == null ? void 0 : appId.toString();
|
|
openPlayStoreInlineInstall(url, appId, $mk84944(r104)).then($mk84945(r104)).catch($mk84946(r104));
|
|
return void 0;
|
|
}
|
|
}
|
|
openURL(r31);
|
|
}
|
|
export function openAdGameLinkDirectly({ adContentId, adCreativeType, cta }, a1) {
|
|
let c18078_2 = a1;
|
|
let url = cta.url;
|
|
const directAppStoreLinkFromCta = getDirectAppStoreLinkFromCta(cta);
|
|
if (directAppStoreLinkFromCta != null) {
|
|
url = directAppStoreLinkFromCta;
|
|
}
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_3_CLICKED_EXTERNAL, "open_ad_game_link_directly")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_EXTERNAL_ADVERTISER_CTA,
|
|
adCreativeType,
|
|
adCreativeId: adContentId,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
questContentPosition: a1.position,
|
|
impressionId: a1.impressionId
|
|
});
|
|
} else {
|
|
trackAdContentClicked({
|
|
adContentId,
|
|
adCreativeType,
|
|
questContent: a1.content,
|
|
questContentCTA: a1.ctaContent,
|
|
questContentPosition: a1.position,
|
|
impressionId: a1.impressionId,
|
|
sourceQuestContent: a1.sourceQuestContent
|
|
});
|
|
}
|
|
ComponentDispatch.dispatch(ComponentActions.QUEST_GAME_LINK_OPENED);
|
|
if (!AppStoreBottomSheetOverlayFeatureGate.getConfig({
|
|
location: "quest_open_game_link"
|
|
}).enabled && directAppStoreLinkFromCta != null) {
|
|
const inlineStoreParamsFromCta = getInlineStoreParamsFromCta(cta);
|
|
if (inlineStoreParamsFromCta != null) {
|
|
let env18079;
|
|
const r64 = env18079 = {
|
|
$parent: env7043
|
|
};
|
|
env18079[0] = (a0, a1, a2) => trackAdContentAppStoreOverlayEvent({
|
|
adContentId,
|
|
adCreativeType
|
|
}, c18078_2, a1, a0, a2);
|
|
env18079[1] = clearAppStoreOverlayOpen;
|
|
env18079[2] = setAppStoreOverlayOpen;
|
|
const { url: url2, appId } = inlineStoreParamsFromCta;
|
|
env18079[3] = appId == null ? void 0 : appId.toString();
|
|
openPlayStoreInlineInstall(url2, appId, $mk84944(r64)).then($mk84945(r64)).catch($mk84946(r64));
|
|
return void 0;
|
|
}
|
|
}
|
|
openURL(url);
|
|
}
|
|
export function openConsoleConnectionSettings({ quest }, a1) {
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_2_CLICKED_INTERNAL, "open_console_connection_settings")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_INTERNAL,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: quest.id,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
impressionId: a1.impressionId,
|
|
questContentPosition: a1.position
|
|
});
|
|
} else {
|
|
trackQuestContentClicked({
|
|
questId: quest.id,
|
|
questContent: a1.content,
|
|
questContentPosition: a1.position,
|
|
questContentCTA: a1.ctaContent,
|
|
impressionId: a1.impressionId,
|
|
sourceQuestContent: a1.sourceQuestContent
|
|
});
|
|
}
|
|
(0, openUserSettings)({
|
|
screen: UserSettingsSections.CONNECTIONS
|
|
});
|
|
}
|
|
export function openAddConsoleConnectionModal({ quest }, a1) {
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_2_CLICKED_INTERNAL, "open_add_console_connection_modal")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_INTERNAL,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: quest.id,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
impressionId: a1.impressionId,
|
|
questContentPosition: a1.position,
|
|
questContentRowIndex: a1.rowIndex
|
|
});
|
|
} else {
|
|
trackQuestContentClicked({
|
|
questId: quest.id,
|
|
questContent: a1.content,
|
|
questContentPosition: a1.position,
|
|
questContentRowIndex: a1.rowIndex,
|
|
questContentCTA: a1.ctaContent,
|
|
impressionId: a1.impressionId,
|
|
sourceQuestContent: a1.sourceQuestContent
|
|
});
|
|
}
|
|
const r53 = supportedConsoles(quest);
|
|
if (r53.length === 1) {
|
|
return authorizeConnection_native({
|
|
platformType: r53.at(0)
|
|
});
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "CONNECTIONS_GRID_MODAL_SHOW",
|
|
onComplete: (a0) => authorizeConnection_native({
|
|
platformType: a0
|
|
}),
|
|
includedPlatformTypes: new Set(r53),
|
|
includeApplicationConnections: false
|
|
});
|
|
}
|
|
export function openSingleConsoleConnectionModal({ quest }, a1, a2) {
|
|
if (shouldMigrateToAdAnalyticsInterface(AdAnalyticsInterfaceExperimentStep.STEP_2_CLICKED_INTERNAL, "open_single_console_connection_modal")) {
|
|
captureAdUserAction({
|
|
type: AdUserActionType.CLICK_INTERNAL,
|
|
adCreativeType: AdCreativeType.QUEST,
|
|
adCreativeId: quest.id,
|
|
questContentCTA: a1.ctaContent,
|
|
surfaceId: a1.content,
|
|
sourceQuestContent: a1.sourceQuestContent,
|
|
impressionId: a1.impressionId,
|
|
questContentPosition: a1.position,
|
|
questContentRowIndex: a1.rowIndex
|
|
});
|
|
} else {
|
|
trackQuestContentClicked({
|
|
questId: quest.id,
|
|
questContent: a1.content,
|
|
questContentPosition: a1.position,
|
|
questContentRowIndex: a1.rowIndex,
|
|
questContentCTA: a1.ctaContent,
|
|
impressionId: a1.impressionId,
|
|
sourceQuestContent: a1.sourceQuestContent
|
|
});
|
|
}
|
|
return authorizeConnection_native({
|
|
platformType: a2
|
|
});
|
|
}
|