diff --git a/www/apps/book/app/learn/debugging-and-testing/debug-workflows/page.mdx b/www/apps/book/app/learn/debugging-and-testing/debug-workflows/page.mdx
new file mode 100644
index 0000000000..8b87ee82a5
--- /dev/null
+++ b/www/apps/book/app/learn/debugging-and-testing/debug-workflows/page.mdx
@@ -0,0 +1,471 @@
+import { Table, Prerequisites, CodeTabs, CodeTab } from "docs-ui"
+
+export const metadata = {
+ title: `${pageNumber} Debug Workflows`,
+}
+
+# {metadata.title}
+
+In this chapter, you'll learn about the different ways you can debug workflows in Medusa.
+
+Debugging workflows is essential to ensure your custom features work as expected. It helps you identify unexpected issues and bugs in your workflow logic.
+
+## Approaches to Debug Workflows
+
+There are several ways to debug workflows in Medusa:
+
+
+
+
+
+ Approach
+
+
+ When to Use
+
+
+
+
+
+
+ Write integration tests
+
+
+ To ensure your workflow produces the expected results and handles edge cases.
+
+
+
+
+ Add breakpoints
+
+
+ To inspect specific steps in your workflow and understand the data flow.
+
+
+
+
+ Log messages
+
+
+ To check values during execution with minimal overhead.
+
+
+
+
+ View Workflow Executions in Medusa Admin
+
+
+ To monitor stored workflow executions and long-running workflows, especially in production environments.
+
+
+
+
+
+---
+
+## Approach 1: Write Integration Tests
+
+Integration tests run your workflow in a controlled environment to verify its behavior and outcome. By writing integration tests, you ensure your workflow produces the expected results and handles edge cases.
+
+### When to Use Integration Tests
+
+It's recommended to always write integration tests for your workflows. This helps you catch issues early and ensures your custom logic works as intended.
+
+### How to Write Integration Tests for Workflows
+
+Refer to the [Integration Tests](../testing-tools/integration-tests/page.mdx) chapter to learn how to write integration tests for your workflows and find examples of testing workflows.
+
+---
+
+## Approach 2: Add Breakpoints
+
+Breakpoints allow you to pause workflow execution at specific steps and inspect the data. They're useful for understanding the data flow in your steps and identifying issues.
+
+### When to Use Breakpoints
+
+Use breakpoints when you need to debug specific steps in your workflow, rather than the entire workflow. You can verify that the step is behaving as expected and is producing the correct output.
+
+### Where Can You Add Breakpoints
+
+Since Medusa stores an internal representation of the workflow constructor on application startup, breakpoints within the workflow's constructor won't work during execution. Learn more in the [Data Manipulation](../../fundamentals/workflows/variable-manipulation/page.mdx) chapter.
+
+Instead, you can add breakpoints in:
+
+- A step function.
+- A step's compensation function.
+- The `transform` callback function of a step.
+
+For example:
+
+
+
+
+```ts highlights={[["11"], ["12"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ // Add a breakpoint here to inspect the message
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+
+
+```ts highlights={[["18"], ["19"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk";
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!";
+
+ return new StepResponse(
+ message
+ )
+ },
+ async () => {
+ // Add a breakpoint here to inspect the compensation logic
+ console.log("Compensating step 1")
+ }
+)
+
+const step2 = createStep(
+ "step-2",
+ async () => {
+ throw new Error("This is an error in step 2")
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+ step2()
+
+ return new WorkflowResponse({
+ response
+ })
+ }
+);
+```
+
+
+
+```ts highlights={[["28"], ["29"]]} collapsibleLines="1-8" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+ transform,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ const transformedMessage = transform(
+ { response },
+ (data) => {
+ // Add a breakpoint here to inspect the transformed data
+ const upperCase = data.response.toUpperCase()
+ return upperCase
+ }
+ )
+
+ return new WorkflowResponse({
+ response: transformedMessage,
+ })
+ }
+)
+```
+
+
+
+### How to Add Breakpoints
+
+If your code editor supports adding breakpoints, you can add them in your step and compensation functions, or the `transform` callback function. When the workflow execution reaches the breakpoint, your code editor will pause execution, allowing you to inspect the data and walk through the code.
+
+If you're using VS Code or Cursor, learn how to add breakpoints in the [VS Code documentation](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_breakpoints). For other code editors, refer to their respective documentation.
+
+---
+
+## Approach 3: Log Messages
+
+Logging messages is a simple yet effective way to debug code. By logging messages, you can check values during execution with minimal overhead.
+
+### When to Use Logging
+
+Use logging when debugging workflows and you want to check values during execution without the overhead of setting up breakpoints.
+
+Logging is also useful when you want to verify variable values between steps or in a `transform` callback function.
+
+### How to Log Messages
+
+Since Medusa stores an internal representation of the workflow constructor on application startup, you can't directly log messages in the workflow's constructor.
+
+Instead, you can log messages in:
+
+- A step function.
+- A step's compensation function.
+- The `transform` callback function of a step.
+
+You can log messages with `console.log`. In step and compensation functions, you can also use the [Logger](../logging/page.mdx) to log messages with different log levels (info, warn, error).
+
+For example:
+
+
+
+
+```ts highlights={[["14"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async ({}, { container }) => {
+ const logger = container.resolve("logger")
+ const message = "Hello from step 1!"
+
+ logger.info(`Step 1 output: ${message}`)
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+
+
+
+```ts highlights={[["22"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async ({}, { container }) => {
+ const logger = container.resolve("logger")
+ const message = "Hello from step 1!"
+
+ logger.info(`Step 1 output: ${message}`)
+
+ return new StepResponse(
+ message
+ )
+ },
+ async (_, { container }) => {
+ const logger = container.resolve("logger")
+ logger.warn("Compensating step 1")
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+
+
+
+```ts highlights={[["29"]]} collapsibleLines="1-8" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+ transform,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ const transformedMessage = transform(
+ { response },
+ (data) => {
+ const upperCase = data.response.toUpperCase()
+ console.log("Transformed Data:", upperCase)
+ return upperCase
+ }
+ )
+
+ return new WorkflowResponse({
+ response: transformedMessage,
+ })
+ }
+)
+```
+
+
+
+
+If you execute the workflow, you'll see the logged message in your console.
+
+
+
+Learn more about logging in the [Logger](../logging/page.mdx) chapter.
+
+
+
+---
+
+## Approach 4: Monitor Workflow Executions in Medusa Admin
+
+The Medusa Admin has a [Workflows](!user-guide!/settings/developer/workflows) settings page that provides a user-friendly interface to view stored workflow executions.
+
+### When to Use Admin Monitoring
+
+Use the Medusa Admin to monitor [stored workflow executions](../../fundamentals/workflows/store-executions/page.mdx) when debugging unexpected issues and edge cases, especially in production environments and long-running workflows that run in the background.
+
+By viewing the workflow executions through the Medusa Admin, you can:
+
+- View the status of stored workflow executions.
+- Inspect input and output data for each execution and its steps.
+- Identify any issues or errors in the workflow execution.
+
+### How to Monitor Workflow Executions in the Admin
+
+The Workflows settings page in the Medusa Admin shows you the history of stored workflow executions only. Workflow executions are stored if a workflow is [long-running](../../fundamentals/workflows/long-running-workflow/page.mdx), or if the `store` and `retentionTime` options are set on the workflow.
+
+For example, to store workflow executions:
+
+
+
+```ts highlights={[["22"], ["23"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk";
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!";
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ {
+ name: "my-workflow",
+ retentionTime: 99999,
+ store: true,
+ },
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response
+ })
+ }
+);
+```
+
+
+
+Refer to the [Store Workflow Executions](../../fundamentals/workflows/store-executions/page.mdx) chapter to learn more.
+
+
+
+You can view all executions of this workflow in the Medusa Admin under the [Workflows settings page](!user-guide!/settings/developer/workflows). Each execution will show you the status, input, and output data.
+
+---
+
+## Related Topics
+
+- [Error Handling in Workflows](../../fundamentals/workflows/errors/page.mdx) - For debugging error scenarios and compensation functions
+- [Long-Running Workflows](../../fundamentals/workflows/long-running-workflow/page.mdx) - For debugging async workflows and step status management
+- [Store Workflow Executions](../../fundamentals/workflows/store-executions/page.mdx) - For programmatic access to execution details
+- [Workflow Execution States](!user-guide!/settings/developer/workflows#workflow-execution-status) - For understanding execution statuses in the admin
diff --git a/www/apps/book/app/learn/introduction/from-v1-to-v2/page.mdx b/www/apps/book/app/learn/introduction/from-v1-to-v2/page.mdx
index 6c6e6de368..70e19eb058 100644
--- a/www/apps/book/app/learn/introduction/from-v1-to-v2/page.mdx
+++ b/www/apps/book/app/learn/introduction/from-v1-to-v2/page.mdx
@@ -1082,7 +1082,7 @@ For example, if you extended the `CartService` in v1 to add items with custom pr
import {
createWorkflow,
transform,
- WorkflowResponse
+ WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"
import { addToCartWorkflow } from "@medusajs/medusa/core-flows"
import {
@@ -1223,7 +1223,7 @@ For example:
```ts title="src/workflows/hello-world.ts"
import {
createWorkflow,
- WorkflowResponse
+ WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"
export const helloWorldWorkflow = createWorkflow(
diff --git a/www/apps/book/generated/edit-dates.mjs b/www/apps/book/generated/edit-dates.mjs
index c9733fca5a..f3409924ee 100644
--- a/www/apps/book/generated/edit-dates.mjs
+++ b/www/apps/book/generated/edit-dates.mjs
@@ -125,5 +125,6 @@ export const generatedEditDates = {
"app/learn/introduction/build-with-llms-ai/page.mdx": "2025-07-22T16:19:11.668Z",
"app/learn/installation/docker/page.mdx": "2025-07-23T15:34:18.530Z",
"app/learn/fundamentals/generated-types/page.mdx": "2025-07-25T13:17:35.319Z",
- "app/learn/introduction/from-v1-to-v2/page.mdx": "2025-07-28T08:10:25.987Z"
+ "app/learn/introduction/from-v1-to-v2/page.mdx": "2025-07-30T08:13:48.592Z",
+ "app/learn/debugging-and-testing/debug-workflows/page.mdx": "2025-07-30T10:38:41.398Z"
}
\ No newline at end of file
diff --git a/www/apps/book/generated/sidebar.mjs b/www/apps/book/generated/sidebar.mjs
index aecf2125ee..5c2972e06c 100644
--- a/www/apps/book/generated/sidebar.mjs
+++ b/www/apps/book/generated/sidebar.mjs
@@ -844,6 +844,16 @@ export const generatedSidebars = [
"children": [],
"chapterTitle": "3.7.14. Multiple Step Usage",
"number": "3.7.14."
+ },
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "ref",
+ "path": "/learn/debugging-and-testing/debug-workflows",
+ "title": "Debug Workflows",
+ "children": [],
+ "chapterTitle": "3.7.15. Debug Workflows",
+ "number": "3.7.15."
}
],
"chapterTitle": "3.7. Workflows",
@@ -1152,6 +1162,16 @@ export const generatedSidebars = [
"chapterTitle": "7.3. Modules Tests",
"number": "7.3."
},
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "link",
+ "path": "/learn/debugging-and-testing/debug-workflows",
+ "title": "Debug Workflows",
+ "children": [],
+ "chapterTitle": "7.4. Debug Workflows",
+ "number": "7.4."
+ },
{
"loaded": true,
"isPathHref": true,
@@ -1166,12 +1186,12 @@ export const generatedSidebars = [
"path": "/resources/integrations/guides/sentry",
"title": "Guide: Sentry",
"children": [],
- "chapterTitle": "7.4.1. Guide: Sentry",
- "number": "7.4.1."
+ "chapterTitle": "7.5.1. Guide: Sentry",
+ "number": "7.5.1."
}
],
- "chapterTitle": "7.4. Instrumentation",
- "number": "7.4."
+ "chapterTitle": "7.5. Instrumentation",
+ "number": "7.5."
},
{
"loaded": true,
@@ -1180,8 +1200,8 @@ export const generatedSidebars = [
"path": "/learn/debugging-and-testing/logging",
"title": "Logging",
"children": [],
- "chapterTitle": "7.5. Logging",
- "number": "7.5."
+ "chapterTitle": "7.6. Logging",
+ "number": "7.6."
}
],
"chapterTitle": "7. Debugging & Testing",
diff --git a/www/apps/book/public/llms-full.txt b/www/apps/book/public/llms-full.txt
index 821c9b621e..d9f1433bc5 100644
--- a/www/apps/book/public/llms-full.txt
+++ b/www/apps/book/public/llms-full.txt
@@ -3480,6 +3480,411 @@ Medusa provides the tooling to create a plugin package, test it in a local Medus
To learn more about plugins and how to create them, refer to [this chapter](https://docs.medusajs.com/learn/fundamentals/plugins/index.html.md).
+# Debug Workflows
+
+In this chapter, you'll learn about the different ways you can debug workflows in Medusa.
+
+Debugging workflows is essential to ensure your custom features work as expected. It helps you identify unexpected issues and bugs in your workflow logic.
+
+## Approaches to Debug Workflows
+
+There are several ways to debug workflows in Medusa:
+
+|Approach|When to Use|
+|---|---|
+|Write integration tests|To ensure your workflow produces the expected results and handles edge cases.|
+|Add breakpoints|To inspect specific steps in your workflow and understand the data flow.|
+|Log messages|To check values during execution with minimal overhead.|
+|View Workflow Executions in Medusa Admin|To monitor stored workflow executions and long-running workflows, especially in production environments.|
+
+***
+
+## Approach 1: Write Integration Tests
+
+Integration tests run your workflow in a controlled environment to verify its behavior and outcome. By writing integration tests, you ensure your workflow produces the expected results and handles edge cases.
+
+### When to Use Integration Tests
+
+It's recommended to always write integration tests for your workflows. This helps you catch issues early and ensures your custom logic works as intended.
+
+### How to Write Integration Tests for Workflows
+
+Refer to the [Integration Tests](https://docs.medusajs.com/learn/debugging-and-testing/testing-tools/integration-tests/index.html.md) chapter to learn how to write integration tests for your workflows and find examples of testing workflows.
+
+***
+
+## Approach 2: Add Breakpoints
+
+Breakpoints allow you to pause workflow execution at specific steps and inspect the data. They're useful for understanding the data flow in your steps and identifying issues.
+
+### When to Use Breakpoints
+
+Use breakpoints when you need to debug specific steps in your workflow, rather than the entire workflow. You can verify that the step is behaving as expected and is producing the correct output.
+
+### Where Can You Add Breakpoints
+
+Since Medusa stores an internal representation of the workflow constructor on application startup, breakpoints within the workflow's constructor won't work during execution. Learn more in the [Data Manipulation](https://docs.medusajs.com/learn/fundamentals/workflows/variable-manipulation/index.html.md) chapter.
+
+Instead, you can add breakpoints in:
+
+- A step function.
+- A step's compensation function.
+- The `transform` callback function of a step.
+
+For example:
+
+### Step Function
+
+```ts highlights={[["11"], ["12"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ // Add a breakpoint here to inspect the message
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+### Compensation Function
+
+```ts highlights={[["18"], ["19"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk";
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!";
+
+ return new StepResponse(
+ message
+ )
+ },
+ async () => {
+ // Add a breakpoint here to inspect the compensation logic
+ console.log("Compensating step 1")
+ }
+)
+
+const step2 = createStep(
+ "step-2",
+ async () => {
+ throw new Error("This is an error in step 2")
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+ step2()
+
+ return new WorkflowResponse({
+ response
+ })
+ }
+);
+```
+
+### Transform Callback
+
+```ts highlights={[["28"], ["29"]]} collapsibleLines="1-8" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+ transform,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ const transformedMessage = transform(
+ { response },
+ (data) => {
+ // Add a breakpoint here to inspect the transformed data
+ const upperCase = data.response.toUpperCase()
+ return upperCase
+ }
+ )
+
+ return new WorkflowResponse({
+ response: transformedMessage,
+ })
+ }
+)
+```
+
+### How to Add Breakpoints
+
+If your code editor supports adding breakpoints, you can add them in your step and compensation functions, or the `transform` callback function. When the workflow execution reaches the breakpoint, your code editor will pause execution, allowing you to inspect the data and walk through the code.
+
+If you're using VS Code or Cursor, learn how to add breakpoints in the [VS Code documentation](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_breakpoints). For other code editors, refer to their respective documentation.
+
+***
+
+## Approach 3: Log Messages
+
+Logging messages is a simple yet effective way to debug code. By logging messages, you can check values during execution with minimal overhead.
+
+### When to Use Logging
+
+Use logging when debugging workflows and you want to check values during execution without the overhead of setting up breakpoints.
+
+Logging is also useful when you want to verify variable values between steps or in a `transform` callback function.
+
+### How to Log Messages
+
+Since Medusa stores an internal representation of the workflow constructor on application startup, you can't directly log messages in the workflow's constructor.
+
+Instead, you can log messages in:
+
+- A step function.
+- A step's compensation function.
+- The `transform` callback function of a step.
+
+You can log messages with `console.log`. In step and compensation functions, you can also use the [Logger](https://docs.medusajs.com/learn/debugging-and-testing/logging/index.html.md) to log messages with different log levels (info, warn, error).
+
+For example:
+
+### Step Function
+
+```ts highlights={[["14"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async ({}, { container }) => {
+ const logger = container.resolve("logger")
+ const message = "Hello from step 1!"
+
+ logger.info(`Step 1 output: ${message}`)
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+### Compensation Function
+
+```ts highlights={[["22"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async ({}, { container }) => {
+ const logger = container.resolve("logger")
+ const message = "Hello from step 1!"
+
+ logger.info(`Step 1 output: ${message}`)
+
+ return new StepResponse(
+ message
+ )
+ },
+ async (_, { container }) => {
+ const logger = container.resolve("logger")
+ logger.warn("Compensating step 1")
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response,
+ })
+ }
+)
+```
+
+### Transform Callback
+
+```ts highlights={[["29"]]} collapsibleLines="1-8" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+ transform,
+} from "@medusajs/framework/workflows-sdk"
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!"
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ "my-workflow",
+ () => {
+ const response = step1()
+
+ const transformedMessage = transform(
+ { response },
+ (data) => {
+ const upperCase = data.response.toUpperCase()
+ console.log("Transformed Data:", upperCase)
+ return upperCase
+ }
+ )
+
+ return new WorkflowResponse({
+ response: transformedMessage,
+ })
+ }
+)
+```
+
+If you execute the workflow, you'll see the logged message in your console.
+
+Learn more about logging in the [Logger](https://docs.medusajs.com/learn/debugging-and-testing/logging/index.html.md) chapter.
+
+***
+
+## Approach 4: Monitor Workflow Executions in Medusa Admin
+
+The Medusa Admin has a [Workflows](https://docs.medusajs.com/user-guide/settings/developer/workflows/index.html.md) settings page that provides a user-friendly interface to view stored workflow executions.
+
+### When to Use Admin Monitoring
+
+Use the Medusa Admin to monitor [stored workflow executions](https://docs.medusajs.com/learn/fundamentals/workflows/store-executions/index.html.md) when debugging unexpected issues and edge cases, especially in production environments and long-running workflows that run in the background.
+
+By viewing the workflow executions through the Medusa Admin, you can:
+
+- View the status of stored workflow executions.
+- Inspect input and output data for each execution and its steps.
+- Identify any issues or errors in the workflow execution.
+
+### How to Monitor Workflow Executions in the Admin
+
+The Workflows settings page in the Medusa Admin shows you the history of stored workflow executions only. Workflow executions are stored if a workflow is [long-running](https://docs.medusajs.com/learn/fundamentals/workflows/long-running-workflow/index.html.md), or if the `store` and `retentionTime` options are set on the workflow.
+
+For example, to store workflow executions:
+
+### Prerequisites
+
+- [Redis Workflow Engine must be installed and configured.](https://docs.medusajs.com/resources/infrastructure-modules/workflow-engine/redis/index.html.md)
+
+```ts highlights={[["22"], ["23"]]} collapsibleLines="1-7" expandButtonLabel="Show Imports"
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk";
+
+const step1 = createStep(
+ "step-1",
+ async () => {
+ const message = "Hello from step 1!";
+
+ return new StepResponse(
+ message
+ )
+ }
+)
+
+export const myWorkflow = createWorkflow(
+ {
+ name: "my-workflow",
+ retentionTime: 99999,
+ store: true,
+ },
+ () => {
+ const response = step1()
+
+ return new WorkflowResponse({
+ response
+ })
+ }
+);
+```
+
+Refer to the [Store Workflow Executions](https://docs.medusajs.com/learn/fundamentals/workflows/store-executions/index.html.md) chapter to learn more.
+
+You can view all executions of this workflow in the Medusa Admin under the [Workflows settings page](https://docs.medusajs.com/user-guide/settings/developer/workflows/index.html.md). Each execution will show you the status, input, and output data.
+
+***
+
+## Related Topics
+
+- [Error Handling in Workflows](https://docs.medusajs.com/learn/fundamentals/workflows/errors/index.html.md) - For debugging error scenarios and compensation functions
+- [Long-Running Workflows](https://docs.medusajs.com/learn/fundamentals/workflows/long-running-workflow/index.html.md) - For debugging async workflows and step status management
+- [Store Workflow Executions](https://docs.medusajs.com/learn/fundamentals/workflows/store-executions/index.html.md) - For programmatic access to execution details
+- [Workflow Execution States](https://docs.medusajs.com/user-guide/settings/developer/workflows#workflow-execution-status/index.html.md) - For understanding execution statuses in the admin
+
+
# Configure Instrumentation
In this chapter, you'll learn about observability in Medusa and how to configure instrumentation with OpenTelemetry.
@@ -20494,7 +20899,7 @@ For example, if you extended the `CartService` in v1 to add items with custom pr
import {
createWorkflow,
transform,
- WorkflowResponse
+ WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"
import { addToCartWorkflow } from "@medusajs/medusa/core-flows"
import {
@@ -20596,7 +21001,7 @@ For example:
```ts title="src/workflows/hello-world.ts"
import {
createWorkflow,
- WorkflowResponse
+ WorkflowResponse,
} from "@medusajs/framework/workflows-sdk"
export const helloWorldWorkflow = createWorkflow(
@@ -21230,7 +21635,7 @@ If your use case is complex and these rules are not enough, you can create a new
Medusa v1 has gift card features out-of-the-box.
-In Medusa v2, gift card features are now only available to [Medusa Cloud](https://medusajs.com/cloud/) users.
+In Medusa v2, gift card features are now only available to [Cloud](https://medusajs.com/cloud/) users.
***
@@ -101382,7 +101787,7 @@ Medusa's [Framework](https://docs.medusajs.com/docs/learn/fundamentals/framework
In a marketplace, a business or a vendor has a user, and they can use that user to authenticate and manage the vendor's data.
-You can create a marketplace module that implements data models for vendors, their admins, and any other data models that fits your use case.
+You can create a marketplace module that implements data models for vendors, their admins, and any other data models that fit your use case.
- [Create a Module](https://docs.medusajs.com/docs/learn/fundamentals/modules/index.html.md): Learn how to create a module.
- [Create Data Models](https://docs.medusajs.com/docs/learn/fundamentals/modules#1-create-data-model/index.html.md): Create data models in the module.
@@ -101442,7 +101847,7 @@ The Medusa Admin is an extensible application within your Medusa application. Yo
***
-## Build Dashbord for Vendors
+## Build Dashboard for Vendors
For more complex use cases, customizing the Medusa Admin may not be enough to allow vendors to manage their data.
diff --git a/www/apps/book/sidebar.mjs b/www/apps/book/sidebar.mjs
index 38e9b80695..f7d86b56ba 100644
--- a/www/apps/book/sidebar.mjs
+++ b/www/apps/book/sidebar.mjs
@@ -443,6 +443,11 @@ export const sidebars = [
path: "/learn/fundamentals/workflows/multiple-step-usage",
title: "Multiple Step Usage",
},
+ {
+ type: "ref",
+ path: "/learn/debugging-and-testing/debug-workflows",
+ title: "Debug Workflows",
+ },
],
},
{
@@ -604,6 +609,11 @@ export const sidebars = [
path: "/learn/debugging-and-testing/testing-tools/modules-tests",
title: "Modules Tests",
},
+ {
+ type: "link",
+ path: "/learn/debugging-and-testing/debug-workflows",
+ title: "Debug Workflows",
+ },
{
type: "link",
path: "/learn/debugging-and-testing/instrumentation",