Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ Every AI call above starts from one of three places: a sequence an administrator
| Any user-supplied URL | Adding a URL source, the URL preview utility route, analyzing or sideloading an image card | Plain GET. `SsrfGuard` blocks private IPs and sets redirects to 0 |
| `en.wikipedia.org/w/api.php` | The Wikipedia research assistant runs | The search query |
| Parse.ly Content API and Suggestions API, through wp-parsely's service classes | Smart links, headline suggestions, performance tools, the poll and the warmers | **Post content** (smart links, title suggestions), headlines and URLs |
| VIP Telemetry library (Pendo and Tracks), only when `Automattic\VIP\Telemetry\Telemetry` exists | Tool runs, agent runs, transition gates, rate-limit hits | Counts, outcomes and durations. No content |
| VIP Telemetry library (Tracks), only when `Automattic\VIP\Telemetry\Telemetry` exists | Tool runs, agent runs, transition gates, rate-limit hits, experiment toggles. From the browser: sequence editing, My Work filters and grouping, and editor workflow actions | Counts, outcomes, durations, IDs and option values. No content |

Parse.ly calls require the wp-parsely plugin and its `apikey`/`api_secret` option.

Expand All @@ -499,11 +499,12 @@ Parse.ly calls require the wp-parsely plugin and its `apikey`/`api_secret` optio
| User-supplied URLs | 10 s for metadata, 30 s for downloads | `vip-workflows/includes/integrations/class-url-meta-extractor.php`, `vip-workflows/includes/integrations/class-ssrf-guard.php`, `vip-workflows/includes/api/class-ideation-controller.php` |
| Wikipedia | 5 s through `vip_safe_wp_remote_get` | `workflow-assistant-wikipedia/workflow-assistant-wikipedia.php` |
| Parse.ly | Set by wp-parsely | `workflow-parsely/includes/class-parsely-client.php` |
| VIP Telemetry | Errors are swallowed | `vip-workflows/includes/telemetry/class-tracker.php` |
| VIP Telemetry | Errors are swallowed. The browser sends nothing where the library isn't loaded or `vip_env` is `local` | `vip-workflows/includes/telemetry/class-tracker.php`, `vip-workflows/src/common/tracks.js` |

Other outbound behavior:

- The browser embeds YouTube and Vimeo iframes for video cards (`vip-workflows/src/admin/components/ideation/cards/ImageCard.js`).
- Browser telemetry queues events on `window._tkq` and loads `stats.wp.com/w.js` on the first event, not before.
- `ContentExtractor` (`vip-workflows/includes/integrations/class-content-extractor.php`) has no callers.
- **Jetpack:** no PHP, JS or Composer reference anywhere in the core plugin or the extensions. Parse.ly goes through wp-parsely, not Jetpack.

Expand Down
1 change: 1 addition & 0 deletions vip-workflows/includes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ public function enqueue_scripts( string $hook_suffix ): void {
'myWork' => array(
'windowDays' => \VIPWorkflows\API\WorkflowController::MY_WORK_WINDOW_DAYS,
),
'tracks' => \VIPWorkflows\Telemetry\Tracker::get_client_properties(),
);

if ( self::screen_carries_skills( $hook_suffix ) ) {
Expand Down
19 changes: 19 additions & 0 deletions vip-workflows/includes/api/class-experiments-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace VIPWorkflows\API;

use VIPWorkflows\Plugin;
use VIPWorkflows\Telemetry\Tracker;
use WP_Error;
use WP_REST_Controller;
use WP_REST_Request;
Expand Down Expand Up @@ -112,12 +113,30 @@ public function toggle_experiment( WP_REST_Request $request ) {
);
}

$was_enabled = $registry->is_enabled( $id );

if ( $enabled ) {
$registry->enable( $id );
} else {
$registry->disable( $id );
}

// The vip_workflows_experiments filter can pin an experiment on or off
// whatever was requested, so compare the effective state before and after.
$is_enabled = $registry->is_enabled( $id );

// Recorded here rather than in the browser: the Settings screen reloads
// as soon as its save resolves, which would drop an event still queued.
if ( $was_enabled !== $is_enabled ) {
Tracker::record(
'settings_experiment_toggled',
array(
'experiment_id' => $id,
'enabled' => $is_enabled,
)
);
}

return new WP_REST_Response( $registry->to_array() );
}
}
1 change: 1 addition & 0 deletions vip-workflows/includes/editor/class-editor-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function enqueue_editor_assets(): void {
'metadataFields' => $metadata_fields,
'roles' => $roles,
'workflowStatus' => $workflow_status,
'tracks' => \VIPWorkflows\Telemetry\Tracker::get_client_properties(),
)
) . ';',
'before'
Expand Down
38 changes: 38 additions & 0 deletions vip-workflows/includes/telemetry/class-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace VIPWorkflows\Telemetry;

use function Automattic\VIP\Telemetry\Tracks\get_base_properties_of_track_event;
use function Automattic\VIP\Telemetry\Tracks\get_base_properties_of_track_user;

