Makes a call to an analytics function.

async def postback_analytics(msg: BaseMessage, platform: Platform) -> Response:
    """
    Makes a call to an analytics function.
    """

    try:
        pb = msg.get_layers()[0]
        assert isinstance(pb, Postback)

        user = msg.get_user()
        user_lang = await user.get_locale()
        user_id = user.id

        if pb.payload['event'] == 'page_view':
            func = 'page_view'
            path = pb.payload['path']
            title = pb.payload.get('title', '')
            args = [path, title, user_id, user_lang]
        else:
            return json_response({
                'status': 'unknown event',
                'message': f'"{pb.payload["event"]}" is not a recognized '
                           f'analytics event',
            })

        async for p in providers():
            await getattr(p, func)(*args)

    except (KeyError, IndexError, AssertionError, TypeError):
        return json_response({
            'status': 'missing data'
        }, status=400)

    else:
        return json_response({
            'status': 'ok',
        })