AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
feat(web): report which platform admin pages and buttons admins use, and where their plan stops them (#15640)
Ahmad Tash6682aac9f399
diff --git a/brain/knowledge/decisions/000045-platform-admin-telemetry-is-sent-from-every-edition.md b/brain/knowledge/decisions/000045-platform-admin-telemetry-is-sent-from-every-edition.mdnew file mode 100644index 00000000000..7c484a7824d--- /dev/null+++ b/brain/knowledge/decisions/000045-platform-admin-telemetry-is-sent-from-every-edition.md@@ -0,0 +1,59 @@+---+status: accepted+---++# Platform admin telemetry is sent from every edition++## Decision++The six `platform.admin.*` events are deliberately **not** in+`CLOUD_ONLY_TELEMETRY_EVENTS`. They fire wherever product analytics is on, which+means Cloud always, and self-hosted CE and EE whenever the platform owner has+switched Product analytics on under Account > Configurations.++## Context++The account and sign-in events went the other way: decision+`000034-account-and-sign-in-telemetry-is-cloud-only` put all thirteen behind+`CLOUD_ONLY_TELEMETRY_EVENTS` and hid them from the self-hosted disclosure dialog.+A reader who meets that rule first will reasonably assume every new event follows+it, so the divergence is worth stating rather than leaving to be discovered from a+missing set membership.++## Why++Platform administration is the one surface where self-hosted signal is worth more+than Cloud signal. Cloud admins are a small, well-instrumented population we can+ask directly; EE admins are the people the admin redesign was drawn for, and+we have no other read on which of those pages they open or which locked control+they press. Fencing the events to Cloud would leave the redesign unmeasurable+exactly where it matters.++The consent argument that carried `000034` does not apply here. Account events fire+during sign-up, before anyone could have opted in, and eleven of the thirteen could+not physically happen off Cloud. These fire only for a signed-in platform admin on+an instance whose owner has already turned the switch on, and+`tracked-events-catalog.ts` is a `Record` over the whole enum, so the compiler+refuses to build until each one is described in the "Events we track" dialog those+same admins read. The disclosure is enforced, not promised.++Rejected: mirroring `000034` for symmetry. Consistency between the two sets is not+a property anyone benefits from, and buying it costs the only admin-usage data we+would ever get from Enterprise.++## Consequences++Self-hosters see a new **Platform administration** group in the disclosure dialog+listing all six events, and the existing `tracked-events-catalog` test that+asserts which groups appear had to be updated to expect it. Any later+`platform.admin.*` event inherits this decision by default; putting one in+`CLOUD_ONLY_TELEMETRY_EVENTS` is now the choice that needs an argument.++Comparisons across editions must account for the switch: a self-hosted instance+with analytics off contributes nothing, so absence in the data is not absence of+use. Event volume is not a population count.++On Cloud, the Cloud-only `admin.nav.locked.clicked` (a crowned sidebar row, whose+page then records a `page.viewed`) and `sales.handoff.clicked` (Contact+Sales, alongside `sales.contacted`) cover some of the same moments. They are+separate events, so never add them to these when counting.diff --git a/brain/knowledge/decisions/000046-admin-button-clicks-are-one-event-with-a-control-id.md b/brain/knowledge/decisions/000046-admin-button-clicks-are-one-event-with-a-control-id.mdnew file mode 100644index 00000000000..ca015e1ade4--- /dev/null+++ b/brain/knowledge/decisions/000046-admin-button-clicks-are-one-event-with-a-control-id.md@@ -0,0 +1,57 @@+---+status: accepted+---++# Admin button clicks are one event with a control id++## Decision++Every clickable control in the platform admin reports through one event,+`platform.admin.control.clicked`, with `{ control, page }`. `control` is a member of one+`AdminControl` enum and `page` is the route pattern. It records clicks only, copy buttons and external+links included, not whether the action then succeeded.++Ids are named `area.thing.action` (`pieces.install.open`, `projects.delete.confirm`,+`api-keys.value.copy`), so they survive a reworded or translated label. The action is one of+`open`, `submit`, `confirm`, `toggle`, `select`, `copy`, `link` or `run` (a button that acts+at once, such as Sync or Refresh). Cancel, Close and Back carry no id. A control opts in by+carrying `adminControl(AdminControl.AREA_THING_ACTION)`, and one click listener on the admin layout+reports it. Keeping new buttons covered is a convention for reviewers, not a failing test.+A control the plan has locked carries no id, because its click already reports+`platform.admin.gate.blocked`, and that event names the control with the same enum member, so+clicks and blocks join on one key.++## Context++Decision `000045` gave the paywall surfaces five named events. The admin has some 190 more+controls (Install Piece, New Project, Invite, Delete, Save, toggles, copy, docs links). On+Cloud, autocapture is fenced to the auth funnel, so none of them reported anything beyond+`platform.admin.page.viewed`.++## Why++A named event per control costs a `TelemetryEventName` member, a unique label in the "Events we track"+dialog (the catalog test requires one per event) and a shared version bump, about 190 times.+One event keeps the disclosure dialog to a single plain-language line, and a new button costs+one web-only `AdminControl` member, with no label and no shared bump.++Rejected: PostHog autocapture on `/platform/*`. It records element text, and admin tables+show emails and project, connection and key names, which breaks the no-names rule of+`000045`. It also only runs on Cloud.++## Consequences++Dashboards split by `control`, not by event name, and renaming a control starts a new series+rather than moving the old one. A submit click fires even when validation or the API fails,+so `*.submit` means attempted, not done. Billing, invites and plan changes already emit+server-side events, so web clicks there would double count outcomes. The paywall events from+`000045` stay as they are; never add them to this one when counting.++A Radix Select value choice carries no id. Radix selects on pointer-up and unmounts the item,+and sets `pointer-events: none` on the body while open, so a document click listener cannot+see the choice reliably. Tag a button or menu item instead, or report it from the select's+`onValueChange`.++The consent controls on Configurations (the Product analytics and Deployment setup switches and+its Save) carry no id. Turning analytics off would send a click at the moment of opting out, and+turning it on would be dropped because consent is not saved yet.diff --git a/brain/knowledge/engineering/ci-pipeline.md b/brain/knowledge/engineering/ci-pipeline.mdindex 815370ca5d2..3cd954ee91f 100644--- a/brain/knowledge/engineering/ci-pipeline.md+++ b/brain/knowledge/engineering/ci-pipeline.md@@ -29,6 +29,7 @@ The PR checks that decide whether a change builds and passes tests. Lives in `.g- The engine's tests execute five pieces (`AP_DEV_PIECES` in `packages/server/engine/vitest.config.ts`: http, data-mapper, approval, webhook, delay), so those five are engine devDependencies. That edge is what makes `--affected` pull engine in when one of them changes; without it a pieces-only PR ran the piece's checks and skipped the engine tests that exercise it (caught on the retirement PR, 2026-09-27). Three lists name the same set and must move together: that `AP_DEV_PIECES`, `@activepieces/engine#test` `dependsOn` in `turbo.json`, and engine's devDependencies.- `TURBO_SCM_BASE` must be `origin/<base branch>` in CI. turbo's default base is `main`, which a CI checkout does not have, so without it every run degrades to "everything affected".- Required status checks are set by a repo admin (branch ruleset on `main`) and match on job display name. A job its `if:` skips reports `skipped`, which GitHub counts as passing, so every job here can be required: `changes`, `lint`, `build-test`, `api (ce)`, `api (cloud)`, `api (ee, unit, migrations)`, `tool-search (postgres)`. A workflow-level skip (`on.paths`) leaves a required check pending forever, so keep the filtering inside the `changes` job. On 2026-09-27, when the old `ci.yml` was retired, nothing was required yet: `isRequired` was false on every check and the only ruleset enforced codeowner review.+- CI runs Node 24. A web jsdom test that navigates through a data router (`createMemoryRouter` + `RouterProvider`, including a `<Navigate>` redirect) passes on Node 20 and fails on 24. The test times out on an empty `<div />`, and the swallowed unhandled rejection reads `RequestInit: Expected signal ... to be an instance of AbortSignal`, because Node's undici `Request` rejects jsdom's `AbortSignal`. Mount routes with `<MemoryRouter>` + `useRoutes`/`<Routes>` instead, and run web tests on Node 24 locally before calling them green.## Key filesdiff --git a/brain/knowledge/engineering/ci-pr-review-hygiene.md b/brain/knowledge/engineering/ci-pr-review-hygiene.mdindex dae907053d3..fe6a5caee7e 100644--- a/brain/knowledge/engineering/ci-pr-review-hygiene.md+++ b/brain/knowledge/engineering/ci-pr-review-hygiene.md@@ -56,6 +56,7 @@ Enforcement is the **`Codeowners review` repository ruleset** (active on the def- **`@activepieces/shared` re-exports from `@activepieces/core-execution`, so a partial rebuild produces phantom "has no exported member" errors in unrelated files.** Rebuilding `core/shared` against a stale `core/execution` dist drops those re-exports, and the API typecheck then fails in `ee/agent/*` on symbols like `GetPersonalizationConfigRequest` — which live in `core/execution/src/lib/workers/worker-contract.ts`, not in shared at all. It reads exactly like a bad merge. The dependency order that actually works is `core/utils` → `core/piece-types` → `core/formula` → `core/execution` → `core/shared` → `server/utils` → `pieces/framework` → `core/ai-providers`; skipping a link silently poisons everything downstream of it. The same staleness makes an editor report missing enum members that exist in the source. **There is no api typecheck "error baseline" — rebuild first, then trust it.** A stale `core/shared/dist` reliably yields a handful of `ee/agent` errors that look permanent enough to be waved off as known, which is how a real error hides among them; after `npx turbo run build --filter=@activepieces/shared`, `tsc --noEmit -p packages/server/api/tsconfig.app.json` comes back completely clean. The same staleness invents errors in files a rebase just touched, so during a conflict resolution rebuild before concluding you resolved it wrong.- **To pull a file back out of a PR, restore it from the merge-base, never from `origin/main`.** A PR's diff is computed against the merge-base, so `git checkout origin/main -- <file>` does not "revert" the file — it imports every change `main` made to it since the fork and attributes them to you. Dropping one web file from [#15001](https://github.com/activepieces/activepieces/pull/15001) that way would have silently added 82 insertions / 44 deletions of somebody else's work. `git checkout $(git merge-base origin/main HEAD) -- <file>` makes it byte-identical to where the branch started, so it leaves the diff entirely and merges cleanly instead of conflicting. Verify with `git diff --quiet $(git merge-base origin/main HEAD) -- <file>` before committing, and read `git status` first — a `bun.lock` left dirty by an earlier `bun install` loves to ride along on a commit like this.- **Retargeting a stacked PR to `main` does not drop its base branch — it merges the whole thing.** A PR opened against a long-lived feature branch shows a small diff *relative to that base*, but `gh pr edit --base main` only moves the target; the branch still contains every commit of its old base. [#14593](https://github.com/activepieces/activepieces/pull/14593) read as 2 docs files against `feat/autumn-billing-integration` and as 198 commits / 211 files / +12k lines against `main`. Check with `git diff --stat origin/main...<branch>` **before** retargeting, and if it disagrees with the PR page, cherry-pick that PR's own commits onto `main` and force-push instead. A "conflict" on such a PR is often against the feature base only — those same commits can apply to `main` cleanly.+- **Never `git merge main` into a PR whose stacked base was squash-merged: it brings back files `main` has since deleted, with no conflict.** The merge base predates the squash, so a file the stack added and a later `main` PR removed reads as added on one side only, and git keeps it. On [#15640](https://github.com/activepieces/activepieces/pull/15640) a merge would have restored the eight `admin-pages.ts` and `overview/*` files #15727 deleted, on top of ~30 conflicts. Replay only the PR's own commits with `git rebase --onto origin/main <base PR's last commit> <branch>` and force-push; that left five conflicted files.- **Each link of a stack runs CI against its own base, so verifying the top proves nothing about the ones below it.** A refactor that lands on the bottom branch and is repaired two branches up is green where you tested and red on the PR that actually carries it, and the failure reads as unrelated because the file it names was fine when you last looked at it. Before pushing a stack, check out each branch in turn and run the package's typecheck, lint and full test suite there, not just at the tip; the suites legitimately differ (this stack's tip runs two more web tests than its base). Do the same after any rebase, since a conflict resolved in one replay can leave a lower branch importing something only a higher one defines.- **A deliberately stacked PR is charged only for its own delta, but each link pays its own `@activepieces/shared` bump.** `pr-size-check.ts` diffs `HEAD^1...HEAD^2` on the `pull_request` merge commit precisely so an ancestor PR is not re-counted — a stack member measures the same whether reviewed against `main` or against the PR below it, so splitting a large change into a stack really does buy budget rather than just moving it. Two things the split still costs you. Every PR in the stack that touches `packages/core/shared` needs its **own** version increment (0.158.0 then 0.159.0, not the same bump twice), and `bun.lock` records each workspace's version, so edit that one line **by hand** in each — regenerating sweeps `main`'s pending drift into your diff, per the regenerator trap above. And prove the split is faithful before pushing: tag the pre-split commit, then `git diff <tag>..<stack tip>` must come back empty apart from those intentional version lines. A file that lands partially in one PR and grows in the next (a service that gains its read side, a test file that gains its endpoint cases) is exactly where a hand-split silently drops a hunk.- **A migration-check failure in a stack names the PR that *introduced* the file, which is usually not the branch you are sitting on.** `check-migration-rollback.ts` lists candidates with `git diff --name-only --diff-filter=A origin/$GITHUB_BASE_REF...HEAD`, so a migration is only ever scanned on the stack member that **adds** it; every branch above inherits the file and its CI stays green on that check. So the pasted failure belongs to the lowest link, and editing the file on the tip you happen to have checked out fixes nothing the gate looks at. Confirm ownership before touching anything — `gh pr view <n> --json headRefName` for the branch the number really points at, then `git cat-file -e <branch>:<path>` across the stack for the first branch holding the file — fix it there, and rebase upward. Two things make that cheap: the file is usually byte-identical across the stack (`git diff <lower> <upper> -- <path>` comes back empty), and `git rebase` reports `skipped previously applied commit` for the lower branch's pre-rebase commits, which is the expected signal rather than a lost commit. Verify each link the same way the split rule above does — tag the old tip, then `git diff <tag> <rebased branch>` must show only the intended delta. Hit on PR 15240 (`feat/mcp-activity-recording`) while its own migration read as a failure on `feat/mcp-activity-serve` two links up.diff --git a/brain/knowledge/engineering/platform-admin-structure.md b/brain/knowledge/engineering/platform-admin-structure.mdindex 2bcdee8ea20..81b053274b6 100644--- a/brain/knowledge/engineering/platform-admin-structure.md+++ b/brain/knowledge/engineering/platform-admin-structure.md@@ -158,6 +158,18 @@ silently. Worker groups is the last page on the old full-page teaser.hiding them (AI Center's old `allowWrite`) only makes the teaser look empty. The overlay is UI only:a server gate is a separate `platformMustHaveFeatureEnabled`, and AI Center's write routes have none.A feature sold on a tier not in `FeatureTier` (AI Center is on Plus) needs that tier added there first.+- **`platform.admin.page.viewed` fires from the route's `SuspenseWrapper`**, which no redirect renders, so a+ page route without one (Billing's Stripe return pages) is never counted. `page` is the route pattern, not+ the URL, and `locked` is true only under the sample overlay, not on a crowned page that locks another way.+ Renaming a route therefore starts a new series in PostHog; the old one stops, it does not move.+- **A new admin action control reports its click by carrying `adminControl(AdminControl.AREA_THING_ACTION)`** (decision+ `000046`). Spread it on the element that receives the click and add the member to the `AdminControl` enum in+ `src/lib/admin-control.ts`, with the id `area.thing.action` as its value; a test pins the id naming, the+ member spelling and that every member is used. One document click listener, mounted by `SuspenseWrapper`, reports the nearest tagged element,+ dialogs and menus included. A shared component needs an optional prop to tag a button it renders itself+ (`controlId` on `ConfirmationDeleteDialog` and `CopyToClipboardInput`). Do not tag Cancel or Close, the paywall+ buttons that already report `platform.admin.*` events, the Configurations consent controls, or a Radix+ Select value choice, which a click listener cannot see reliably.- **Moving or renaming a route needs a `LEGACY_PATHS` row**, or every bookmark, doc link and in-flightStripe checkout to the old URL lands on a 404.- **Source folders still follow the old grouping** (`routes/platform/security/embed`,diff --git a/bun.lock b/bun.lockindex c0abd161d6d..42da3687229 100644--- a/bun.lock+++ b/bun.lock@@ -165,7 +165,7 @@},"packages/core/shared": {"name": "@activepieces/shared",- "version": "0.190.0",+ "version": "0.191.0","dependencies": {"@activepieces/core-execution": "workspace:*","@activepieces/core-formula": "workspace:*",diff --git a/packages/core/shared/package.json b/packages/core/shared/package.jsonindex f99d70d6eb6..6ddecbf2e2a 100644--- a/packages/core/shared/package.json+++ b/packages/core/shared/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/shared",- "version": "0.190.0",+ "version": "0.191.0","type": "commonjs","sideEffects": false,"main": "./dist/src/index.js",diff --git a/packages/core/shared/src/lib/core/common/telemetry.ts b/packages/core/shared/src/lib/core/common/telemetry.tsindex de456b1cbeb..84428aac3cf 100644--- a/packages/core/shared/src/lib/core/common/telemetry.ts+++ b/packages/core/shared/src/lib/core/common/telemetry.ts@@ -131,6 +131,38 @@ type McpToolCalled = {toolName: string}+type PlatformAdminPageViewed = {+ page: string+ locked: boolean+}++type PlatformAdminGateBlocked = {+ feature: string+ control: string+}++type PlatformAdminUpgradeClicked = {+ feature: string | null+ tier: string | null+ surface: PlatformAdminSurface+}++type PlatformAdminSalesContacted = {+ feature: string+ surface: Exclude<PlatformAdminSurface, PlatformAdminSurface.DIALOG>+}++type PlatformAdminControlClicked = {+ control: string+ page: string+}++type PlatformAdminLimitReached = {+ limit: PlatformAdminLimit+ used: number+ allowed: number | null+}+type McpServerConnected = {userId: stringprojectId?: string@@ -173,6 +205,23 @@ export enum TelemetryEventName {INVITE_ACCEPTED = 'invite.accepted',SALES_HANDOFF_CLICKED = 'sales.handoff.clicked',ADMIN_NAV_LOCKED_CLICKED = 'admin.nav.locked.clicked',+ PLATFORM_ADMIN_PAGE_VIEWED = 'platform.admin.page.viewed',+ PLATFORM_ADMIN_GATE_BLOCKED = 'platform.admin.gate.blocked',+ PLATFORM_ADMIN_UPGRADE_CLICKED = 'platform.admin.upgrade.clicked',+ PLATFORM_ADMIN_SALES_CONTACTED = 'platform.admin.sales.contacted',+ PLATFORM_ADMIN_LIMIT_REACHED = 'platform.admin.limit.reached',+ PLATFORM_ADMIN_CONTROL_CLICKED = 'platform.admin.control.clicked',+}++export enum PlatformAdminSurface {+ SAMPLE = 'sample',+ TEASER = 'teaser',+ DIALOG = 'dialog',+ LIMIT = 'limit',+}++export enum PlatformAdminLimit {+ TEAM_PROJECTS = 'teamProjects',}export type TelemetryEvent =@@ -206,6 +255,12 @@ export type TelemetryEvent =| BaseTelemetryEvent<TelemetryEventName.INVITE_ACCEPTED, InviteAccepted>| BaseTelemetryEvent<TelemetryEventName.SALES_HANDOFF_CLICKED, SalesHandoffClicked>| BaseTelemetryEvent<TelemetryEventName.ADMIN_NAV_LOCKED_CLICKED, AdminNavLockedClicked>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_PAGE_VIEWED, PlatformAdminPageViewed>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED, PlatformAdminGateBlocked>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_UPGRADE_CLICKED, PlatformAdminUpgradeClicked>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED, PlatformAdminSalesContacted>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED, PlatformAdminLimitReached>+ | BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_CONTROL_CLICKED, PlatformAdminControlClicked>export const CLOUD_ONLY_TELEMETRY_EVENTS: ReadonlySet<TelemetryEventName> = new Set([TelemetryEventName.ONBOARDING_COMPLETED,diff --git a/packages/web/public/locales/en/translation.json b/packages/web/public/locales/en/translation.jsonindex 28245aa9141..721fbd58873 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -3159,6 +3159,13 @@"Pay your provider directly, with no model markup": "Pay your provider directly, with no model markup","Add an AI provider before uploading. Files are indexed when uploaded so agents can search them.": "Add an AI provider before uploading. Files are indexed when uploaded so agents can search them.","This file has no text that can be searched.": "This file has no text that can be searched.",+ "Platform administration": "Platform administration",+ "Opened a platform administration page": "Opened a platform administration page",+ "Used a control your plan does not include": "Used a control your plan does not include",+ "Opened the upgrade options from a locked feature": "Opened the upgrade options from a locked feature",+ "Started a sales enquiry from a locked feature": "Started a sales enquiry from a locked feature",+ "Reached a plan limit": "Reached a plan limit",+ "Clicked a button on a platform administration page": "Clicked a button on a platform administration page","{value} (not in the list)": "{value} (not in the list)","invalidHexColor": "Enter a color as #abc or #aabbcc","Surface": "Surface",diff --git a/packages/web/src/app/components/feature-banner.tsx b/packages/web/src/app/components/feature-banner.tsxindex 62130907d19..5661c67a2d6 100644--- a/packages/web/src/app/components/feature-banner.tsx+++ b/packages/web/src/app/components/feature-banner.tsx@@ -5,6 +5,7 @@ import { ExternalLink } from 'lucide-react';import { Alert, AlertDescription } from '@/components/ui/alert';import { useManagePlanDialogStore } from '@/features/billing';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';export function FeatureBanner({message,@@ -22,6 +23,7 @@ export function FeatureBanner({<span>{message}</span>{isCommunity ? (<a+ {...adminControl(AdminControl.PLAN_BANNER_LINK)}href={docsUrl}target="_blank"rel="noopener noreferrer"@@ -32,6 +34,7 @@ export function FeatureBanner({</a>) : (<button+ {...adminControl(AdminControl.PLAN_BANNER_OPEN)}type="button"onClick={() => openManagePlanDialog()}className="font-medium text-accent-11 hover:underline"diff --git a/packages/web/src/app/components/feature-sample.tsx b/packages/web/src/app/components/feature-sample.tsxindex f9613ce989c..8dc25902c5d 100644--- a/packages/web/src/app/components/feature-sample.tsx+++ b/packages/web/src/app/components/feature-sample.tsx@@ -1,7 +1,11 @@-import { ApEdition, ApFlagId } from '@activepieces/shared';+import {+ ApEdition,+ ApFlagId,+ PlatformAdminSurface,+} from '@activepieces/shared';import { t } from 'i18next';import { ExternalLink, Lock } from 'lucide-react';-import { ReactNode } from 'react';+import { createContext, ReactNode, useContext } from 'react';import { Button } from '@/components/ui/button';import {@@ -9,9 +13,10 @@ import {FeatureTier,RequestTrial,TIER_LABELS,- useManagePlanDialogStore,+ useUpgradeClick,} from '@/features/billing';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';export function FeatureSample({locked,@@ -23,7 +28,7 @@ export function FeatureSample({showContactSales = true,children,}: FeatureSampleProps) {- const { openDialog: openManagePlanDialog } = useManagePlanDialogStore();+ const upgradeClick = useUpgradeClick();const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);if (!locked) {@@ -39,7 +44,9 @@ export function FeatureSample({aria-hiddenclassName="flex flex-1 min-h-0 min-w-0 flex-col pointer-events-none select-none opacity-25">- {children}+ <InsideFeatureSampleContext.Provider value={true}>+ {children}+ </InsideFeatureSampleContext.Provider></div><div className="absolute inset-0 grid place-items-center overflow-auto p-6">@@ -58,9 +65,13 @@ export function FeatureSample({{isCommunity ? (<div className="flex flex-col items-center gap-3">{showContactSales && featureKey !== undefined && (- <RequestTrial featureKey={featureKey} />+ <RequestTrial+ featureKey={featureKey}+ surface={PlatformAdminSurface.SAMPLE}+ />)}<a+ {...adminControl(AdminControl.PLAN_SAMPLE_LINK)}href={documentationUrl ?? ENTERPRISE_DOCUMENTATION_URL}target="_blank"rel="noopener noreferrer"@@ -71,7 +82,16 @@ export function FeatureSample({</a></div>) : (- <Button className="w-full" onClick={() => openManagePlanDialog()}>+ <Button+ className="w-full"+ onClick={() =>+ upgradeClick({+ feature: featureKey,+ tier,+ surface: PlatformAdminSurface.SAMPLE,+ })+ }+ >{tier === undefined? t('Upgrade to unlock'): t('Upgrade to {tier}', { tier: TIER_LABELS[tier] })}@@ -93,6 +113,12 @@ export function FeatureSample({);}+export function useInsideFeatureSample(): boolean {+ return useContext(InsideFeatureSampleContext);+}++const InsideFeatureSampleContext = createContext(false);+const ENTERPRISE_DOCUMENTATION_URL ='https://www.activepieces.com/docs/install/configuration/overview#enterprise-edition-optional';diff --git a/packages/web/src/app/components/feature-teaser.tsx b/packages/web/src/app/components/feature-teaser.tsxindex 319e93b5b65..58a3b0172cd 100644--- a/packages/web/src/app/components/feature-teaser.tsx+++ b/packages/web/src/app/components/feature-teaser.tsx@@ -1,19 +1,20 @@-import { ApEdition, ApFlagId } from '@activepieces/shared';+import {+ ApEdition,+ ApFlagId,+ PlatformAdminSurface,+} from '@activepieces/shared';import { t } from 'i18next';import { Check, ExternalLink } from 'lucide-react';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';-import {- FeatureKey,- RequestTrial,- useManagePlanDialogStore,-} from '@/features/billing';+import { FeatureKey, RequestTrial, useUpgradeClick } from '@/features/billing';import {FeatureTier,TIER_LABELS,} from '@/features/billing/utils/feature-tier';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';export function FeatureTeaserContent({title,@@ -25,7 +26,7 @@ export function FeatureTeaserContent({featureKey,showContactSales = true,}: FeatureTeaserProps) {- const { openDialog: openManagePlanDialog } = useManagePlanDialogStore();+ const upgradeClick = useUpgradeClick();const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);const showcase =@@ -50,6 +51,7 @@ export function FeatureTeaserContent({{t('This is an Enterprise feature, available on our paid plans.')}</p><a+ {...adminControl(AdminControl.PLAN_TEASER_LINK)}href={docsUrl}target="_blank"rel="noopener noreferrer"@@ -60,7 +62,10 @@ export function FeatureTeaserContent({</a>{showContactSales && (<div className="w-fit pt-2">- <RequestTrial featureKey={featureKey} />+ <RequestTrial+ featureKey={featureKey}+ surface={PlatformAdminSurface.TEASER}+ /></div>)}{showcase}@@ -92,11 +97,20 @@ export function FeatureTeaserContent({)}<div className="flex items-center gap-3">- <Button onClick={() => openManagePlanDialog()}>+ <Button+ onClick={() =>+ upgradeClick({+ feature: featureKey,+ tier,+ surface: PlatformAdminSurface.TEASER,+ })+ }+ >{t('Upgrade plan')}</Button>{documentationUrl !== undefined && (<a+ {...adminControl(AdminControl.PLAN_TEASER_LINK)}href={documentationUrl}target="_blank"rel="noopener noreferrer"diff --git a/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tool-tier-list.tsx b/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tool-tier-list.tsxindex f3271903f81..225458d2b7c 100644--- a/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tool-tier-list.tsx+++ b/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tool-tier-list.tsx@@ -33,6 +33,7 @@ import {} from '@/components/ui/tooltip';import { useAuthorization } from '@/hooks/authorization-hooks';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { getToolCategories } from '../utils/mcp-tools-metadata';@@ -256,6 +257,7 @@ function TierRow({size="sm"className={cn('text-gray-11', someOff && 'text-gray-12')}onClick={onOpenTools}+ {...adminControl(AdminControl.MCP_TIER_TOOLS_OPEN)}aria-label={t('{tier}: {status}', {tier: copy.label,status: countLabel,@@ -267,6 +269,7 @@ function TierRow({<div className="flex w-8 justify-end">{!tier.locked && (<Switch+ {...adminControl(AdminControl.MCP_TIER_TOGGLE)}checked={editable.length > 0 && editableOn === editable.length}indeterminate={isPartial}disabled={readOnly || offForPlatform}diff --git a/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tools-sheet.tsx b/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tools-sheet.tsxindex 40f6cc2cac9..2dd16aeae4e 100644--- a/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tools-sheet.tsx+++ b/packages/web/src/app/components/project-settings/mcp-server/tool-tiers/mcp-tools-sheet.tsx@@ -21,6 +21,7 @@ import {SheetTitle,} from '@/components/ui/sheet';import { Switch } from '@/components/ui/switch';+import { AdminControl, adminControl } from '@/lib/admin-control';import { McpToolTierGroup, mcpToolTiers } from './mcp-tool-tiers';@@ -84,6 +85,7 @@ function TierTools({variant="outline"size="sm"className="shrink-0"+ {...adminControl(AdminControl.MCP_TOOLS_ALL_RUN)}onClick={() =>onSetAll({ names: editableNames, enabled: !allOn })}@@ -120,6 +122,7 @@ function TierTools({{!tier.locked && (<ItemActions><Switch+ {...adminControl(AdminControl.MCP_TOOL_TOGGLE)}checked={!offTools.includes(tool.name)}disabled={readOnly || offForPlatform}onCheckedChange={(checked) =>diff --git a/packages/web/src/app/connections/create-edit-connection-dialog.tsx b/packages/web/src/app/connections/create-edit-connection-dialog.tsxindex 921e55d27d2..709f8ed6ddc 100644--- a/packages/web/src/app/connections/create-edit-connection-dialog.tsx+++ b/packages/web/src/app/connections/create-edit-connection-dialog.tsx@@ -54,6 +54,7 @@ import {} from '@/features/connections';import { formUtils } from '@/features/pieces';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { authenticationSession } from '@/lib/authentication-session';import { BasicAuthConnectionSettings } from './basic-secret-connection-settings';@@ -277,6 +278,7 @@ function CreateOrEditConnectionSection({onClick={(e) => form.handleSubmit(() => upsertConnection())(e)}loading={isPending}type="submit"+ {...adminControl(AdminControl.CONNECTIONS_CONNECTION_SUBMIT)}>{reconnectConnection ? t('Reconnect') : t('Connect')}</Button>@@ -303,6 +305,7 @@ function CreateOrEditConnectionSection({}loading={isPending}type="submit"+ {...adminControl(AdminControl.CONNECTIONS_CONNECTION_SUBMIT)}>{t('Save')}</Button>diff --git a/packages/web/src/app/connections/new-connection-dialog.tsx b/packages/web/src/app/connections/new-connection-dialog.tsxindex 4123e55722a..d7dd1805a78 100644--- a/packages/web/src/app/connections/new-connection-dialog.tsx+++ b/packages/web/src/app/connections/new-connection-dialog.tsx@@ -18,6 +18,7 @@ import {import { Input } from '@/components/ui/input';import { ScrollArea } from '@/components/ui/scroll-area';import { piecesHooks } from '@/features/pieces';+import { AdminControl, adminControl } from '@/lib/admin-control';import { CreateOrEditConnectionDialog } from './create-edit-connection-dialog';@@ -102,6 +103,7 @@ const NewConnectionDialog = React.memo(<divkey={index}onClick={() => clickPiece(piece.name)}+ {...adminControl(AdminControl.CONNECTIONS_PIECE_OPEN)}className="border p-2 h-[150px] w-[150px] flex flex-col items-center justify-center hover:bg-gray-4 hover:text-gray-12 cursor-pointer rounded-lg"><LogoPlatediff --git a/packages/web/src/app/connections/reconnect-button-dialog.tsx b/packages/web/src/app/connections/reconnect-button-dialog.tsxindex d2f44bd6dd0..fed8d597aa5 100644--- a/packages/web/src/app/connections/reconnect-button-dialog.tsx+++ b/packages/web/src/app/connections/reconnect-button-dialog.tsx@@ -14,6 +14,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { piecesHooks } from '@/features/pieces';+import { AdminControl, adminControl } from '@/lib/admin-control';type ReconnectButtonDialogProps = {connection: AppConnectionWithoutSensitiveData;@@ -42,6 +43,9 @@ const ReconnectButtonDialog = ({onClick={() => setOpen(true)}disabled={!hasPermission}variant={'ghost'}+ {...adminControl(+ AdminControl.CONNECTIONS_CONNECTION_RECONNECT_OPEN,+ )}><Cable className="h-4 w-4" /></Button>diff --git a/packages/web/src/app/routes/platform-routes.tsx b/packages/web/src/app/routes/platform-routes.tsxindex 7dcc2b677a7..fbe30678efe 100644--- a/packages/web/src/app/routes/platform-routes.tsx+++ b/packages/web/src/app/routes/platform-routes.tsx@@ -1,5 +1,5 @@-import React, { Suspense } from 'react';-import { Navigate } from 'react-router-dom';+import React, { Suspense, useMemo } from 'react';+import { matchRoutes, Navigate, useLocation } from 'react-router-dom';import { PageTitle } from '@/app/components/page-title';import { RouteLoadingBar } from '@/components/custom/route-loading-bar';@@ -10,6 +10,8 @@ import { PlatformLayout } from '../components/platform-layout';import { LegacyPathRedirect } from './platform/legacy-path-redirect';import { LegacyTabRedirect } from './platform/legacy-tab-redirect';import { PlanFeatureSample } from './platform/plan-feature-sample';+import { useAdminControlClicks } from './platform/use-admin-control-clicks';+import { useAdminPageViewed } from './platform/use-admin-page-viewed';const SettingsBilling = React.lazy(() =>import('./platform/billing').then((m) => ({ default: m.BillingPlanTab })),@@ -92,10 +94,6 @@ const PlatformConnectionsPage = React.lazy(() => import('./platform/connections'),);-function SuspenseWrapper({ children }: { children: React.ReactNode }) {- return <Suspense fallback={<RouteLoadingBar />}>{children}</Suspense>;-}-const HEALTH_TAB_PATHS = { system: '', runs: 'runs', queue: 'queue' };const WORKERS_TAB_PATHS = { health: '', 'worker-groups': 'groups' };const AI_TAB_PATHS = { providers: '', capabilities: 'capabilities' };@@ -551,3 +549,18 @@ export const platformRoutes = ['/platform/infrastructure/*',].map((path) => ({ path, element: <LegacyPathRedirect /> })),];++function SuspenseWrapper({ children }: { children: React.ReactNode }) {+ const page = useAdminPage();+ useAdminPageViewed(page);+ useAdminControlClicks(page);+ return <Suspense fallback={<RouteLoadingBar />}>{children}</Suspense>;+}++function useAdminPage(): string {+ const { pathname } = useLocation();+ return useMemo(+ () => matchRoutes(platformRoutes, pathname)?.[0]?.route.path ?? pathname,+ [pathname],+ );+}diff --git a/packages/web/src/app/routes/platform/billing/index.tsx b/packages/web/src/app/routes/platform/billing/index.tsxindex b39ca0c6e55..11b19f5020c 100644--- a/packages/web/src/app/routes/platform/billing/index.tsx+++ b/packages/web/src/app/routes/platform/billing/index.tsx@@ -32,6 +32,7 @@ import {} from '@/features/billing';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { UsageTab } from './usage-tab';@@ -81,6 +82,7 @@ function BillingRefreshButton() {return (<Button+ {...adminControl(AdminControl.BILLING_REFRESH_RUN)}variant="outline"size="sm"className="shrink-0"@@ -158,7 +160,10 @@ function PlanTab({ platform, info }: PlanTabProps) {'Upgrade anytime to get more credits and unlock features.',)}</span>- <LinkButton onClick={openDialog}>+ <LinkButton+ {...adminControl(AdminControl.BILLING_PLANS_OPEN)}+ onClick={openDialog}+ >{t('Explore plans')}</LinkButton></div>@@ -224,6 +229,7 @@ function PlanTab({ platform, info }: PlanTabProps) {<div className="flex flex-col items-center gap-3">{hasBillingPortal && (<Button+ {...adminControl(AdminControl.BILLING_STRIPE_PORTAL_LINK)}variant="outline"className="w-full"loading={isOpeningPortal}@@ -236,6 +242,9 @@ function PlanTab({ platform, info }: PlanTabProps) {{!isCompedLifetimePlan &&(isNil(info.cancelAt) ? (<Button+ {...adminControl(+ AdminControl.BILLING_CANCEL_SUBSCRIPTION_OPEN,+ )}variant="link"className="text-danger-11 hover:text-danger-11"onClick={() => setIsCancelOpen(true)}@@ -244,6 +253,7 @@ function PlanTab({ platform, info }: PlanTabProps) {</Button>) : (<Button+ {...adminControl(AdminControl.BILLING_KEEP_PLAN_OPEN)}variant="default"className="w-full"onClick={() => setIsKeepPlanOpen(true)}@@ -358,16 +368,10 @@ function dayjsCancelDate(cancelAt: string): string {return dayjs(cancelAt).format('MMM D, YYYY');}-const LinkButton = ({- onClick,- children,-}: {- onClick: () => void;- children: React.ReactNode;-}) => (+const LinkButton = ({ children, ...props }: React.ComponentProps<'button'>) => (<buttontype="button"- onClick={onClick}+ {...props}className="inline-flex w-fit items-center gap-1 text-sm font-medium text-accent-11 hover:underline">{children}diff --git a/packages/web/src/app/routes/platform/connections/index.tsx b/packages/web/src/app/routes/platform/connections/index.tsxindex f74ec83c4fc..67cf82ce128 100644--- a/packages/web/src/app/routes/platform/connections/index.tsx+++ b/packages/web/src/app/routes/platform/connections/index.tsx@@ -40,6 +40,7 @@ import { appConnectionUtils } from '@/features/connections';import { PieceIconWithPieceName, piecesHooks } from '@/features/pieces';import { platformAppConnectionsQueries } from '@/features/platform-admin/hooks/platform-app-connections-hooks';import { getProjectName, projectCollectionUtils } from '@/features/projects';+import { AdminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';export default function PlatformConnectionsPage() {@@ -121,6 +122,7 @@ export default function PlatformConnectionsPage() {<CopyTextTooltiptitle={t('External ID')}text={row.original.externalId || ''}+ controlId={AdminControl.CONNECTIONS_EXTERNAL_ID_COPY}><div className="flex items-center gap-2 w-fit min-w-0"><PieceIconWithPieceNamediff --git a/packages/web/src/app/routes/platform/infra/configurations/tracked-events-catalog.ts b/packages/web/src/app/routes/platform/infra/configurations/tracked-events-catalog.tsindex 6de0d395504..29e78709ccd 100644--- a/packages/web/src/app/routes/platform/infra/configurations/tracked-events-catalog.ts+++ b/packages/web/src/app/routes/platform/infra/configurations/tracked-events-catalog.ts@@ -8,6 +8,7 @@ import {Layers,LucideIcon,Mail,+ Shield,User,Workflow,} from 'lucide-react';@@ -133,6 +134,30 @@ const buildEventLabels = (): Record<TelemetryEventName, TrackedEvent> => ({group: 'billing',label: t('Opened a paid admin page'),},+ [TelemetryEventName.PLATFORM_ADMIN_PAGE_VIEWED]: {+ group: 'platformAdmin',+ label: t('Opened a platform administration page'),+ },+ [TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED]: {+ group: 'platformAdmin',+ label: t('Used a control your plan does not include'),+ },+ [TelemetryEventName.PLATFORM_ADMIN_UPGRADE_CLICKED]: {+ group: 'platformAdmin',+ label: t('Opened the upgrade options from a locked feature'),+ },+ [TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED]: {+ group: 'platformAdmin',+ label: t('Started a sales enquiry from a locked feature'),+ },+ [TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED]: {+ group: 'platformAdmin',+ label: t('Reached a plan limit'),+ },+ [TelemetryEventName.PLATFORM_ADMIN_CONTROL_CLICKED]: {+ group: 'platformAdmin',+ label: t('Clicked a button on a platform administration page'),+ },});const buildGroups = (): TrackedEventGroup[] => {@@ -143,6 +168,11 @@ const buildGroups = (): TrackedEventGroup[] => {{ id: 'flows', title: t('Flows and the builder'), icon: Workflow },{ id: 'mcp', title: t('MCP'), icon: Layers },{ id: 'billing', title: t('Billing'), icon: CreditCard },+ {+ id: 'platformAdmin',+ title: t('Platform administration'),+ icon: Shield,+ },];return definitions.map((definition) => ({@@ -165,7 +195,8 @@ export type TrackedEventGroupId =| 'emailCodes'| 'flows'| 'mcp'- | 'billing';+ | 'billing'+ | 'platformAdmin';export type TrackedEvent = {group: TrackedEventGroupId;diff --git a/packages/web/src/app/routes/platform/infra/configurations/tracked-events-dialog.tsx b/packages/web/src/app/routes/platform/infra/configurations/tracked-events-dialog.tsxindex 6b36eb9b305..230ff58c716 100644--- a/packages/web/src/app/routes/platform/infra/configurations/tracked-events-dialog.tsx+++ b/packages/web/src/app/routes/platform/infra/configurations/tracked-events-dialog.tsx@@ -11,6 +11,7 @@ import {DialogTrigger,} from '@/components/ui/dialog';import { ScrollArea } from '@/components/ui/scroll-area';+import { AdminControl, adminControl } from '@/lib/admin-control';import {trackedEventsCatalog,@@ -26,7 +27,13 @@ export const TrackedEventsDialog = () => {return (<Dialog><DialogTrigger asChild>- <Button type="button" variant="ghost" size="sm" className="w-fit">+ <Button+ {...adminControl(AdminControl.TELEMETRY_EVENTS_OPEN)}+ type="button"+ variant="ghost"+ size="sm"+ className="w-fit"+ ><List className="size-4" /> {t('See the events we track')}</Button></DialogTrigger>@@ -46,6 +53,7 @@ export const TrackedEventsDialog = () => {showCloseButton><a+ {...adminControl(AdminControl.TELEMETRY_DOCS_LINK)}href={TELEMETRY_DOCS_URL}target="_blank"rel="noopener noreferrer"diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-actions.tsx b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-actions.tsxindex 23a8f139e85..0ac34aa78ee 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-actions.tsx+++ b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-actions.tsx@@ -13,6 +13,7 @@ import {DropdownMenuTrigger,} from '@/components/ui/dropdown-menu';import { INTERNAL_ERROR_MESSAGE } from '@/components/ui/sonner';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { eventDestinationsCollectionUtils } from '../lib/event-destinations-collection';@@ -41,6 +42,9 @@ const EventDestinationActions = ({<DropdownMenuContent><EventDestinationDialog destination={destination}><DropdownMenuItem+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_DESTINATION_EDIT_OPEN,+ )}onSelect={(e) => {e.preventDefault();}}@@ -71,8 +75,14 @@ const EventDestinationActions = ({});}}isDanger+ controlId={+ AdminControl.EVENT_DESTINATIONS_DESTINATION_DELETE_CONFIRM+ }><DropdownMenuItem+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_DESTINATION_DELETE_OPEN,+ )}variant="destructive"onSelect={(e) => {e.preventDefault();diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-dialog.tsx b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-dialog.tsxindex fddba842391..4a36972a6e8 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-dialog.tsx+++ b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-dialog.tsx@@ -42,6 +42,7 @@ import { Label } from '@/components/ui/label';import { ScrollArea } from '@/components/ui/scroll-area';import { INTERNAL_ERROR_MESSAGE } from '@/components/ui/sonner';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { eventDestinationsCollectionUtils } from '../lib/event-destinations-collection';@@ -306,6 +307,9 @@ const EventDestinationForm = ({)}</span><Button+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_HANDLER_FLOW_RUN,+ )}type="button"variant="outline"size="sm"@@ -351,6 +355,9 @@ const EventDestinationForm = ({<DropdownMenuContent align="end">{watchedEvents.map((event) => (<DropdownMenuItem+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_WEBHOOK_TEST_RUN,+ )}key={event}onSelect={() =>testDestination({@@ -365,6 +372,11 @@ const EventDestinationForm = ({</DropdownMenuContent></DropdownMenu><Button+ {...adminControl(+ destination+ ? AdminControl.EVENT_DESTINATIONS_DESTINATION_UPDATE_SUBMIT+ : AdminControl.EVENT_DESTINATIONS_DESTINATION_CREATE_SUBMIT,+ )}type="submit"disabled={isSubmitDisabled}loading={isSaving}diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-row.tsx b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-row.tsxindex 8dc003d3afa..15b0ce8cab8 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-row.tsx+++ b/packages/web/src/app/routes/platform/infra/event-destinations/components/event-destination-row.tsx@@ -18,6 +18,7 @@ import {TooltipContent,TooltipTrigger,} from '@/components/ui/tooltip';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { ParsedDestination } from '../lib/parse-flow-id-from-url';@@ -87,6 +88,9 @@ export const EventDestinationRow = ({<Tooltip><TooltipTrigger asChild><Button+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_HANDLER_FLOW_LINK,+ )}variant="ghost"size="sm"onClick={() =>diff --git a/packages/web/src/app/routes/platform/infra/event-destinations/index.tsx b/packages/web/src/app/routes/platform/infra/event-destinations/index.tsxindex 809dd44560b..88336cd0b5b 100644--- a/packages/web/src/app/routes/platform/infra/event-destinations/index.tsx+++ b/packages/web/src/app/routes/platform/infra/event-destinations/index.tsx@@ -12,6 +12,7 @@ import { SkeletonList } from '@/components/ui/skeleton';import { flowsApi } from '@/features/flows';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { sampleData } from '../../sample-data';@@ -87,7 +88,14 @@ const EventDestinationsPage = () => {)}actions={<EventDestinationDialog destination={null}>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ {...adminControl(+ AdminControl.EVENT_DESTINATIONS_DESTINATION_NEW_OPEN,+ )}+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ >{t('New Destination')}</AnimatedIconButton></EventDestinationDialog>diff --git a/packages/web/src/app/routes/platform/infra/health/components/system-health-tab.tsx b/packages/web/src/app/routes/platform/infra/health/components/system-health-tab.tsxindex 73bb9d97593..94334f29931 100644--- a/packages/web/src/app/routes/platform/infra/health/components/system-health-tab.tsx+++ b/packages/web/src/app/routes/platform/infra/health/components/system-health-tab.tsx@@ -19,6 +19,7 @@ import { Alert, AlertDescription } from '@/components/ui/alert';import { Card, CardContent } from '@/components/ui/card';import { healthQueries } from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { DailyHealthStrip } from './daily-health-strip';@@ -170,7 +171,12 @@ export function SystemHealthTab({ onSeeRuns }: SystemHealthTabProps) {{t('In production setups, we recommend a ratio of about 1 app instance to 10 workers.',)}{' '}- <a href={PRODUCTION_SETUP_LINK} target="_blank" rel="noreferrer">+ <a+ {...adminControl(AdminControl.HEALTH_PRODUCTION_SETUP_LINK)}+ href={PRODUCTION_SETUP_LINK}+ target="_blank"+ rel="noreferrer"+ >{t('Learn more')}</a></AlertDescription>@@ -256,6 +262,7 @@ function HealthRowItem({ row, loading }: { row: HealthRow; loading: boolean }) {<span className="text-sm font-medium">{row.title}</span>{row.link && (<a+ {...adminControl(AdminControl.HEALTH_CHECK_DOCS_LINK)}href={row.link}target="_blank"rel="noreferrer"diff --git a/packages/web/src/app/routes/platform/infra/workers/assign-projects-dialog.tsx b/packages/web/src/app/routes/platform/infra/workers/assign-projects-dialog.tsxindex 4d39ab47d79..5fae7cf66f8 100644--- a/packages/web/src/app/routes/platform/infra/workers/assign-projects-dialog.tsx+++ b/packages/web/src/app/routes/platform/infra/workers/assign-projects-dialog.tsx@@ -17,6 +17,7 @@ import {import { Input } from '@/components/ui/input';import { ScrollArea } from '@/components/ui/scroll-area';import { projectCollectionUtils } from '@/features/projects/stores/project-collection';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { ProjectAvatar } from './project-avatar';@@ -184,7 +185,11 @@ function AssignProjectsContent({>{t('Cancel')}</Button>- <Button type="button" onClick={handleSave}>+ <Button+ {...adminControl(AdminControl.WORKERS_ASSIGN_SUBMIT)}+ type="button"+ onClick={handleSave}+ >{t('Save')}</Button></div>diff --git a/packages/web/src/app/routes/platform/infra/workers/by-group-view.tsx b/packages/web/src/app/routes/platform/infra/workers/by-group-view.tsxindex 7fe023b280c..25df4b4a023 100644--- a/packages/web/src/app/routes/platform/infra/workers/by-group-view.tsx+++ b/packages/web/src/app/routes/platform/infra/workers/by-group-view.tsx@@ -10,6 +10,7 @@ import { useState } from 'react';import { TextWithTooltip } from '@/components/custom/text-with-tooltip';import { Button } from '@/components/ui/button';import { WorkerGroupInfo } from '@/features/platform-admin/api/workers-api';+import { AdminControl, adminControl } from '@/lib/admin-control';import { AssignProjectsDialog } from './assign-projects-dialog';import { ProjectAvatar } from './project-avatar';@@ -101,6 +102,7 @@ function GroupCard({ groupLabel, allProjects, workers }: GroupCardProps) {{t('PROJECTS')}</span><Button+ {...adminControl(AdminControl.WORKERS_ASSIGN_OPEN)}variant="ghost"size="sm"className="h-7 px-2 text-xs"diff --git a/packages/web/src/app/routes/platform/infra/workers/worker-assignments-tab.tsx b/packages/web/src/app/routes/platform/infra/workers/worker-assignments-tab.tsxindex 3305b2c58d2..7af05a47195 100644--- a/packages/web/src/app/routes/platform/infra/workers/worker-assignments-tab.tsx+++ b/packages/web/src/app/routes/platform/infra/workers/worker-assignments-tab.tsx@@ -6,6 +6,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';import { workersQueries } from '@/features/platform-admin';import { projectCollectionUtils } from '@/features/projects/stores/project-collection';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { ByGroupView } from './by-group-view';import { ByProjectView } from './by-project-view';@@ -31,6 +32,7 @@ export function WorkerAssignmentsTab() {'Worker groups reserve a dedicated queue for the projects you assign. Defined in your deployment with AP_WORKER_GROUP_ID.',)}{' '}<a+ {...adminControl(AdminControl.WORKERS_DOCS_LINK)}href="https://www.activepieces.com/docs/install/configure-operate/worker-groups"target="_blank"rel="noreferrer"diff --git a/packages/web/src/app/routes/platform/projects/index.tsx b/packages/web/src/app/routes/platform/projects/index.tsxindex b20dea5dff0..f78be6d7083 100644--- a/packages/web/src/app/routes/platform/projects/index.tsx+++ b/packages/web/src/app/routes/platform/projects/index.tsx@@ -39,6 +39,7 @@ import {} from '@/features/projects';import { PlatformAdminProjectAlertSubscriptionBulkActions } from '@/features/projects/components/platform-admin-project-alert-subscription-bulk-actions';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { validationUtils } from '@/lib/validation-utils';@@ -266,6 +267,7 @@ export default function ProjectsPage() {)}entityName={t('Projects')}buttonText={t('Delete')}+ controlId={AdminControl.PROJECTS_DELETE_CONFIRM}mutationFn={async () => {const deletableProjects = selectedRows.filter((row) => row.id !== currentProject?.id,@@ -289,6 +291,7 @@ export default function ProjectsPage() {size="sm"className="text-danger-11 hover:text-danger-11"disabled={!canDeleteAny}+ {...adminControl(AdminControl.PROJECTS_DELETE_OPEN)}><Trash className="mr-1 w-4" />{`${t('Delete')} (${selectedRows.length})`}@@ -338,6 +341,7 @@ export default function ProjectsPage() {<Buttonvariant="ghost"className="size-8 p-0"+ {...adminControl(AdminControl.PROJECTS_EDIT_OPEN)}onClick={async (e) => {e.stopPropagation();e.preventDefault();@@ -385,6 +389,7 @@ export default function ProjectsPage() {toggleAutoCreatePersonalProjects(checked)}disabled={isAutoCreatePersonalProjectsPending}+ {...adminControl(AdminControl.PROJECTS_AUTO_PERSONAL_TOGGLE)}/></ItemActions></Item>diff --git a/packages/web/src/app/routes/platform/security/api-keys/index.tsx b/packages/web/src/app/routes/platform/security/api-keys/index.tsxindex 9a1b8e87e07..cd52b355aa5 100644--- a/packages/web/src/app/routes/platform/security/api-keys/index.tsx+++ b/packages/web/src/app/routes/platform/security/api-keys/index.tsx@@ -27,6 +27,7 @@ import { SkeletonList } from '@/components/ui/skeleton';import { internalErrorToast } from '@/components/ui/sonner';import { apiKeyApi, apiKeyQueries } from '@/features/platform-admin';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { sampleData } from '../../sample-data';@@ -45,7 +46,12 @@ const ApiKeysPage = () => {description={t('Manage API keys to access Activepieces APIs.')}actions={<NewApiKeyDialog onCreate={() => refetch()}>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ {...adminControl(AdminControl.API_KEYS_API_KEY_OPEN)}+ >{t('New API Key')}</AnimatedIconButton></NewApiKeyDialog>@@ -106,6 +112,7 @@ const ApiKeysPage = () => {)}entityName={t('API Key')}buttonText={t('Revoke')}+ controlId={AdminControl.API_KEYS_API_KEY_REVOKE_CONFIRM}mutationFn={async () => {await apiKeyApi.delete(apiKey.id);refetch();@@ -115,6 +122,9 @@ const ApiKeysPage = () => {<DropdownMenuItemclassName="text-danger-11 focus:text-danger-11"onSelect={(e) => e.preventDefault()}+ {...adminControl(+ AdminControl.API_KEYS_API_KEY_REVOKE_OPEN,+ )}><Trash className="size-4 mr-2 text-danger-11" />{t('Revoke API Key')}diff --git a/packages/web/src/app/routes/platform/security/api-keys/new-api-key-dialog.tsx b/packages/web/src/app/routes/platform/security/api-keys/new-api-key-dialog.tsxindex 148df2cbe73..2804d06d67c 100644--- a/packages/web/src/app/routes/platform/security/api-keys/new-api-key-dialog.tsx+++ b/packages/web/src/app/routes/platform/security/api-keys/new-api-key-dialog.tsx@@ -26,6 +26,7 @@ import {} from '@/components/ui/form';import { Input } from '@/components/ui/input';import { apiKeyApi } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';type NewApiKeyDialogProps = {children: React.ReactNode;@@ -97,6 +98,7 @@ export const NewApiKeyDialog = ({useInput={true}textToCopy={apiKey.value}fileName={`${apiKey.displayName}`}+ controlId={AdminControl.API_KEYS_API_KEY_COPY}/></div></div>@@ -144,7 +146,11 @@ export const NewApiKeyDialog = ({>{t('Cancel')}</Button>- <Button disabled={isPending} loading={isPending}>+ <Button+ disabled={isPending}+ loading={isPending}+ {...adminControl(AdminControl.API_KEYS_API_KEY_SUBMIT)}+ >{t('Create')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/security/audit-logs/index.tsx b/packages/web/src/app/routes/platform/security/audit-logs/index.tsxindex 2818830f3f6..3f456e6bc19 100644--- a/packages/web/src/app/routes/platform/security/audit-logs/index.tsx+++ b/packages/web/src/app/routes/platform/security/audit-logs/index.tsx@@ -46,6 +46,7 @@ import { auditLogQueries } from '@/features/platform-admin';import { platformUserHooks } from '@/features/platform-admin/hooks/platform-user-hooks';import { projectCollectionUtils } from '@/features/projects';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { sampleData } from '../../sample-data';@@ -229,6 +230,7 @@ export default function AuditLogsPage() {size: 50,cell: ({ row }) => (<Button+ {...adminControl(AdminControl.AUDIT_LOG_EVENT_OPEN)}variant="ghost"size="icon"className="size-8"diff --git a/packages/web/src/app/routes/platform/security/embed/index.tsx b/packages/web/src/app/routes/platform/security/embed/index.tsxindex 423e5aafcc4..d4e36bd3fcf 100644--- a/packages/web/src/app/routes/platform/security/embed/index.tsx+++ b/packages/web/src/app/routes/platform/security/embed/index.tsx@@ -24,6 +24,7 @@ import {} from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { sampleData } from '../../sample-data';@@ -142,6 +143,7 @@ const EmbedPage = () => {asChild><a+ {...adminControl(AdminControl.EMBEDDING_DOCS_LINK)}href="https://www.activepieces.com/docs/embedding/overview"target="_blank"rel="noopener noreferrer"diff --git a/packages/web/src/app/routes/platform/security/embed/steps/allowed-domains-step.tsx b/packages/web/src/app/routes/platform/security/embed/steps/allowed-domains-step.tsxindex d3c8a944ed8..9e3eabd2db2 100644--- a/packages/web/src/app/routes/platform/security/embed/steps/allowed-domains-step.tsx+++ b/packages/web/src/app/routes/platform/security/embed/steps/allowed-domains-step.tsx@@ -22,6 +22,7 @@ import {import { internalErrorToast } from '@/components/ui/sonner';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { StepShell } from '../stepper';@@ -121,7 +122,12 @@ export const AllowedDomainsStep = ({</div>)}<div className="flex justify-end mt-6">- <Button size="sm" type="submit" disabled={isPending}>+ <Button+ {...adminControl(AdminControl.EMBEDDING_ALLOWED_DOMAINS_SUBMIT)}+ size="sm"+ type="submit"+ disabled={isPending}+ >{isPending && <Loader2 className="size-4 animate-spin mr-2" />}{t('Save')}</Button>diff --git a/packages/web/src/app/routes/platform/security/embed/steps/dns-step.tsx b/packages/web/src/app/routes/platform/security/embed/steps/dns-step.tsxindex 49cfbdffa0f..cc197657cb3 100644--- a/packages/web/src/app/routes/platform/security/embed/steps/dns-step.tsx+++ b/packages/web/src/app/routes/platform/security/embed/steps/dns-step.tsx@@ -9,6 +9,7 @@ import { CheckCircle, Loader2, XCircle } from 'lucide-react';import { CopyToClipboardInput } from '@/components/custom/clipboard/copy-to-clipboard';import { Label } from '@/components/ui/label';+import { AdminControl } from '@/lib/admin-control';import { StepShell } from '../stepper';@@ -93,11 +94,19 @@ const VerificationRow = ({ record }: { record: EmbedVerificationRecord }) => {<div className="grid grid-cols-2 gap-3"><div className="flex flex-col gap-1.5 min-w-0"><Label className="text-xs text-gray-11">{t('Name')}</Label>- <CopyToClipboardInput textToCopy={record.name} useInput={true} />+ <CopyToClipboardInput+ textToCopy={record.name}+ useInput={true}+ controlId={AdminControl.EMBEDDING_DNS_NAME_COPY}+ /></div><div className="flex flex-col gap-1.5 min-w-0"><Label className="text-xs text-gray-11">{t('Value')}</Label>- <CopyToClipboardInput textToCopy={record.value} useInput={true} />+ <CopyToClipboardInput+ textToCopy={record.value}+ useInput={true}+ controlId={AdminControl.EMBEDDING_DNS_VALUE_COPY}+ /></div></div></div>diff --git a/packages/web/src/app/routes/platform/security/embed/steps/hostname-step.tsx b/packages/web/src/app/routes/platform/security/embed/steps/hostname-step.tsxindex bbafd52503f..710bfce0fd5 100644--- a/packages/web/src/app/routes/platform/security/embed/steps/hostname-step.tsx+++ b/packages/web/src/app/routes/platform/security/embed/steps/hostname-step.tsx@@ -20,6 +20,7 @@ import {} from '@/components/ui/form';import { Input } from '@/components/ui/input';import { embedSubdomainMutations } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { StepShell } from '../stepper';@@ -97,7 +98,12 @@ const EmbedHostnameForm = () => {</p>)}<div className="flex justify-end mt-6">- <Button type="submit" size="sm" disabled={isPending}>+ <Button+ {...adminControl(AdminControl.EMBEDDING_HOSTNAME_SUBMIT)}+ type="submit"+ size="sm"+ disabled={isPending}+ >{isPending && <Loader2 className="size-4 animate-spin mr-2" />}{t('Save domain')}</Button>@@ -157,7 +163,12 @@ const EmbedHostnameSummary = ({ subdomain }: { subdomain: EmbedSubdomain }) => {<p className="text-sm text-danger-11">{errorMessage}</p>)}<div className="flex justify-end mt-6">- <Button type="submit" size="sm" disabled={!isDirty || isPending}>+ <Button+ {...adminControl(AdminControl.EMBEDDING_HOSTNAME_UPDATE_OPEN)}+ type="submit"+ size="sm"+ disabled={!isDirty || isPending}+ >{isPending && <Loader2 className="size-4 animate-spin mr-2" />}{t('Update')}</Button>@@ -173,6 +184,7 @@ const EmbedHostnameSummary = ({ subdomain }: { subdomain: EmbedSubdomain }) => {buttonText={t('Update domain')}entityName={t('domain')}mutationFn={handleConfirm}+ controlId={AdminControl.EMBEDDING_HOSTNAME_UPDATE_CONFIRM}/></form></Form>diff --git a/packages/web/src/app/routes/platform/security/embed/steps/signing-keys-step.tsx b/packages/web/src/app/routes/platform/security/embed/steps/signing-keys-step.tsxindex a9baa1c8213..9f51f6aa906 100644--- a/packages/web/src/app/routes/platform/security/embed/steps/signing-keys-step.tsx+++ b/packages/web/src/app/routes/platform/security/embed/steps/signing-keys-step.tsx@@ -22,6 +22,7 @@ import {import { SkeletonList } from '@/components/ui/skeleton';import { internalErrorToast } from '@/components/ui/sonner';import { NewSigningKeyDialog, signingKeyApi } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { StepShell } from '../stepper';@@ -43,7 +44,12 @@ export const SigningKeysStep = ({)}actions={<NewSigningKeyDialog onCreate={refetch}>- <Button size="sm">{t('New Signing Key')}</Button>+ <Button+ {...adminControl(AdminControl.EMBEDDING_SIGNING_KEY_NEW_OPEN)}+ size="sm"+ >+ {t('New Signing Key')}+ </Button></NewSigningKeyDialog>}>@@ -121,8 +127,12 @@ const SigningKeysList = ({refetch();}}onError={() => internalErrorToast()}+ controlId={AdminControl.EMBEDDING_SIGNING_KEY_DELETE_CONFIRM}><DropdownMenuItem+ {...adminControl(+ AdminControl.EMBEDDING_SIGNING_KEY_DELETE_OPEN,+ )}className="text-danger-11 focus:text-danger-11"onSelect={(e) => e.preventDefault()}>diff --git a/packages/web/src/app/routes/platform/security/project-role/permission-grid.tsx b/packages/web/src/app/routes/platform/security/project-role/permission-grid.tsxindex 786dc95b278..f9a1c60acb4 100644--- a/packages/web/src/app/routes/platform/security/project-role/permission-grid.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/permission-grid.tsx@@ -7,6 +7,7 @@ import {PermissionRow,rolePermissionModel,} from '@/features/members/lib/role-permissions';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';export function PermissionGrid({@@ -122,6 +123,7 @@ function Box({disabled={disabled}aria-label={label}onCheckedChange={(value) => onCheckedChange(value === true)}+ {...adminControl(AdminControl.ROLES_PERMISSION_TOGGLE)}/>) : (<spandiff --git a/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx b/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsxindex 4f134b1e7e1..284fa91423a 100644--- a/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/project-role-dialog.tsx@@ -31,6 +31,7 @@ import {rolePermissionModel,} from '@/features/members/lib/role-permissions';import { projectRoleMutations } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { cn } from '@/lib/utils';@@ -257,6 +258,7 @@ function RoleDialogBody({setTab('permissions');}}disabled={isEditingPermissions}+ {...adminControl(AdminControl.ROLES_EDIT_OPEN)}><Pencil className="size-4" />{t('Edit permissions')}@@ -273,10 +275,12 @@ function RoleDialogBody({mutationFn={async () => {await deleteRole(projectRole.name);}}+ controlId={AdminControl.ROLES_DELETE_CONFIRM}><DropdownMenuItemvariant="destructive"onSelect={(event) => event.preventDefault()}+ {...adminControl(AdminControl.ROLES_DELETE_OPEN)}><Trash className="size-4" />{t('Delete role')}@@ -312,6 +316,7 @@ function RoleDialogBody({'bg-panel text-gray-12 shadow-xs hover:bg-panel',)}onClick={() => changeBase(roleBase)}+ {...adminControl(AdminControl.ROLES_BASE_SELECT)}>{t(roleBase)}</Button>@@ -407,7 +412,16 @@ function RoleDialogBody({>{t('Cancel')}</Button>- <Button type="button" disabled={!canSubmit} onClick={submit}>+ <Button+ type="button"+ disabled={!canSubmit}+ onClick={submit}+ {...adminControl(+ isCreate+ ? AdminControl.ROLES_NEW_SUBMIT+ : AdminControl.ROLES_EDIT_SUBMIT,+ )}+ >{isCreate ? t('Create role') : t('Save changes')}</Button></div>diff --git a/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsx b/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsxindex 61a0a5eed1f..b4c1de61293 100644--- a/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/project-roles-list.tsx@@ -16,6 +16,7 @@ import {} from '@/components/ui/item';import { SkeletonList } from '@/components/ui/skeleton';import { roleCopy } from '@/features/members/lib/role-copy';+import { AdminControl, adminControl } from '@/lib/admin-control';import { ProjectRoleDialog } from './project-role-dialog';import { RoleAvatar } from './role-avatar';@@ -76,6 +77,7 @@ export function ProjectRolesList({type="button"className="min-w-0 text-left after:absolute after:inset-0 after:content-['']"onClick={() => setOpened({ role, tab: 'permissions' })}+ {...adminControl(AdminControl.ROLES_ROLE_OPEN)}><TextWithTooltip tooltipMessage={role.name}><span className="block truncate">{role.name}</span>@@ -104,6 +106,7 @@ export function ProjectRolesList({type="button"className="relative z-10 shrink-0 text-sm tabular-nums text-accent-11 underline-offset-4 hover:underline"onClick={() => setOpened({ role, tab: 'people' })}+ {...adminControl(AdminControl.ROLES_PEOPLE_OPEN)}>{t('rolePeopleCount', { count: role.userCount })}</button>diff --git a/packages/web/src/app/routes/platform/security/project-role/roles-card.tsx b/packages/web/src/app/routes/platform/security/project-role/roles-card.tsxindex c258f1628c9..c46dada0901 100644--- a/packages/web/src/app/routes/platform/security/project-role/roles-card.tsx+++ b/packages/web/src/app/routes/platform/security/project-role/roles-card.tsx@@ -12,6 +12,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { PlatformRolesList } from './platform-roles-list';import { ProjectRoleDialog } from './project-role-dialog';@@ -45,7 +46,12 @@ export function RolesCard({</Tooltip>) : (<ProjectRoleDialog mode="create" onSave={() => refetch()}>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ {...adminControl(AdminControl.ROLES_NEW_OPEN)}+ >{t('New role')}</AnimatedIconButton></ProjectRoleDialog>diff --git a/packages/web/src/app/routes/platform/security/secret-managers/connect-secret-manager-dialog.tsx b/packages/web/src/app/routes/platform/security/secret-managers/connect-secret-manager-dialog.tsxindex 7cab191a45b..f86ee33f8dd 100644--- a/packages/web/src/app/routes/platform/security/secret-managers/connect-secret-manager-dialog.tsx+++ b/packages/web/src/app/routes/platform/security/secret-managers/connect-secret-manager-dialog.tsx@@ -40,6 +40,7 @@ import {} from '@/components/ui/tooltip';import { ProjectSelector } from '@/features/connections';import { secretManagersHooks } from '@/features/secret-managers';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { secretManagersUtils } from './util';@@ -275,7 +276,11 @@ const AddEditSecretManagerForm = ({>{t('Cancel')}</Button>- <Button loading={isPending} type="submit">+ <Button+ loading={isPending}+ type="submit"+ {...adminControl(AdminControl.SECRET_MANAGERS_CONNECTION_SUBMIT)}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/security/secret-managers/index.tsx b/packages/web/src/app/routes/platform/security/secret-managers/index.tsxindex df3f37a780f..9898120c24e 100644--- a/packages/web/src/app/routes/platform/security/secret-managers/index.tsx+++ b/packages/web/src/app/routes/platform/security/secret-managers/index.tsx@@ -32,6 +32,7 @@ import {import { PieceIcon } from '@/features/pieces';import { secretManagersHooks } from '@/features/secret-managers';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { sampleData } from '../../sample-data';@@ -158,7 +159,13 @@ const SecretManagersPage = () => {return (<div className="flex items-center gap-1 justify-end"><AddEditSecretManagerConnectionDialog connection={connection}>- <Button variant="ghost" size="sm">+ <Button+ variant="ghost"+ size="sm"+ {...adminControl(+ AdminControl.SECRET_MANAGERS_CONNECTION_EDIT_OPEN,+ )}+ ><Pencil className="size-4" /></Button></AddEditSecretManagerConnectionDialog>@@ -172,12 +179,19 @@ const SecretManagersPage = () => {'Deleting this secret manager connection will break all flows/app connections using it.',)}entityName={connection.name}+ controlId={AdminControl.SECRET_MANAGERS_CONNECTION_DELETE_CONFIRM}mutationFn={async () => deleteConnection(connection.id)}><div><Tooltip><TooltipTrigger asChild>- <Button variant="ghost" size="sm">+ <Button+ variant="ghost"+ size="sm"+ {...adminControl(+ AdminControl.SECRET_MANAGERS_CONNECTION_DELETE_OPEN,+ )}+ ><Trash className="size-4 text-danger-11" /></Button></TooltipTrigger>@@ -198,7 +212,12 @@ const SecretManagersPage = () => {description={t('Manage Secret Manager connections')}><AddEditSecretManagerConnectionDialog>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ {...adminControl(AdminControl.SECRET_MANAGERS_CONNECTION_OPEN)}+ >{t('New Connection')}</AnimatedIconButton></AddEditSecretManagerConnectionDialog>@@ -238,6 +257,7 @@ const SecretManagerClearCacheButton = ({size="sm"loading={isClearingCache}onClick={() => clearCache(connection.id)}+ {...adminControl(AdminControl.SECRET_MANAGERS_CACHE_RUN)}><RefreshCcw className="size-4" /></Button>diff --git a/packages/web/src/app/routes/platform/security/sso/allowed-domain.tsx b/packages/web/src/app/routes/platform/security/sso/allowed-domain.tsxindex 612e1309c27..0b35779e0ef 100644--- a/packages/web/src/app/routes/platform/security/sso/allowed-domain.tsx+++ b/packages/web/src/app/routes/platform/security/sso/allowed-domain.tsx@@ -23,6 +23,7 @@ import {} from '@/components/ui/dialog';import { Form, FormField, FormItem, FormMessage } from '@/components/ui/form';import { Input } from '@/components/ui/input';+import { AdminControl, adminControl } from '@/lib/admin-control';type AllowedDomainDialogProps = {platform: PlatformWithoutSensitiveData;@@ -83,7 +84,12 @@ export const AllowedDomainDialog = ({}}><DialogTrigger asChild>- <Button size={'sm'} variant={'basic'} onClick={() => setOpen(true)}>+ <Button+ {...adminControl(AdminControl.SSO_ALLOWED_DOMAINS_OPEN)}+ size={'sm'}+ variant={'basic'}+ onClick={() => setOpen(true)}+ >{platform.allowedAuthDomains.length > 0 ? t('Update') : t('Enable')}</Button></DialogTrigger>@@ -162,6 +168,7 @@ export const AllowedDomainDialog = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.SSO_ALLOWED_DOMAINS_SUBMIT)}loading={isPending}disabled={!form.formState.isValid}type="submit"diff --git a/packages/web/src/app/routes/platform/security/sso/index.tsx b/packages/web/src/app/routes/platform/security/sso/index.tsxindex 3a32a0d2437..365ce196919 100644--- a/packages/web/src/app/routes/platform/security/sso/index.tsx+++ b/packages/web/src/app/routes/platform/security/sso/index.tsx@@ -18,6 +18,7 @@ import {import { Switch } from '@/components/ui/switch';import { ssoMutations } from '@/features/platform-admin';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import GoogleIcon from '../../../../../assets/img/custom/auth/google-icon.svg';@@ -90,6 +91,7 @@ const SSOPage = () => {</ItemContent><ItemActions><Switch+ {...adminControl(AdminControl.SSO_GOOGLE_TOGGLE)}checked={platform.googleAuthEnabled}onCheckedChange={() =>toggleGoogleAuth({@@ -149,6 +151,7 @@ const SSOPage = () => {</ItemContent><ItemActions><Switch+ {...adminControl(AdminControl.SSO_EMAIL_LOGIN_TOGGLE)}checked={emailAuthEnabled}onCheckedChange={() =>toggleEmailAuthentication({diff --git a/packages/web/src/app/routes/platform/security/sso/saml-dialog.tsx b/packages/web/src/app/routes/platform/security/sso/saml-dialog.tsxindex 1698b9142d8..17823d0590e 100644--- a/packages/web/src/app/routes/platform/security/sso/saml-dialog.tsx+++ b/packages/web/src/app/routes/platform/security/sso/saml-dialog.tsx@@ -40,6 +40,7 @@ import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';import { samlSsoApi } from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { cn } from '@/lib/utils';@@ -53,7 +54,12 @@ export const ConfigureSamlDialog = ({return (<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>- <Button size="sm" variant="basic" onClick={() => setOpen(true)}>+ <Button+ {...adminControl(AdminControl.SSO_SAML_OPEN)}+ size="sm"+ variant="basic"+ onClick={() => setOpen(true)}+ >{connected ? t('Edit') : t('Enable')}</Button></DialogTrigger>@@ -304,6 +310,7 @@ const DomainStep = ({<DialogFooter>{disableAction && (<Button+ {...adminControl(AdminControl.SSO_SAML_DISABLE_RUN)}type="button"variant="basic"className="text-danger-11"@@ -315,6 +322,11 @@ const DomainStep = ({)}{isDirty ? (<Button+ {...adminControl(+ platform.ssoDomain+ ? AdminControl.SSO_SAML_DOMAIN_UPDATE_SUBMIT+ : AdminControl.SSO_SAML_DOMAIN_SUBMIT,+ )}type="submit"loading={isSaving}disabled={!form.formState.isValid}@@ -351,6 +363,7 @@ const DomainStep = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.SSO_SAML_DOMAIN_UPDATE_CONFIRM)}type="button"loading={isSaving}onClick={() => saveDomain(form.getValues())}@@ -475,6 +488,7 @@ Activepieces<DialogFooter>{disableAction && (<Button+ {...adminControl(AdminControl.SSO_SAML_DISABLE_RUN)}type="button"variant="basic"className="text-danger-11 mr-auto"@@ -488,6 +502,7 @@ Activepieces{t('Back')}</Button><Button+ {...adminControl(AdminControl.SSO_SAML_CONFIG_SUBMIT)}loading={isPending}disabled={!form.formState.isValid}type="submit"@@ -524,6 +539,7 @@ const DomainVerificationPanel = ({<VerificationRecordRow record={verification.record} /><div><Button+ {...adminControl(AdminControl.SSO_SAML_DNS_RUN)}type="button"size="sm"variant="outline"@@ -574,11 +590,19 @@ const VerificationRecordRow = ({<div className="grid grid-cols-2 gap-3"><div className="flex flex-col gap-1.5 min-w-0"><Label className="text-xs text-gray-11">{t('Name')}</Label>- <CopyToClipboardInput textToCopy={record.name} useInput={true} />+ <CopyToClipboardInput+ textToCopy={record.name}+ useInput={true}+ controlId={AdminControl.SSO_SAML_DNS_NAME_COPY}+ /></div><div className="flex flex-col gap-1.5 min-w-0"><Label className="text-xs text-gray-11">{t('Value')}</Label>- <CopyToClipboardInput textToCopy={record.value} useInput={true} />+ <CopyToClipboardInput+ textToCopy={record.value}+ useInput={true}+ controlId={AdminControl.SSO_SAML_DNS_VALUE_COPY}+ /></div></div></div>diff --git a/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx b/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsxindex ca4d77f33c5..7b3dc7673fc 100644--- a/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/ai-capabilities/ai-capability-dialog.tsx@@ -46,6 +46,7 @@ import {aiProviderQueries,aiToolConfigMutations,} from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { aiCapabilitySources, AiToolCapabilityInfo } from './catalog';@@ -333,6 +334,7 @@ function CapabilityForm({target="_blank"rel="noreferrer"className="inline-flex items-center gap-1 text-xs text-gray-11 hover:underline"+ {...adminControl(AdminControl.AI_API_KEY_LINK)}>{t('Get a {provider} API key', {provider: selectedProvider.name,@@ -356,7 +358,11 @@ function CapabilityForm({<Button type="button" variant="outline" onClick={onClose}>{t('Cancel')}</Button>- <Button type="submit" loading={isPending || isReenabling}>+ <Button+ type="submit"+ loading={isPending || isReenabling}+ {...adminControl(AdminControl.AI_CAPABILITY_SUBMIT)}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx b/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsxindex 9ec2703c1d0..14932171b5b 100644--- a/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx+++ b/packages/web/src/app/routes/platform/setup/ai/capabilities-tab/index.tsx@@ -17,6 +17,7 @@ import {aiToolConfigMutations,aiToolConfigQueries,} from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { AiCapabilityDialog } from '../../ai-capabilities/ai-capability-dialog';@@ -167,12 +168,14 @@ function CapabilityCard({)}entityName={capabilityInfo.name}+ controlId={AdminControl.AI_CAPABILITY_RESET_CONFIRM}mutationFn={async () => onDelete()}><Buttonvariant="ghost"size="icon-sm"className="text-gray-11 opacity-0 transition-opacity hover:text-danger-11 group-focus-within:opacity-100 group-hover:opacity-100"+ {...adminControl(AdminControl.AI_CAPABILITY_RESET_OPEN)}><Trash2 className="size-4" /></Button>@@ -194,7 +197,11 @@ function CapabilityCard({defaultProviderId={chatProviderFallback?.id}onSaved={onSaved}>- <Button variant="outline" size="sm">+ <Button+ variant="outline"+ size="sm"+ {...adminControl(AdminControl.AI_CAPABILITY_OPEN)}+ >{inUse ? t('Change') : t('Connect')}</Button></AiCapabilityDialog>diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsxindex 2e681952586..adcf533a2ea 100644--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/config-detail.tsx@@ -34,6 +34,7 @@ import {} from '@/components/ui/select';import { AiProviderInfo } from '@/features/agents';import { aiProviderApi, aiProviderKeys } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { SectionHeader } from '../components/section-header';@@ -210,7 +211,12 @@ export function ConfigDetail({</p></div></div>- <Button variant="outline" size="sm" onClick={onReplaceCredentials}>+ <Button+ variant="outline"+ size="sm"+ onClick={onReplaceCredentials}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_CREDENTIALS_OPEN)}+ >{t('Replace')}</Button></div>@@ -233,6 +239,7 @@ export function ConfigDetail({size="sm"loading={isRechecking}onClick={onRecheck}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_RECHECK_RUN)}>{t('Recheck')}</Button>@@ -349,6 +356,7 @@ export function ConfigDetail({size="sm"className="shrink-0 gap-2 border-danger-7 text-danger-11 enabled:hover:bg-danger-3 enabled:hover:text-danger-11"onClick={() => setDeleteOpen(true)}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_DELETE_OPEN)}><Trash2 className="size-4" />{t('Delete')}@@ -361,6 +369,7 @@ export function ConfigDetail({message={t('Steps and agents using this key will stop working.')}entityName={config.name}showToast={true}+ controlId={AdminControl.AI_PROVIDER_KEY_DELETE_CONFIRM}mutationFn={async () => {await onDelete();leavingOnPurpose.current = true;@@ -387,6 +396,7 @@ export function ConfigDetail({keyboardShortcut="S"onKeyboardShortcut={save}onClick={save}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_SETTINGS_SUBMIT)}>{t('Save')}</Button>diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/connect-provider-dialog.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/connect-provider-dialog.tsxindex e374ff1b0c0..4806ff2d58d 100644--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/connect-provider-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/connect-provider-dialog.tsx@@ -49,6 +49,7 @@ import {import { Textarea } from '@/components/ui/textarea';import { AiProviderInfo, SUPPORTED_AI_PROVIDERS } from '@/features/agents';import { aiProviderMutations } from '@/features/platform-admin';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { CredentialField, providerCredentials } from './provider-credentials';@@ -235,7 +236,16 @@ function ConnectProviderForm({<Button type="button" variant="outline" onClick={onCancel}>{t('Cancel')}</Button>- <Button type="submit" loading={connecting} disabled={connecting}>+ <Button+ type="submit"+ loading={connecting}+ disabled={connecting}+ {...adminControl(+ editing+ ? AdminControl.AI_PROVIDER_KEY_CREDENTIALS_SUBMIT+ : AdminControl.AI_PROVIDER_KEY_SUBMIT,+ )}+ >{editing ? t('Save credentials') : t('Connect')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx b/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsxindex 8840ed79042..c13721f9439 100644--- a/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx+++ b/packages/web/src/app/routes/platform/setup/ai/providers-tab/index.tsx@@ -30,6 +30,7 @@ import {aiProviderQueries,} from '@/features/platform-admin';import { projectCollectionUtils } from '@/features/projects';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { SectionHeader } from '../components/section-header';@@ -208,7 +209,12 @@ export function ProvidersTab() {: t('Each key has its own models and project access.')}/>- <Button size="sm" className="shrink-0" onClick={() => openConnect()}>+ <Button+ size="sm"+ className="shrink-0"+ onClick={() => openConnect()}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_OPEN)}+ ><Plus className="size-4" />{t('Add key')}</Button>@@ -311,7 +317,12 @@ function ProviderGroup({{t('configurationsCount', { count: configs.length })}</p></div>- <Button variant="ghost" size="sm" onClick={onAdd}>+ <Button+ variant="ghost"+ size="sm"+ onClick={onAdd}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_OPEN)}+ ><Plus className="size-4" />{t('Add key')}</Button>@@ -431,6 +442,7 @@ function ConfigRow({size="sm"className="px-2 text-gray-11 opacity-0 transition-opacity hover:bg-danger-3 hover:text-danger-11 focus-visible:opacity-100 group-hover:opacity-100"onClick={() => setDeleteOpen(true)}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_DELETE_OPEN)}><Trash2 className="size-4" /><span className="sr-only">{t('Delete')}</span>@@ -446,6 +458,7 @@ function ConfigRow({message={t('Steps and agents using this key will stop working.')}entityName={config.name}showToast={true}+ controlId={AdminControl.AI_PROVIDER_KEY_DELETE_CONFIRM}mutationFn={async () => {await onDelete();}}@@ -578,7 +591,10 @@ function EmptyProviders({)}</p></div>- <Button onClick={() => onConnect()}>+ <Button+ onClick={() => onConnect()}+ {...adminControl(AdminControl.AI_PROVIDER_KEY_OPEN)}+ ><Plus className="size-4" />{t('Connect a provider')}</Button>@@ -639,6 +655,7 @@ function AvailableProviderCard({size="sm"variant={recommended ? 'default' : 'outline'}onClick={onConnect}+ {...adminControl(AdminControl.AI_PROVIDER_OPEN)}>{t('Connect')}</Button>diff --git a/packages/web/src/app/routes/platform/setup/connections/index.tsx b/packages/web/src/app/routes/platform/setup/connections/index.tsxindex 88900ce86f3..c263229699e 100644--- a/packages/web/src/app/routes/platform/setup/connections/index.tsx+++ b/packages/web/src/app/routes/platform/setup/connections/index.tsx@@ -50,6 +50,7 @@ import {import { PieceIconWithPieceName } from '@/features/pieces';import { useAuthorization } from '@/hooks/authorization-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { formatUtils } from '@/lib/format-utils';import { sampleData } from '../../sample-data';@@ -104,6 +105,7 @@ const GlobalConnectionsTable = () => {<CopyTextTooltiptitle={t('External ID')}text={row.original.externalId || ''}+ controlId={AdminControl.CONNECTIONS_EXTERNAL_ID_COPY}><div className="flex items-center gap-2 w-fit"><PieceIconWithPieceName@@ -258,6 +260,7 @@ const GlobalConnectionsTable = () => {warning={<DeleteConnectionWarning />}entityName="connections"buttonText={t('Delete')}+ controlId={AdminControl.CONNECTIONS_CONNECTION_DELETE_CONFIRM}mutationFn={async () => {try {await bulkDeleteGlobalConnections.mutateAsync(@@ -276,6 +279,9 @@ const GlobalConnectionsTable = () => {size="sm"className="text-danger-11 hover:text-danger-11"disabled={!userHasPermissionToWriteAppConnection}+ {...adminControl(+ AdminControl.CONNECTIONS_CONNECTION_DELETE_OPEN,+ )}><Trash className="mr-1 w-4" />{`${t('Delete')} (${selectedRows.length})`}@@ -300,7 +306,12 @@ const GlobalConnectionsTable = () => {refetchGlobalConnections();}}>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ {...adminControl(AdminControl.CONNECTIONS_CONNECTION_OPEN)}+ >{t('New Connection')}</AnimatedIconButton></NewConnectionDialog>,diff --git a/packages/web/src/app/routes/platform/setup/general/appearance-section.tsx b/packages/web/src/app/routes/platform/setup/general/appearance-section.tsxindex fbb36207353..4eb06de4442 100644--- a/packages/web/src/app/routes/platform/setup/general/appearance-section.tsx+++ b/packages/web/src/app/routes/platform/setup/general/appearance-section.tsx@@ -38,6 +38,7 @@ import {import { Label } from '@/components/ui/label';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { brandSeed } from '@/lib/brand-seed';import { ColorPreview, ColorTone } from './color-preview';@@ -330,6 +331,7 @@ export const AppearanceSection = () => {{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.GENERAL_APPEARANCE_SUBMIT)}type="submit"loading={isPending}disabled={!hasChanges || hasFieldErrors}@@ -375,6 +377,7 @@ const ColorRow = ({</span></div><Button+ {...adminControl(AdminControl.GENERAL_COLOUR_RESET_RUN)}type="button"variant="ghost"size="sm"diff --git a/packages/web/src/app/routes/platform/setup/general/danger-zone-section.tsx b/packages/web/src/app/routes/platform/setup/general/danger-zone-section.tsxindex 570618fc3f1..9b5222fe309 100644--- a/packages/web/src/app/routes/platform/setup/general/danger-zone-section.tsx+++ b/packages/web/src/app/routes/platform/setup/general/danger-zone-section.tsx@@ -5,6 +5,7 @@ import { useState } from 'react';import { Button } from '@/components/ui/button';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { DeletePlatformDialog } from './delete-platform-dialog';@@ -29,6 +30,7 @@ export const DangerZoneSection = ({ platformName }: DangerZoneSectionProps) => {</span></div><Button+ {...adminControl(AdminControl.GENERAL_PLATFORM_DELETE_OPEN)}variant="destructive"size="sm"disabled={hasSubscription}diff --git a/packages/web/src/app/routes/platform/setup/general/delete-platform-dialog.tsx b/packages/web/src/app/routes/platform/setup/general/delete-platform-dialog.tsxindex 9ddd5eaa3f1..d78962d39ce 100644--- a/packages/web/src/app/routes/platform/setup/general/delete-platform-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/general/delete-platform-dialog.tsx@@ -24,6 +24,7 @@ import {} from '@/components/ui/form';import { Input } from '@/components/ui/input';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';export const DeletePlatformDialog = ({platformName,@@ -117,6 +118,7 @@ const DeletePlatformForm = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.GENERAL_PLATFORM_DELETE_CONFIRM)}variant="destructive"type="submit"disabled={!form.formState.isValid}diff --git a/packages/web/src/app/routes/platform/setup/pieces/customize-selector-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/customize-selector-dialog.tsxindex 69d87186402..0af301b3e23 100644--- a/packages/web/src/app/routes/platform/setup/pieces/customize-selector-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/customize-selector-dialog.tsx@@ -3,6 +3,7 @@ import {apId,PieceSelectorTabConfig,PieceSelectorTabSection,+ TelemetryEventName,} from '@activepieces/shared';import { t } from 'i18next';import {@@ -22,6 +23,7 @@ import { ReactNode, useMemo, useState } from 'react';import { toast } from 'sonner';import { ConfirmationDeleteDialog } from '@/components/custom/delete-dialog';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import {Command,@@ -61,6 +63,7 @@ import {} from '@/features/pieces';import { platformPiecesMutations } from '@/features/platform-admin';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';const borderlessInputClass =@@ -76,11 +79,25 @@ export const CustomizeSelectorDialog = ({locked: !isEnabled,feature: PLATFORM_FEATURES.pieces,});+ const { capture } = useTelemetry();if (gate.locked) {return (<>- <Button variant="outline" size="sm" onClick={gate.open}>+ <Button+ variant="outline"+ size="sm"+ onClick={() => {+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED,+ payload: {+ feature: PLATFORM_FEATURES.pieces.featureKey,+ control: AdminControl.PIECES_SELECTOR_OPEN,+ },+ });+ gate.open();+ }}+ ><Crown className="size-3.5 shrink-0 text-accent-11" />{t('Customize Selector')}</Button>@@ -92,7 +109,11 @@ export const CustomizeSelectorDialog = ({return (<Sheet open={open} onOpenChange={setOpen}><SheetTrigger asChild>- <Button variant="outline" size="sm">+ <Button+ {...adminControl(AdminControl.PIECES_SELECTOR_OPEN)}+ variant="outline"+ size="sm"+ ><Settings2Icon className="size-4 mr-2" />{t('Customize Selector')}</Button>@@ -229,14 +250,24 @@ const SelectorTabsEditor = ({ onClose }: { onClose: () => void }) => {)}buttonText={t('Reset')}entityName={t('customization')}+ controlId={AdminControl.PIECES_SELECTOR_RESET_CONFIRM}mutationFn={async () => {await saveMutation.mutateAsync(null);onClose();}}>- <Button variant="ghost">{t('Reset to default')}</Button>+ <Button+ {...adminControl(AdminControl.PIECES_SELECTOR_RESET_OPEN)}+ variant="ghost"+ >+ {t('Reset to default')}+ </Button></ConfirmationDeleteDialog>- <Button onClick={handleSave} loading={saveMutation.isPending}>+ <Button+ {...adminControl(AdminControl.PIECES_SELECTOR_SUBMIT)}+ onClick={handleSave}+ loading={saveMutation.isPending}+ >{t('Save')}</Button></SheetFooter>diff --git a/packages/web/src/app/routes/platform/setup/pieces/download-pieces-report.tsx b/packages/web/src/app/routes/platform/setup/pieces/download-pieces-report.tsxindex 6a9b634c087..e5add772d87 100644--- a/packages/web/src/app/routes/platform/setup/pieces/download-pieces-report.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/download-pieces-report.tsx@@ -4,6 +4,7 @@ import { Download } from 'lucide-react';import { toast } from 'sonner';import { Button } from '@/components/ui/button';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';const DownloadPiecesReportButton = () => {@@ -33,6 +34,7 @@ const DownloadPiecesReportButton = () => {return (<Button+ {...adminControl(AdminControl.PIECES_REPORT_RUN)}variant={'outline'}onClick={() => mutate()}loading={isPending}diff --git a/packages/web/src/app/routes/platform/setup/pieces/index.tsx b/packages/web/src/app/routes/platform/setup/pieces/index.tsxindex 58ec5a07208..aa881c24c2f 100644--- a/packages/web/src/app/routes/platform/setup/pieces/index.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/index.tsx@@ -37,6 +37,7 @@ import {piecesHooks,} from '@/features/pieces';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';export const PiecesListTab = () => {@@ -140,6 +141,7 @@ export const PiecesListTab = () => {<ConfirmationDeleteDialogtitle={t('Delete {name}', { name: row.original.name })}entityName={t('Piece')}+ controlId={AdminControl.PIECES_DELETE_CONFIRM}message={t('This will permanently delete this piece, all steps using it will fail.',)}@@ -158,7 +160,12 @@ export const PiecesListTab = () => {toast.error(t('Failed to delete piece'));}}>- <Button variant="ghost" size={'sm'} disabled={!isEnabled}>+ <Button+ {...adminControl(AdminControl.PIECES_DELETE_OPEN)}+ variant="ghost"+ size={'sm'}+ disabled={!isEnabled}+ ><Trash className="size-4 text-danger-11" /></Button></ConfirmationDeleteDialog>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-actions.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-actions.tsxindex 1808414072a..31c179fd47b 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-actions.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-actions.tsx@@ -9,6 +9,7 @@ import {} from '@/components/ui/tooltip';import { platformPiecesMutations } from '@/features/platform-admin';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';type PieceActionsProps = {pieceName: string;@@ -32,6 +33,7 @@ const PieceActions = ({ pieceName, isEnabled }: PieceActionsProps) => {<Tooltip><TooltipTrigger asChild><Button+ {...adminControl(AdminControl.PIECES_PIN_RUN)}variant="ghost"size={'sm'}loading={isPinPending}diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-component-visibility-sheet.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-component-visibility-sheet.tsxindex 961e876ff6f..b9958ddcbf3 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-component-visibility-sheet.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-component-visibility-sheet.tsx@@ -22,6 +22,7 @@ import {import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';import { pieceSetMutations } from '@/features/piece-sets';import { piecesHooks } from '@/features/pieces';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';type PieceComponentVisibilitySheetProps = {@@ -340,7 +341,11 @@ function PieceComponentVisibilitySheetContent({>{t('Cancel')}</Button>- <Button disabled={!isDirty || isMutating} onClick={handleSave}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_COMPONENTS_SUBMIT)}+ disabled={!isDirty || isMutating}+ onClick={handleSave}+ >{isMutating && <Loader2 className="size-4 animate-spin" />}{t('Save changes')}</Button>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/create-piece-set-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/create-piece-set-dialog.tsxindex 7ba65488db9..efe19d27d52 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/create-piece-set-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/create-piece-set-dialog.tsx@@ -26,6 +26,7 @@ import {import { Input } from '@/components/ui/input';import { pieceSetMutations } from '@/features/piece-sets';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';const formSchema = CreatePieceSetRequestBody;@@ -89,7 +90,11 @@ const CreatePieceSetForm = ({>{t('Cancel')}</Button>- <Button type="submit" loading={isPending}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_CREATE_SUBMIT)}+ type="submit"+ loading={isPending}+ >{t('Create')}</Button></DialogFooter>@@ -107,7 +112,10 @@ export const CreatePieceSetDialog = ({return (<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild>- <Button disabled={!isEnabled}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_CREATE_OPEN)}+ disabled={!isEnabled}+ ><Plus className="size-4 mr-1" />{t('New Piece Set')}</Button>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/duplicate-piece-set-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/duplicate-piece-set-dialog.tsxindex ac98ea71f76..49f01259d3c 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/duplicate-piece-set-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/duplicate-piece-set-dialog.tsx@@ -22,6 +22,7 @@ import {} from '@/components/ui/form';import { Input } from '@/components/ui/input';import { pieceSetMutations } from '@/features/piece-sets';+import { AdminControl, adminControl } from '@/lib/admin-control';type DuplicatePieceSetDialogProps = {open: boolean;@@ -82,7 +83,11 @@ const DuplicatePieceSetForm = ({>{t('Cancel')}</Button>- <Button type="submit" loading={isPending}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_DUPLICATE_SUBMIT)}+ type="submit"+ loading={isPending}+ >{t('Duplicate')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/edit-piece-set-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/edit-piece-set-dialog.tsxindex d32e8b911a3..5f3c63efbc5 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/edit-piece-set-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/edit-piece-set-dialog.tsx@@ -23,6 +23,7 @@ import {} from '@/components/ui/form';import { Input } from '@/components/ui/input';import { pieceSetMutations } from '@/features/piece-sets';+import { AdminControl, adminControl } from '@/lib/admin-control';const formSchema = z.object({name: z.string().min(1, { message: formErrors.required }),@@ -118,7 +119,11 @@ const EditPieceSetForm = ({>{t('Cancel')}</Button>- <Button type="submit" loading={isPending}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_SAVE_SUBMIT)}+ type="submit"+ loading={isPending}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page.tsxindex 0b6b4070a41..2ae25bf3655 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page.tsx@@ -10,6 +10,7 @@ import { Switch } from '@/components/ui/switch';import { pieceSetMutations, pieceSetQueries } from '@/features/piece-sets';import { piecesHooks } from '@/features/pieces';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { PieceSetPiecesTab } from './piece-set-pieces-tab';@@ -159,6 +160,7 @@ function AutoIncludePill({)}><Switch+ {...adminControl(AdminControl.PIECE_SETS_NEW_PIECES_TOGGLE)}size="sm"checked={checked}disabled={disabled}diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-pieces-tab.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-pieces-tab.tsxindex 61169d76503..c0e034b878f 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-pieces-tab.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-pieces-tab.tsx@@ -33,6 +33,7 @@ import {} from '@/components/ui/tooltip';import { pieceSetMutations } from '@/features/piece-sets';import { PieceIcon, piecesHooks } from '@/features/pieces';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { PieceComponentVisibilitySheet } from '../piece-component-visibility-sheet';@@ -100,6 +101,7 @@ const BulkPieceSetActions = ({return (<><Button+ {...adminControl(AdminControl.PIECE_SETS_INCLUDE_RUN)}variant="ghost"size="sm"loading={isPending && !!pendingRequest?.pieces}@@ -124,6 +126,7 @@ const BulkPieceSetActions = ({{t('Include')}</Button><Button+ {...adminControl(AdminControl.PIECE_SETS_EXCLUDE_RUN)}variant="ghost"size="sm"loading={isPending && !!pendingRequest?.pieces}@@ -278,6 +281,7 @@ export const PieceSetPiecesTab = ({ pieceSet }: PieceSetPiecesTabProps) => {<Tooltip><TooltipTrigger asChild><button+ {...adminControl(AdminControl.PIECE_SETS_COMPONENTS_OPEN)}type="button"disabled={!included}onClick={() =>@@ -315,6 +319,7 @@ export const PieceSetPiecesTab = ({ pieceSet }: PieceSetPiecesTabProps) => {return (<div className="flex items-center justify-end"><Switch+ {...adminControl(AdminControl.PIECE_SETS_PIECE_TOGGLE)}checked={included}disabled={isPending}onCheckedChange={() =>diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-projects-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-projects-dialog.tsxindex 95765d16c38..0b1280f0fb6 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-projects-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-set-projects-dialog.tsx@@ -31,6 +31,7 @@ import {} from '@/components/ui/dialog';import { pieceSetMutations } from '@/features/piece-sets';import { projectHooks } from '@/features/projects';+import { AdminControl, adminControl } from '@/lib/admin-control';type PieceSetProjectsDialogProps = {pieceSet: PieceSet;@@ -148,7 +149,12 @@ const AssignProjectsForm = ({>{t('Cancel')}</Button>- <Button type="button" loading={isSaving} onClick={handleSave}>+ <Button+ {...adminControl(AdminControl.PIECE_SETS_PROJECTS_SUBMIT)}+ type="button"+ loading={isSaving}+ onClick={handleSave}+ >{t('Save')}</Button></DialogFooter>@@ -183,6 +189,7 @@ export const PieceSetProjectsDialog = ({<Dialog open={open} onOpenChange={setOpen}><DialogTrigger asChild><Button+ {...adminControl(AdminControl.PIECE_SETS_PROJECTS_OPEN)}variant="outline"role="combobox"disabled={isLoading}diff --git a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-sets-tab.tsx b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-sets-tab.tsxindex f63ab7f3cfa..2a63c938be8 100644--- a/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-sets-tab.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/piece-sets/piece-sets-tab.tsx@@ -31,6 +31,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { pieceSetMutations, pieceSetQueries } from '@/features/piece-sets';+import { AdminControl, adminControl } from '@/lib/admin-control';import { CreatePieceSetDialog } from './create-piece-set-dialog';import { DuplicatePieceSetDialog } from './duplicate-piece-set-dialog';@@ -121,6 +122,7 @@ export const PieceSetsTab = () => {<Tooltip><TooltipTrigger asChild><Button+ {...adminControl(AdminControl.PIECE_SETS_EDIT_OPEN)}variant="ghost"size="sm"onClick={() => setEditingSet(row.original)}@@ -133,6 +135,7 @@ export const PieceSetsTab = () => {<Tooltip><TooltipTrigger asChild><Button+ {...adminControl(AdminControl.PIECE_SETS_DUPLICATE_OPEN)}variant="ghost"size="sm"onClick={() => setDuplicatingSet(row.original)}@@ -145,6 +148,7 @@ export const PieceSetsTab = () => {<ConfirmationDeleteDialogtitle={t('Delete {name}', { name: row.original.name })}entityName={t('Piece Set')}+ controlId={AdminControl.PIECE_SETS_DELETE_CONFIRM}message={t('Projects assigned to this set will be reassigned to the default set.',)}@@ -153,6 +157,7 @@ export const PieceSetsTab = () => {}}><Button+ {...adminControl(AdminControl.PIECE_SETS_DELETE_OPEN)}variant="ghost"size="sm"disabled={row.original.isDefault}diff --git a/packages/web/src/app/routes/platform/setup/pieces/sync-pieces.tsx b/packages/web/src/app/routes/platform/setup/pieces/sync-pieces.tsxindex 0c7adc5fdce..0782c8eaab0 100644--- a/packages/web/src/app/routes/platform/setup/pieces/sync-pieces.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/sync-pieces.tsx@@ -4,6 +4,7 @@ import { RefreshCcw } from 'lucide-react';import { Button } from '@/components/ui/button';import { platformPiecesMutations } from '@/features/platform-admin';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';const SyncPiecesButton = () => {const { data: piecesSyncMode } = flagsHooks.useFlag<string>(@@ -16,6 +17,7 @@ const SyncPiecesButton = () => {<>{piecesSyncMode === PieceSyncMode.OFFICIAL_AUTO && (<Button+ {...adminControl(AdminControl.PIECES_SYNC_RUN)}variant={'outline'}onClick={() => syncPieces()}loading={isPending}diff --git a/packages/web/src/app/routes/platform/setup/pieces/update-oauth2-dialog.tsx b/packages/web/src/app/routes/platform/setup/pieces/update-oauth2-dialog.tsxindex 586e4a02bb8..5af6383fcc5 100644--- a/packages/web/src/app/routes/platform/setup/pieces/update-oauth2-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/pieces/update-oauth2-dialog.tsx@@ -23,6 +23,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { oauthAppsMutations, oauthAppsQueries } from '@/features/connections';+import { AdminControl, adminControl } from '@/lib/admin-control';type ConfigurePieceOAuth2DialogProps = {pieceName: string;@@ -66,6 +67,11 @@ export const ConfigurePieceOAuth2Dialog = forwardRef<<Tooltip><TooltipTrigger asChild><Button+ {...adminControl(+ isNil(oauth2App)+ ? AdminControl.PIECES_OAUTH_CONFIGURE_OPEN+ : AdminControl.PIECES_OAUTH_DELETE_RUN,+ )}ref={ref}size={'sm'}variant={'ghost'}@@ -160,6 +166,7 @@ export const ConfigurePieceOAuth2Dialog = forwardRef<{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.PIECES_OAUTH_CONFIGURE_SUBMIT)}loading={isUpserting}disabled={!form.formState.isValid}type="submit"diff --git a/packages/web/src/app/routes/platform/setup/templates/create-template-dialog.tsx b/packages/web/src/app/routes/platform/setup/templates/create-template-dialog.tsxindex e74b2fe2d63..7cad685f45e 100644--- a/packages/web/src/app/routes/platform/setup/templates/create-template-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/templates/create-template-dialog.tsx@@ -25,6 +25,7 @@ import { Label } from '@/components/ui/label';import { templateUtils } from '@/features/flows';import { templatesApi } from '@/features/templates';import { userHooks } from '@/hooks/user-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { Textarea } from '../../../../../components/ui/textarea';@@ -241,6 +242,7 @@ export const CreateTemplateDialog = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.TEMPLATES_NEW_SUBMIT)}disabled={isPending}loading={isPending}onClick={(e) => {diff --git a/packages/web/src/app/routes/platform/setup/templates/index.tsx b/packages/web/src/app/routes/platform/setup/templates/index.tsxindex 02b1784ac87..ed69de0818d 100644--- a/packages/web/src/app/routes/platform/setup/templates/index.tsx+++ b/packages/web/src/app/routes/platform/setup/templates/index.tsx@@ -28,6 +28,7 @@ import {import { PieceIconList } from '@/features/pieces';import { templatesApi, templatesMutations } from '@/features/templates';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { sampleData } from '../../sample-data';@@ -168,6 +169,7 @@ const PlatformTemplatesPage = () => {'Are you sure you want to delete the selected templates?',)}entityName={t('Templates')}+ controlId={AdminControl.TEMPLATES_DELETE_CONFIRM}mutationFn={async () => {await bulkDeleteMutation.mutateAsync(selectedRows.map((row) => row.id),@@ -178,6 +180,7 @@ const PlatformTemplatesPage = () => {>{selectedRows.length > 0 && (<Button+ {...adminControl(AdminControl.TEMPLATES_DELETE_OPEN)}variant="ghost"size="sm"className="text-danger-11 hover:text-danger-11"@@ -197,7 +200,12 @@ const PlatformTemplatesPage = () => {const toolbarButtons = useMemo(() => [<CreateTemplateDialog key="new-template" onDone={() => refetch()}>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ {...adminControl(AdminControl.TEMPLATES_NEW_OPEN)}+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ >{t('New Template')}</AnimatedIconButton></CreateTemplateDialog>,@@ -238,7 +246,11 @@ const PlatformTemplatesPage = () => {onDone={() => refetch()}template={row}>- <Button variant="ghost" className="size-8 p-0">+ <Button+ {...adminControl(AdminControl.TEMPLATES_EDIT_OPEN)}+ variant="ghost"+ className="size-8 p-0"+ ><Pencil className="size-4" /></Button></UpdateTemplateDialog>diff --git a/packages/web/src/app/routes/platform/setup/templates/update-template-dialog.tsx b/packages/web/src/app/routes/platform/setup/templates/update-template-dialog.tsxindex ae44a899ab1..27b5a9b3670 100644--- a/packages/web/src/app/routes/platform/setup/templates/update-template-dialog.tsx+++ b/packages/web/src/app/routes/platform/setup/templates/update-template-dialog.tsx@@ -25,6 +25,7 @@ import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';import { templateUtils } from '@/features/flows';import { templatesApi } from '@/features/templates';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';const UpdateFlowTemplateSchema = z.object({@@ -230,6 +231,7 @@ export const UpdateTemplateDialog = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.TEMPLATES_EDIT_SUBMIT)}disabled={isPending}loading={isPending}onClick={(e) => {diff --git a/packages/web/src/app/routes/platform/use-admin-control-clicks.ts b/packages/web/src/app/routes/platform/use-admin-control-clicks.tsnew file mode 100644index 00000000000..d5f49296081--- /dev/null+++ b/packages/web/src/app/routes/platform/use-admin-control-clicks.ts@@ -0,0 +1,40 @@+import { isNil } from '@activepieces/core-utils';+import { TelemetryEventName } from '@activepieces/shared';+import { useEffect } from 'react';+import { useLatest } from 'react-use';++import { useTelemetry } from '@/components/providers/telemetry-provider';+import { ADMIN_CONTROL_ATTRIBUTE } from '@/lib/admin-control';++export function useAdminControlClicks(page: string) {+ const { capture } = useTelemetry();+ const latestCapture = useLatest(capture);+ const latestPage = useLatest(page);++ useEffect(() => {+ const reportClick = (event: MouseEvent) => {+ const control = controlIdOf(event.target);+ if (isNil(control)) {+ return;+ }+ latestCapture.current({+ name: TelemetryEventName.PLATFORM_ADMIN_CONTROL_CLICKED,+ payload: { control, page: latestPage.current },+ });+ };+ document.addEventListener('click', reportClick, true);+ return () => document.removeEventListener('click', reportClick, true);+ }, [latestCapture, latestPage]);+}++function controlIdOf(target: EventTarget | null): string | null {+ if (!(target instanceof Element)) {+ return null;+ }+ return (+ target.closest(CONTROL_SELECTOR)?.getAttribute(ADMIN_CONTROL_ATTRIBUTE) ??+ null+ );+}++const CONTROL_SELECTOR = `[${ADMIN_CONTROL_ATTRIBUTE}]`;diff --git a/packages/web/src/app/routes/platform/use-admin-page-viewed.ts b/packages/web/src/app/routes/platform/use-admin-page-viewed.tsnew file mode 100644index 00000000000..aa846918c1c--- /dev/null+++ b/packages/web/src/app/routes/platform/use-admin-page-viewed.ts@@ -0,0 +1,19 @@+import { TelemetryEventName } from '@activepieces/shared';+import { useEffect } from 'react';+import { useLatest } from 'react-use';++import { useInsideFeatureSample } from '@/app/components/feature-sample';+import { useTelemetry } from '@/components/providers/telemetry-provider';++export function useAdminPageViewed(page: string) {+ const { capture } = useTelemetry();+ const latestCapture = useLatest(capture);+ const locked = useInsideFeatureSample();++ useEffect(() => {+ latestCapture.current({+ name: TelemetryEventName.PLATFORM_ADMIN_PAGE_VIEWED,+ payload: { page, locked },+ });+ }, [latestCapture, page, locked]);+}diff --git a/packages/web/src/app/routes/platform/users/actions/update-user-dialog.tsx b/packages/web/src/app/routes/platform/users/actions/update-user-dialog.tsxindex 45ddcb39913..67db2fcf59a 100644--- a/packages/web/src/app/routes/platform/users/actions/update-user-dialog.tsx+++ b/packages/web/src/app/routes/platform/users/actions/update-user-dialog.tsx@@ -23,6 +23,7 @@ import { Form, FormField, FormItem, FormMessage } from '@/components/ui/form';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { RoleSelector } from '@/features/members';+import { AdminControl, adminControl } from '@/lib/admin-control';export const UpdateUserDialog = ({children,@@ -123,6 +124,7 @@ export const UpdateUserDialog = ({<Buttondisabled={isPending}loading={isPending}+ {...adminControl(AdminControl.USERS_EDIT_SUBMIT)}onClick={(e) => {e.stopPropagation();e.preventDefault();diff --git a/packages/web/src/app/routes/platform/users/actions/user-actions.tsx b/packages/web/src/app/routes/platform/users/actions/user-actions.tsxindex 640e357a579..17d6b88a886 100644--- a/packages/web/src/app/routes/platform/users/actions/user-actions.tsx+++ b/packages/web/src/app/routes/platform/users/actions/user-actions.tsx@@ -17,6 +17,7 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from '@/components/ui/dropdown-menu';+import { AdminControl, adminControl } from '@/lib/admin-control';import { UserRowData } from '../index';@@ -58,7 +59,10 @@ export const UserActions = ({externalId={row.data.externalId ?? undefined}onUpdate={onUpdate}>- <DropdownMenuItem onSelect={(e) => e.preventDefault()}>+ <DropdownMenuItem+ onSelect={(e) => e.preventDefault()}+ {...adminControl(AdminControl.USERS_EDIT_OPEN)}+ ><Pencil className="h-4 w-4" />{t('Edit')}</DropdownMenuItem>@@ -71,6 +75,11 @@ export const UserActions = ({onToggleStatus(row.data.id, row.data.status);setOpen(false);}}+ {...adminControl(+ isActive+ ? AdminControl.USERS_DEACTIVATE_RUN+ : AdminControl.USERS_ACTIVATE_RUN,+ )}>{isActive ? (<CircleMinus className="h-4 w-4" />@@ -93,10 +102,12 @@ export const UserActions = ({mutationFn={async () => {onDelete(isInvitation ? row.id : row.data.id, isInvitation);}}+ controlId={AdminControl.USERS_DELETE_CONFIRM}><DropdownMenuItemvariant="destructive"onSelect={(e) => e.preventDefault()}+ {...adminControl(AdminControl.USERS_DELETE_OPEN)}><Trash className="h-4 w-4" />{t('Delete')}diff --git a/packages/web/src/app/routes/platform/users/index.tsx b/packages/web/src/app/routes/platform/users/index.tsxindex ae4b96f4d69..dc05f4a3dbd 100644--- a/packages/web/src/app/routes/platform/users/index.tsx+++ b/packages/web/src/app/routes/platform/users/index.tsx@@ -18,6 +18,7 @@ import {platformUserHooks,platformUserMutations,} from '@/features/platform-admin/hooks/platform-user-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { UserActions } from './actions/user-actions';import { createUsersTableColumns } from './columns';@@ -149,6 +150,7 @@ export default function UsersPage() {key="invite"className="gap-2"size="sm"+ {...adminControl(AdminControl.USERS_INVITE_OPEN)}onClick={() => {if (ensureSeatsAvailable(1)) {setInviteOpen(true);diff --git a/packages/web/src/components/custom/clipboard/copy-text-tooltip.tsx b/packages/web/src/components/custom/clipboard/copy-text-tooltip.tsxindex d29bf87a532..55bb139aa2b 100644--- a/packages/web/src/components/custom/clipboard/copy-text-tooltip.tsx+++ b/packages/web/src/components/custom/clipboard/copy-text-tooltip.tsx@@ -1,3 +1,5 @@+import { AdminControl, adminControl } from '@/lib/admin-control';+import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip';import { CopyButton } from './copy-button';@@ -6,10 +8,12 @@ const CopyTextTooltip = ({text,title,children,+ controlId,}: {text: string;title: string;children: React.ReactNode;+ controlId?: AdminControl;}) => {return (<Tooltip>@@ -22,6 +26,7 @@ const CopyTextTooltip = ({variant="ghost"className="hover:bg-gray-1/20 hover:text-gray-1"textToCopy={text || ''}+ {...adminControl(controlId)}></CopyButton></div></TooltipContent>diff --git a/packages/web/src/components/custom/clipboard/copy-to-clipboard.tsx b/packages/web/src/components/custom/clipboard/copy-to-clipboard.tsxindex 34fa4cc5240..32ec833a2af 100644--- a/packages/web/src/components/custom/clipboard/copy-to-clipboard.tsx+++ b/packages/web/src/components/custom/clipboard/copy-to-clipboard.tsx@@ -1,5 +1,6 @@import { Input } from '@/components/ui/input';import { Textarea } from '@/components/ui/textarea';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { DownloadButton } from '../download-button';@@ -10,6 +11,7 @@ type CopyToClipboardInputProps = {textToCopy: string;useInput: boolean;fileName?: string;+ controlId?: AdminControl;};const noBorderInputClass = `border-none w-full focus-visible:ring-transparent focus-visible:ring-offset-0`;@@ -18,6 +20,7 @@ const CopyToClipboardInput = ({textToCopy,fileName,useInput,+ controlId,}: CopyToClipboardInputProps) => {return (<div className="flex gap-2 items-center bg-gray-1 border border-solid text-sm rounded block w-full select-none pr-3">@@ -36,7 +39,11 @@ const CopyToClipboardInput = ({'flex-col': !useInput,})}>- <CopyButton textToCopy={textToCopy} variant="ghost" />+ <CopyButton+ textToCopy={textToCopy}+ variant="ghost"+ {...adminControl(controlId)}+ />{fileName && (<DownloadButtontextToDownload={textToCopy}diff --git a/packages/web/src/components/custom/delete-dialog.tsx b/packages/web/src/components/custom/delete-dialog.tsxindex 0cbdec19550..4ce09a61282 100644--- a/packages/web/src/components/custom/delete-dialog.tsx+++ b/packages/web/src/components/custom/delete-dialog.tsx@@ -15,6 +15,7 @@ import {DialogTitle,DialogTrigger,} from '@/components/ui/dialog';+import { AdminControl, adminControl } from '@/lib/admin-control';interface ConfirmationDeleteDialogProps {title: string;@@ -30,6 +31,7 @@ interface ConfirmationDeleteDialogProps {onError?: (error: Error) => void;warning?: React.ReactNode | string;confirmDisabled?: boolean;+ controlId?: AdminControl;}export const ConfirmationDeleteDialog = ({@@ -46,6 +48,7 @@ export const ConfirmationDeleteDialog = ({onOpenChange,warning,confirmDisabled,+ controlId,}: ConfirmationDeleteDialogProps) => {const [isControlled] = useState(open !== undefined && onOpenChange !== undefined,@@ -106,6 +109,7 @@ export const ConfirmationDeleteDialog = ({loading={isPending}disabled={confirmDisabled}onClick={() => mutate()}+ {...adminControl(controlId)}>{isDanger && <TriangleAlert className="size-4 mr-2" />}{buttonText || t('Remove')}diff --git a/packages/web/src/features/billing/components/activate-license-dialog.tsx b/packages/web/src/features/billing/components/activate-license-dialog.tsxindex 742e06b573d..f8b87098bbb 100644--- a/packages/web/src/features/billing/components/activate-license-dialog.tsx+++ b/packages/web/src/features/billing/components/activate-license-dialog.tsx@@ -18,6 +18,7 @@ import {import { Form, FormField, FormItem, FormMessage } from '@/components/ui/form';import { Input } from '@/components/ui/input';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';const LicenseKeySchema = z.object({tempLicenseKey: z.string({ message: t('License key is invalid') }),@@ -120,6 +121,7 @@ export const ActivateLicenseDialog = ({</Button></DialogClose><Button+ {...adminControl(AdminControl.BILLING_LICENSE_KEY_SUBMIT)}onClick={form.handleSubmit(handleSubmit)}disabled={isPending || !form.watch('tempLicenseKey')?.trim()}className="min-w-20"diff --git a/packages/web/src/features/billing/components/cancel-subscription-dialog.tsx b/packages/web/src/features/billing/components/cancel-subscription-dialog.tsxindex a93bc1b6d82..4fc34e7558f 100644--- a/packages/web/src/features/billing/components/cancel-subscription-dialog.tsx+++ b/packages/web/src/features/billing/components/cancel-subscription-dialog.tsx@@ -23,6 +23,7 @@ import {import { Form, FormControl, FormField, FormItem } from '@/components/ui/form';import { Label } from '@/components/ui/label';import { Textarea } from '@/components/ui/textarea';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';export function CancelSubscriptionDialog({@@ -158,7 +159,12 @@ function CancelSubscriptionForm({>{t('Keep my plan')}</Button>- <Button type="submit" variant="destructive" loading={isPending}>+ <Button+ {...adminControl(AdminControl.BILLING_CANCEL_SUBSCRIPTION_SUBMIT)}+ type="submit"+ variant="destructive"+ loading={isPending}+ >{confirmText}</Button></DialogFooter>diff --git a/packages/web/src/features/billing/components/confirm-purchase-dialog.tsx b/packages/web/src/features/billing/components/confirm-purchase-dialog.tsxindex 30bf9600629..bb0b395edf4 100644--- a/packages/web/src/features/billing/components/confirm-purchase-dialog.tsx+++ b/packages/web/src/features/billing/components/confirm-purchase-dialog.tsx@@ -11,6 +11,7 @@ import {DialogHeader,DialogTitle,} from '@/components/ui/dialog';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingMutations } from '../hooks/billing-hooks';import { usePlanSeatFloorGuard } from '../hooks/use-plan-seat-floor-guard';@@ -101,6 +102,9 @@ export function ConfirmPurchaseDialog() {{t('Cancel')}</Button><Button+ {...adminControl(+ AdminControl.BILLING_PURCHASE_CONFIRM_SUBMIT,+ )}type="button"loading={isPending}onClick={() =>diff --git a/packages/web/src/features/billing/components/credits-action-button.tsx b/packages/web/src/features/billing/components/credits-action-button.tsxindex 313ed89d413..5993da8d43a 100644--- a/packages/web/src/features/billing/components/credits-action-button.tsx+++ b/packages/web/src/features/billing/components/credits-action-button.tsx@@ -6,6 +6,7 @@ import { useState } from 'react';import { useEmbedding } from '@/components/providers/embed-provider';import { Button } from '@/components/ui/button';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingQueries } from '../hooks/billing-hooks';import { useCreditsUsage } from '../hooks/use-credits-usage';@@ -48,6 +49,7 @@ export function CreditsActionButton({case 'upgrade':return (<Button+ {...adminControl(AdminControl.BILLING_CREDITS_UPGRADE_OPEN)}variant={variant}size="sm"className={className}@@ -61,6 +63,7 @@ export function CreditsActionButton({return (<><Button+ {...adminControl(AdminControl.BILLING_CREDITS_RECHARGE_OPEN)}variant={variant}size="sm"className={className}diff --git a/packages/web/src/features/billing/components/current-subscription-card.tsx b/packages/web/src/features/billing/components/current-subscription-card.tsxindex 519e6d7df07..6dc69efb4fb 100644--- a/packages/web/src/features/billing/components/current-subscription-card.tsx+++ b/packages/web/src/features/billing/components/current-subscription-card.tsx@@ -4,6 +4,7 @@ import { t } from 'i18next';import nonFreePlanBg from '@/assets/img/custom/non-free-plan-bg.jpg';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { billingUtils } from '../utils/billing-utils';@@ -36,6 +37,7 @@ export const CurrentSubscriptionCard = ({</Badge></div><Button+ {...adminControl(AdminControl.BILLING_UPGRADE_OPEN)}className="w-full text-gray-12 shadow-edge"onClick={onExplorePlans}variant={'outline'}@@ -55,7 +57,11 @@ export const CurrentSubscriptionCard = ({><span className="text-sm text-gray-11">{t('Current plan')}</span><div className="text-2xl font-semibold">{planTitle(info)}</div>- <Button className="w-full" onClick={onExplorePlans}>+ <Button+ {...adminControl(AdminControl.BILLING_UPGRADE_OPEN)}+ className="w-full"+ onClick={onExplorePlans}+ >{t('Upgrade')}</Button></div>diff --git a/packages/web/src/features/billing/components/feature-usage/auto-recharge-card.tsx b/packages/web/src/features/billing/components/feature-usage/auto-recharge-card.tsxindex 48d230e1430..6412f56f465 100644--- a/packages/web/src/features/billing/components/feature-usage/auto-recharge-card.tsx+++ b/packages/web/src/features/billing/components/feature-usage/auto-recharge-card.tsx@@ -10,6 +10,7 @@ import { type ReactNode, useState } from 'react';import { Button } from '@/components/ui/button';import { Switch } from '@/components/ui/switch';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingMutations } from '../../hooks/billing-hooks';import { DetailRow } from '../detail-row';@@ -57,6 +58,7 @@ export const AutoRechargeCard = ({)}</span><Button+ {...adminControl(AdminControl.BILLING_PAYMENT_METHOD_OPEN)}variant="outline"size="sm"className="self-start"@@ -73,6 +75,7 @@ export const AutoRechargeCard = ({<div className="flex flex-col gap-4 rounded-xl border bg-panel p-5"><div className="flex items-center gap-3"><Switch+ {...adminControl(AdminControl.BILLING_AUTO_RECHARGE_TOGGLE)}checked={enabled}disabled={isPending}onCheckedChange={toggle}@@ -106,6 +109,7 @@ export const AutoRechargeCard = ({/></div><Button+ {...adminControl(AdminControl.BILLING_AUTO_RECHARGE_OPEN)}variant="outline"size="sm"className="self-start"diff --git a/packages/web/src/features/billing/components/feature-usage/auto-recharge-config-dialog.tsx b/packages/web/src/features/billing/components/feature-usage/auto-recharge-config-dialog.tsxindex 59aa90d1b3b..1ebb24ba1b8 100644--- a/packages/web/src/features/billing/components/feature-usage/auto-recharge-config-dialog.tsx+++ b/packages/web/src/features/billing/components/feature-usage/auto-recharge-config-dialog.tsx@@ -40,6 +40,7 @@ import {SelectTrigger,SelectValue,} from '@/components/ui/select';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { billingMutations } from '../../hooks/billing-hooks';@@ -217,7 +218,11 @@ export function AutoRechargeConfigDialog({>{t('Cancel')}</Button>- <Button type="submit" loading={isPending}>+ <Button+ {...adminControl(AdminControl.BILLING_AUTO_RECHARGE_SUBMIT)}+ type="submit"+ loading={isPending}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/features/billing/components/feature-usage/deactivate-users-dialog.tsx b/packages/web/src/features/billing/components/feature-usage/deactivate-users-dialog.tsxindex e621653dcde..0b1e5bdda07 100644--- a/packages/web/src/features/billing/components/feature-usage/deactivate-users-dialog.tsx+++ b/packages/web/src/features/billing/components/feature-usage/deactivate-users-dialog.tsx@@ -23,6 +23,7 @@ import {platformUserKeys,} from '@/features/platform-admin/hooks/platform-user-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';export const DeactivateUsersDialog = ({@@ -174,6 +175,7 @@ function DeactivateUsersForm({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.BILLING_DEACTIVATE_USERS_SUBMIT)}type="button"loading={isPending}disabled={!withinLimit}diff --git a/packages/web/src/features/billing/components/feature-usage/manage-seats-dialog.tsx b/packages/web/src/features/billing/components/feature-usage/manage-seats-dialog.tsxindex 5801a3c990b..706a5ebd73e 100644--- a/packages/web/src/features/billing/components/feature-usage/manage-seats-dialog.tsx+++ b/packages/web/src/features/billing/components/feature-usage/manage-seats-dialog.tsx@@ -24,6 +24,7 @@ import {FormMessage,} from '@/components/ui/form';import { Input } from '@/components/ui/input';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingMutations } from '../../hooks/billing-hooks';import { PriceSummary } from '../price-summary';@@ -174,6 +175,7 @@ function ManageSeatsForm({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.BILLING_SEATS_SUBMIT)}type="submit"loading={isPending}disabled={!form.formState.isValid}diff --git a/packages/web/src/features/billing/components/feature-usage/out-of-seats-dialog.tsx b/packages/web/src/features/billing/components/feature-usage/out-of-seats-dialog.tsxindex 81d963992b9..6599cce24b9 100644--- a/packages/web/src/features/billing/components/feature-usage/out-of-seats-dialog.tsx+++ b/packages/web/src/features/billing/components/feature-usage/out-of-seats-dialog.tsx@@ -16,6 +16,7 @@ import {DialogHeader,DialogTitle,} from '@/components/ui/dialog';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingMutations } from '../../hooks/billing-hooks';import { billingUtils } from '../../utils/billing-utils';@@ -82,6 +83,7 @@ export const OutOfSeatsDialog = ({)}{capBinds ? (<Button+ {...adminControl(AdminControl.BILLING_SEATS_KEEP_PLAN_RUN)}type="button"loading={isReactivating}onClick={() => reactivate()}@@ -90,6 +92,7 @@ export const OutOfSeatsDialog = ({</Button>) : (<Button+ {...adminControl(AdminControl.BILLING_SEATS_ADD_OPEN)}type="button"onClick={() => {onOpenChange(false);diff --git a/packages/web/src/features/billing/components/feature-usage/users-card.tsx b/packages/web/src/features/billing/components/feature-usage/users-card.tsxindex f42f3bd2c34..547d1cf76eb 100644--- a/packages/web/src/features/billing/components/feature-usage/users-card.tsx+++ b/packages/web/src/features/billing/components/feature-usage/users-card.tsx@@ -8,6 +8,7 @@ import { Pencil, Plus } from 'lucide-react';import { useState } from 'react';import { Button } from '@/components/ui/button';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingUtils } from '../../utils/billing-utils';import { DetailRow } from '../detail-row';@@ -74,6 +75,7 @@ export const UsersCard = ({ info, feature }: UsersCardProps) => {) : (<><Button+ {...adminControl(AdminControl.BILLING_SEATS_OPEN)}type="button"variant="outline"size="sm"diff --git a/packages/web/src/features/billing/components/keep-plan-dialog.tsx b/packages/web/src/features/billing/components/keep-plan-dialog.tsxindex e30181de1d7..67a99b9fdf0 100644--- a/packages/web/src/features/billing/components/keep-plan-dialog.tsx+++ b/packages/web/src/features/billing/components/keep-plan-dialog.tsx@@ -13,6 +13,7 @@ import {DialogTitle,} from '@/components/ui/dialog';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { billingMutations, billingQueries } from '../hooks/billing-hooks';@@ -98,6 +99,7 @@ export function KeepPlanDialog({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.BILLING_KEEP_PLAN_SUBMIT)}type="button"loading={isPending}onClick={() => reactivate()}diff --git a/packages/web/src/features/billing/components/license-key.tsx b/packages/web/src/features/billing/components/license-key.tsxindex 3912392a0e7..c23bc2a8626 100644--- a/packages/web/src/features/billing/components/license-key.tsx+++ b/packages/web/src/features/billing/components/license-key.tsx@@ -5,6 +5,7 @@ import { useState } from 'react';import { AnimatedIconButton } from '@/components/custom/animated-icon-button';import { CopyToClipboardInput } from '@/components/custom/clipboard/copy-to-clipboard';import { ArrowUpIcon } from '@/components/icons/arrow-up';+import { AdminControl, adminControl } from '@/lib/admin-control';import { ActivateLicenseDialog } from './activate-license-dialog';@@ -27,11 +28,13 @@ export const LicenseKey = ({<>{isSelfHosted && platform.plan.licenseKey && (<CopyToClipboardInput+ controlId={AdminControl.BILLING_LICENSE_KEY_COPY}textToCopy={platform.plan.licenseKey}useInput={true}/>)}<AnimatedIconButton+ {...adminControl(AdminControl.BILLING_LICENSE_KEY_OPEN)}icon={ArrowUpIcon}iconSize={16}variant="default"diff --git a/packages/web/src/features/billing/components/plan-selector.tsx b/packages/web/src/features/billing/components/plan-selector.tsxindex e43b4f0dbcf..5e331d09916 100644--- a/packages/web/src/features/billing/components/plan-selector.tsx+++ b/packages/web/src/features/billing/components/plan-selector.tsx@@ -15,6 +15,7 @@ import {TooltipTrigger,} from '@/components/ui/tooltip';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { billingMutations, billingQueries } from '../hooks/billing-hooks';@@ -356,6 +357,7 @@ function PlanCta({asChild><a+ {...adminControl(AdminControl.BILLING_PLAN_SALES_LINK)}href={planSelectorUtils.SALES_URL}target="_blank"rel="noopener noreferrer"@@ -375,7 +377,12 @@ function PlanCta({if (isCurrent) {if (hasScheduledChange) {return (- <Button variant="default" className="w-full" onClick={onKeepPlan}>+ <Button+ {...adminControl(AdminControl.BILLING_PLAN_KEEP_OPEN)}+ variant="default"+ className="w-full"+ onClick={onKeepPlan}+ >{t('Keep current plan')}</Button>);@@ -396,7 +403,12 @@ function PlanCta({);}return (- <Button variant="outline" className="w-full" onClick={onDowngrade}>+ <Button+ {...adminControl(AdminControl.BILLING_PLAN_DOWNGRADE_OPEN)}+ variant="outline"+ className="w-full"+ onClick={onDowngrade}+ >{t('Downgrade')}</Button>);@@ -408,6 +420,7 @@ function PlanCta({const action = planSelectorUtils.actionFor({ currentPlanId });return (<Button+ {...adminControl(AdminControl.BILLING_PLAN_PURCHASE_SUBMIT)}variant={highlighted ? 'default' : 'outline'}className="w-full"disabled={isPending}diff --git a/packages/web/src/features/billing/components/request-trial.tsx b/packages/web/src/features/billing/components/request-trial.tsxindex 0de625dc1a7..6fe75d16f1a 100644--- a/packages/web/src/features/billing/components/request-trial.tsx+++ b/packages/web/src/features/billing/components/request-trial.tsx@@ -1,5 +1,6 @@import { isNil } from '@activepieces/core-utils';import {+ PlatformAdminSurface,TelemetryEventName,UserWithMetaInformation,} from '@activepieces/shared';@@ -13,6 +14,7 @@ import { telemetryUtils } from '@/lib/telemetry-utils';export const RequestTrial = ({featureKey,+ surface,buttonVariant = 'default',buttonSize = 'default',}: RequestTrialProps) => {@@ -20,6 +22,12 @@ export const RequestTrial = ({const { capture } = useTelemetry();const handleClick = () => {+ if (surface !== undefined) {+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED,+ payload: { feature: featureKey, surface },+ });+ }capture({name: TelemetryEventName.SALES_HANDOFF_CLICKED,payload: { featureKey, surface: 'locked_feature' },@@ -96,6 +104,7 @@ export type FeatureKey =type RequestTrialProps = {featureKey: FeatureKey;+ surface?: Exclude<PlatformAdminSurface, PlatformAdminSurface.DIALOG>;customButton?: React.ReactNode;buttonVariant?: 'default' | 'basic';buttonSize?: 'default' | 'sm' | 'xs';diff --git a/packages/web/src/features/billing/hooks/use-feature-gate.tsx b/packages/web/src/features/billing/hooks/use-feature-gate.tsxindex f64a7567dbf..f657bd3b582 100644--- a/packages/web/src/features/billing/hooks/use-feature-gate.tsx+++ b/packages/web/src/features/billing/hooks/use-feature-gate.tsx@@ -1,4 +1,8 @@-import { ApEdition, ApFlagId } from '@activepieces/shared';+import {+ ApEdition,+ ApFlagId,+ PlatformAdminSurface,+} from '@activepieces/shared';import { t } from 'i18next';import { Check, Crown, ExternalLink } from 'lucide-react';import { ReactNode, useState } from 'react';@@ -14,11 +18,13 @@ import {DialogTitle,} from '@/components/ui/dialog';import { flagsHooks } from '@/hooks/flags-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { FeatureKey } from '../components/request-trial';-import { useManagePlanDialogStore } from '../stores/manage-plan-dialog-state';import { FeatureTier, TIER_LABELS } from '../utils/feature-tier';+import { useUpgradeClick } from './use-upgrade-click';+export function useFeatureGate({ locked, feature }: UseFeatureGateParams) {const [open, setOpen] = useState(false);@@ -42,8 +48,9 @@ export function UpgradeFeatureDialog({bullets,tier,documentationUrl,+ featureKey,}: UpgradeFeatureDialogProps) {- const { openDialog: openManagePlanDialog } = useManagePlanDialogStore();+ const upgradeClick = useUpgradeClick();const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);const isCommunity = edition === ApEdition.COMMUNITY;const docsUrl = documentationUrl ?? ENTERPRISE_DOCUMENTATION_URL;@@ -79,6 +86,7 @@ export function UpgradeFeatureDialog({<DialogFooter className="sm:justify-start">{isCommunity ? (<a+ {...adminControl(AdminControl.PLAN_DIALOG_LINK)}href={docsUrl}target="_blank"rel="noopener noreferrer"@@ -91,7 +99,11 @@ export function UpgradeFeatureDialog({<ButtononClick={() => {onOpenChange(false);- openManagePlanDialog();+ upgradeClick({+ feature: featureKey,+ tier,+ surface: PlatformAdminSurface.DIALOG,+ });}}>{t('Upgrade plan')}diff --git a/packages/web/src/features/billing/hooks/use-team-project-limit-guard.tsx b/packages/web/src/features/billing/hooks/use-team-project-limit-guard.tsxindex e3978c5aab0..ad401772ad3 100644--- a/packages/web/src/features/billing/hooks/use-team-project-limit-guard.tsx+++ b/packages/web/src/features/billing/hooks/use-team-project-limit-guard.tsx@@ -2,12 +2,17 @@ import { isNil } from '@activepieces/core-utils';import {ApEdition,ApFlagId,+ PlatformAdminLimit,+ PlatformAdminSurface,ProjectType,ProjectWithLimits,+ TelemetryEventName,} from '@activepieces/shared';import { t } from 'i18next';import { Check, LayoutGrid } from 'lucide-react';+import { useEffectOnce } from 'react-use';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import {@@ -21,10 +26,11 @@ import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';import { RequestTrial } from '../components/request-trial';-import { useManagePlanDialogStore } from '../stores/manage-plan-dialog-state';import { TIER_LABELS } from '../utils/feature-tier';import { PLATFORM_FEATURES } from '../utils/platform-features';+import { useUpgradeClick } from './use-upgrade-click';+export const useTeamProjectLimitGuard = ({projects,}: {@@ -32,7 +38,6 @@ export const useTeamProjectLimitGuard = ({}) => {const isPlatformAdmin = useIsPlatformAdmin();const { platform } = platformHooks.useCurrentPlatform();- const { openDialog } = useManagePlanDialogStore();const { data: edition } = flagsHooks.useFlag<ApEdition>(ApFlagId.EDITION);const limit = platform.plan.billedTeamProjectsLimit;@@ -46,11 +51,8 @@ export const useTeamProjectLimitGuard = ({limit={limit ?? 0}isPlatformAdmin={isPlatformAdmin}isCommunity={edition === ApEdition.COMMUNITY}+ used={teamProjectsUsed}onClose={onClose}- onExplorePlans={() => {- onClose();- openDialog();- }}/>);@@ -64,10 +66,22 @@ function TeamProjectLimitContent({limit,isPlatformAdmin,isCommunity,+ used,onClose,- onExplorePlans,}: TeamProjectLimitContentProps) {const feature = PLATFORM_FEATURES.projects;+ const { capture } = useTelemetry();+ const upgradeClick = useUpgradeClick();+ useEffectOnce(() =>+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED,+ payload: {+ limit: PlatformAdminLimit.TEAM_PROJECTS,+ used,+ allowed: limit,+ },+ }),+ );const isFirstTeamProject = limit === 0;const showBenefits = isPlatformAdmin && isFirstTeamProject;@@ -115,9 +129,22 @@ function TeamProjectLimitContent({{t('Cancel')}</Button>{isCommunity ? (- <RequestTrial featureKey={feature.featureKey} />+ <RequestTrial+ featureKey={feature.featureKey}+ surface={PlatformAdminSurface.LIMIT}+ />) : (- <Button type="button" onClick={onExplorePlans}>+ <Button+ type="button"+ onClick={() => {+ onClose();+ upgradeClick({+ feature: feature.featureKey,+ tier: feature.tier,+ surface: PlatformAdminSurface.LIMIT,+ });+ }}+ >{t('Explore plans')}</Button>)}@@ -136,6 +163,6 @@ type TeamProjectLimitContentProps = {limit: number;isPlatformAdmin: boolean;isCommunity: boolean;+ used: number;onClose: () => void;- onExplorePlans: () => void;};diff --git a/packages/web/src/features/billing/hooks/use-upgrade-click.ts b/packages/web/src/features/billing/hooks/use-upgrade-click.tsnew file mode 100644index 00000000000..2f76534fed7--- /dev/null+++ b/packages/web/src/features/billing/hooks/use-upgrade-click.ts@@ -0,0 +1,26 @@+import { PlatformAdminSurface, TelemetryEventName } from '@activepieces/shared';++import { useTelemetry } from '@/components/providers/telemetry-provider';++import { FeatureKey } from '../components/request-trial';+import { useManagePlanDialogStore } from '../stores/manage-plan-dialog-state';+import { FeatureTier } from '../utils/feature-tier';++export function useUpgradeClick() {+ const { capture } = useTelemetry();+ const { openDialog } = useManagePlanDialogStore();++ return ({ feature, tier, surface }: UpgradeClickParams) => {+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_UPGRADE_CLICKED,+ payload: { feature: feature ?? null, tier: tier ?? null, surface },+ });+ openDialog();+ };+}++type UpgradeClickParams = {+ feature?: FeatureKey;+ tier?: FeatureTier;+ surface: PlatformAdminSurface;+};diff --git a/packages/web/src/features/billing/index.ts b/packages/web/src/features/billing/index.tsindex 0a56444bd4d..2054d8a884c 100644--- a/packages/web/src/features/billing/index.ts+++ b/packages/web/src/features/billing/index.ts@@ -31,6 +31,7 @@ export {export { useManagePlanDialogStore } from './stores/manage-plan-dialog-state';export { AutomaticTrialActivation } from './components/automatic-trial-activation';export { useFeatureGate, UpgradeFeatureDialog } from './hooks/use-feature-gate';+export { useUpgradeClick } from './hooks/use-upgrade-click';export type { PlatformFeature } from './hooks/use-feature-gate';export { RequestTrial } from './components/request-trial';export type { FeatureKey } from './components/request-trial';diff --git a/packages/web/src/features/connections/components/edit-global-connection-dialog.tsx b/packages/web/src/features/connections/components/edit-global-connection-dialog.tsxindex 0e5c7de1ae5..f38b8ee5662 100644--- a/packages/web/src/features/connections/components/edit-global-connection-dialog.tsx+++ b/packages/web/src/features/connections/components/edit-global-connection-dialog.tsx@@ -24,6 +24,7 @@ import {TooltipContent,TooltipTrigger,} from '@/components/ui/tooltip';+import { AdminControl, adminControl } from '@/lib/admin-control';import { ProjectSelector } from '../../projects/components/projects-selector';import { globalConnectionsMutations } from '../hooks/global-connections-hooks';@@ -88,6 +89,7 @@ const EditGlobalConnectionDialog: React.FC<EditGlobalConnectionDialogProps> = ({e.preventDefault();setIsOpen(true);}}+ {...adminControl(AdminControl.CONNECTIONS_CONNECTION_EDIT_OPEN)}><Pencil className="h-4 w-4" /></Button>@@ -176,7 +178,12 @@ const EditGlobalConnectionDialog: React.FC<EditGlobalConnectionDialogProps> = ({>{t('Cancel')}</Button>- <Button loading={isUpdatingGlobalConnection}>+ <Button+ loading={isUpdatingGlobalConnection}+ {...adminControl(+ AdminControl.CONNECTIONS_CONNECTION_EDIT_SUBMIT,+ )}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/features/members/components/invite-user/invite-user-dialog.tsx b/packages/web/src/features/members/components/invite-user/invite-user-dialog.tsxindex c5de1233f86..a21b07f2f78 100644--- a/packages/web/src/features/members/components/invite-user/invite-user-dialog.tsx+++ b/packages/web/src/features/members/components/invite-user/invite-user-dialog.tsx@@ -43,6 +43,7 @@ import { projectCollectionUtils } from '@/features/projects/stores/project-colleimport { useAuthorization } from '@/hooks/authorization-hooks';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { HttpError } from '@/lib/api';import { errorReporting } from '@/lib/error-reporting';import { formatUtils } from '@/lib/format-utils';@@ -373,7 +374,11 @@ const InviteUserDialogInternal = ({{t('Cancel')}</Button></DialogClose>- <Button type="submit" loading={isPending}>+ <Button+ type="submit"+ loading={isPending}+ {...adminControl(AdminControl.USERS_INVITE_SUBMIT)}+ >{isPlatformInvite ? t('Invite') : t('Add')}</Button></DialogFooter>@@ -389,6 +394,7 @@ const InviteUserDialogInternal = ({<CopyToClipboardInputuseInput={true}textToCopy={result.link!}+ controlId={AdminControl.USERS_INVITE_LINK_COPY}/></div>))}@@ -401,6 +407,7 @@ const InviteUserDialogInternal = ({variant="outline"className="flex-1"onClick={copyAllLinks}+ {...adminControl(AdminControl.USERS_INVITE_ALL_COPY)}><CopyIcon height={15} width={15} />{t('Copy All')}@@ -410,6 +417,7 @@ const InviteUserDialogInternal = ({variant="outline"className="flex-1"onClick={downloadCsv}+ {...adminControl(AdminControl.USERS_INVITE_CSV_RUN)}><DownloadIcon height={15} width={15} />{t('Download CSV')}diff --git a/packages/web/src/features/pieces/components/install-piece-dialog.tsx b/packages/web/src/features/pieces/components/install-piece-dialog.tsxindex cf957385793..128f693d7a6 100644--- a/packages/web/src/features/pieces/components/install-piece-dialog.tsx+++ b/packages/web/src/features/pieces/components/install-piece-dialog.tsx@@ -44,6 +44,7 @@ import {} from '@/components/ui/select';import { flagsHooks } from '@/hooks/flags-hooks';import { platformHooks } from '@/hooks/platform-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';import { api } from '@/lib/api';import { authenticationSession } from '@/lib/authentication-session';@@ -172,7 +173,12 @@ const InstallPieceDialog = ({return (<Dialog open={isOpen} onOpenChange={(open) => setIsOpen(open)}><DialogTrigger asChild>- <AnimatedIconButton icon={PlusIcon} iconSize={16} size="sm">+ <AnimatedIconButton+ {...adminControl(AdminControl.PIECES_INSTALL_OPEN)}+ icon={PlusIcon}+ iconSize={16}+ size="sm"+ >{t('Install Piece')}</AnimatedIconButton></DialogTrigger>@@ -320,7 +326,11 @@ const InstallPieceDialog = ({{form.formState.errors.root.serverError.message}</FormMessage>)}- <Button loading={isPending} type="submit">+ <Button+ {...adminControl(AdminControl.PIECES_INSTALL_SUBMIT)}+ loading={isPending}+ type="submit"+ >{t('Install')}</Button></form>diff --git a/packages/web/src/features/platform-admin/components/new-signing-key-dialog.tsx b/packages/web/src/features/platform-admin/components/new-signing-key-dialog.tsxindex ae471f95513..f05f4ac524a 100644--- a/packages/web/src/features/platform-admin/components/new-signing-key-dialog.tsx+++ b/packages/web/src/features/platform-admin/components/new-signing-key-dialog.tsx@@ -22,6 +22,7 @@ import { Form, FormField, FormItem, FormMessage } from '@/components/ui/form';import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { signingKeyApi } from '@/features/platform-admin/api/signing-key-api';+import { AdminControl, adminControl } from '@/lib/admin-control';type NewSigningKeyDialogProps = {children: React.ReactNode;@@ -80,6 +81,7 @@ export const NewSigningKeyDialog = ({useInput={false}fileName={signingKey.displayName}textToCopy={signingKey.privateKey}+ controlId={AdminControl.EMBEDDING_SIGNING_KEY_SECRET_COPY}/></div></div>@@ -120,6 +122,7 @@ export const NewSigningKeyDialog = ({{t('Cancel')}</Button><Button+ {...adminControl(AdminControl.EMBEDDING_SIGNING_KEY_NEW_SUBMIT)}disabled={isPending || !form.formState.isValid}loading={isPending}onClick={() => mutate()}diff --git a/packages/web/src/features/projects/components/create-project-button.tsx b/packages/web/src/features/projects/components/create-project-button.tsxindex 5369da15ad4..8c1eb524fa3 100644--- a/packages/web/src/features/projects/components/create-project-button.tsx+++ b/packages/web/src/features/projects/components/create-project-button.tsx@@ -1,10 +1,11 @@-import { ProjectWithLimits } from '@activepieces/shared';+import { ProjectWithLimits, TelemetryEventName } from '@activepieces/shared';import { t } from 'i18next';import { Crown, Plus } from 'lucide-react';import React from 'react';import { AnimatedIconButton } from '@/components/custom/animated-icon-button';import { PlusIcon } from '@/components/icons/plus';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import { SidebarMenuButton } from '@/components/ui/sidebar-shadcn';import {@@ -12,6 +13,7 @@ import {useFeatureGate,useTeamProjectLimitGuard,} from '@/features/billing';+import { AdminControl, adminControl } from '@/lib/admin-control';import { cn } from '@/lib/utils';import { NewProjectDialog } from './new-project-dialog';@@ -29,6 +31,7 @@ export function CreateProjectButton({locked: hasReachedLimit,feature: PLATFORM_FEATURES.projects,});+ const { capture } = useTelemetry();const trigger = triggerFor({variant,@@ -40,6 +43,15 @@ export function CreateProjectButton({return (<NewProjectDialogonCreate={onCreate}+ onBlocked={() =>+ capture({+ name: TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED,+ payload: {+ feature: PLATFORM_FEATURES.projects.featureKey,+ control: AdminControl.PROJECTS_NEW_OPEN,+ },+ })+ }gate={{locked: hasReachedLimit,content: teamProjectLimitContent,@@ -51,6 +63,9 @@ export function CreateProjectButton({}function triggerFor({ variant, className, crown, locked }: TriggerForParams) {+ const control = adminControl(+ locked ? undefined : AdminControl.PROJECTS_NEW_OPEN,+ );switch (variant) {case 'icon':return (@@ -58,13 +73,18 @@ function triggerFor({ variant, className, crown, locked }: TriggerForParams) {variant="ghost"size="icon"className={cn('h-6 w-6 hover:bg-gray-4', className)}+ {...control}>{locked ? <Crown className="text-accent-11" /> : <Plus />}</Button>);case 'full':return crown ? (- <Button size="sm" className={cn('has-[>svg]:px-2.5', className)}>+ <Button+ size="sm"+ className={cn('has-[>svg]:px-2.5', className)}+ {...control}+ >{crown}{t('New Project')}</Button>@@ -74,13 +94,17 @@ function triggerFor({ variant, className, crown, locked }: TriggerForParams) {iconSize={16}size="sm"className={className}+ {...control}>{t('New Project')}</AnimatedIconButton>);case 'sidebar-menu':return (- <SidebarMenuButton className={cn('text-gray-11 gap-2', className)}>+ <SidebarMenuButton+ className={cn('text-gray-11 gap-2', className)}+ {...control}+ >{locked ? (<Crown className="size-4 text-accent-11" />) : (diff --git a/packages/web/src/features/projects/components/edit-project-dialog.tsx b/packages/web/src/features/projects/components/edit-project-dialog.tsxindex aa4d8710684..39ec1ee4553 100644--- a/packages/web/src/features/projects/components/edit-project-dialog.tsx+++ b/packages/web/src/features/projects/components/edit-project-dialog.tsx@@ -36,6 +36,7 @@ import { projectCollectionUtils } from '@/features/projects/stores/project-colleimport { useAuthorization } from '@/hooks/authorization-hooks';import { platformHooks } from '@/hooks/platform-hooks';import { userHooks } from '@/hooks/user-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';interface EditProjectDialogProps {open: boolean;@@ -212,6 +213,7 @@ const EditProjectForm = ({id="sensitive"checked={!!field.value}onCheckedChange={field.onChange}+ {...adminControl(AdminControl.PROJECTS_SENSITIVE_TOGGLE)}/><FormMessage /></FormItem>@@ -248,7 +250,12 @@ const EditProjectForm = ({<Button type="button" variant="outline" onClick={onClose}>{t('Cancel')}</Button>- <Button type="submit" disabled={isPending} loading={isPending}>+ <Button+ type="submit"+ disabled={isPending}+ loading={isPending}+ {...adminControl(AdminControl.PROJECTS_EDIT_SUBMIT)}+ >{t('Save')}</Button></DialogFooter>diff --git a/packages/web/src/features/projects/components/new-project-dialog.tsx b/packages/web/src/features/projects/components/new-project-dialog.tsxindex 760faded854..5b689d0614f 100644--- a/packages/web/src/features/projects/components/new-project-dialog.tsx+++ b/packages/web/src/features/projects/components/new-project-dialog.tsx@@ -40,10 +40,12 @@ import { globalConnectionsQueries } from '@/features/connections';import { projectCollectionUtils } from '@/features/projects';import { platformHooks } from '@/hooks/platform-hooks';import { userHooks } from '@/hooks/user-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';type NewProjectDialogProps = {children: React.ReactNode;onCreate?: (project: ProjectWithLimits) => void;+ onBlocked?: () => void;gate?: {locked: boolean;content: (args: { onClose: () => void }) => React.ReactNode;@@ -67,6 +69,9 @@ export const NewProjectDialog = (props: NewProjectDialogProps) => {const changeOpen = (next: boolean) => {setOpen(next);+ if (next && props.gate?.locked === true) {+ props.onBlocked?.();+ }if (!next) {setBlockedOnSubmit(false);}@@ -103,7 +108,10 @@ export const NewProjectDialog = (props: NewProjectDialogProps) => {? undefined: {locked: props.gate.locked,- onBlocked: () => setBlockedOnSubmit(true),+ onBlocked: () => {+ setBlockedOnSubmit(true);+ props.onBlocked?.();+ },}}/>@@ -245,6 +253,7 @@ const NewProjectForm = ({id="sensitive"checked={!!field.value}onCheckedChange={field.onChange}+ {...adminControl(AdminControl.PROJECTS_SENSITIVE_TOGGLE)}/><FormMessage /></FormItem>@@ -302,6 +311,7 @@ const NewProjectForm = ({<Buttondisabled={isPending}loading={isPending}+ {...adminControl(AdminControl.PROJECTS_NEW_SUBMIT)}onClick={(e) => {e.stopPropagation();e.preventDefault();diff --git a/packages/web/src/features/projects/components/platform-admin-project-alert-subscription-bulk-actions.tsx b/packages/web/src/features/projects/components/platform-admin-project-alert-subscription-bulk-actions.tsxindex bf05a537fcb..0dee610ea5a 100644--- a/packages/web/src/features/projects/components/platform-admin-project-alert-subscription-bulk-actions.tsx+++ b/packages/web/src/features/projects/components/platform-admin-project-alert-subscription-bulk-actions.tsx@@ -14,6 +14,7 @@ import {} from '@/components/ui/dialog';import { alertMutations } from '@/features/alerts';import { userHooks } from '@/hooks/user-hooks';+import { AdminControl, adminControl } from '@/lib/admin-control';export const PlatformAdminProjectAlertSubscriptionBulkActions = ({selectedProjects,@@ -52,6 +53,7 @@ export const PlatformAdminProjectAlertSubscriptionBulkActions = ({size="sm"disabled={isRunning}onClick={handleSubscribe}+ {...adminControl(AdminControl.PROJECTS_SUBSCRIBE_RUN)}><BellPlus className="mr-1 w-4" />{t('Subscribe to alerts')}@@ -61,6 +63,7 @@ export const PlatformAdminProjectAlertSubscriptionBulkActions = ({size="sm"disabled={isRunning}onClick={() => setConfirmUnsubscribeOpen(true)}+ {...adminControl(AdminControl.PROJECTS_UNSUBSCRIBE_OPEN)}><BellMinus className="mr-1 w-4" />{t('Unsubscribe from alerts')}@@ -89,7 +92,11 @@ export const PlatformAdminProjectAlertSubscriptionBulkActions = ({>{t('Cancel')}</Button>- <Button variant="destructive" onClick={handleUnsubscribe}>+ <Button+ variant="destructive"+ onClick={handleUnsubscribe}+ {...adminControl(AdminControl.PROJECTS_UNSUBSCRIBE_CONFIRM)}+ >{t('Unsubscribe')}</Button></DialogFooter>diff --git a/packages/web/src/lib/admin-control.ts b/packages/web/src/lib/admin-control.tsnew file mode 100644index 00000000000..cd2e7479c37--- /dev/null+++ b/packages/web/src/lib/admin-control.ts@@ -0,0 +1,198 @@+export function adminControl(+ id: AdminControl | undefined,+): AdminControlAttributes {+ return { [ADMIN_CONTROL_ATTRIBUTE]: id };+}++export const ADMIN_CONTROL_ATTRIBUTE = 'data-ap-control';++export enum AdminControl {+ AI_API_KEY_LINK = 'ai.api-key.link',+ AI_CAPABILITY_RESET_CONFIRM = 'ai.capability-reset.confirm',+ AI_CAPABILITY_RESET_OPEN = 'ai.capability-reset.open',+ AI_CAPABILITY_OPEN = 'ai.capability.open',+ AI_CAPABILITY_SUBMIT = 'ai.capability.submit',+ AI_PROVIDER_KEY_CREDENTIALS_OPEN = 'ai.provider-key-credentials.open',+ AI_PROVIDER_KEY_CREDENTIALS_SUBMIT = 'ai.provider-key-credentials.submit',+ AI_PROVIDER_KEY_DELETE_CONFIRM = 'ai.provider-key-delete.confirm',+ AI_PROVIDER_KEY_DELETE_OPEN = 'ai.provider-key-delete.open',+ AI_PROVIDER_KEY_RECHECK_RUN = 'ai.provider-key-recheck.run',+ AI_PROVIDER_KEY_SETTINGS_SUBMIT = 'ai.provider-key-settings.submit',+ AI_PROVIDER_KEY_OPEN = 'ai.provider-key.open',+ AI_PROVIDER_KEY_SUBMIT = 'ai.provider-key.submit',+ AI_PROVIDER_OPEN = 'ai.provider.open',+ API_KEYS_API_KEY_REVOKE_CONFIRM = 'api-keys.api-key-revoke.confirm',+ API_KEYS_API_KEY_REVOKE_OPEN = 'api-keys.api-key-revoke.open',+ API_KEYS_API_KEY_COPY = 'api-keys.api-key.copy',+ API_KEYS_API_KEY_OPEN = 'api-keys.api-key.open',+ API_KEYS_API_KEY_SUBMIT = 'api-keys.api-key.submit',+ AUDIT_LOG_EVENT_OPEN = 'audit-log.event.open',+ BILLING_AUTO_RECHARGE_OPEN = 'billing.auto-recharge.open',+ BILLING_AUTO_RECHARGE_SUBMIT = 'billing.auto-recharge.submit',+ BILLING_AUTO_RECHARGE_TOGGLE = 'billing.auto-recharge.toggle',+ BILLING_CANCEL_SUBSCRIPTION_OPEN = 'billing.cancel-subscription.open',+ BILLING_CANCEL_SUBSCRIPTION_SUBMIT = 'billing.cancel-subscription.submit',+ BILLING_CREDITS_RECHARGE_OPEN = 'billing.credits-recharge.open',+ BILLING_CREDITS_UPGRADE_OPEN = 'billing.credits-upgrade.open',+ BILLING_DEACTIVATE_USERS_SUBMIT = 'billing.deactivate-users.submit',+ BILLING_KEEP_PLAN_OPEN = 'billing.keep-plan.open',+ BILLING_KEEP_PLAN_SUBMIT = 'billing.keep-plan.submit',+ BILLING_LICENSE_KEY_COPY = 'billing.license-key.copy',+ BILLING_LICENSE_KEY_OPEN = 'billing.license-key.open',+ BILLING_LICENSE_KEY_SUBMIT = 'billing.license-key.submit',+ BILLING_PAYMENT_METHOD_OPEN = 'billing.payment-method.open',+ BILLING_PLAN_DOWNGRADE_OPEN = 'billing.plan-downgrade.open',+ BILLING_PLAN_KEEP_OPEN = 'billing.plan-keep.open',+ BILLING_PLAN_PURCHASE_SUBMIT = 'billing.plan-purchase.submit',+ BILLING_PLAN_SALES_LINK = 'billing.plan-sales.link',+ BILLING_PLANS_OPEN = 'billing.plans.open',+ BILLING_PURCHASE_CONFIRM_SUBMIT = 'billing.purchase-confirm.submit',+ BILLING_REFRESH_RUN = 'billing.refresh.run',+ BILLING_SEATS_ADD_OPEN = 'billing.seats-add.open',+ BILLING_SEATS_KEEP_PLAN_RUN = 'billing.seats-keep-plan.run',+ BILLING_SEATS_OPEN = 'billing.seats.open',+ BILLING_SEATS_SUBMIT = 'billing.seats.submit',+ BILLING_STRIPE_PORTAL_LINK = 'billing.stripe-portal.link',+ BILLING_UPGRADE_OPEN = 'billing.upgrade.open',+ CONNECTIONS_CONNECTION_DELETE_CONFIRM = 'connections.connection-delete.confirm',+ CONNECTIONS_CONNECTION_DELETE_OPEN = 'connections.connection-delete.open',+ CONNECTIONS_CONNECTION_EDIT_OPEN = 'connections.connection-edit.open',+ CONNECTIONS_CONNECTION_EDIT_SUBMIT = 'connections.connection-edit.submit',+ CONNECTIONS_CONNECTION_RECONNECT_OPEN = 'connections.connection-reconnect.open',+ CONNECTIONS_CONNECTION_OPEN = 'connections.connection.open',+ CONNECTIONS_CONNECTION_SUBMIT = 'connections.connection.submit',+ CONNECTIONS_EXTERNAL_ID_COPY = 'connections.external-id.copy',+ CONNECTIONS_PIECE_OPEN = 'connections.piece.open',+ EMBEDDING_ALLOWED_DOMAINS_SUBMIT = 'embedding.allowed-domains.submit',+ EMBEDDING_DNS_NAME_COPY = 'embedding.dns-name.copy',+ EMBEDDING_DNS_VALUE_COPY = 'embedding.dns-value.copy',+ EMBEDDING_DOCS_LINK = 'embedding.docs.link',+ EMBEDDING_HOSTNAME_UPDATE_CONFIRM = 'embedding.hostname-update.confirm',+ EMBEDDING_HOSTNAME_UPDATE_OPEN = 'embedding.hostname-update.open',+ EMBEDDING_HOSTNAME_SUBMIT = 'embedding.hostname.submit',+ EMBEDDING_SIGNING_KEY_DELETE_CONFIRM = 'embedding.signing-key-delete.confirm',+ EMBEDDING_SIGNING_KEY_DELETE_OPEN = 'embedding.signing-key-delete.open',+ EMBEDDING_SIGNING_KEY_NEW_OPEN = 'embedding.signing-key-new.open',+ EMBEDDING_SIGNING_KEY_NEW_SUBMIT = 'embedding.signing-key-new.submit',+ EMBEDDING_SIGNING_KEY_SECRET_COPY = 'embedding.signing-key-secret.copy',+ EVENT_DESTINATIONS_DESTINATION_CREATE_SUBMIT = 'event-destinations.destination-create.submit',+ EVENT_DESTINATIONS_DESTINATION_DELETE_CONFIRM = 'event-destinations.destination-delete.confirm',+ EVENT_DESTINATIONS_DESTINATION_DELETE_OPEN = 'event-destinations.destination-delete.open',+ EVENT_DESTINATIONS_DESTINATION_EDIT_OPEN = 'event-destinations.destination-edit.open',+ EVENT_DESTINATIONS_DESTINATION_NEW_OPEN = 'event-destinations.destination-new.open',+ EVENT_DESTINATIONS_DESTINATION_UPDATE_SUBMIT = 'event-destinations.destination-update.submit',+ EVENT_DESTINATIONS_HANDLER_FLOW_LINK = 'event-destinations.handler-flow.link',+ EVENT_DESTINATIONS_HANDLER_FLOW_RUN = 'event-destinations.handler-flow.run',+ EVENT_DESTINATIONS_WEBHOOK_TEST_RUN = 'event-destinations.webhook-test.run',+ GENERAL_APPEARANCE_SUBMIT = 'general.appearance.submit',+ GENERAL_COLOUR_RESET_RUN = 'general.colour-reset.run',+ GENERAL_PLATFORM_DELETE_CONFIRM = 'general.platform-delete.confirm',+ GENERAL_PLATFORM_DELETE_OPEN = 'general.platform-delete.open',+ HEALTH_CHECK_DOCS_LINK = 'health.check-docs.link',+ HEALTH_PRODUCTION_SETUP_LINK = 'health.production-setup.link',+ MCP_TIER_TOOLS_OPEN = 'mcp.tier-tools.open',+ MCP_TIER_TOGGLE = 'mcp.tier.toggle',+ MCP_TOOL_TOGGLE = 'mcp.tool.toggle',+ MCP_TOOLS_ALL_RUN = 'mcp.tools-all.run',+ PIECE_SETS_COMPONENTS_OPEN = 'piece-sets.components.open',+ PIECE_SETS_COMPONENTS_SUBMIT = 'piece-sets.components.submit',+ PIECE_SETS_CREATE_OPEN = 'piece-sets.create.open',+ PIECE_SETS_CREATE_SUBMIT = 'piece-sets.create.submit',+ PIECE_SETS_DELETE_CONFIRM = 'piece-sets.delete.confirm',+ PIECE_SETS_DELETE_OPEN = 'piece-sets.delete.open',+ PIECE_SETS_DUPLICATE_OPEN = 'piece-sets.duplicate.open',+ PIECE_SETS_DUPLICATE_SUBMIT = 'piece-sets.duplicate.submit',+ PIECE_SETS_EDIT_OPEN = 'piece-sets.edit.open',+ PIECE_SETS_EXCLUDE_RUN = 'piece-sets.exclude.run',+ PIECE_SETS_INCLUDE_RUN = 'piece-sets.include.run',+ PIECE_SETS_NEW_PIECES_TOGGLE = 'piece-sets.new-pieces.toggle',+ PIECE_SETS_PIECE_TOGGLE = 'piece-sets.piece.toggle',+ PIECE_SETS_PROJECTS_OPEN = 'piece-sets.projects.open',+ PIECE_SETS_PROJECTS_SUBMIT = 'piece-sets.projects.submit',+ PIECE_SETS_SAVE_SUBMIT = 'piece-sets.save.submit',+ PIECES_DELETE_CONFIRM = 'pieces.delete.confirm',+ PIECES_DELETE_OPEN = 'pieces.delete.open',+ PIECES_INSTALL_OPEN = 'pieces.install.open',+ PIECES_INSTALL_SUBMIT = 'pieces.install.submit',+ PIECES_OAUTH_CONFIGURE_OPEN = 'pieces.oauth-configure.open',+ PIECES_OAUTH_CONFIGURE_SUBMIT = 'pieces.oauth-configure.submit',+ PIECES_OAUTH_DELETE_RUN = 'pieces.oauth-delete.run',+ PIECES_PIN_RUN = 'pieces.pin.run',+ PIECES_REPORT_RUN = 'pieces.report.run',+ PIECES_SELECTOR_RESET_CONFIRM = 'pieces.selector-reset.confirm',+ PIECES_SELECTOR_RESET_OPEN = 'pieces.selector-reset.open',+ PIECES_SELECTOR_OPEN = 'pieces.selector.open',+ PIECES_SELECTOR_SUBMIT = 'pieces.selector.submit',+ PIECES_SYNC_RUN = 'pieces.sync.run',+ PLAN_BANNER_LINK = 'plan.banner.link',+ PLAN_BANNER_OPEN = 'plan.banner.open',+ PLAN_DIALOG_LINK = 'plan.dialog.link',+ PLAN_SAMPLE_LINK = 'plan.sample.link',+ PLAN_TEASER_LINK = 'plan.teaser.link',+ PROJECTS_AUTO_PERSONAL_TOGGLE = 'projects.auto-personal.toggle',+ PROJECTS_DELETE_CONFIRM = 'projects.delete.confirm',+ PROJECTS_DELETE_OPEN = 'projects.delete.open',+ PROJECTS_EDIT_OPEN = 'projects.edit.open',+ PROJECTS_EDIT_SUBMIT = 'projects.edit.submit',+ PROJECTS_NEW_OPEN = 'projects.new.open',+ PROJECTS_NEW_SUBMIT = 'projects.new.submit',+ PROJECTS_SENSITIVE_TOGGLE = 'projects.sensitive.toggle',+ PROJECTS_SUBSCRIBE_RUN = 'projects.subscribe.run',+ PROJECTS_UNSUBSCRIBE_CONFIRM = 'projects.unsubscribe.confirm',+ PROJECTS_UNSUBSCRIBE_OPEN = 'projects.unsubscribe.open',+ ROLES_BASE_SELECT = 'roles.base.select',+ ROLES_DELETE_CONFIRM = 'roles.delete.confirm',+ ROLES_DELETE_OPEN = 'roles.delete.open',+ ROLES_EDIT_OPEN = 'roles.edit.open',+ ROLES_EDIT_SUBMIT = 'roles.edit.submit',+ ROLES_NEW_OPEN = 'roles.new.open',+ ROLES_NEW_SUBMIT = 'roles.new.submit',+ ROLES_PEOPLE_OPEN = 'roles.people.open',+ ROLES_PERMISSION_TOGGLE = 'roles.permission.toggle',+ ROLES_ROLE_OPEN = 'roles.role.open',+ SECRET_MANAGERS_CACHE_RUN = 'secret-managers.cache.run',+ SECRET_MANAGERS_CONNECTION_DELETE_CONFIRM = 'secret-managers.connection-delete.confirm',+ SECRET_MANAGERS_CONNECTION_DELETE_OPEN = 'secret-managers.connection-delete.open',+ SECRET_MANAGERS_CONNECTION_EDIT_OPEN = 'secret-managers.connection-edit.open',+ SECRET_MANAGERS_CONNECTION_OPEN = 'secret-managers.connection.open',+ SECRET_MANAGERS_CONNECTION_SUBMIT = 'secret-managers.connection.submit',+ SSO_ALLOWED_DOMAINS_OPEN = 'sso.allowed-domains.open',+ SSO_ALLOWED_DOMAINS_SUBMIT = 'sso.allowed-domains.submit',+ SSO_EMAIL_LOGIN_TOGGLE = 'sso.email-login.toggle',+ SSO_GOOGLE_TOGGLE = 'sso.google.toggle',+ SSO_SAML_CONFIG_SUBMIT = 'sso.saml-config.submit',+ SSO_SAML_DISABLE_RUN = 'sso.saml-disable.run',+ SSO_SAML_DNS_NAME_COPY = 'sso.saml-dns-name.copy',+ SSO_SAML_DNS_VALUE_COPY = 'sso.saml-dns-value.copy',+ SSO_SAML_DNS_RUN = 'sso.saml-dns.run',+ SSO_SAML_DOMAIN_UPDATE_CONFIRM = 'sso.saml-domain-update.confirm',+ SSO_SAML_DOMAIN_UPDATE_SUBMIT = 'sso.saml-domain-update.submit',+ SSO_SAML_DOMAIN_SUBMIT = 'sso.saml-domain.submit',+ SSO_SAML_OPEN = 'sso.saml.open',+ TELEMETRY_DOCS_LINK = 'telemetry.docs.link',+ TELEMETRY_EVENTS_OPEN = 'telemetry.events.open',+ TEMPLATES_DELETE_CONFIRM = 'templates.delete.confirm',+ TEMPLATES_DELETE_OPEN = 'templates.delete.open',+ TEMPLATES_EDIT_OPEN = 'templates.edit.open',+ TEMPLATES_EDIT_SUBMIT = 'templates.edit.submit',+ TEMPLATES_NEW_OPEN = 'templates.new.open',+ TEMPLATES_NEW_SUBMIT = 'templates.new.submit',+ USERS_ACTIVATE_RUN = 'users.activate.run',+ USERS_DEACTIVATE_RUN = 'users.deactivate.run',+ USERS_DELETE_CONFIRM = 'users.delete.confirm',+ USERS_DELETE_OPEN = 'users.delete.open',+ USERS_EDIT_OPEN = 'users.edit.open',+ USERS_EDIT_SUBMIT = 'users.edit.submit',+ USERS_INVITE_ALL_COPY = 'users.invite-all.copy',+ USERS_INVITE_CSV_RUN = 'users.invite-csv.run',+ USERS_INVITE_LINK_COPY = 'users.invite-link.copy',+ USERS_INVITE_OPEN = 'users.invite.open',+ USERS_INVITE_SUBMIT = 'users.invite.submit',+ WORKERS_ASSIGN_OPEN = 'workers.assign.open',+ WORKERS_ASSIGN_SUBMIT = 'workers.assign.submit',+ WORKERS_DOCS_LINK = 'workers.docs.link',+}++type AdminControlAttributes = {+ [ADMIN_CONTROL_ATTRIBUTE]: AdminControl | undefined;+};diff --git a/packages/web/test/app/platform/admin-control-clicks.test.tsx b/packages/web/test/app/platform/admin-control-clicks.test.tsxnew file mode 100644index 00000000000..694a41ec662--- /dev/null+++ b/packages/web/test/app/platform/admin-control-clicks.test.tsx@@ -0,0 +1,157 @@+/**+ * @vitest-environment jsdom+ */+/* eslint-disable jest-dom/prefer-in-document -- @testing-library/jest-dom is not a dependency of packages/web */+import { ApEdition, TelemetryEventName } from '@activepieces/shared';+import { fireEvent, render, screen } from '@testing-library/react';+import * as React from 'react';+import { createPortal } from 'react-dom';+import { MemoryRouter, useRoutes } from 'react-router-dom';+import { beforeEach, describe, expect, it, vi } from 'vitest';++const capture = vi.fn();++vi.mock('i18next', () => ({ t: (key: string) => key }));++vi.mock('@/components/providers/telemetry-provider', () => ({+ useTelemetry: () => ({ capture }),+}));++vi.mock('@/hooks/platform-hooks', () => ({+ platformHooks: {+ useCurrentPlatform: () => ({ platform: { plan: { ssoEnabled: true } } }),+ },+}));+vi.mock('@/hooks/flags-hooks', () => ({+ flagsHooks: { useFlag: () => ({ data: ApEdition.CLOUD }) },+}));+vi.mock('@/features/billing/stores/manage-plan-dialog-state', () => ({+ useManagePlanDialogStore: () => ({ openDialog: vi.fn() }),+}));+vi.mock('@/app/components/platform-layout', () => ({+ PlatformLayout: ({ children }: React.PropsWithChildren) => <>{children}</>,+}));+vi.mock('@/app/components/page-title', () => ({+ PageTitle: ({ children }: React.PropsWithChildren) => <>{children}</>,+}));+vi.mock('@/app/routes/platform/projects', () => ({+ default: () => (+ <div>+ <button {...adminControl(AdminControl.PROJECTS_NEW_OPEN)}>+ New Project+ </button>+ <button>Plain button</button>+ <div {...adminControl(AdminControl.PROJECTS_EDIT_OPEN)}>+ <button {...adminControl(AdminControl.PROJECTS_DELETE_OPEN)}>+ Row action+ </button>+ </div>+ {createPortal(+ <button {...adminControl(AdminControl.PROJECTS_DELETE_CONFIRM)}>+ Delete+ </button>,+ document.body,+ )}+ </div>+ ),+}));+vi.mock(+ '@/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page',+ () => ({+ PieceSetDetailsPage: () => (+ <button {...adminControl(AdminControl.PIECE_SETS_SAVE_SUBMIT)}>+ Save+ </button>+ ),+ }),+);++import { platformRoutes } from '@/app/routes/platform-routes';+import {+ ADMIN_CONTROL_ATTRIBUTE,+ AdminControl,+ adminControl,+} from '@/lib/admin-control';++const PlatformRoutes = () => useRoutes(platformRoutes);++const visit = (url: string) =>+ render(+ <MemoryRouter initialEntries={[url]}>+ <PlatformRoutes />+ </MemoryRouter>,+ );++const capturedClicks = () =>+ capture.mock.calls+ .map(([event]) => event)+ .filter(+ (event) =>+ event.name === TelemetryEventName.PLATFORM_ADMIN_CONTROL_CLICKED,+ )+ .map((event) => event.payload);++beforeEach(() => {+ capture.mockClear();+});++describe('admin control click telemetry', () => {+ it('reports the control id with the route pattern of the page', async () => {+ visit('/platform/projects');+ fireEvent.click(await screen.findByText('New Project'));+ expect(capturedClicks()).toEqual([+ { control: AdminControl.PROJECTS_NEW_OPEN, page: '/platform/projects' },+ ]);+ });++ it('names the page by its route, never by the id in the URL', async () => {+ visit('/platform/pieces/piece-sets/ps_42');+ fireEvent.click(await screen.findByText('Save'));+ expect(capturedClicks()).toEqual([+ {+ control: AdminControl.PIECE_SETS_SAVE_SUBMIT,+ page: '/platform/pieces/piece-sets/:id',+ },+ ]);+ });++ it('stays silent for a button that carries no control id', async () => {+ visit('/platform/projects');+ fireEvent.click(await screen.findByText('Plain button'));+ expect(capturedClicks()).toEqual([]);+ });++ it('reports a control rendered in a portal, such as a dialog button', async () => {+ visit('/platform/projects');+ await screen.findByText('New Project');+ fireEvent.click(screen.getByText('Delete'));+ expect(capturedClicks()).toEqual([+ {+ control: AdminControl.PROJECTS_DELETE_CONFIRM,+ page: '/platform/projects',+ },+ ]);+ });++ it('reports only the nearest control when one is nested in another', async () => {+ visit('/platform/projects');+ fireEvent.click(await screen.findByText('Row action'));+ expect(capturedClicks()).toEqual([+ {+ control: AdminControl.PROJECTS_DELETE_OPEN,+ page: '/platform/projects',+ },+ ]);+ });++ it('stops listening once the page is gone', async () => {+ const { unmount } = visit('/platform/projects');+ await screen.findByText('New Project');+ unmount();+ const stray = document.createElement('button');+ stray.setAttribute(ADMIN_CONTROL_ATTRIBUTE, AdminControl.PROJECTS_NEW_OPEN);+ document.body.appendChild(stray);+ fireEvent.click(stray);+ expect(capturedClicks()).toEqual([]);+ });+});diff --git a/packages/web/test/app/platform/admin-page-view.test.tsx b/packages/web/test/app/platform/admin-page-view.test.tsxnew file mode 100644index 00000000000..b606881d63c--- /dev/null+++ b/packages/web/test/app/platform/admin-page-view.test.tsx@@ -0,0 +1,112 @@+/**+ * @vitest-environment jsdom+ */+/* eslint-disable jest-dom/prefer-in-document -- @testing-library/jest-dom is not a dependency of packages/web */+import { ApEdition, TelemetryEventName } from '@activepieces/shared';+import { render, screen } from '@testing-library/react';+import * as React from 'react';+import { MemoryRouter, useRoutes } from 'react-router-dom';+import { beforeEach, describe, expect, it, vi } from 'vitest';++const capture = vi.fn();+let ssoEnabled = true;++vi.mock('i18next', () => ({ t: (key: string) => key }));++vi.mock('@/components/providers/telemetry-provider', () => ({+ useTelemetry: () => ({ capture }),+}));++vi.mock('@/hooks/platform-hooks', () => ({+ platformHooks: {+ useCurrentPlatform: () => ({ platform: { plan: { ssoEnabled } } }),+ },+}));+vi.mock('@/hooks/flags-hooks', () => ({+ flagsHooks: { useFlag: () => ({ data: ApEdition.CLOUD }) },+}));+vi.mock('@/features/billing/stores/manage-plan-dialog-state', () => ({+ useManagePlanDialogStore: () => ({ openDialog: vi.fn() }),+}));+vi.mock('@/app/components/platform-layout', () => ({+ PlatformLayout: ({ children }: React.PropsWithChildren) => <>{children}</>,+}));+vi.mock('@/app/components/page-title', () => ({+ PageTitle: ({ children }: React.PropsWithChildren) => <>{children}</>,+}));+vi.mock('@/app/routes/platform/projects', () => ({+ default: () => <div>projects</div>,+}));+vi.mock('@/app/routes/platform/infra/health', () => ({+ default: ({ section }: { section: string }) => <div>{section} health</div>,+}));+vi.mock('@/app/routes/platform/security/sso', () => ({+ SSOPage: () => <div>sso</div>,+}));+vi.mock(+ '@/app/routes/platform/setup/pieces/piece-sets/piece-set-details-page',+ () => ({ PieceSetDetailsPage: () => <div>piece set</div> }),+);++import { platformRoutes } from '@/app/routes/platform-routes';++const PlatformRoutes = () => useRoutes(platformRoutes);++const visit = (url: string) =>+ render(+ <MemoryRouter initialEntries={[url]}>+ <PlatformRoutes />+ </MemoryRouter>,+ );++const capturedViews = () =>+ capture.mock.calls+ .map(([event]) => event)+ .filter(+ (event) => event.name === TelemetryEventName.PLATFORM_ADMIN_PAGE_VIEWED,+ )+ .map((event) => event.payload);++beforeEach(() => {+ ssoEnabled = true;+ capture.mockClear();+});++describe('admin page view telemetry', () => {+ it('names the page by its route, never by the id in the URL', async () => {+ visit('/platform/pieces/piece-sets/ps_42');+ expect(await screen.findByText('piece set')).toBeDefined();+ expect(capturedViews()).toEqual([+ { page: '/platform/pieces/piece-sets/:id', locked: false },+ ]);+ });++ it('counts only the page /platform redirects to', async () => {+ visit('/platform');+ expect(await screen.findByText('projects')).toBeDefined();+ expect(capturedViews()).toEqual([+ { page: '/platform/projects', locked: false },+ ]);+ });++ it('counts only the sub-page a released ?tab= link redirects to', async () => {+ visit('/platform/health?tab=runs');+ expect(await screen.findByText('runs health')).toBeDefined();+ expect(capturedViews()).toEqual([+ { page: '/platform/health/runs', locked: false },+ ]);+ });++ it('counts only the page an old folder URL redirects to', async () => {+ visit('/platform/security/sso');+ expect(await screen.findByText('sso')).toBeDefined();+ expect(capturedViews()).toEqual([{ page: '/platform/sso', locked: false }]);+ });++ it('marks a page shown under the sample overlay as locked', async () => {+ ssoEnabled = false;+ visit('/platform/sso');+ expect(await screen.findByText('sso')).toBeDefined();+ expect(capturedViews()).toEqual([{ page: '/platform/sso', locked: true }]);+ });+});diff --git a/packages/web/test/app/platform/admin-telemetry.test.tsx b/packages/web/test/app/platform/admin-telemetry.test.tsxnew file mode 100644index 00000000000..c9f7940fbc7--- /dev/null+++ b/packages/web/test/app/platform/admin-telemetry.test.tsx@@ -0,0 +1,227 @@+/**+ * @vitest-environment jsdom+ */+/* eslint-disable jest-dom/prefer-in-document, jest-dom/prefer-to-have-attribute -- @testing-library/jest-dom is not a dependency of packages/web */+import {+ ApEdition,+ PlatformAdminLimit,+ PlatformAdminSurface,+ TelemetryEventName,+} from '@activepieces/shared';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import { render, screen, fireEvent } from '@testing-library/react';+import * as React from 'react';+import { beforeEach, describe, expect, it, vi } from 'vitest';++let teamProjectsLimit: number | null = 0;+let edition: ApEdition = ApEdition.CLOUD;+const capture = vi.fn();++vi.mock('i18next', () => ({ t: (key: string) => key }));++vi.mock('@/components/providers/telemetry-provider', () => ({+ useTelemetry: () => ({ capture }),+}));++vi.mock('@/hooks/platform-hooks', () => ({+ platformHooks: {+ useCurrentPlatform: () => ({+ platform: {+ plan: {+ billedTeamProjectsLimit: teamProjectsLimit,+ globalConnectionsEnabled: false,+ },+ },+ }),+ },+}));+vi.mock('@/hooks/user-hooks', () => ({+ userHooks: {+ getCurrentUserPlatformRole: () => 'ADMIN',+ useCurrentUser: () => ({ data: undefined }),+ },+}));+vi.mock('@/hooks/authorization-hooks', () => ({+ useIsPlatformAdmin: () => true,+}));+vi.mock('@/hooks/flags-hooks', () => ({+ flagsHooks: {+ useFlag: () => ({ data: edition }),+ useFlags: () => ({ data: {} }),+ },+}));+vi.mock('@/features/billing/stores/manage-plan-dialog-state', () => ({+ useManagePlanDialogStore: () => ({ openDialog: vi.fn() }),+}));+vi.mock('@/features/connections', () => ({+ globalConnectionsQueries: {+ useGlobalConnections: () => ({ data: { data: [] }, isLoading: false }),+ },+}));+vi.mock('@/features/projects', () => ({+ projectCollectionUtils: {+ invalidate: vi.fn(),+ useCreateProject: () => ({ mutate: vi.fn(), isPending: false }),+ },+}));+vi.mock('@/components/custom/global-connection-utils', () => ({+ DefaultTag: () => null,+}));+vi.mock('@/components/custom/multi-select-piece-property', () => ({+ MultiSelectPieceProperty: () => null,+}));+vi.mock('@/components/ui/sonner', () => ({ internalErrorToast: vi.fn() }));+vi.mock('@/components/custom/animated-icon-button', () => ({+ AnimatedIconButton: ({+ children,+ icon: _icon,+ iconSize: _iconSize,+ ...rest+ }: React.PropsWithChildren<Record<string, unknown>>) => (+ <button {...rest}>{children}</button>+ ),+}));+vi.mock('@/components/icons/plus', () => ({ PlusIcon: () => null }));+vi.mock('@/components/ui/sidebar-shadcn', () => ({+ SidebarMenuButton: ({+ children,+ ...rest+ }: React.PropsWithChildren<Record<string, unknown>>) => (+ <button {...rest}>{children}</button>+ ),+}));++import { FeatureSample } from '@/app/components/feature-sample';+import { FeatureTeaser } from '@/app/components/feature-teaser';+import { UpgradeFeatureDialog } from '@/features/billing';+import { CreateProjectButton } from '@/features/projects/components/create-project-button';+import { ADMIN_CONTROL_ATTRIBUTE, AdminControl } from '@/lib/admin-control';++const renderWithQueryClient = (ui: React.ReactElement) =>+ render(+ <QueryClientProvider+ client={+ new QueryClient({ defaultOptions: { queries: { retry: false } } })+ }+ >+ {ui}+ </QueryClientProvider>,+ );++const usedTeamProjects = (count: number) =>+ Array.from({ length: count }, () => ({ type: 'TEAM' })) as never;++const capturedNames = () => capture.mock.calls.map(([event]) => event.name);++const capturedPayload = (name: TelemetryEventName) =>+ capture.mock.calls.find(([event]) => event.name === name)?.[0].payload;++beforeEach(() => {+ teamProjectsLimit = 0;+ edition = ApEdition.CLOUD;+ capture.mockClear();+ vi.stubGlobal('open', vi.fn());+});++describe('platform admin telemetry', () => {+ it('reports the upgrade click from the sample overlay with its tier', () => {+ render(+ <FeatureSample+ locked+ title="Unlock Audit Logs"+ tier="enterprise"+ featureKey="AUDIT_LOGS"+ >+ <div />+ </FeatureSample>,+ );+ fireEvent.click(screen.getByRole('button', { name: /upgrade to/i }));+ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_UPGRADE_CLICKED),+ ).toEqual({+ feature: 'AUDIT_LOGS',+ tier: 'enterprise',+ surface: PlatformAdminSurface.SAMPLE,+ });+ });++ it('reports the sales enquiry from the sample overlay', () => {+ edition = ApEdition.COMMUNITY;+ render(+ <FeatureSample locked title="Unlock Audit Logs" featureKey="AUDIT_LOGS">+ <div />+ </FeatureSample>,+ );+ fireEvent.click(screen.getByRole('button', { name: /contact sales/i }));+ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED),+ ).toEqual({ feature: 'AUDIT_LOGS', surface: PlatformAdminSurface.SAMPLE });+ });++ it('reports the sales enquiry from the full page teaser', () => {+ edition = ApEdition.COMMUNITY;+ render(+ <FeatureTeaser featureKey="API" title="Enable API Keys" description="" />,+ );+ fireEvent.click(screen.getByRole('button', { name: /contact sales/i }));+ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED),+ ).toEqual({ feature: 'API', surface: PlatformAdminSurface.TEASER });+ });++ it('reports a refused control and the limit behind it, with no control id on the locked trigger', () => {+ teamProjectsLimit = 3;+ renderWithQueryClient(+ <CreateProjectButton variant="icon" projects={usedTeamProjects(3)} />,+ );+ const trigger = screen.getByRole('button');+ expect(trigger.getAttribute(ADMIN_CONTROL_ATTRIBUTE)).toBeNull();+ fireEvent.click(trigger);++ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED),+ ).toEqual({ feature: 'PROJECTS', control: AdminControl.PROJECTS_NEW_OPEN });+ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED),+ ).toEqual({ limit: PlatformAdminLimit.TEAM_PROJECTS, used: 3, allowed: 3 });+ });++ it('names the feature by its stable key on every surface, not the title', () => {+ render(+ <UpgradeFeatureDialog+ open+ onOpenChange={vi.fn()}+ featureKey="PROJECTS"+ title="Unlock Projects"+ description=""+ tier="team"+ />,+ );+ fireEvent.click(screen.getByRole('button', { name: /upgrade plan/i }));+ expect(+ capturedPayload(TelemetryEventName.PLATFORM_ADMIN_UPGRADE_CLICKED),+ ).toEqual({+ feature: 'PROJECTS',+ tier: 'team',+ surface: PlatformAdminSurface.DIALOG,+ });+ });++ it('stays silent while the plan still has room', () => {+ teamProjectsLimit = 3;+ renderWithQueryClient(+ <CreateProjectButton variant="full" projects={usedTeamProjects(1)} />,+ );+ const trigger = screen.getByRole('button', { name: /new project/i });+ expect(trigger.getAttribute(ADMIN_CONTROL_ATTRIBUTE)).toBe(+ AdminControl.PROJECTS_NEW_OPEN,+ );+ fireEvent.click(trigger);+ expect(capturedNames()).not.toContain(+ TelemetryEventName.PLATFORM_ADMIN_GATE_BLOCKED,+ );+ expect(capturedNames()).not.toContain(+ TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED,+ );+ });+});diff --git a/packages/web/test/app/routes/platform/infra/configurations/tracked-events-catalog.test.ts b/packages/web/test/app/routes/platform/infra/configurations/tracked-events-catalog.test.tsindex 5c5af46c21d..40d5d1f9a23 100644--- a/packages/web/test/app/routes/platform/infra/configurations/tracked-events-catalog.test.ts+++ b/packages/web/test/app/routes/platform/infra/configurations/tracked-events-catalog.test.ts@@ -50,7 +50,7 @@ describe('trackedEventsCatalog', () => {expect(groupIds).not.toContain('emailCodes');expect(groupIds).not.toContain('billing');- expect(groupIds).toEqual(['accounts', 'flows', 'mcp']);+ expect(groupIds).toEqual(['accounts', 'flows', 'mcp', 'platformAdmin']);});it('keeps only the self-hosted invitation events in the accounts group', () => {diff --git a/packages/web/test/lib/admin-controls.test.ts b/packages/web/test/lib/admin-controls.test.tsnew file mode 100644index 00000000000..abba457c165--- /dev/null+++ b/packages/web/test/lib/admin-controls.test.ts@@ -0,0 +1,62 @@+import { readdirSync, readFileSync, statSync } from 'node:fs';+import { join } from 'node:path';++import { describe, expect, it } from 'vitest';++import { AdminControl } from '@/lib/admin-control';++const CONTROL_ID_PATTERN =+ /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.(open|submit|confirm|toggle|select|copy|link|run)$/;++const SOURCE_ROOT = join(__dirname, '..', '..', 'src');+const ENUM_FILE = join(SOURCE_ROOT, 'lib', 'admin-control.ts');++const adminControlEntries = Object.entries(AdminControl);++describe('AdminControl', () => {+ it('names every id area.thing.action with a verb from the fixed set', () => {+ const malformed = Object.values(AdminControl).filter(+ (id) => !CONTROL_ID_PATTERN.test(id),+ );++ expect(malformed).toEqual([]);+ });++ it('spells every member as its id in upper case with underscores', () => {+ const drifted = adminControlEntries.filter(+ ([member, id]) => member !== id.toUpperCase().replace(/[.-]/g, '_'),+ );++ expect(drifted).toEqual([]);+ });++ it('keeps the consent controls of the Configurations page out of the enum', () => {+ const consent = Object.values(AdminControl).filter((id) =>+ id.startsWith('configurations.'),+ );++ expect(consent).toEqual([]);+ });++ it('uses every member on at least one control', () => {+ const source = sourceFiles({ directory: SOURCE_ROOT })+ .filter((file) => file !== ENUM_FILE)+ .map((file) => readFileSync(file, 'utf8'))+ .join('\n');+ const unused = adminControlEntries+ .filter(([member]) => !source.includes(`AdminControl.${member}`))+ .map(([member]) => member);++ expect(unused).toEqual([]);+ });+});++function sourceFiles({ directory }: { directory: string }): string[] {+ return readdirSync(directory).flatMap((entry) => {+ const path = join(directory, entry);+ if (statSync(path).isDirectory()) {+ return sourceFiles({ directory: path });+ }+ return /\.tsx?$/.test(entry) ? [path] : [];+ });+}