Skip to content

feat(web): let each brand choose its Google account in Brand settings > Integrations (brand access PR 15) - #2112

Merged
gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/brand-access-integrations-ui
Nov 4, 2026
Merged

gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/brand-access-integrations-ui

Conversation

@cihan-gyk

@cihan-gyk cihan-gyk commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Brings brand access PR 15 onto main. PR 13 (Brand settings > People) landed separately as #2055, and main (2881144) is merged into this branch, so the diff now holds only PR 15 plus the review fixes (19 files). No PR 13 file differs from main.

  • Brand settings > Integrations: the Search Console and Analytics cards say which Google account the brand reads from and which brands share it. Admins and managers who can access the brand can use the same account as another brand (or the workspace's), connect another Google account (one more connected account under the Account's Composio entity, pending until active), or disconnect, then pick the property from that account's list. Settings > Integrations gets a "Google per brand" overview.
  • API: GET /api/integrations/brands/:brandId plus use / connect / activate / DELETE per provider and brand, gated on brand access plus admin or manager. No Composio id leaves the server. A brand's own login that no brand uses any more is removed. The demo guard refuses these writes on the demo brand.
  • Review fixes (bd37581):
    • the brand's property (gsc_property / ga_property_id) is cleared when its account changes or is removed (kept on a no-op use);
    • /use checks the target sign-in's reach (assertSignInReach) before switching;
    • the workspace status, disconnect and property list use the account the workspace's integration_connections row names, never a brand's own login;
    • starting a login drops the person's unfinished ones for that provider and anyone's older than a day.
  • Fix: the "connected on" date uses the app's date format.
  • Merged with main: main's sign-in reach check and per-brand property PUT routes are kept alongside the new routes; the demo guard names both. The merge with feat(web): show who can see a brand in Brand settings > People (brand access PR 13) #2055 kept main's PR 13 code and added PR 15's lines next to it (web/messages/en.json, the brand settings page and its test). No migrations.
  • Help: settings/google-per-brand (new, approved: false); it says that changing or disconnecting the account clears the property.

Related issue

Brand access series, PR 15. Follows #2042, #2050 and #2055 (PR 13).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open a brand's Settings > Integrations as an admin or manager: use Use the same account as…, connect another Google account, pick a property from it, then Disconnect. The property is cleared when the account changes.
  2. Settings > Integrations > Google per brand lists each brand's account; Change opens that brand.
  3. On the demo brand, the Integrations writes are refused.
  4. cd server && npm test (5,659 passed, 4 skipped); cd web && yarn test (10,188 passed, 1 skipped).

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change) — see help/README.md

Also run on 15c12bf: server npm run lint, npm run format:check, npm test; web yarn build (with CI's placeholder env); bash supabase/build-schema.sh leaves schema.sql unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

cihan-gyk and others added 9 commits November 3, 2026 00:56
…ign-ins (brand access PR 14, 00470)

- 00470: integration_accounts (the Account's Google logins and CMS sites,
  Composio's entity and connected account ids, never a token) and
  brand_integrations (the sign-in each brand uses per provider, settings
  jsonb for later). The Account's Google rows are copied as sign-ins used by
  every brand; each CMS connection as a sign-in used by its brand. Triggers
  keep the pool in step while Settings > Integrations and the CMS cards still
  write the old tables, and give a new brand the Account's Google sign-ins.
  RLS: a brand's rows for people who can access it (user_brand_ids), a
  sign-in for people who can access a brand that uses it; the server writes.
  integration_connections loses its unused admin/manager write policy.
- Server: lib/brand-integrations.js resolves a brand's connection; the GSC
  and GA syncs, the Action Center's Analytics tool and sources use it, and
  every Google call names the connected account (several may share a
  Composio entity). The property lists take ?brandId= for the brand's own
  sign-in; without it, the Account's list for All brands as before.
- Web: lib/brand-integrations.ts; suggestion sources, AI Referral Traffic and
  Chat's Google reads ask it. Both resolvers read the Account's row until
  00470 is applied.
- Tests: resolver, schema, policy coverage (integration_connections off the
  deferred list), demo coverage, syncs, routes.

Behaviour-neutral while everyone is 'all': every brand uses the Account's
Google connection, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… database stub

resolveBrandSources reads the brand's Analytics connection through
lib/brand-integrations.js (00470), which asks for one row with maybeSingle;
the generate test's PostgREST stub had no maybeSingle, so every
generateActionsForBrand test threw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd access PR 12, 00471)

- Invite: role, then All brands or Selected brands with a brand picker (at
  least one); the invitation keeps the choice. Admins are always All brands.
  Only on plans with more than one brand.
- Team: each person's row shows All brands or "N brands" to admins, with
  Edit brands; pending invitations show theirs. Admins only change it.
- Roles & access: the Brands column shows the real scope (names for admins
  and for the person); Your access lists the person's brands.
- 00471: accept_invitation joins the person with the invitation's role and
  brand scope and shares the invited brands that still exist, in one
  transaction; set_member_brand_access replaces a person's brands in one,
  the profile locked. Both service-role only. acceptInvitation falls back to
  the old path for All-brands invitations until 00471 is applied.
- Help: settings/team-brands (approved: false).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… access PR 13)

