Skip to content

Commit

Permalink
feat(user-tracking): Include userId in execution params
Browse files Browse the repository at this point in the history
- Add userId to execution parameters for executeStep and retryStep
  functions to capture user-specific telemetry data
- Modify page functions to pass userId from the user context for
  more granular tracking and user-driven analytics
- Ensure all execution paths maintain consistent userId propagation
  for future scalability in user data insights

This enhancement improves the ability to trace executions back to
specific users, enabling better analytics and debugging capabilities
with no breaking changes introduced.
  • Loading branch information
toyamarinyon committed Jan 2, 2025
1 parent e07259a commit c13463e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/(playground)/p/[agentId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default async function Page({
stepId,
artifacts,
stream: true,
userId: user.id,
});
}
async function putExecutionAction(executionSnapshot: ExecutionSnapshot) {
Expand Down Expand Up @@ -169,19 +170,19 @@ export default async function Page({
stepId,
artifacts,
stream: true,
userId: user.id,
});
}

async function executeNodeAction(executionId: ExecutionId, nodeId: NodeId) {
"use server";
const response = await executeNode({
return await executeNode({
agentId,
executionId,
nodeId,
stream: true,
userId: user.id,
});
return response;
}

async function onFinishPerformExecutionAction(
Expand Down
6 changes: 6 additions & 0 deletions packages/lib/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ interface ExecuteStepParams {
stepId: StepId;
artifacts: Artifact[];
stream?: boolean;
userId?: string;
overrideData?: OverrideData[];
}
export async function executeStep({
Expand All @@ -420,6 +421,7 @@ export async function executeStep({
stepId,
artifacts,
stream,
userId,
overrideData,
}: ExecuteStepParams) {
const agent = await db.query.agents.findFirst({
Expand Down Expand Up @@ -490,6 +492,7 @@ export async function executeStep({
artifacts,
nodes: graph.nodes,
connections: graph.connections,
userId,
stream,
};

Expand All @@ -503,6 +506,7 @@ interface RetryStepParams {
stepId: StepId;
artifacts: Artifact[];
stream?: boolean;
userId?: string;
}
export async function retryStep({
agentId,
Expand All @@ -511,6 +515,7 @@ export async function retryStep({
stepId,
artifacts,
stream,
userId,
}: RetryStepParams) {
const executionSnapshot = await fetch(retryExecutionSnapshotUrl).then(
(res) => res.json() as unknown as ExecutionSnapshot,
Expand All @@ -537,6 +542,7 @@ export async function retryStep({
nodes: executionSnapshot.nodes,
connections: executionSnapshot.connections,
stream,
userId,
};

return performFlowExecution(context);
Expand Down

0 comments on commit c13463e

Please sign in to comment.