Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdp): support nested google ad accounts #28531

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

MarconLP
Copy link
Member

@MarconLP MarconLP commented Feb 11, 2025

Problem

At the moment we only support accounts on level 0.
2025-03-04 at 08 56 44

Changes

  • Include the parent_id as part of the customer_id. We'll need to include this value in the login-customer-id header, when accessing accounts with indirect access (level 2 or greater).
  • Updating the hog function from the old version is going to reset the customer id field.

Does this work well for both Cloud and self-hosted?

How did you test this code?

Did manual testing to ensure sending events back into Google Ads is still working.

@MarconLP MarconLP changed the title feat(cdp): support nested accounts feat(cdp): support nested google ad accounts Feb 11, 2025
@MarconLP MarconLP mentioned this pull request Feb 11, 2025
21 tasks
@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

@MarconLP MarconLP added waiting Prevents stale-bot from marking the PR as stale. and removed stale labels Feb 19, 2025
@MarconLP MarconLP removed the waiting Prevents stale-bot from marking the PR as stale. label Mar 3, 2025
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (wasn't pushed!)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

github-actions bot commented Mar 4, 2025

Size Change: -195 kB (-1.97%)

Total Size: 9.73 MB

Filename Size Change
frontend/dist/toolbar.js 9.73 MB -195 kB (-1.97%)

compressed-size-action

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@MarconLP MarconLP marked this pull request as ready for review March 4, 2025 11:17
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Added support for nested Google Ads accounts by implementing parent-child account relationships and indirect access handling across the integration stack.

  • Added DFS traversal in list_google_ads_accessible_accounts to discover nested accounts up to level 5, with duplicate filtering that prioritizes direct access
  • Modified customerId format to include parent ID (e.g. 1231231234/5675675678), used for the login-customer-id header when accessing indirect accounts
  • Added validation in list_google_ads_accessible_accounts to only include enabled accounts and proper error handling for API responses
  • Updated frontend components to handle new account structure with parent_id and level fields while maintaining backward compatibility
  • Potential issue: Updating hog function from old version will reset customer ID field, requiring migration handling

7 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 67 to 69
if (requiresFieldValue) {
loadGoogleAdsConversionActions(requiresFieldValue)
loadGoogleAdsConversionActions(requiresFieldValue.split('/')[0], requiresFieldValue.split('/')[1])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Add error handling for malformed requiresFieldValue that doesn't contain '/'

Suggested change
if (requiresFieldValue) {
loadGoogleAdsConversionActions(requiresFieldValue)
loadGoogleAdsConversionActions(requiresFieldValue.split('/')[0], requiresFieldValue.split('/')[1])
}
if (requiresFieldValue?.includes('/')) {
loadGoogleAdsConversionActions(requiresFieldValue.split('/')[0], requiresFieldValue.split('/')[1])
}

Comment on lines 574 to 575
# if nested_account["customerClient"].get("manager") == True and int(nested_account["customerClient"].get("level")) >= 1:
# accounts = dfs(nested_account["customerClient"].get("clientCustomer").split("/")[1], accounts, parent_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Commented-out DFS recursion code suggests incomplete implementation of nested account traversal. Either remove or implement the recursive traversal.

Comment on lines +564 to +565
if nested_account["customerClient"].get("status") != "ENABLED":
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider logging disabled accounts for debugging purposes instead of silently skipping

@MarconLP MarconLP requested a review from benjackwhite March 4, 2025 11:24
@benjackwhite benjackwhite requested a review from a team March 4, 2025 11:26
@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Contributor

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

As far as I understood this looks good apart from a few nits

@MarconLP MarconLP requested a review from benjackwhite March 4, 2025 12:16
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.

3 participants