mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #12337: Enable anonymized reporting of census data
This commit is contained in:
@ -45,6 +45,16 @@ Sets content for the top banner in the user interface.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## CENSUS_REPORTING_ENABLED
|
||||||
|
|
||||||
|
Default: True
|
||||||
|
|
||||||
|
Enables anonymous census reporting. To opt out of census reporting, set this to False.
|
||||||
|
|
||||||
|
This data enables the project maintainers to estimate how many NetBox deployments exist and track the adoption of new versions over time. Census reporting effects a single HTTP request each time a worker starts. The only data reported by this function are the NetBox version, Python version, and a pseudorandom unique identifier.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## CHANGELOG_RETENTION
|
## CHANGELOG_RETENTION
|
||||||
|
|
||||||
!!! tip "Dynamic Configuration Parameter"
|
!!! tip "Dynamic Configuration Parameter"
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* [#11623](https://github.com/netbox-community/netbox/issues/11623) - Hide PSK strings under wireless LAN & link views
|
* [#11623](https://github.com/netbox-community/netbox/issues/11623) - Hide PSK strings under wireless LAN & link views
|
||||||
* [#12205](https://github.com/netbox-community/netbox/issues/12205) - Sanitize rendered custom links to mitigate malicious links
|
* [#12205](https://github.com/netbox-community/netbox/issues/12205) - Sanitize rendered custom links to mitigate malicious links
|
||||||
* [#12226](https://github.com/netbox-community/netbox/issues/12226) - Enable setting user name & email values via remote authenticate headers
|
* [#12226](https://github.com/netbox-community/netbox/issues/12226) - Enable setting user name & email values via remote authenticate headers
|
||||||
|
* [#12337](https://github.com/netbox-community/netbox/issues/12337) - Enable anonymized reporting of census data
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -3,9 +3,10 @@ import importlib
|
|||||||
import importlib.util
|
import importlib.util
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import requests
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlencode, urlsplit
|
||||||
|
|
||||||
import django
|
import django
|
||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
@ -78,6 +79,7 @@ BASE_PATH = getattr(configuration, 'BASE_PATH', '')
|
|||||||
if BASE_PATH:
|
if BASE_PATH:
|
||||||
BASE_PATH = BASE_PATH.strip('/') + '/' # Enforce trailing slash only
|
BASE_PATH = BASE_PATH.strip('/') + '/' # Enforce trailing slash only
|
||||||
CSRF_COOKIE_PATH = LANGUAGE_COOKIE_PATH = SESSION_COOKIE_PATH = f'/{BASE_PATH.rstrip("/")}'
|
CSRF_COOKIE_PATH = LANGUAGE_COOKIE_PATH = SESSION_COOKIE_PATH = f'/{BASE_PATH.rstrip("/")}'
|
||||||
|
CENSUS_REPORTING_ENABLED = getattr(configuration, 'CENSUS_REPORTING_ENABLED', True)
|
||||||
CORS_ORIGIN_ALLOW_ALL = getattr(configuration, 'CORS_ORIGIN_ALLOW_ALL', False)
|
CORS_ORIGIN_ALLOW_ALL = getattr(configuration, 'CORS_ORIGIN_ALLOW_ALL', False)
|
||||||
CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIST', [])
|
CORS_ORIGIN_REGEX_WHITELIST = getattr(configuration, 'CORS_ORIGIN_REGEX_WHITELIST', [])
|
||||||
CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', [])
|
CORS_ORIGIN_WHITELIST = getattr(configuration, 'CORS_ORIGIN_WHITELIST', [])
|
||||||
@ -499,6 +501,24 @@ if SENTRY_ENABLED:
|
|||||||
sentry_sdk.set_tag('netbox.deployment_id', DEPLOYMENT_ID)
|
sentry_sdk.set_tag('netbox.deployment_id', DEPLOYMENT_ID)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Census collection
|
||||||
|
#
|
||||||
|
|
||||||
|
CENSUS_URL = 'https://census.netbox.dev/api/v1/'
|
||||||
|
CENSUS_PARAMS = {
|
||||||
|
'version': VERSION,
|
||||||
|
'python_version': sys.version.split()[0],
|
||||||
|
'deployment_id': DEPLOYMENT_ID,
|
||||||
|
}
|
||||||
|
if CENSUS_REPORTING_ENABLED and not DEBUG and 'test' not in sys.argv:
|
||||||
|
try:
|
||||||
|
# Report anonymous census data
|
||||||
|
requests.get(f'{CENSUS_URL}?{urlencode(CENSUS_PARAMS)}', timeout=3, proxies=HTTP_PROXIES)
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Django social auth
|
# Django social auth
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user