The reverse of Settings > Team (BRAND-ACCESS §3.2): a People tab lists the
members who can see the brand, with their role, by the same rule as the
assignee pickers. Admins also see why (All brands, or shared with them),
the e-mails, and a link to Team; anyone else names and roles only. The demo
brand says it is everyone's. Help: team-brands gets the section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… > Integrations (brand access PR 15)

- Brand settings > Integrations: Search Console and Analytics cards say
  which Google account the brand reads from (the workspace's, another
  brand's, its own) and which brands share it. Admins and managers who can
  access the brand use the same account as another brand (D6), connect
  another Google account (one more connected account under the Account's
  Composio entity, linked with allowMultiple, pending until active) or
  disconnect; the property is picked from that account's list.
- Settings > Integrations: "Google per brand" lists which account each
  brand uses, with a link to change it.
- API: GET /api/integrations/brands/:brandId and the use/connect/activate/
  disconnect endpoints, brand access plus admin or manager; no Composio id
  leaves. A brand's own login no brand uses any more is removed.
- Help: settings/google-per-brand (approved: false).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…app's date format

next-intl has no named 'short' date format here, so the card fell back to the
raw date; formatDate is what Settings uses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rand in the demo guard

The demo guard names every write route; the four Brand settings >
Integrations routes name their brand in the path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brand access PRs 12 and 14 landed on main as ansvisor#2050 and ansvisor#2042 with review
changes. Main's versions are kept, and PRs 13 and 15 and their fixes are
re-applied on top: the integrations routes keep main's sign-in reach check
(assertSignInReach) and per-brand property PUT routes next to the brand's
own sign-in routes, and the demo guard names both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Switching or disconnecting a brand's Google account keeps gsc_property/ga_property_id (brand-integrations.js use/activate/disconnect): clear them on any account change, and run assertSignInReach on the target account in /use. 2) The workspace-level lookups (integrations.js status ~139, DELETE ~247, properties ~324) find the active account by entity alone, so they can pick up a brand's own login: pass the workspace row's composio_account_id. Small: an unfinished connect leaves a pending integration_accounts row.

…, and keep workspace lookups to the workspace's account

Review on ansvisor#2112:
- Using another account, finishing a login of the brand's own or
  disconnecting clears the brand's property for that product (gsc_property
  or ga_property_id): it was picked from the old account.
- /use checks the target sign-in's reach (assertSignInReach): reading
  through it lists the properties of every brand that uses it.
- Settings > Integrations' status, disconnect and property list find the
  workspace's account by the id its integration_connections row names, not
  by the entity alone, which brands' own logins share; with no id, the
  entity's first active account that is no brand's login.
- Starting a login drops the person's unfinished ones, and anyone's older
  than a day, with their Composio accounts.
- Help: google-per-brand says the property is cleared.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

Copy link
Copy Markdown
Collaborator Author

Thanks @gkhngyk, addressed in bd37581:

  1. Property on account change — useAccountForBrand, activateBrandAccount and removeBrandAccount now clear the brand's property for that product (gsc_property / ga_property_id) whenever the brand's sign-in changes or is removed (kept when it picks the account it already uses). /use now runs assertSignInReach on the target sign-in before switching, so the caller needs every brand that uses it. Tests: brand-integrations-own.test.js (cleared on use/activate/disconnect, kept on a no-op use), integrations-brands.test.js (reach check called with the target, 403 and no switch when refused).
  2. Workspace lookups — status, DELETE /:provider and the workspace property list go through a new workspaceActiveConnection, which asks Composio for the account id the workspace's integration_connections row names. If the row names none, it takes the entity's first active account that isn't a brand's own login (integration_accounts with no integration_connection_id). composio.js gains listActiveConnections. Tests: new integrations-workspace.test.js (status and disconnect never pick or delete a brand's login), integrations-properties.test.js (workspace list by the row's id, never a brand's login).
  3. Unfinished connect — startBrandAccount first drops the person's earlier pending logins for that provider, and anyone's pending for more than a day, along with their Composio accounts (best effort). Test in brand-integrations-own.test.js.

Help settings/google-per-brand now says that changing or disconnecting the account clears the property.

Locally: server lint, format:check and tests (5,556 passed, 4 skipped); web format:check, lint, typecheck, tests (9,985 passed, 1 skipped) and yarn build; schema.sql unchanged.


Generated by Claude Code

gkhngyk
gkhngyk previously approved these changes Nov 4, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

Brand access PR 13 landed on main as ansvisor#2055. Main's People tab, team
actions and Help are kept as they are; the branch now adds only PR 15's
Integrations tab (its tab, import and messages next to People's) and the
review fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
@cihan-gyk cihan-gyk changed the title feat(web): show who can see a brand and let each brand choose its Google account (brand access PRs 13, 15) feat(web): let each brand choose its Google account in Brand settings > Integrations (brand access PR 15) Nov 4, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

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