// Metro module 13526 (f13527). import ApplicationStore from "../../../applications/ApplicationStore"; import { RPC_LOCAL_SCOPE } from "../../Constants"; import { ApplicationFlags, Endpoints, RPCErrors, RPCCommands } from "../../../../Constants"; import createRpcJoiSchemaObject from "../../helpers/createRpcJoiSchemaObject"; import { validatePostMessageTransport, validateApplication } from "../../RPCHelpers"; import getCurrentEmbeddedActivityChannel from "../../helpers/getCurrentEmbeddedActivityChannel"; import { hasApplicationFlag } from "../../../applications/utils/ApplicationFlagUtils"; import RPCError from "../../RPCError"; import { getActiveAnalyticsSessionIDs } from "../../../activities/EmbeddedActivitiesManager"; import AnalyticsUtils from "../../../../utils/AnalyticsUtils"; import { HTTP } from "../../../../_bundle/sendRequest"; import { isTestModeForApplication } from "../../../game_store/TestModeUtils"; const r24 = {}; r24[RPCCommands.SEND_ANALYTICS_EVENT] = { validation: (a0) => createRpcJoiSchemaObject(a0).required().keys({ event_name: a0.string().required(), event_properties: createRpcJoiSchemaObject(a0).required() }), handler: ({ socket, args }) => { const { event_name, event_properties } = args; validatePostMessageTransport(socket.transport); validateApplication(socket.application); const id = socket.application.id; const currentEmbeddedActivityChannel = getCurrentEmbeddedActivityChannel(); const activity_guild_id = currentEmbeddedActivityChannel == null ? void 0 : currentEmbeddedActivityChannel.getGuildId(); if (hasApplicationFlag(ApplicationStore.getApplication(id), ApplicationFlags.EMBEDDED_FIRST_PARTY)) { AnalyticsUtils.track(event_name, { ...{ activity_application_id: id, activity_channel_type: currentEmbeddedActivityChannel?.type, activity_guild_id, activity_user_session_id: getActiveAnalyticsSessionIDs(id)?.activityUserSessionId }, ...event_properties }); return void 0; } throw new RPCError({ errorCode: RPCErrors.INVALID_COMMAND }, "This application cannot access this API"); } }; r24[RPCCommands.GET_APPLICATION_TICKET] = { scope: RPC_LOCAL_SCOPE, handler: (a0) => { const id = a0.socket.application.id; if (id == null) { throw new RPCError({ errorCode: RPCErrors.INVALID_COMMAND }, "No application."); } return HTTP.post({ url: Endpoints.APPLICATION_TICKET(id), body: { test_mode: isTestModeForApplication(id) }, retries: 3, oldFormErrors: true, rejectWithError: false }).then((result) => result.body); } }; export default r24;