Skip to content

fix GOOGLE_TAG_MANAGER_ID#122

Merged
gkorland merged 1 commit intostagingfrom
tag-manager
Aug 25, 2025
Merged

fix GOOGLE_TAG_MANAGER_ID#122
gkorland merged 1 commit intostagingfrom
tag-manager

Conversation

@gkorland
Copy link
Contributor

@gkorland gkorland commented Aug 25, 2025

Summary by CodeRabbit

  • Refactor

    • Streamlined how the Google Tag Manager ID is provided to templates by using a global template configuration instead of request-based injection. No change to authentication flows or overall app behavior.
  • Chores

    • Removed legacy middleware related to analytics ID injection to reduce overhead and simplify initialization.

@gkorland gkorland requested a review from galshubeli August 25, 2025 07:07
@vercel
Copy link

vercel bot commented Aug 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
queryweaver Ready Ready Preview Comment Aug 25, 2025 7:07am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

Walkthrough

The app-level middleware that injected the Google Tag Manager ID into request.state was removed. Instead, the GTM ID is now exposed to templates via a Jinja2 global set during auth route setup. No other initialization, routing, or exception handling behavior changed.

Changes

Cohort / File(s) Summary
Remove request.state GTM middleware
api/app_factory.py
Deleted middleware that set request.state.google_tag_manager_id from the GOOGLETAGMANAGER env var; other app setup unchanged.
Expose GTM via Jinja globals
api/routes/auth.py
Sets templates.env.globals["google_tag_manager_id"] from environment to make GTM ID available in templates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled the middleware, tiny bite—
Now GTM hops in template light.
No state to carry, no heavy load,
Just globals on a breezy road.
Thump-thump goes my deploy drum,
Carrots cached—production, here I come! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tag-manager

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

galshubeli
galshubeli previously approved these changes Aug 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/routes/auth.py (1)

209-209: Fix pylint trailing whitespace (pipeline failure).

There’s trailing whitespace on Line 209 reported by pylint (C0303). Replace that whitespace-only line with a true blank line.

Apply this diff:

-        
+
🧹 Nitpick comments (1)
api/routes/auth.py (1)

39-39: Default and validate GOOGLE_TAG_MANAGER_ID before injecting into templates

Verified via a repository-wide search that no templates reference request.state.google_tag_manager_id—all usages read from the global google_tag_manager_id in base.j2. It’s safe to centralize defaulting and validation in one place to prevent “None” from leaking into rendered templates and to warn on misconfiguration.

• Location: api/routes/auth.py, line 39.

Apply this diff:

- templates.env.globals["google_tag_manager_id"] = os.getenv("GOOGLE_TAG_MANAGER_ID")
+ gtm_id = os.getenv("GOOGLE_TAG_MANAGER_ID", "")
+ if gtm_id and not (gtm_id.startswith("GTM-") or gtm_id.startswith("G-")):
+     logging.warning("GOOGLE_TAG_MANAGER_ID doesn't look valid: %s", gtm_id)
+ templates.env.globals["google_tag_manager_id"] = gtm_id
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a9dd3b3 and d80d6ae.

📒 Files selected for processing (2)
  • api/app_factory.py (0 hunks)
  • api/routes/auth.py (1 hunks)
💤 Files with no reviewable changes (1)
  • api/app_factory.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to pylint standards across all Python files (repository uses make lint)

Files:

  • api/routes/auth.py
🪛 GitHub Actions: Pylint
api/routes/auth.py

[warning] 209-209: C0303: Trailing whitespace (trailing-whitespace)

⏰ 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). (2)
  • GitHub Check: e2e-tests
  • GitHub Check: e2e-tests

@gkorland gkorland changed the base branch from main to staging August 25, 2025 07:19
@gkorland gkorland dismissed galshubeli’s stale review August 25, 2025 07:19

The base branch was changed.

@gkorland gkorland merged commit 50e27c8 into staging Aug 25, 2025
11 of 13 checks passed
@gkorland gkorland deleted the tag-manager branch August 25, 2025 07:23
This was referenced Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants