Skip to content

feat(ketch): add Ketch privacy consent integration#3794

Merged
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/add-ketch-integration
Mar 26, 2026
Merged

feat(ketch): add Ketch privacy consent integration#3794
waleedlatif1 merged 4 commits intostagingfrom
waleedlatif1/add-ketch-integration

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Add Ketch integration for managing privacy consent, subscriptions, and data subject rights
  • 5 tools: get/set consent, get/set subscriptions, invoke right (access, delete, correct, restrict processing)
  • Ketch Web API is unauthenticated — no API key or OAuth required
  • Includes block, icon, docs, and registry entries

Type of Change

  • New feature

Testing

Tested manually

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)

@cursor
Copy link

cursor bot commented Mar 26, 2026

PR Summary

Medium Risk
Adds a new external integration that makes live HTTP calls to Ketch’s public Web API and parses user-provided JSON, so failures/malformed inputs could surface at runtime. Changes are additive and isolated to new tools/registry entries with minimal impact on existing integrations.

Overview
Adds Ketch as a new integration across the product: new KetchBlock with configurable operations (get/set consent, get/set subscriptions, invoke rights) and wiring into the block registry.

Implements five new Ketch tools that call Ketch’s public Web API endpoints and normalizes responses/errors, plus shared types.ts for tool inputs/outputs.

Updates docs and UI plumbing: introduces KetchIcon, maps ketch in docs/landing icon mappings, adds ketch.mdx and includes ketch in tools meta.json and landing integrations.json.

Written by Cursor Bugbot for commit 166f53b. Configure here.

@vercel
Copy link

vercel bot commented Mar 26, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 26, 2026 10:45pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR adds a Ketch privacy consent integration with 5 tools covering the full Ketch Web API surface: get/set consent, get/set subscriptions, and invoke data subject rights. The implementation follows all established patterns in the codebase — block config, tool files, type definitions, icon registration, docs, and registry entries are all present and correctly wired.

Key changes:

  • New apps/sim/tools/ketch/ directory with 5 tool implementations and shared types
  • apps/sim/blocks/blocks/ketch.ts block config with conditional sub-blocks per operation
  • Icons added to both apps/sim/components/icons.tsx and apps/docs/components/icons.tsx
  • Block and tool registrations in their respective registry.ts files
  • Documentation page at apps/docs/content/docs/en/tools/ketch.mdx
  • Integration metadata added to integrations.json

Minor issues found:

  • The get_consent tool supports an optional purposes filter parameter, but the block's params function only passes purposes to the API for set_consent. There is also no corresponding UI sub-block for this filter in the get_consent context, so the filtering capability is silently unavailable to users.
  • Error-path output objects across several tools (get_consent, get_subscriptions, set_subscriptions) include an untyped error field not declared in the TypeScript response interfaces, creating a minor type-safety gap.

Confidence Score: 4/5

Safe to merge; the integration is well-structured and follows all codebase conventions with only minor P2 issues.

All 5 tools are correctly implemented and registered. Error handling, 204 responses, and JSON body construction are handled properly throughout. The two flagged issues (unexposed get_consent filter and error-output type mismatch) are non-blocking and don't affect the primary user path.

