def _ClearcutRequest(survey_instance): """Prepares clearcut LogRequest. Args: survey_instance: googlecloudsdk.command_lib.survey.survey.Survey, a survey object which contains user's response. Returns: A clearcut LogRequest object. """ current_platform = platforms.Platform.Current() log_event = [{ 'source_extension_json': json.dumps(_ConcordEventForSurvey(survey_instance), sort_keys=True), 'event_time_ms': metrics.GetTimeMillis() }] return { 'client_info': { 'client_type': 'DESKTOP', 'desktop_client_info': { 'os': current_platform.operating_system.id } }, 'log_source_name': 'CONCORD', 'zwieback_cookie': metrics.GetCID(), 'request_time_ms': metrics.GetTimeMillis(), 'log_event': log_event }
def _ConcordEventForSurvey(survey_instance): return { 'event_metadata': _SurveyEnvironment(), 'client_install_id': metrics.GetCID(), 'console_type': 'CloudSDK', 'event_type': 'hatsSurvey', 'hats_response': _HatsResponseFromSurvey(survey_instance) }
def _SurveyEnvironment(): """Gets user's environment.""" install_type = ('Google' if socket.gethostname().endswith('.google.com') else 'External') env = { 'install_type': install_type, 'cid': metrics.GetCID(), 'user_agent': metrics.GetUserAgent(), 'release_channel': config.INSTALLATION_CONFIG.release_channel, 'python_version': platform.python_version(), 'environment': properties.GetMetricsEnvironment(), 'environment_version': properties.VALUES.metrics.environment_version.Get() } return [{'key': k, 'value': v} for k, v in env.items() if v is not None]