Skip to content

feat(google-analytics): add Google Analytics 4 integration - #7067

Open
waleedlatif1 wants to merge 4 commits into
stagingfrom
feat/google-analytics-integration
Open

feat(google-analytics): add Google Analytics 4 integration#7067
waleedlatif1 wants to merge 4 commits into
stagingfrom
feat/google-analytics-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a Google Analytics 4 block with 10 tools across the Data API (run report, realtime report, pivot report, check compatibility, get metadata) and the Admin API (list accounts, account summaries, properties, get property, list data streams)
  • Property and account dropdowns backed by new selectors, so you pick a property instead of pasting a numeric ID; advanced mode still takes a manual ID for referencing an earlier block
  • Report rows come back flattened and keyed by dimension/metric API name rather than GA4's parallel positional arrays
  • OAuth service google-analytics requesting only analytics.readonly (plus userinfo) — every operation is a read, so no analytics.edit
  • Wires the deployment capability, service-account projection, generated tool metadata, and integration docs

Type of Change

  • New feature

Testing

Tested manually. bun run check:audits (33/33), bunx turbo run type-check (26/26), bun run lint, and the integration/selector suites all pass.

Two bug classes worth calling out, caught during validation and fixed:

  • switch sub-blocks serialize as the strings 'true'/'false' and as null when untouched, so a raw mapping inverted every toggle and put a literal null on the wire. Coerced in both the block and the tools.
  • An untouched numeric input resolves to null, and Number(null) is 0 — a blank Limit was sending limit: 0 instead of omitting it.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Adds a Google Analytics block backed by the GA4 Data and Admin APIs, with
property and account selectors, OAuth wiring, and generated docs.
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 25, 2026 7:01pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a Google Analytics 4 integration spanning OAuth, workflow selectors, reporting and administration tools, generated metadata, deployment configuration, and documentation.

  • Introduces ten read-only GA4 Data and Admin API operations.
  • Adds account and property selectors backed by authorized API routes.
  • Normalizes report responses into field-keyed rows and wires integration discovery across product surfaces.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/google_analytics.ts Defines the GA4 workflow block, operation-specific fields, selector wiring, parameter normalization, and output mappings.
apps/sim/tools/google_analytics/run_report.ts Implements standard GA4 report requests and transforms positional provider rows into field-keyed output.
apps/sim/tools/google_analytics/get_metadata.ts Implements metadata retrieval with separate dimension and metric response shapes and optional custom-definition filtering.
apps/sim/app/api/tools/google_analytics/properties/route.ts Adds an authorized, bounded account-summary traversal used to populate the property selector.
apps/sim/hooks/selectors/providers/google-analytics/selectors.ts Maps authorized account and property route responses into workflow selector options.
apps/sim/lib/oauth/oauth.ts Registers the read-only Google Analytics OAuth service and required user-information scopes.
packages/deployment-config/src/integrations.json Adds Google Analytics deployment capability and service-account availability metadata.

Sequence Diagram

sequenceDiagram
  participant User
  participant Block as GA4 Workflow Block
  participant Selector as Account/Property Selector
  participant Auth as Credential Authorization
  participant Google as Google Analytics APIs
  User->>Block: Configure operation and credential
  Block->>Selector: Request accounts or properties
  Selector->>Auth: Authorize credential use
  Auth->>Google: Fetch paginated resources
  Google-->>Selector: Accounts or properties
  Selector-->>Block: Selectable options
  User->>Block: Run workflow
  Block->>Auth: Resolve OAuth access token
  Auth->>Google: Execute Data or Admin API request
  Google-->>Block: GA4 response
  Block-->>User: Normalized workflow output
Loading

Reviews (3): Last reviewed commit: "fix(google-analytics): correct metadata ..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread apps/sim/tools/google_analytics/list_data_streams.ts Outdated
Comment thread apps/sim/tools/google_analytics/get_metadata.ts Outdated
Comment thread apps/sim/app/api/tools/google_analytics/properties/route.ts Outdated
Comment thread apps/sim/app/api/tools/google_analytics/properties/route.ts Outdated
Comment thread apps/sim/tools/google_analytics/list_account_summaries.ts Outdated
Comment thread apps/sim/blocks/blocks/google_analytics.ts Outdated
… params

- DimensionMetadata has no dataType field; split dimension/metric metadata
  shapes and expose category, plus expression on metrics
- Treat null pageSize/limit/offset as omitted so they are not serialized
- Bound provider error body reads and surface pagination truncation
- Keep the property scope on report canvas cards
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

…ics-integration

# Conflicts:
#	apps/sim/tools/generated/tool-ids.ts
#	apps/sim/tools/generated/tool-metadata.ts
#	apps/sim/tools/generated/tool-outputs.ts
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.

1 participant