// Metro module 8446 (f8447). import QuestStore from "../../quests/QuestStore"; import { AnalyticEvents } from "../../../Constants"; import { AdCreativeType } from "../../../_bundle/Module6013"; import { getCommonClickEventProperties, trackAdContentEvent, trackQuestEvent } from "../../quests/lib/analytics/AnalyticsActions"; import { isBillableQuestContent, getAdMetadataSealed, getAdTrafficMetadataSealed } from "../../quests/utils/QuestDataUtils"; import { getContentProperties, getQuestContentName } from "../../quests/lib/analytics/AnalyticsTypes"; import { getCurrentQuestHomeSearchSession } from "../../quests/lib/analytics/QuestHomeSearchSession"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; import { v4 } from "../../../_bundle/Module514"; import { isIOS, isAndroid } from "../../../utils/PlatformUtils"; import getDeviceMetadata_native from "../../device/getDeviceMetadata.native"; import { getBrandSafetyContext } from "../../quests/lib/analytics/BrandSafetyContext"; import { getAdUser } from "../utils/AdDataUtils.android"; import { getQuestLogger } from "../../quests/lib/getQuestLogger"; import { AdUserActionType } from "./captureAdUserActionTypes"; let _handleClickInternalAction, _handleClickExternalAdvertiserCtaAction, handleViewImpression, _handleViewInternalSurfaceImpressionAction, reportCaptureAdUserActionError; const emitClickEventWithCreative = async function emitClickEventWithCreative(c26205_0) { let uuid, adMetadataSealed, adTrafficMetadataSealed, uuid2, c26205_6; let c29952_6; c26205_6 = void 0; let c29952_0 = c26205_0; c29952_6 = void 0; let c29952_1 = c26205_0.adCreativeType; const { questContentCTA, surfaceId } = c26205_0; let c29952_2 = surfaceId; let c29952_3 = c26205_0.sourceQuestContent; const { impressionId, clickId: clickId2, questContentPosition, questContentRowIndex } = c26205_0; let c29952_4 = c26205_0.trackGuildAndChannelMetadata; let c29952_5 = await getCommonClickEventProperties({ questContent: surfaceId, questContentPosition, questContentRowIndex, questContentCTA, impressionId, clickId: clickId2 }); if (c29952_1 !== AdCreativeType.QUEST) { const uuid3 = getCurrentQuestHomeSearchSession()?.uuid; uuid = uuid3; if (uuid3 == null) { uuid = null; } trackAdContentEvent({ adContentId: c29952_0.adCreativeId, relatedQuestId: c29952_0.relatedQuestId, adCreativeType: c29952_1, event: AnalyticEvents.QUEST_CONTENT_CLICKED, properties: { ...c29952_5, search_session_id: uuid }, trackGuildAndChannelMetadata: c29952_4, shouldExtendSession: isBillableQuestContent(c29952_2), sourceQuestContent: c29952_3 }); } else { c29952_6 = c29952_0.adCreativeId; adMetadataSealed = getAdMetadataSealed(c29952_3, c29952_6); if (adMetadataSealed == null) { adMetadataSealed = null; } adTrafficMetadataSealed = getAdTrafficMetadataSealed(c29952_3, c29952_6); if (adTrafficMetadataSealed == null) { adTrafficMetadataSealed = null; } const uuid4 = getCurrentQuestHomeSearchSession()?.uuid; uuid2 = uuid4; if (uuid4 == null) { uuid2 = null; } trackQuestEvent({ questId: c29952_6, event: AnalyticEvents.QUEST_CONTENT_CLICKED, properties: { ...c29952_5, metadata_sealed: adMetadataSealed, traffic_metadata_sealed: adTrafficMetadataSealed, search_session_id: uuid2 }, trackGuildAndChannelMetadata: c29952_4, shouldExtendSession: isBillableQuestContent(c29952_2), sourceQuestContent: c29952_3 }); } }; _handleClickInternalAction = function _handleClickInternalAction() { const r8 = async (c26206_0) => { let clickId, isTargeted; L16: { if (c26206_0.adCreativeType != null) { await emitClickEventWithCreative(c26206_0); break L16; } const { surfaceId, questContentCTA, clickId: clickId2 } = c26206_0; const contentProperties = getContentProperties(surfaceId, c26206_0.questContentPosition, c26206_0.questContentRowIndex); const QUEST_CONTENT_CLICKED = AnalyticEvents.QUEST_CONTENT_CLICKED; clickId = clickId2; if (clickId2 == null) { clickId = v4(); } const isTargeted3 = c26206_0.isTargeted; isTargeted = isTargeted3; if (isTargeted3 == null) { isTargeted = false; } AnalyticsUtils.track(QUEST_CONTENT_CLICKED, { cta_name: questContentCTA, click_id: clickId, is_targeted: isTargeted, content_id: contentProperties.content_id, content_name: contentProperties.content_name, content_position: contentProperties.content_position, row_index: contentProperties.row_index, ad_content_id: c26206_0.adContentId, quest_id: c26206_0.relatedQuestId }); return void 0; } }; _handleClickInternalAction = r8; return r8.apply(this, arguments); }; _handleClickExternalAdvertiserCtaAction = function _handleClickExternalAdvertiserCtaAction() { const r8 = async (c26207_0) => { await emitClickEventWithCreative(c26207_0); }; _handleClickExternalAdvertiserCtaAction = r8; return r8.apply(this, arguments); }; handleViewImpression = function handleViewImpression(a0) { const { surfaceId, sourceQuestContent, impressionId, triggeredByStatusChange, minViewTimeSeconds, minViewportPercentage, isQuestEnrollmentBlocked, shouldExtendSession, adUser, questContentPosition, questContentRowIndex, trackGuildAndChannelMetadata } = a0; const r7 = { min_view_time_seconds: minViewTimeSeconds, min_viewport_percentage: minViewportPercentage, triggered_by_status_change: triggeredByStatusChange, apple_advertising_id: adUser != null ? isIOS() ? adUser.advertisingId : null : null, android_advertising_id: adUser != null ? isAndroid() ? adUser.advertisingId : null : null, ...getDeviceMetadata_native(), ...getBrandSafetyContext(surfaceId), impression_id: impressionId, is_quest_enrollment_blocked: isQuestEnrollmentBlocked, ...getContentProperties(surfaceId, questContentPosition, questContentRowIndex) }; if (a0.adCreativeType !== AdCreativeType.QUEST) { trackAdContentEvent({ event: AnalyticEvents.QUEST_CONTENT_VIEWED, adContentId: a0.adCreativeId, adCreativeType: a0.adCreativeType, trackGuildAndChannelMetadata, shouldExtendSession, sourceQuestContent, properties: { ...r7 } }); } else { const adCreativeId = a0.adCreativeId; let metadata_sealed = getAdMetadataSealed(sourceQuestContent, adCreativeId); if (metadata_sealed == null) { metadata_sealed = null; } let search_session_id = getCurrentQuestHomeSearchSession()?.uuid; if (search_session_id == null) { search_session_id = null; } let traffic_metadata_sealed = getAdTrafficMetadataSealed(sourceQuestContent, adCreativeId); if (traffic_metadata_sealed == null) { traffic_metadata_sealed = null; } trackQuestEvent({ event: AnalyticEvents.QUEST_CONTENT_VIEWED, questId: adCreativeId, trackGuildAndChannelMetadata, shouldExtendSession, sourceQuestContent, properties: { ...r7, metadata_sealed, search_session_id, traffic_metadata_sealed } }); } }; _handleViewInternalSurfaceImpressionAction = function _handleViewInternalSurfaceImpressionAction() { const r8 = async (c26208_0) => { let isTargeted2, c26208_3; let c29953_0, c29953_1; L22: { c26208_3 = void 0; c29953_0 = c26208_0; c29953_1 = void 0; if (c26208_0.adCreativeType != null) { handleViewImpression(c26208_0); break L22; } c29953_1 = await getAdUser(getQuestContentName(c26208_0.surfaceId)); const QUEST_CONTENT_VIEWED = AnalyticEvents.QUEST_CONTENT_VIEWED; const r63 = { ...getContentProperties(c29953_0.surfaceId), apple_advertising_id: c29953_1 != null ? isIOS() ? c29953_1.advertisingId : null : null, android_advertising_id: c29953_1 != null ? isAndroid() ? c29953_1.advertisingId : null : null }; const isTargeted3 = c29953_0.isTargeted; isTargeted2 = isTargeted3; if (isTargeted3 == null) { isTargeted2 = false; } r63.is_targeted = isTargeted2; AnalyticsUtils.track(QUEST_CONTENT_VIEWED, r63); return void 0; } }; _handleViewInternalSurfaceImpressionAction = r8; return r8.apply(this, arguments); }; reportCaptureAdUserActionError = function reportCaptureAdUserActionError(a0) { getQuestLogger().error("captureAdUserAction failed to report an ad user action", a0); }; export function captureAdUserAction(a0) { try { const type = a0.type; if (AdUserActionType.END_CONTENT_LOAD === type) { (function handleEndContentLoadAction(a0) { const is_quest_enrollment_blocked = QuestStore.questEnrollmentBlockedUntil != null; if (a0.adCreativeType === AdCreativeType.QUEST) { const adCreativeId = a0.adCreativeId; let metadata_sealed = getAdMetadataSealed(a0.sourceQuestContent, adCreativeId); if (metadata_sealed == null) { metadata_sealed = null; } let traffic_metadata_sealed = getAdTrafficMetadataSealed(a0.sourceQuestContent, adCreativeId); if (traffic_metadata_sealed == null) { traffic_metadata_sealed = null; } trackQuestEvent({ event: AnalyticEvents.QUEST_CONTENT_LOADED, questId: adCreativeId, trackGuildAndChannelMetadata: a0.trackGuildAndChannelMetadata, sourceQuestContent: a0.sourceQuestContent, properties: { triggered_by_status_change: a0.triggeredByStatusChange, metadata_sealed, traffic_metadata_sealed, impression_id: a0.impressionId, is_quest_enrollment_blocked, content_id: a0.surfaceId, content_name: getQuestContentName(a0.surfaceId), content_position: a0.questContentPosition, row_index: a0.questContentRowIndex } }); } else { trackAdContentEvent({ event: AnalyticEvents.QUEST_CONTENT_LOADED, adContentId: a0.adCreativeId, adCreativeType: a0.adCreativeType, trackGuildAndChannelMetadata: a0.trackGuildAndChannelMetadata, sourceQuestContent: a0.sourceQuestContent, properties: { triggered_by_status_change: a0.triggeredByStatusChange, impression_id: a0.impressionId, is_quest_enrollment_blocked, content_id: a0.surfaceId, content_name: getQuestContentName(a0.surfaceId), content_position: a0.questContentPosition, row_index: a0.questContentRowIndex } }); } })(a0); } else if (AdUserActionType.CLICK_INTERNAL === type) { (function handleClickInternalAction() { return _handleClickInternalAction.apply(this, arguments); })(a0).catch(reportCaptureAdUserActionError); } else if (AdUserActionType.CLICK_EXTERNAL_ADVERTISER_CTA === type) { (function handleClickExternalAdvertiserCtaAction() { return _handleClickExternalAdvertiserCtaAction.apply(this, arguments); })(a0).catch(reportCaptureAdUserActionError); } else if (AdUserActionType.VIEW_INTERNAL_SURFACE_IMPRESSION === type) { (function handleViewInternalSurfaceImpressionAction() { return _handleViewInternalSurfaceImpressionAction.apply(this, arguments); })(a0).catch(reportCaptureAdUserActionError); } else if (AdUserActionType.VIEW_EXTERNAL_PAID_AD_PLACEMENT_IMPRESSION === type) { handleViewImpression(a0); } } catch ($e) { reportCaptureAdUserActionError($e); } }