Returns an authenticated client for resource.
Called once, on the first successful McpSessionTelemetry.bind.
true when the user or organization opted out.
OptionalnodeEnv?: stringdevelopment or test reports as development;
anything else, or nothing, reports as production.
OptionalsessionId?: stringShared id for every telemetry object in one MCP session. Use a random id, never a credential or session handle. Omit to mint one.
Assumes the host has clientForResource and telemetryEnabled, and that
address and client belong to the current tool call.
import {createMcpSessionTelemetry, createWorkflowEngine} from '@sanity/workflow-mcp'
const telemetry = createMcpSessionTelemetry({
clientFor: (resource) => clientForResource(resource),
denied: !telemetryEnabled,
})
// For each tool call:
telemetry.bind(address.workflowResource)
const engine = createWorkflowEngine({address, client, telemetry: telemetry.logger})
// When the session closes:
await telemetry.flush()
telemetry.end()
Create the Workflows telemetry for one MCP session.
Events go to the first project the session binds to. They carry the package version, project id, and dataset, never tool arguments, results, or a user id.
Nothing is sent when
deniedistrue, or when nothing is logged. Otherwise the account's consent is checked at the first send, retried if that check fails, and cached for this telemetry object. Sending never throws.