Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Add trigger receipt tables and repositories (SKY-18377) (#8931)
Aaron Perezda5a16477190
diff --git a/docs/api-reference/openapi.json b/docs/api-reference/openapi.jsonindex ad5ae276c..4a04cdb4f 100644--- a/docs/api-reference/openapi.json+++ b/docs/api-reference/openapi.json@@ -34122,11 +34122,12 @@"api","scheduled","webhook",+ "event","job_recipe_extract","job_recipe_apply"],"title": "WorkflowRunTriggerType",- "description": "How a workflow run was initiated.\n\n- manual: User clicked \"Run\" in the UI\n- mcp: First-party MCP client request\n- api: Direct API call to the run endpoint\n- scheduled: Triggered by a cron schedule\n- webhook: Triggered by an external system via the webhook endpoint\n- job_recipe_extract: Launched by a job recipe extract request\n- job_recipe_apply: Launched by a job recipe apply request"+ "description": "How a workflow run was initiated.\n\n- manual: User clicked \"Run\" in the UI\n- mcp: First-party MCP client request\n- api: Direct API call to the run endpoint\n- scheduled: Triggered by a cron schedule\n- webhook: Triggered by an external system via the webhook endpoint\n- event: Triggered by an external event source\n- job_recipe_extract: Launched by a job recipe extract request\n- job_recipe_apply: Launched by a job recipe apply request"},"WorkflowSchedule": {"properties": {diff --git a/fern/openapi/skyvern_openapi.json b/fern/openapi/skyvern_openapi.jsonindex 6f637252c..9c549fe7f 100644--- a/fern/openapi/skyvern_openapi.json+++ b/fern/openapi/skyvern_openapi.json@@ -33828,11 +33828,12 @@"api","scheduled","webhook",+ "event","job_recipe_extract","job_recipe_apply"],"title": "WorkflowRunTriggerType",- "description": "How a workflow run was initiated.\n\n- manual: User clicked \"Run\" in the UI\n- mcp: First-party MCP client request\n- api: Direct API call to the run endpoint\n- scheduled: Triggered by a cron schedule\n- webhook: Triggered by an external system via the webhook endpoint\n- job_recipe_extract: Launched by a job recipe extract request\n- job_recipe_apply: Launched by a job recipe apply request"+ "description": "How a workflow run was initiated.\n\n- manual: User clicked \"Run\" in the UI\n- mcp: First-party MCP client request\n- api: Direct API call to the run endpoint\n- scheduled: Triggered by a cron schedule\n- webhook: Triggered by an external system via the webhook endpoint\n- event: Triggered by an external event source\n- job_recipe_extract: Launched by a job recipe extract request\n- job_recipe_apply: Launched by a job recipe apply request"},"WorkflowSchedule": {"properties": {diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.pyindex 6e26b96c6..d1de6bdec 100644--- a/skyvern/forge/agent_functions.py+++ b/skyvern/forge/agent_functions.py@@ -1057,6 +1057,17 @@ class AgentFunction:"""return None+ async def capture_workflow_run_created(+ self,+ *,+ workflow_run_id: str,+ organization_id: str,+ workflow_permanent_id: str,+ trigger_type: WorkflowRunTriggerType,+ ) -> None:+ """Capture Cloud run-creation telemetry; OSS builds have no product analytics sink."""+ return None+def is_backup_queue_organization(self, organization_id: str) -> bool:return Falsediff --git a/skyvern/forge/sdk/db/enums.py b/skyvern/forge/sdk/db/enums.pyindex 68726196f..56469b40a 100644--- a/skyvern/forge/sdk/db/enums.py+++ b/skyvern/forge/sdk/db/enums.py@@ -49,6 +49,7 @@ class WorkflowRunTriggerType(StrEnum):- api: Direct API call to the run endpoint- scheduled: Triggered by a cron schedule- webhook: Triggered by an external system via the webhook endpoint+ - event: Triggered by an external event source- job_recipe_extract: Launched by a job recipe extract request- job_recipe_apply: Launched by a job recipe apply request"""@@ -58,6 +59,7 @@ class WorkflowRunTriggerType(StrEnum):api = "api"scheduled = "scheduled"webhook = "webhook"+ event = "event"job_recipe_extract = "job_recipe_extract"job_recipe_apply = "job_recipe_apply"diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.pyindex dc2daad4f..83bad3d4c 100644--- a/skyvern/forge/sdk/workflow/service.py+++ b/skyvern/forge/sdk/workflow/service.py@@ -3454,6 +3454,7 @@ class WorkflowService:resolved_trigger_type = ambient_context.trigger_typeif resolved_trigger_type is None:resolved_trigger_type = WorkflowRunTriggerType.api+ otel_trace.get_current_span().set_attribute("trigger_type", resolved_trigger_type.value)prevalidated_workflow_parameters: list[WorkflowParameter] | None = Noneif refuse_unusable_parameters_before_create:@@ -3523,6 +3524,7 @@ class WorkflowService:workflow_run_id=workflow_run.workflow_run_id,workflow_id=workflow.workflow_id,organization_id=workflow.organization_id,+ run_source=resolved_trigger_type.value,proxy_location=workflow_request.proxy_location,webhook_callback_url=workflow_request.webhook_callback_url,max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolls,@@ -3530,6 +3532,21 @@ class WorkflowService:run_with=workflow_request.run_with,code_gen=code_gen,)+ if parent_workflow_run_id is None and retried_from_workflow_run_id is None:+ try:+ await app.AGENT_FUNCTION.capture_workflow_run_created(+ workflow_run_id=workflow_run.workflow_run_id,+ organization_id=organization.organization_id,+ workflow_permanent_id=workflow.workflow_permanent_id,+ trigger_type=resolved_trigger_type,+ )+ except Exception: # Telemetry must never fail run creation.+ LOG.warning(+ "Failed to capture workflow run creation event",+ workflow_run_id=workflow_run.workflow_run_id,+ organization_id=organization.organization_id,+ exc_info=True,+ )context: skyvern_context.SkyvernContext | None = skyvern_context.current()current_run_id = context.run_id if context and context.run_id else workflow_run.workflow_run_idroot_workflow_run_id = (