export default defineEventHandler(async (event) => {
  const platform = getRouterParam(event, 'platform') as 'ios' | 'android' | 'h5'
  const body = await readBody(event)
  const appId = body?.appId

  if (!['ios', 'android', 'h5'].includes(platform)) {
    throw createError({
      statusCode: 400,
      message: 'Invalid platform',
    })
  }

  await trackDownload(platform)

  return { success: true, appId, platform }
})
