Skip to content

Commit 8ff0618

Browse files
authored
Make telemetry opt-in for v4.4 (#132)
1 parent 6845ef7 commit 8ff0618

5 files changed

Lines changed: 135 additions & 35 deletions

File tree

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ pip install datafog[nlp-advanced]
2525
pip install datafog[all]
2626
```
2727

28+
Python 3.13 support is certified for the core SDK and CLI. Optional extras such
29+
as `nlp`, `nlp-advanced`, `ocr`, `distributed`, and `all` are available but not
30+
yet certified on Python 3.13.
31+
2832
## Quick Start
2933

3034
```python
@@ -132,9 +136,15 @@ datafog hash-text "john@example.com"
132136

133137
## Telemetry
134138

135-
DataFog includes anonymous telemetry by default.
139+
DataFog telemetry is disabled by default.
140+
141+
To opt in:
142+
143+
```bash
144+
export DATAFOG_TELEMETRY=1
145+
```
136146

137-
To opt out:
147+
To force telemetry off:
138148

139149
```bash
140150
export DATAFOG_NO_TELEMETRY=1

datafog/telemetry.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""
2-
Anonymous, opt-out usage telemetry for DataFog.
2+
Anonymous, opt-in usage telemetry for DataFog.
33
44
Collects anonymous usage data to help the DataFog team understand which engines,
55
functions, and features are actually used. No text content is ever sent.
66
7-
Opt out by setting either environment variable:
7+
Telemetry is disabled by default. Opt in by setting:
8+
DATAFOG_TELEMETRY=1
9+
10+
Force telemetry off by setting either environment variable:
811
DATAFOG_NO_TELEMETRY=1
912
DO_NOT_TRACK=1
1013
"""
@@ -29,13 +32,18 @@
2932
_scope = threading.local()
3033

3134

35+
def _env_truthy(name: str) -> bool:
36+
"""Return True when an environment variable explicitly opts in/out."""
37+
return os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "on"}
38+
39+
3240
def _is_telemetry_enabled() -> bool:
33-
"""Check if telemetry is enabled (opt-out via env vars)."""
34-
if os.environ.get("DATAFOG_NO_TELEMETRY", "").strip() == "1":
41+
"""Check if telemetry is enabled (opt-in, with opt-out overrides)."""
42+
if _env_truthy("DATAFOG_NO_TELEMETRY"):
3543
return False
36-
if os.environ.get("DO_NOT_TRACK", "").strip() == "1":
44+
if _env_truthy("DO_NOT_TRACK"):
3745
return False
38-
return True
46+
return _env_truthy("DATAFOG_TELEMETRY")
3947

4048

4149
def _get_anonymous_id() -> str:

docs/v5-compatibility-matrix.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ Compatibility Matrix
127127
- Deferred for v5.1+ overhaul.
128128
- Keep compatibility where practical; no runtime package installs.
129129
* - Telemetry
130-
- Default-on opt-out telemetry.
130+
- Opt-in telemetry.
131131
- Trust-critical behavior change.
132-
- Make opt-in or no-network-by-default.
132+
- Keep no-network-by-default.
133133
* - ``*_lean`` and ``*_original`` modules
134134
- Parallel historical implementations.
135135
- Remove or make private after migration path.

scripts/generate_changelog.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
from datetime import datetime
88

99

10+
def get_current_version():
11+
"""Read the current package version from datafog/__about__.py."""
12+
try:
13+
with open("datafog/__about__.py") as f:
14+
match = re.search(r'^__version__ = "([^"]+)"', f.read(), re.M)
15+
return match.group(1) if match else None
16+
except OSError:
17+
return None
18+
19+
1020
def get_latest_tag():
1121
"""Get the latest git tag."""
1222
try:
@@ -65,6 +75,7 @@ def generate_changelog(beta=False, alpha=False):
6575
"""Generate changelog content."""
6676
latest_tag = get_latest_tag()
6777
commits = get_commits_since_tag(latest_tag)
78+
current_version = get_current_version()
6879

6980
if not commits:
7081
return "No changes since last release."
@@ -85,6 +96,32 @@ def generate_changelog(beta=False, alpha=False):
8596
changelog = "# What's New\n\n"
8697
changelog += f"*Released: {datetime.now().strftime('%Y-%m-%d')}*\n\n"
8798

99+
if not alpha and not beta and current_version == "4.4.0":
100+
changelog += "## Python 3.13 Support Scope\n\n"
101+
changelog += (
102+
"Python 3.13 support is certified for the core SDK and CLI: "
103+
"`pip install datafog` and `pip install datafog[cli]`.\n\n"
104+
)
105+
changelog += (
106+
"Optional extras including `nlp`, `nlp-advanced`, `ocr`, "
107+
"`distributed`, and `all` are available but not yet certified on "
108+
"Python 3.13. They will be validated separately based on user "
109+
"demand.\n\n"
110+
)
111+
changelog += "## v5 Migration Bridge\n\n"
112+
changelog += (
113+
"This release adds the v5-preview top-level APIs `datafog.scan`, "
114+
"`datafog.redact`, and `datafog.protect` while keeping the legacy "
115+
"`datafog.detect` and `datafog.process` APIs working with targeted "
116+
"migration warnings.\n\n"
117+
)
118+
changelog += "## Privacy Defaults\n\n"
119+
changelog += (
120+
"Telemetry is now opt-in. DataFog does not send telemetry unless "
121+
"`DATAFOG_TELEMETRY=1` is explicitly set. `DATAFOG_NO_TELEMETRY=1` "
122+
"and `DO_NOT_TRACK=1` continue to force telemetry off.\n\n"
123+
)
124+
88125
if categories["features"]:
89126
changelog += "## 🚀 New Features\n"
90127
for commit in categories["features"]:

0 commit comments

Comments
 (0)