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(connections): send telemetry for connection switches and replaces (#17142)
Abduladb049a948a3
diff --git a/packages/core/shared/package.json b/packages/core/shared/package.jsonindex ddf60861a33..5a0a1185bd8 100644--- a/packages/core/shared/package.json+++ b/packages/core/shared/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/shared",- "version": "0.214.0",+ "version": "0.215.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 84428aac3cf..f30b98cdb9a 100644--- a/packages/core/shared/src/lib/core/common/telemetry.ts+++ b/packages/core/shared/src/lib/core/common/telemetry.ts@@ -169,6 +169,25 @@ type McpServerConnected = {platformId?: string}+type ConnectionSwitchDecided = {+ choice: ConnectionSwitchChoice+ pieceName: string+ clearedInputCount: number+ replaceAvailable: boolean+}++type ConnectionReplaceOpened = {+ source: ConnectionReplaceSource+ pieceName?: string+}++type ConnectionReplaceCompleted = {+ source: ConnectionReplaceSource+ pieceName: string+ flowCount: number+ applyToPublishedVersions: boolean+}+type BaseTelemetryEvent<T, P> = {name: Tpayload: P@@ -211,6 +230,21 @@ export enum TelemetryEventName {PLATFORM_ADMIN_SALES_CONTACTED = 'platform.admin.sales.contacted',PLATFORM_ADMIN_LIMIT_REACHED = 'platform.admin.limit.reached',PLATFORM_ADMIN_CONTROL_CLICKED = 'platform.admin.control.clicked',+ CONNECTION_SWITCH_DECIDED = 'connection.switch.decided',+ CONNECTION_REPLACE_OPENED = 'connection.replace.opened',+ CONNECTION_REPLACE_COMPLETED = 'connection.replace.completed',+}++export enum ConnectionSwitchChoice {+ SWITCH = 'switch',+ REPLACE = 'replace',+ CANCEL = 'cancel',+}++export enum ConnectionReplaceSource {+ BUILDER_CONNECTIONS_BUTTON = 'builder_connections_button',+ SWITCH_DIALOG = 'switch_dialog',+ PROJECT_CONNECTIONS_PAGE = 'project_connections_page',}export enum PlatformAdminSurface {@@ -261,6 +295,9 @@ export type TelemetryEvent =| BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_SALES_CONTACTED, PlatformAdminSalesContacted>| BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_LIMIT_REACHED, PlatformAdminLimitReached>| BaseTelemetryEvent<TelemetryEventName.PLATFORM_ADMIN_CONTROL_CLICKED, PlatformAdminControlClicked>+ | BaseTelemetryEvent<TelemetryEventName.CONNECTION_SWITCH_DECIDED, ConnectionSwitchDecided>+ | BaseTelemetryEvent<TelemetryEventName.CONNECTION_REPLACE_OPENED, ConnectionReplaceOpened>+ | BaseTelemetryEvent<TelemetryEventName.CONNECTION_REPLACE_COMPLETED, ConnectionReplaceCompleted>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 0229dda3ad5..0b7b7ad015e 100644--- a/packages/web/public/locales/en/translation.json+++ b/packages/web/public/locales/en/translation.json@@ -3727,6 +3727,9 @@"Replace in all steps": "Replace in all steps","Switch": "Switch","{flowCount, plural, =1 {We recommend testing the flow after the replace. If {newName} can't access the same data as {oldName}, the flow could break.} other {We recommend testing these flows after the replace. If {newName} can't access the same data as {oldName}, they could break.}}": "{flowCount, plural, =1 {We recommend testing the flow after the replace. If {newName} can't access the same data as {oldName}, the flow could break.} other {We recommend testing these flows after the replace. If {newName} can't access the same data as {oldName}, they could break.}}",+ "Chose an option when switching a step's connection": "Chose an option when switching a step's connection",+ "Opened the replace connection dialog": "Opened the replace connection dialog",+ "Replaced a connection": "Replaced a connection","Switching can clear {inputs} in this step's settings, if the {newConnectionDisplayName} connection doesn't have access to them.": "Switching can clear {inputs} in this step's settings, if the {newConnectionDisplayName} connection doesn't have access to them.","Switch to {newConnectionDisplayName}?": "Switch to {newConnectionDisplayName}?"}diff --git a/packages/web/src/app/builder/builder-header/flow-connections-popover.tsx b/packages/web/src/app/builder/builder-header/flow-connections-popover.tsxindex bb3b1602362..5a0cfbea9a2 100644--- a/packages/web/src/app/builder/builder-header/flow-connections-popover.tsx+++ b/packages/web/src/app/builder/builder-header/flow-connections-popover.tsx@@ -1,4 +1,8 @@-import { AppConnectionWithoutSensitiveData } from '@activepieces/shared';+import {+ AppConnectionWithoutSensitiveData,+ ConnectionReplaceSource,+ TelemetryEventName,+} from '@activepieces/shared';import { t } from 'i18next';import { Plug } from 'lucide-react';import { useState } from 'react';@@ -7,6 +11,7 @@ import { flowCanvasHooks } from '@/app/builder/flow-canvas/hooks';import { DataFetchErrorState } from '@/components/custom/data-fetch-error-state';import { PermissionNeededTooltip } from '@/components/custom/permission-needed-tooltip';import { TextWithTooltip } from '@/components/custom/text-with-tooltip';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import {Popover,@@ -31,6 +36,7 @@ export const FlowConnectionsPopover = ({flowCanvasHooks.useFlowConnections();const { showReplace, hasPermissionToReplace } =appConnectionsHooks.useReplaceConnectionAccess();+ const { capture } = useTelemetry();const [popoverOpen, setPopoverOpen] = useState(false);const [connectionToReplace, setConnectionToReplace] =useState<AppConnectionWithoutSensitiveData | null>(null);@@ -100,6 +106,14 @@ export const FlowConnectionsPopover = ({onClick={() => {setPopoverOpen(false);setConnectionToReplace(connection);+ capture({+ name: TelemetryEventName.CONNECTION_REPLACE_OPENED,+ payload: {+ source:+ ConnectionReplaceSource.BUILDER_CONNECTIONS_BUTTON,+ pieceName: connection.pieceName,+ },+ });}}>{t('Replace')}@@ -116,6 +130,7 @@ export const FlowConnectionsPopover = ({{connectionToReplace && (<ReplaceConnectionForFlowDialogsourceConnection={connectionToReplace}+ source={ConnectionReplaceSource.BUILDER_CONNECTIONS_BUTTON}openonOpenChange={(open) => {if (!open) {diff --git a/packages/web/src/app/builder/builder-header/replace-connection-for-flow-dialog.tsx b/packages/web/src/app/builder/builder-header/replace-connection-for-flow-dialog.tsxindex fa8759ba9b7..0f16ab803f5 100644--- a/packages/web/src/app/builder/builder-header/replace-connection-for-flow-dialog.tsx+++ b/packages/web/src/app/builder/builder-header/replace-connection-for-flow-dialog.tsx@@ -1,4 +1,8 @@-import { AppConnectionWithoutSensitiveData } from '@activepieces/shared';+import {+ AppConnectionWithoutSensitiveData,+ ConnectionReplaceSource,+ TelemetryEventName,+} from '@activepieces/shared';import { useMutation } from '@tanstack/react-query';import { t } from 'i18next';import { useForm } from 'react-hook-form';@@ -12,6 +16,7 @@ import {ReplaceConnectionSourceKind,ReplaceConnectionTestFlowsAlert,} from '@/app/connections/replace-connection-selection-form';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import {Dialog,@@ -34,6 +39,7 @@ import { authenticationSession } from '@/lib/authentication-session';const ReplaceConnectionForFlowDialog = ({sourceConnection,targetConnection,+ source,open,onOpenChange,}: ReplaceConnectionForFlowDialogProps) => {@@ -60,6 +66,7 @@ const ReplaceConnectionForFlowDialog = ({key={open ? 'open' : 'closed'}sourceConnection={sourceConnection}targetConnection={targetConnection}+ source={source}setDialogOpen={onOpenChange}/></DialogContent>@@ -70,12 +77,15 @@ const ReplaceConnectionForFlowDialog = ({function ReplaceConnectionForFlowForm({sourceConnection,targetConnection,+ source,setDialogOpen,}: {sourceConnection: AppConnectionWithoutSensitiveData;targetConnection?: AppConnectionWithoutSensitiveData;+ source: ConnectionReplaceSource;setDialogOpen: (open: boolean) => void;}) {+ const { capture } = useTelemetry();const [flow, savePendingEdits, showsNewestVersion] = useBuilderStateContext((state) => [state.flow, state.savePendingEdits, state.showsNewestVersion],);@@ -92,6 +102,16 @@ function ReplaceConnectionForFlowForm({appConnectionsMutations.useReplaceConnections({setDialogOpen,connections: connections?.data ?? [],+ onReplaced: (request) =>+ capture({+ name: TelemetryEventName.CONNECTION_REPLACE_COMPLETED,+ payload: {+ source,+ pieceName: sourceConnection.pieceName,+ flowCount: request.flowIds.length,+ applyToPublishedVersions: request.applyToPublishedVersions ?? false,+ },+ }),refetch: () => {if (showsNewestVersion()) {refreshDraft().catch(() => internalErrorToast());@@ -165,6 +185,7 @@ type FlowReplaceFormValues = ReplaceConnectionFlowVersionsSelection & {type ReplaceConnectionForFlowDialogProps = {sourceConnection: AppConnectionWithoutSensitiveData;targetConnection?: AppConnectionWithoutSensitiveData;+ source: ConnectionReplaceSource;open: boolean;onOpenChange: (open: boolean) => void;};diff --git a/packages/web/src/app/builder/step-settings/piece-settings/switch-connection-confirmation-dialog.tsx b/packages/web/src/app/builder/step-settings/piece-settings/switch-connection-confirmation-dialog.tsxindex 3a0412f9705..00aab29ace6 100644--- a/packages/web/src/app/builder/step-settings/piece-settings/switch-connection-confirmation-dialog.tsx+++ b/packages/web/src/app/builder/step-settings/piece-settings/switch-connection-confirmation-dialog.tsx@@ -12,10 +12,13 @@ import {} from '@activepieces/pieces-framework';import {AppConnectionWithoutSensitiveData,+ ConnectionReplaceSource,+ ConnectionSwitchChoice,PieceAction,PieceTrigger,PropertyExecutionType,PropertySettings,+ TelemetryEventName,} from '@activepieces/shared';import i18next, { t } from 'i18next';import { useState } from 'react';@@ -23,6 +26,7 @@ import { useFormContext } from 'react-hook-form';import { ReplaceConnectionForFlowDialog } from '@/app/builder/builder-header/replace-connection-for-flow-dialog';import { ConnectionSelect } from '@/app/connections/connection-select';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Button } from '@/components/ui/button';import {Dialog,@@ -46,6 +50,7 @@ export function ConnectionSelectWithSwitchConfirmation({disabled,}: ConnectionSelectWithSwitchConfirmationProps) {const form = useFormContext<PieceAction | PieceTrigger>();+ const { capture } = useTelemetry();const projectId = authenticationSession.getProjectId()!;const { data: pieceConnections } = appConnectionsQueries.useAppConnections({request: { pieceName: piece.name, projectId, limit: 1000 },@@ -97,6 +102,17 @@ export function ConnectionSelectWithSwitchConfirmation({const canReplace =showReplace && hasPermissionToReplace && !isNil(sourceConnection);+ const captureSwitchDecision = (choice: ConnectionSwitchChoice) =>+ capture({+ name: TelemetryEventName.CONNECTION_SWITCH_DECIDED,+ payload: {+ choice,+ pieceName: piece.name,+ clearedInputCount: pendingSwitch?.clearedInputs.length ?? 0,+ replaceAvailable: canReplace,+ },+ });+return (<><ConnectionSelect@@ -112,6 +128,14 @@ export function ConnectionSelectWithSwitchConfirmation({onReplace={canReplace && sourceConnection? () => {+ captureSwitchDecision(ConnectionSwitchChoice.REPLACE);+ capture({+ name: TelemetryEventName.CONNECTION_REPLACE_OPENED,+ payload: {+ source: ConnectionReplaceSource.SWITCH_DIALOG,+ pieceName: sourceConnection.pieceName,+ },+ });setPendingSwitch(null);setConnectionsToReplace({source: sourceConnection,@@ -120,8 +144,12 @@ export function ConnectionSelectWithSwitchConfirmation({}: undefined}- onCancel={() => setPendingSwitch(null)}+ onCancel={() => {+ captureSwitchDecision(ConnectionSwitchChoice.CANCEL);+ setPendingSwitch(null);+ }}onConfirm={() => {+ captureSwitchDecision(ConnectionSwitchChoice.SWITCH);setPendingSwitch(null);onChange(pendingSwitch.newValue);}}@@ -131,6 +159,7 @@ export function ConnectionSelectWithSwitchConfirmation({<ReplaceConnectionForFlowDialogsourceConnection={connectionsToReplace.source}targetConnection={connectionsToReplace.target}+ source={ConnectionReplaceSource.SWITCH_DIALOG}openonOpenChange={(open) => {if (!open) {diff --git a/packages/web/src/app/connections/replace-connection-for-project-dialog.tsx b/packages/web/src/app/connections/replace-connection-for-project-dialog.tsxindex 17c75f25a81..8aa3028ff34 100644--- a/packages/web/src/app/connections/replace-connection-for-project-dialog.tsx+++ b/packages/web/src/app/connections/replace-connection-for-project-dialog.tsx@@ -1,8 +1,13 @@+import {+ ConnectionReplaceSource,+ TelemetryEventName,+} from '@activepieces/shared';import { t } from 'i18next';import { ChevronDown, WorkflowIcon } from 'lucide-react';import React, { useState } from 'react';import { useForm, useWatch } from 'react-hook-form';+import { useTelemetry } from '@/components/providers/telemetry-provider';import { Badge } from '@/components/ui/badge';import { Button } from '@/components/ui/button';import {@@ -45,9 +50,23 @@ const ReplaceConnectionForProjectDialog = ({children,projectId,}: ReplaceConnectionForProjectDialogProps) => {+ const { capture } = useTelemetry();const [dialogOpen, setDialogOpen] = useState(false);return (- <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>+ <Dialog+ open={dialogOpen}+ onOpenChange={(open) => {+ if (open) {+ capture({+ name: TelemetryEventName.CONNECTION_REPLACE_OPENED,+ payload: {+ source: ConnectionReplaceSource.PROJECT_CONNECTIONS_PAGE,+ },+ });+ }+ setDialogOpen(open);+ }}+ ><DialogTrigger asChild>{children}</DialogTrigger><DialogContent className="flex flex-col"><ReplaceConnectionForProjectForm@@ -67,6 +86,7 @@ function ReplaceConnectionForProjectForm({setDialogOpen,}: ReplaceConnectionForProjectFormProps) {const openNewWindow = useNewWindow();+ const { capture } = useTelemetry();const [step, setStep] = useState<ProjectReplaceStep>(ProjectReplaceStep.CHOOSE_CONNECTIONS,);@@ -82,6 +102,16 @@ function ReplaceConnectionForProjectForm({appConnectionsMutations.useReplaceConnections({setDialogOpen,connections: connections?.data ?? [],+ onReplaced: (request) =>+ capture({+ name: TelemetryEventName.CONNECTION_REPLACE_COMPLETED,+ payload: {+ source: ConnectionReplaceSource.PROJECT_CONNECTIONS_PAGE,+ pieceName: form.getValues('pieceName'),+ flowCount: request.flowIds.length,+ applyToPublishedVersions: request.applyToPublishedVersions ?? false,+ },+ }),refetch: onConnectionMerged,});@@ -270,6 +300,7 @@ function ReplaceConnectionForProjectForm({<Buttontype="button"variant="secondary"+ disabled={isReplacing}onClick={() => {form.setValue('applyToPublishedVersions', false);setStep(ProjectReplaceStep.CHOOSE_CONNECTIONS);diff --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 29e78709ccd..dcdf9d7fdc4 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@@ -158,6 +158,18 @@ const buildEventLabels = (): Record<TelemetryEventName, TrackedEvent> => ({group: 'platformAdmin',label: t('Clicked a button on a platform administration page'),},+ [TelemetryEventName.CONNECTION_SWITCH_DECIDED]: {+ group: 'flows',+ label: t("Chose an option when switching a step's connection"),+ },+ [TelemetryEventName.CONNECTION_REPLACE_OPENED]: {+ group: 'flows',+ label: t('Opened the replace connection dialog'),+ },+ [TelemetryEventName.CONNECTION_REPLACE_COMPLETED]: {+ group: 'flows',+ label: t('Replaced a connection'),+ },});const buildGroups = (): TrackedEventGroup[] => {diff --git a/packages/web/src/features/connections/hooks/app-connections-hooks.ts b/packages/web/src/features/connections/hooks/app-connections-hooks.tsindex 3a0cd96d4a1..444edb88503 100644--- a/packages/web/src/features/connections/hooks/app-connections-hooks.ts+++ b/packages/web/src/features/connections/hooks/app-connections-hooks.ts@@ -52,6 +52,7 @@ import {type UseReplaceConnectionsProps = {setDialogOpen: (isOpen: boolean) => void;refetch: () => void;+ onReplaced?: (request: ReplaceAppConnectionsRequestBody) => void;connections: AppConnectionWithoutSensitiveData[];};@@ -324,6 +325,7 @@ export const appConnectionsMutations = {useReplaceConnections: ({setDialogOpen,refetch,+ onReplaced,connections,}: UseReplaceConnectionsProps) => {return useMutation({@@ -343,6 +345,7 @@ export const appConnectionsMutations = {},),});+ onReplaced?.(request);setDialogOpen(false);refetch();},