Skip to content

Fix hardcoded EUR currency — auto-detect from Google Ads account - #2

Merged
kLOsk merged 2 commits into
kLOsk:mainfrom
wozniakm:fix/auto-detect-account-currency
Mar 23, 2026
Merged

Fix hardcoded EUR currency — auto-detect from Google Ads account#2
kLOsk merged 2 commits into
kLOsk:mainfrom
wozniakm:fix/auto-detect-account-currency

Conversation

@wozniakm

@wozniakm wozniakm commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Auto-detect currency from the Google Ads account via customer.currency_code GAQL query, cached per customer_id per server session (one API call), with EUR fallback on error
  • New module src/adloop/ads/currency.py with get_currency_code() and format_currency()
  • Renamed metrics.average_cpc_eurmetrics.average_cpc_amount and added metrics.currency field to all enriched rows
  • Replaced all hardcoded symbols in crossref.py (insight messages) and write.py (budget warnings) with format_currency()
  • Updated docs: config.yaml.example, .cursor/rules/adloop.mdc, .claude/rules/adloop.md

Test plan

  • All 26 existing tests pass
  • 11 new tests in tests/test_currency.py covering:
    • format_currency with EUR, PLN, USD, GBP, unknown codes
    • get_currency_code API query, caching (single call), error fallback, empty rows fallback
    • _enrich_cost_fields with currency parameter and absence of old metrics.average_cpc_eur field
  • Manual: run get_campaign_performance and verify metrics.currency matches account currency
  • Manual: run analyze_campaign_conversions and verify insight messages use correct currency
  • Manual: run draft_campaign with budget < 5x CPA and verify warning uses correct currency

🤖 Generated with Claude Code

wozniakm and others added 2 commits March 20, 2026 08:48
Currency was hardcoded as EUR everywhere (€ symbols, field names).
Now auto-detected via customer.currency_code GAQL query, cached per
customer_id per server session, with EUR fallback on error.

- New: src/adloop/ads/currency.py (get_currency_code, format_currency)
- Renamed: metrics.average_cpc_eur → metrics.average_cpc_amount
- Added: metrics.currency field to all enriched rows
- Replaced hardcoded € in crossref.py and write.py warnings
- Updated docs and rules to reflect currency-agnostic behavior
- Added tests/test_currency.py (11 tests)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace 4 identical inline imports with a single top-level import.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wozniakm

Copy link
Copy Markdown
Contributor Author

Hey @kLOsk!

Just wanted to say this is a great project! Thanks for building it - I tried it out and it works really well.

As a small thank you, I'm contributing two improvements:

  1. Fix hardcoded EUR currency (Fix hardcoded EUR currency — auto-detect from Google Ads account #2) - auto-detect the currency from the Google Ads account instead of assuming EUR
  2. Add asset and customer_asset removal (Add asset and customer_asset removal to remove_entity #3) - support removing standalone assets via AssetService and customer-level asset links via CustomerAssetService, bringing remove_entity from 6 to 8 supported entity types

Both changes follow the existing safety patterns and all tests pass.

Cheers!

@kLOsk

kLOsk commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Thanks! Both great additions will review and merge asap 👍
Do you have any strategic hi ts for using ads? As much as I want to use the AI to handle API requests I would also love to give the AI real world ideas on ehat makes an ad great. Would appreciate your feedback 👍

@kLOsk
kLOsk merged commit e9c2949 into kLOsk:main Mar 23, 2026
kLOsk added a commit that referenced this pull request Mar 23, 2026
…CPC-cap support

Rebased on main after merging PRs #2, #3, #6. Removed duplicate
draft_ad_group (kept PR #6's version with preflight checks). Adds:
- update_ad_group, draft_callouts, draft_structured_snippets, draft_image_assets
- Campaign expansion settings (search_partners, display_network, max_cpc)
- Structured error handling for developer token and OAuth issues
- Shared _apply_campaign_assets helper replacing duplicated sitelink logic

All 77 tests pass.
@wozniakm

Copy link
Copy Markdown
Contributor Author

Thanks! Both great additions will review and merge asap 👍 Do you have any strategic hi ts for using ads? As much as I want to use the AI to handle API requests I would also love to give the AI real world ideas on ehat makes an ad great. Would appreciate your feedback 👍

Unfortunately not, I'm not marketing guy - Claude will be better than me for sure.

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