Skip to content

Commit

Permalink
fix: #5787 Support uppercased version of "COLLECT_ANALYTICS" env var (#…
Browse files Browse the repository at this point in the history
…5788)

- [x] Commit message(s) and PR title follows the format
`[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made`
ex. `fix: DEV-XXXX: Removed inconsistent code usage causing intermittent
errors`
- [x] Tests for the changes have been added/updated (for bug
fixes/features)
- [x] Docs have been added/updated (for bug fixes/features)
- [x] Best efforts were made to ensure docs/code are concise and
coherent (checked for spelling/grammatical errors, commented out code,
debug logs etc.)
- [x] Self-reviewed and ran all changes on a local instance (for bug
fixes/features)

_(check all that apply)_
- [ ] Product design
- [ ] Backend (Database)
- [x] Backend (API)
- [ ] Frontend

_(link to issue, supportive screenshots etc.)_
#5787

_(if this is a bug fix)_

Updates `base.py` to search for `COLLECT_ANALYTICS` environment variable
instead of `collect_analytics`

_(if this is a breaking or feature change)_

_(if this is a breaking or feature change)_

_(list all with version changes)_

_(if so describe the impacts positive or negative)_

_(if so describe the impacts positive or negative)_

Positive: backend analytics are properly disabled when deploying with
Helm.

_(briefly list any if applicable)_

_(briefly list any if applicable)_

_(check only one)_
- [ ] Yes, and covered entirely by feature flag(s)
- [ ] Yes, and covered partially by feature flag(s)
- [ ] No
- [x] Not sure (briefly explain the situation below)
The environment variable name is changing to all upper-case - no impact
if using Helm, as it enforces all caps. Other users who pass variables
in with Docker Compose or other setup methods may already be using lower
case, and their setup methods may not enforce all-caps.

_(check all that apply)_
- [ ] e2e
- [ ] integration
- [x] unit

_(for bug fixes/features, be as precise as possible. ex. Authentication,
Annotation History, Review Stream etc.)_
Analytics / logging

---------

Co-authored-by: Jo Booth <jo.m.booth@gmail.com>
  • Loading branch information
csavage5 and jombooth committed May 3, 2024
1 parent b2fb581 commit f8e8296
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
DJANGO_SETTINGS_MODULE: core.settings.label_studio
COVERAGE_PROCESS_START: 1
LOG_DIR: pytest_logs
collect_analytics: true
COLLECT_ANALYTICS: true
DEBUG_CONTEXTLOG: true
LABEL_STUDIO_TEST_ENVIRONMENT: false
SENTRY_ENVIRONMENT: tests-ubuntu-sqlite
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
DJANGO_SETTINGS_MODULE: core.settings.label_studio
COVERAGE_PROCESS_START: 1
LOG_DIR: pytest_logs
collect_analytics: true
COLLECT_ANALYTICS: true
DEBUG_CONTEXTLOG: true
LABEL_STUDIO_TEST_ENVIRONMENT: false
SENTRY_ENVIRONMENT: tests-ubuntu-sqlite
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
PYTHONPATH: .
LOG_LEVEL: ERROR
LOG_DIR: pytest_logs
collect_analytics: true
COLLECT_ANALYTICS: true
DEBUG_CONTEXTLOG: true
LABEL_STUDIO_TEST_ENVIRONMENT: false
SENTRY_ENVIRONMENT: tests-ubuntu-postgresql
Expand Down Expand Up @@ -244,7 +244,7 @@ jobs:
DJANGO_SETTINGS_MODULE: core.settings.label_studio
COVERAGE_PROCESS_START: 1
LOG_DIR: pytest_logs
collect_analytics: true
COLLECT_ANALYTICS: true
DEBUG_CONTEXTLOG: true
LABEL_STUDIO_TEST_ENVIRONMENT: false
SENTRY_ENVIRONMENT: tests-windows-sqlite
Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:

- name: Test with pytest
env:
collect_analytics: 0
COLLECT_ANALYTICS: 0
run: |
cd label_studio/
poetry run python -m pytest -vv -n auto
2 changes: 1 addition & 1 deletion docs/source/guide/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Label Studio collects usage statistics including the number of page visits, numb

<div class="opensource-only">

You can disable data collection by setting the environment variable `collect_analytics` to `False`.
You can disable data collection by setting the environment variable `COLLECT_ANALYTICS` to `False`.

</div>

Expand Down
4 changes: 2 additions & 2 deletions label_studio/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ def collect_versions_dummy(**kwargs):
# default value for feature flags (if not overridden by environment or client)
FEATURE_FLAGS_DEFAULT_VALUE = False

# Whether to send analytics telemetry data
COLLECT_ANALYTICS = get_bool_env('collect_analytics', True)
# Whether to send analytics telemetry data. Fall back to old lowercase name for legacy compatibility.
COLLECT_ANALYTICS = get_bool_env('COLLECT_ANALYTICS', get_bool_env('collect_analytics', True))

# Strip harmful content from SVG files by default
SVG_SECURITY_CLEANUP = get_bool_env('SVG_SECURITY_CLEANUP', False)
Expand Down

0 comments on commit f8e8296

Please sign in to comment.