@classmethod
    @custommetrics_service
    @secure_post
    def add_event(cls, slug, params=None):
        # Only a validation simulation! Custom events are only tracked on the game site.
        try:
            session = cls.game_session_list.get_session(params['gameSessionId'])
        except (KeyError, TypeError):
            raise BadRequest('Invalid game session id')

        game = session.game
        if game is None:
            raise ApiException('No game with that slug')

        if slug != game.slug:
            raise BadRequest('Slug and game session do not match')

        try:
            event_key = params['key']
        except (TypeError, KeyError):
            raise BadRequest('Event key missing')

        try:
            event_value = params['value']
        except (__HOLE__, KeyError):
            raise BadRequest('Event value missing')
        del params['value']

        try:
            event_key, event_value = _validate_event(event_key, event_value)
        except ValueError as e:
            raise BadRequest(e.message)

        # If reaches this point, assume success
        return  {'ok': True, 'data': {'msg': 'Added "' + str(event_value) + '" for "' + event_key + '" ' \
                                             '(Simulation only - Custom events are only tracked on the game site)'}}
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/controllers/apiv1/custommetrics.py/CustommetricsController.add_event