apps/sim/blocks/blocks/ketch.ts (purposes filter wiring) and the error response shapes across the tool files.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/ketch.ts Block config for all 5 Ketch operations; correctly uses conditional sub-blocks and merges the dual jurisdiction-code fields; optional purposes filter for get_consent is not wired through.
apps/sim/tools/ketch/get_consent.ts Implements consent retrieval; error output shape has an untyped error field; only organizationCode is trimmed while propertyCode/environmentCode are not.
apps/sim/tools/ketch/set_consent.ts Consent update tool; correctly handles 204 No Content; defaults collectedAt to Math.floor(Date.now() / 1000) when not provided.
apps/sim/tools/ketch/invoke_right.ts Data subject rights invocation; maps userData param to user key in the request body as expected by the Ketch API; handles 204 gracefully.
apps/sim/tools/ketch/types.ts Clean shared type definitions covering all 5 operations; CONSENT_PURPOSE_OUTPUT_PROPERTIES reused across tools; types align with Ketch Web API shape.
apps/sim/tools/ketch/get_subscriptions.ts Subscription retrieval tool; straightforward implementation matching the API contract.
apps/sim/tools/ketch/set_subscriptions.ts Subscription update tool; error output includes untyped error field (same pattern as get_consent); otherwise clean.
apps/sim/tools/ketch/index.ts Re-exports all 5 Ketch tools with the expected ketch*Tool naming convention.
apps/sim/blocks/registry.ts Correctly registers KetchBlock in alphabetical order.
apps/sim/tools/registry.ts All 5 Ketch tools registered in correct alphabetical position (between jina_* and linkup_*).

Sequence Diagram

sequenceDiagram
    participant User
    participant KetchBlock as Ketch Block (UI)
    participant Params as params()
    participant Tool as Tool Handler
    participant API as Ketch Web API (global.ketchcdn.com)

    User->>KetchBlock: Select operation + fill fields
    KetchBlock->>Params: Resolve tool name (ketch_${operation})
    Params->>Params: Merge jurisdictionCode / jurisdictionCodeOptional
    Params->>Params: Parse JSON fields (identities, purposes, topics, etc.)
    Params->>Tool: Dispatch to ketch_get_consent / set_consent / get_subscriptions / set_subscriptions / invoke_right

    alt get_consent
        Tool->>API: POST /web/v2/consent/{org}/get
        API-->>Tool: 200 { purposes, vendors }
    else set_consent
        Tool->>API: POST /web/v2/consent/{org}/update
        API-->>Tool: 200 { purposes } or 204 No Content
    else get_subscriptions
        Tool->>API: POST /web/v2/subscriptions/{org}/get
        API-->>Tool: 200 { topics, controls }
    else set_subscriptions
        Tool->>API: POST /web/v2/subscriptions/{org}/update
        API-->>Tool: 200
    else invoke_right
        Tool->>API: POST /web/v2/rights/{org}/invoke
        API-->>Tool: 200 { message } or 204 No Content
    end

    Tool-->>User: Structured output (purposes / topics / success / message)
Loading

Comments Outside Diff (1)

  1. apps/sim/blocks/blocks/ketch.ts, line 436-457 (link)

    Optional purposes filter not wired for get_consent

    The ketch_get_consent tool supports an optional purposes parameter to filter which consent purposes are returned, but the block's params function only passes purposes to the API when operation === 'set_consent'. As a result, users currently have no way to leverage this filtering capability through the block UI.

    The purposes sub-block is also conditionally hidden to set_consent only (condition: { field: 'operation', value: 'set_consent' }), so the field never appears for get_consent either.

    If purpose-filtering for get_consent is an intended feature, a separate optional sub-block (e.g. purposesFilter) with condition: { field: 'operation', value: 'get_consent' } would be needed, along with a corresponding branch in the params function. If it's intentionally omitted for now, a code comment would help clarify the decision.

Reviews (3): Last reviewed commit: "fix(ketch): include errorMessage in erro..." | Re-trigger Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1
Copy link
Collaborator Author

All greptile findings addressed:

  • P1 Missing response.ok checks — fixed in 3790a4b, all 5 tools now guard on response.ok
  • P1 Error messages silently discarded — fixed in 166f53b, error: errorMessage included in all error outputs
  • P2 Registry alphabetical order — fixed in 3790a4b, ketch entries moved after jina_search
  • Optional purposes filter not wired for get_consent — fixed in f42a763, added purposesFilter subBlock (advanced mode) and wired it in params

@waleedlatif1 waleedlatif1 merged commit f37e4b6 into staging Mar 26, 2026
6 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/add-ketch-integration branch March 26, 2026 22:50
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