/**
* Records product-usage events through the VIP Telemetry library.
*
Expand Down Expand Up @@ -85,6 +88,41 @@ public static function is_available(): bool {
return null !== self::telemetry();
}

/**
* Base properties for the events the browser records (src/common/tracks.js).
*
* The same base properties the library puts on server events, from its own
* two helpers: the site and environment (VIP environment and organization,
* WordPress and mu-plugins versions, hosting provider, and similar), and
* the anonymized user. Plus the plugin version. The browser records nothing
* when this is null, or when the environment is local.
*
* Called while an admin screen renders, so a helper that throws (the
* library is outside this plugin's control) yields null, the same as no
* library, rather than breaking the screen. record() does the same.
*
* @return array<string,mixed>|null Null where the VIP Telemetry library isn't loaded or fails.
*/
public static function get_client_properties(): ?array {
if (
! self::is_available()
|| ! function_exists( '\\Automattic\\VIP\\Telemetry\\Tracks\\get_base_properties_of_track_event' )
|| ! function_exists( '\\Automattic\\VIP\\Telemetry\\Tracks\\get_base_properties_of_track_user' )
) {
return null;
}

try {
return array_merge(
get_base_properties_of_track_event(),
get_base_properties_of_track_user(),
array( 'plugin_version' => VIP_WORKFLOWS_VERSION )
);
} catch ( \Throwable $e ) {
return null;
}
}

