feat(analytics): add local validation analytics and CLI - #12
Merged
ankitgadling merged 3 commits intoOct 3, 2025
Merged
Conversation
This adds an optional, local-only analytics feature to track postal code validation stats. - Implements API functions: record_validation, show_stats, and reset_stats. - Adds a CLI command 'postal-regex stats' to display a dashboard. - Integrates stat recording directly into the core validate() function. - All data is stored locally in ~/.postalregex_stats.json.
ankitgadling
requested changes
Oct 2, 2025
ankitgadling
left a comment
Owner
There was a problem hiding this comment.
Remove print() from core analytics and keep validate() pure; use record_validation() optionally and let the CLI handle all output/visualization.
adisingh396
force-pushed
the
feature/analytics-dashboard
branch
from
October 2, 2025 16:05
9e63ba0 to
8e7b9ed
Compare
Contributor
Author
|
Hey @ankitgadling, I've pushed up the changes:
|
adisingh396
force-pushed
the
feature/analytics-dashboard
branch
from
October 2, 2025 16:10
8e7b9ed to
94862de
Compare
ankitgadling
requested changes
Oct 2, 2025
ankitgadling
left a comment
Owner
There was a problem hiding this comment.
all changes looks good. Do Format and lint your code
Contributor
Author
|
@ankitgadling alright removed the unused import and added the new |
Owner
|
@zendrix396 Thanks for the update! but tests on Python 3.12 are failing Please check the CI logs, run tests locally, and update the PR so we can merge. |
adisingh396
force-pushed
the
feature/analytics-dashboard
branch
from
October 3, 2025 06:55
aac9feb to
e233268
Compare
Contributor
Author
|
@ankitgadling fixed the tests! |
ankitgadling
approved these changes
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

📌 Pull Request
Description
This PR introduces a local, opt-in analytics feature to help developers monitor postal code validation usage within their projects. It tracks valid and invalid counts per country and provides both a CLI dashboard and Python functions for interaction, as outlined in the issue. All data is stored locally in the user's home directory (
~/.postalregex_stats.json) with no network requests.Related Issue
Fixes #8
Changes Made
src/postal_regex/analytics.pyto handle all stat tracking logic (load, save, reset).src/postal_regex/cli.pyto create thepostal-regex statscommand.pyproject.tomlto register the new CLI command.core.validate()to automatically callrecord_validation()on every attempt.__init__.py.Checklist
pytest -vpasses locallyAdditional Notes
Some Screenshots
