defget_apptelemetry_event_flags():# default value is 16 bytes of 0flags_hex= \
user_config.apptelemetry_event_flagsor'0x00000000000000000000000000000000'returncoreutils.hex2int_long(flags_hex)
set_apptelemetry_server_url(server_url)
Source code in pyrevitlib/pyrevit/telemetry/__init__.py
defsetup_telemetry(session_id=None):"""Sets up the telemetry default config and environment values."""# make sure session id is availabeifnotsession_id:session_id=sessioninfo.get_session_uuid()# PYREVIT TELEMETRY -------------------------------------------------------# utc timestamptelemetry_utc_timestamp=user_config.telemetry_utc_timestampset_telemetry_utc_timestamp(telemetry_utc_timestamp)# global telemetry toggletelemetry_state=user_config.telemetry_statusset_telemetry_state(telemetry_state)# read or setup default values for file telemetry# default file path and name for telemetrytelemetry_file_dir=user_config.telemetry_file_dirset_telemetry_file_dir(telemetry_file_dir)# check file telemetry config and setup destinationifnottelemetry_file_dirorcoreutils.is_blank(telemetry_file_dir):# if no config is provided, disable outputdisable_telemetry_to_file()# if config exists, create new telemetry file under the same addresseliftelemetry_state:ifop.isdir(telemetry_file_dir):telemetry_file_name= \
FILE_LOG_FILENAME_TEMPLATE.format(PYREVIT_FILE_PREFIX,session_id,FILE_LOG_EXT)# if directory is validtelemetry_fullfilepath= \
op.join(telemetry_file_dir,telemetry_file_name)set_telemetry_file_path(telemetry_fullfilepath)# setup telemetry file or disable if failedtry:_setup_default_logfile(telemetry_fullfilepath)exceptExceptionaswrite_err:mlogger.error('Telemetry is active but log file location ''is not accessible. | %s',write_err)disable_telemetry_to_file()else:# if not, show error and disable telemetrymlogger.error('Provided telemetry address does not exits or is ''not a directory. Telemetry disabled.')disable_telemetry_to_file()# read or setup default values for server telemetrytelemetry_server_url=user_config.telemetry_server_url# check server telemetry config and setup destinationifnottelemetry_server_urlorcoreutils.is_blank(telemetry_server_url):# if no config is provided, disable outputdisable_telemetry_to_server()else:# if config exists, setup server loggingset_telemetry_server_url(telemetry_server_url)# set telemetry script typesset_telemetry_include_hooks(user_config.telemetry_include_hooks)# APP TELEMETRY ------------------------------------------------------------# setup default value for telemetry global switchapptelemetry_state=user_config.apptelemetry_statusset_apptelemetry_state(apptelemetry_state)# read or setup default values for server telemetryapptelemetry_server_url=user_config.apptelemetry_server_url# check server telemetry config and setup destinationifnotapptelemetry_server_url \
orcoreutils.is_blank(apptelemetry_server_url):# if no config is provided, disable outputdisable_apptelemetry_to_server()else:# if config exists, setup server loggingset_apptelemetry_server_url(apptelemetry_server_url)# setup eventsnew_telemetry_handler=EventTelemetry(session_id,HOST_APP.username)telemetry_handler=get_apptelemetry_handler()iftelemetry_handler:# clear existingtelemetry_events.unregister_all_event_telemetries(telemetry_handler)set_apptelemetry_handler(new_telemetry_handler)# register handlers only if telemetry system is activeifapptelemetry_state:apptelemetry_event_flags=get_apptelemetry_event_flags()# re-register events with new telemetry_handlertelemetry_events.register_event_telemetry(new_telemetry_handler,apptelemetry_event_flags)user_config.save_changes()