/**
* Replace the Telemetry instance, for tests. Pass null to use the library.
*
Expand Down
7 changes: 7 additions & 0 deletions vip-workflows/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vip-workflows/src/admin/components/SequencesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { __, _n, sprintf } from '@wordpress/i18n';
import { plus } from '@wordpress/icons';

import { ModalActions } from '../../common/ModalActions';
import { recordTracksEvent } from '../../common/tracks';
import AdminPage from './AdminPage';
import { CardGridView } from './CardGridView';
import { HowToModal } from './HowToModal';
Expand Down Expand Up @@ -321,6 +322,11 @@ export function SequencesList() {
variant="primary"
icon={ plus }
href="#/new?type=workflow"
onClick={ () =>
recordTracksEvent( 'sequence_create_started', {
source: 'header',
} )
}
>
{ __( 'New sequence', 'vip-workflows' ) }
</Button>
Expand Down Expand Up @@ -376,6 +382,14 @@ export function SequencesList() {
<Button
variant="primary"
href="#/new?type=workflow"
onClick={ () =>
recordTracksEvent(
'sequence_create_started',
{
source: 'empty_state',
}
)
}
>
{ __(
'New sequence',
Expand Down Expand Up @@ -586,9 +600,11 @@ function ImportSequenceModal( { onClose, onSuccess, allSequences } ) {
},
} );

recordTracksEvent( 'sequence_imported', { result: 'success' } );
onSuccess();
onClose();
} catch ( err ) {
recordTracksEvent( 'sequence_imported', { result: 'error' } );
setError( err.message );
setImporting( false );
}
Expand Down
4 changes: 4 additions & 0 deletions vip-workflows/src/admin/components/graph/GraphCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { useInstanceId } from '@wordpress/compose';
import { Icon, VisuallyHidden } from '@wordpress/ui';
import { rotateLeft, plus, trash } from '@wordpress/icons';
import { __, sprintf } from '@wordpress/i18n';
import { recordTracksEvent } from '../../../common/tracks';
import StageNode from './StageNode';
import TerminalNode from './TerminalNode';
import RegionNode from './RegionNode';
Expand Down Expand Up @@ -1825,6 +1826,9 @@ function Flow( {
onSelect: () => {
const key = onAddStage( menu.site.region );
placeDroppedStage( key, menu.site );
recordTracksEvent( 'sequence_stage_added', {
source: 'canvas_menu',
} );
},
} );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '@wordpress/components';
import { Stack } from '@wordpress/ui';
import { __ } from '@wordpress/i18n';
import { recordTracksEvent } from '../../../common/tracks';
import { sanitizeMetadataKey } from '../../utils/metadata-keys';
import InspectorFieldList, {
InspectorFieldListAdd,
Expand Down Expand Up @@ -104,7 +105,10 @@ export function MetadataFieldsAdd( { fields, onChange } ) {
addOptions={ [
{ label: __( 'Field', 'vip-workflows' ), value: 'field' },
] }
onAdd={ () => onChange( [ ...fields, createField() ] ) }
onAdd={ () => {
onChange( [ ...fields, createField() ] );
recordTracksEvent( 'sequence_metadata_field_added' );
} }
label={ __( 'Add field', 'vip-workflows' ) }
/>
);
Expand Down
17 changes: 16 additions & 1 deletion vip-workflows/src/admin/components/graph/SequenceGraphEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { __, _n, sprintf } from '@wordpress/i18n';

import AdminPage from '../AdminPage';
import { useConfirm } from '../../../common/use-confirm';
import { recordTracksEvent } from '../../../common/tracks';
import { getSaveButtonLabel } from '../../utils/save-button-label';
import GraphCanvas from './GraphCanvas';
import Inspector from './Inspector';
Expand Down Expand Up @@ -1156,6 +1157,7 @@ export default function SequenceGraphEditor( {
// --- Status region handlers --------------------------------------------

const handleAddRegion = useCallback( ( region ) => {
recordTracksEvent( 'sequence_post_status_added' );
setAddedRegions( ( current ) =>
current.includes( region ) ? current : [ ...current, region ]
);
Expand Down Expand Up @@ -1271,6 +1273,9 @@ export default function SequenceGraphEditor( {
if ( ! result.key ) {
return null;
}
recordTracksEvent( 'sequence_stage_added', {
source: 'connection_drop',
} );
setStages( result.stages );
setSelection( { type: 'node', key: result.key } );
return result.key;
Expand Down Expand Up @@ -1384,6 +1389,9 @@ export default function SequenceGraphEditor( {
if ( ! result.key ) {
return null;
}
recordTracksEvent( 'sequence_stage_added', {
source: 'edge_reconnect',
} );
setStages( result.stages );
setSelection( { type: 'node', key: result.key } );
return result.key;
Expand Down Expand Up @@ -1880,7 +1888,14 @@ export default function SequenceGraphEditor( {
// whether "Required" can mean anything depends on the edges drawn now.
hasTransitionIntoPublish: transitionsIntoPublish( stages ).length > 0,
// Wrapped: the list's add button passes its option value, not a region.
onAddStage: isPhase ? undefined : () => handleAddStage(),
onAddStage: isPhase
? undefined
: () => {
handleAddStage();
recordTracksEvent( 'sequence_stage_added', {
source: 'stage_list',
} );
},
stages,
onStagesChange: setStages,
onRemoveStage: handleDeleteStage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { CheckboxControl, Spinner, ToggleControl } from '@wordpress/components';
import { Stack } from '@wordpress/ui';
import { __, sprintf, _n } from '@wordpress/i18n';
import { recordTracksEvent } from '../../../common/tracks';
import InspectorShell from './InspectorShell';
import InspectorSection from './InspectorSection';
import InspectorDangerZone from './InspectorDangerZone';
Expand Down Expand Up @@ -289,12 +290,15 @@ export default function SequenceSettingsInspector( {
'vip-workflows'
) }
checked={ settings?.allow_agent_publish === true }
onChange={ ( allow ) =>
onChange={ ( allow ) => {
onSettingsChange( {
...settings,
allow_agent_publish: allow,
} )
}
} );
recordTracksEvent( 'sequence_ai_publish_toggled', {
enabled: allow,
} );
} }
/>
</InspectorSection>

Expand Down
13 changes: 10 additions & 3 deletions vip-workflows/src/admin/components/graph/StageInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import {
import { chevronDown, trash } from '@wordpress/icons';
import { Stack, Text } from '@wordpress/ui';
import { __, sprintf } from '@wordpress/i18n';
import { recordTracksEvent } from '../../../common/tracks';
import { paletteOptions } from '../../utils/stage-palette';
import { AgentRequirements } from '../../../common/AgentRequirements';
import { Fact, InfoTip } from './InspectorFacts';
Expand Down Expand Up @@ -788,9 +789,15 @@ export default function StageInspector( {
// Routed through its own field rather than merged into
// `agent`: clearing it drops the whole agent, and the
// editor's mutation is what knows that.
onChange={ ( value ) =>
onChange( { agent_ability_id: value || '' } )
}
onChange={ ( value ) => {
onChange( { agent_ability_id: value || '' } );
if ( value && value !== abilityId ) {
recordTracksEvent(
'sequence_stage_agent_selected',
{ ability_id: value }
);
}
} }
/>
</div>
{ /* Travels with the picker: it explains the agent that was
Expand Down
14 changes: 10 additions & 4 deletions vip-workflows/src/admin/components/graph/TransitionInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
} from '@wordpress/components';
import { Stack } from '@wordpress/ui';
import { __, _n, sprintf } from '@wordpress/i18n';
import { recordTracksEvent } from '../../../common/tracks';
import { requirementText } from '../../../common/AgentRequirements';
import { AssignmentInputConfig } from '../TransitionAssignmentConfig';
import InspectorShell from './InspectorShell';
Expand Down Expand Up @@ -225,8 +226,10 @@ export default function TransitionInspector( {
description: tool.meta?.summary,
} ) );

const addTool = ( id ) =>
const addTool = ( id ) => {
onChange( { required_tools: [ ...requiredToolIds, id ] } );
recordTracksEvent( 'sequence_tool_added', { ability_id: id } );
};

/**
* What a tool's row reads.
Expand Down Expand Up @@ -583,12 +586,15 @@ export default function TransitionInspector( {
value: 'assignment',
},
] }
onAdd={ () =>
onAdd={ () => {
updateInputs( [
...inputs,
createAssignment(),
] )
}
] );
recordTracksEvent(
'sequence_assignment_added'
);
} }
label={ __(
'Add an assignment',
'vip-workflows'
Expand Down
Loading
Loading