feat(telemetry): Create a new SCARF telemetry event to track the registered email address#10432
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe changes add email registration support to telemetry collection by introducing a new utility function to retrieve registered email addresses and integrating it into the telemetry service. The service also caches the platform computation to avoid repeated runtime calls. Changes
Sequence Diagram(s)sequenceDiagram
participant TelemetryService
participant RegisteredEmailUtil
participant LoadRegistrations
TelemetryService->>TelemetryService: Initialize (check is_langflow_desktop cached)
TelemetryService->>TelemetryService: Build common_fields
TelemetryService->>RegisteredEmailUtil: get_registered_email_address()
RegisteredEmailUtil->>LoadRegistrations: load_registrations()
LoadRegistrations-->>RegisteredEmailUtil: registration_data
RegisteredEmailUtil->>RegisteredEmailUtil: Validate & extract email
alt Email valid
RegisteredEmailUtil-->>TelemetryService: email (str)
else Email invalid or error
RegisteredEmailUtil-->>TelemetryService: "" (empty string)
end
TelemetryService->>TelemetryService: Add email to common_fields (if present)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 error, 4 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
673966c to
0cdfed0
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/backend/base/langflow/utils/registered_email_util.py (2)
37-45: Consolidate repetitive exception handlers.The three exception handlers (
JSONDecodeError,PermissionError,OSError) all perform the same action: log an error and return an empty string. Consider consolidating them into a single handler for cleaner code.Apply this diff to consolidate the exception handling:
- except json.JSONDecodeError as e: - logger.error(f"Unable to load email registrations: {e}.") - return "" - except PermissionError as e: - logger.error(f"Unable to load email registrations: {e}.") - return "" - except OSError as e: + except (json.JSONDecodeError, PermissionError, OSError) as e: logger.error(f"Unable to load email registrations: {e}.") return ""
8-45: Consider adding email format validation.While the function validates that the email is a non-empty string, it doesn't verify that it's a valid email format. Consider adding basic email format validation (e.g., contains '@' and domain) to catch obviously malformed email addresses before they're sent with telemetry data.
You could add a simple validation check after line 28:
# Retrieve email address email = email_registration.get("email") # Verify email address is a valid non-zero length string if not isinstance(email, str) or (len(email) == 0): logger.error("Email registration is not a valid non-zero length string.") return "" # Basic email format validation if "@" not in email or "." not in email.split("@")[-1]: logger.error("Email registration is not a valid email format.") return "" return email # noqa: TRY300
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/backend/base/langflow/services/telemetry/service.py(2 hunks)src/backend/base/langflow/utils/registered_email_util.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{src/backend/**/*.py,tests/**/*.py,Makefile}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code
Files:
src/backend/base/langflow/utils/registered_email_util.pysrc/backend/base/langflow/services/telemetry/service.py
🧠 Learnings (1)
📚 Learning: 2025-10-29T03:59:53.796Z
Learnt from: ricofurtado
PR: langflow-ai/langflow#10430
File: src/backend/base/langflow/api/v2/registration.py:0-0
Timestamp: 2025-10-29T03:59:53.796Z
Learning: The user registration functionality in `src/backend/base/langflow/api/v2/registration.py` is temporary and will be deprecated when single-user registration is confirmed as a requirement for the langflow project.
Applied to files:
src/backend/base/langflow/utils/registered_email_util.py
🧬 Code graph analysis (1)
src/backend/base/langflow/services/telemetry/service.py (2)
src/backend/base/langflow/utils/registered_email_util.py (1)
get_registered_email_address(8-45)src/backend/base/langflow/utils/version.py (1)
get_version_info(90-91)
🪛 GitHub Actions: autofix.ci
src/backend/base/langflow/utils/registered_email_util.py
[error] 5-5: ModuleNotFoundError: No module named 'langflow.api.v2.registration' while importing load_registrations in registered_email_util.py during step: 'uv run python scripts/ci/update_starter_projects.py'.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (2)
src/backend/base/langflow/services/telemetry/service.py (2)
56-62: Good optimization: caching the platform computation.Computing
is_langflow_desktoponce and reusing it for the platform field is a good practice that avoids repeated environment variable lookups and string comparisons.
25-25: Fix the broken import chain:langflow.api.v2.registrationmodule does not exist.The import on line 25 will fail because
registered_email_util.pytries to importload_registrationsfromlangflow.api.v2.registration, but this module does not exist anywhere in the codebase. Theapi/v2directory only containsfiles.pyandmcp.py.Either:
- Implement the missing
langflow.api.v2.registrationmodule with theload_registrationsfunction, or- Correct the import path to the actual location of
load_registrations, or- Remove
registered_email_util.pyand its usages if this functionality is not neededThis is a blocking issue that prevents
service.pyfrom being imported at runtime.⛔ Skipped due to learnings
Learnt from: ricofurtado PR: langflow-ai/langflow#10430 File: src/backend/base/langflow/api/v2/registration.py:0-0 Timestamp: 2025-10-29T03:59:53.796Z Learning: The user registration functionality in `src/backend/base/langflow/api/v2/registration.py` is temporary and will be deprecated when single-user registration is confirmed as a requirement for the langflow project.Learnt from: ricofurtado PR: langflow-ai/langflow#10430 File: src/backend/base/langflow/api/v2/registration.py:0-0 Timestamp: 2025-10-29T03:55:50.216Z Learning: In the langflow project, user registration endpoints in API v2 (`src/backend/base/langflow/api/v2/registration.py`) are intentionally designed to be unauthenticated to support Desktop application initialization and onboarding flows.
0cdfed0 to
ac74abb
Compare
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (39.77%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10432 +/- ##
==========================================
+ Coverage 31.45% 31.70% +0.25%
==========================================
Files 1328 1330 +2
Lines 60153 60460 +307
Branches 8994 9059 +65
==========================================
+ Hits 18920 19171 +251
- Misses 40326 40376 +50
- Partials 907 913 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
7dc178c to
3c06ff7
Compare
d878cde to
7245e2f
Compare
…ess #10432 - Create a new telemetry schema for the registered email address - Implement utility methods to send new telemetry event for the registered email address - Send new telemetry event for the registered email address on telemetry service start-up lifecycle method - Code clean-up, commenting & refactoring
7245e2f to
947898f
Compare
…ess #10432 - Create a new telemetry schema for the registered email address - Implement utility methods to send new telemetry event for the registered email address - Send new telemetry event for the registered email address on telemetry service start-up lifecycle method - Code clean-up, commenting & refactoring
22af4f4 to
7bb6cc5
Compare
5e11fcc to
db9a198
Compare
db9a198 to
f64a4ff
Compare
Status Update
|
Status Update
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces email telemetry tracking for Langflow by creating a new EmailPayload schema and implementing collection mechanisms. The feature captures registered email addresses and sends them as telemetry events both during desktop application startup and when users register via the API.
Key Changes:
- Added
EmailPayloadtelemetry schema with email validation - Implemented email telemetry sending on registration and desktop startup
- Created utility module for retrieving and caching registered email addresses
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/base/langflow/services/telemetry/schema.py |
Added new EmailPayload class with email validation using EmailStr |
src/backend/base/langflow/services/telemetry/service.py |
Added email telemetry task and _send_email_telemetry() method for desktop startup |
src/backend/base/langflow/api/v2/registration.py |
Integrated email telemetry into registration endpoint via _send_email_telemetry() |
src/backend/base/langflow/utils/registered_email_util.py |
Implemented email retrieval utility with caching via _RegisteredEmailCache |
src/backend/tests/unit/services/telemetry/test_telemetry_schema.py |
Added 4 test cases for EmailPayload and updated existing tests with new required fields |
src/backend/tests/unit/utils/test_registered_email_util.py |
Added 6 test cases covering email model retrieval scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
411395e to
6414bf5
Compare
…stered email address - Temporarily add hardcoded registered email address to common SCARF telemetry events - Only send registered email address if it's defined and the context is Langflow Desktop - Implement a utility to load and fetch the registered email address - Bootstrap common telemetry fields with the registered email address (only in the Langflow Desktop context) - Lazy load registered email address - Cache loaded registered email address - Adopt latest email registration storage format / schema - Create a new telemetry schema for the registered email address - Implement utility methods to send new telemetry event for the registered email address - Send new telemetry event for the registered email address on telemetry service start-up lifecycle method - Code clean-up, commenting & refactoring - Implement 4 new test scenarios for testing the new Email payload schema - Fix all pre-existing style errors - Implement 6 new test scenarios for testing the "get email model" function from the registered email utility that invokes the registration API endpoint and caches the result
6414bf5 to
5d32dc4
Compare
…stered email address - Address PR feedback from Co-pilot
Status Update
|
Overview
Related PRs
New Test Scenario Results - Email Payload Schema
New Test Scenario Results - Get Email Model
Summary by CodeRabbit