docs: fix examples in Analytics Module docs (#13259)

* docs: fix example in Analytics Module docs

* generate
This commit is contained in:
Shahed Nasser
2025-08-20 18:06:41 +03:00
committed by GitHub
parent e022723e8b
commit a594d32ba3
5 changed files with 63 additions and 29 deletions
@@ -128,13 +128,14 @@ You'll first create a [workflow](!docs!/learn/fundamentals/workflows) that track
For example, create a workflow at `src/workflows/track-order-placed.ts` with the following content:
export const workflowHighlights = [
["13", "resolve", "Resolve the Analytics Module's service"],
["15", "track", "Track the event in the installed Analytics Module Provider"]
["14", "resolve", "Resolve the Analytics Module's service"],
["16", "track", "Track the event in the installed Analytics Module Provider"]
]
```ts title="src/workflows/track-order-created.ts" highlights={workflowHighlights}
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
import { Modules } from "@medusajs/framework/utils"
import { OrderDTO } from "@medusajs/framework/types"
@@ -149,11 +150,11 @@ const trackOrderCreatedStep = createStep(
await analyticsModuleService.track({
event: "order_created",
userId: order.customer_id,
actor_id: order.customer_id,
properties: {
order_id: order.id,
total: order.total,
items: order.items.map((item) => ({
items: order.items?.map((item) => ({
variant_id: item.variant_id,
product_id: item.product_id,
quantity: item.quantity,
@@ -184,7 +185,7 @@ export const trackOrderCreatedWorkflow = createWorkflow(
})
trackOrderCreatedStep({
order: orders[0],
})
} as unknown as StepInput)
}
)
```