v2.5.1

medusajs/medusav2.5.1Feb 24, 2025by olivermrbl

AI Summary

This release improves admin extensibility by supporting loaders, handles, and outlet routes. It also expands instrumentation options and improves structural logging capabilities.

Key Highlights

  • Support for outlet routes, loader, and handle in admin route files.
  • Expanded `registerOtel` options to support all OpenTelemetry NodeSDK options (e.g., Sentry).
  • Enriched structural logging with request ID, size, duration, and more.
  • Allow custom storage solutions in the JS-SDK.

New Features

  • Add support for outlet routes, loader, and handle
  • Allow all NodeSDK options via registerOtel
  • Add support for idempotency key in payments
  • Improve production structured logging
  • Add support to update account holder

Full Release Notes

<!-- 
![image](https://github.com/user-attachments/assets/f5a9d21f-515f-4621-8f0d-65dbb10f8ea4)

# v2.5.1

This release improves our admin extensibility tooling and server instrumentation capabilities.

CMS_BREAK -->

## Highlights

### Support outlet routes, loader, and handle

This release introduces support for
- exporting a loader from a route file
- exporting a handle from a route file

Here's an example using the loader and handle:
```tsx
// src/admin/routes/articles/[id]/page.tsx
import { Button, Container, Heading } from "@medusajs/ui";
import { Link, LoaderFunctionArgs, Outlet, UIMatch, useLoaderData } from "react-router-dom";

export async function loader({ params }: LoaderFunctionArgs) {
  const { id } = params;

  return {
    id,
  };
}

export const handle = {
  breadcrumb: (match: UIMatch<{ id: string }>) => {
    const { id } = match.params;
    return `#${id}`;
  },
};

const ProfilePage = () => {
  const { id } = useLoaderData() as Awaited<ReturnType<typeof loader>>;

  return (
    <div>
      <Container className="flex justify-between items-center">
        <Heading>Article {id}</Heading>
        <Button size="small" variant="secondary" asChild>
          <Link to="edit">Edit</Link>
        </Button>
      </Container>
      {/* This will be used for the next example of an Outlet route */}
      <Outlet />
    </div>
  );
};

export default ProfilePage;
```

In the above example we are passing data to the route from a loader, and defining a breadcrumb using the handle.

See more in https://github.com/medusajs/medusa/pull/11305.

### Expand options for instrumentation via `registerOtel`

This release expands the available options in our `registerOtel` function from our instrumentation tooling. More specifically, the function will allow all options from OpenTelemetry's NodeSDK, which will open up support for a broader range of instrumentation tools, including Sentry. 

Here's an example of configuring Sentry:
```ts
import Sentry from '@sentry/node'
import otelApi from "@opentelemetry/api";
import { registerOtel } from "@medusajs/medusa"
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc" 
import { SentrySpanProcessor, SentryPropagator } from "@sentry/opentelemetry-node"

Sentry.init({
  dsn: "<INSERT SENTRY DSN>",
  tracesSampleRate: 1.0,
  instrumenter: "otel",
});

otelApi.propagation.setGlobalPropagator(new SentryPropagator());

export function register() {
  registerOtel({
    serviceName: "medusa",
    spanProcessor: new SentrySpanProcessor(),
    traceExporter: new OTLPTraceExporter(),
    instrument: {
      http: true,
      workflows: true,
      query: true
    },
  })
}
```

See more in https://github.com/medusajs/medusa/pull/11460.

### Enrich and improve structural logging

This release improves structural logging by expanding the data with additional information, including request ID, request size, response size, request duration, and more.

Here's an example log line:
```
{"level":"http","client_ip":"10.18.85.250","request_id":"53123ef7-f8e9-4e85-8aea-3fecfc7d9ba0","http_version":"1.1","method":"POST","path":"/admin/products","status":200,"response_size":"10754","request_size":"1550","duration":1079.301,"referrer":"-","user_agent":"node","timestamp":"2025-02-24T08:36:17.748Z"}
```

See more in https://github.com/medusajs/medusa/pull/11489. 

### Allow custom storage in JS-SDK

This release introduces support for a custom storage solution in the JS-SDK, instead of using the built-in `memory`, `session`, and `local`. This allows you to pass a custom implementation of the storage interface to be responsible for token management. 

See more in https://github.com/medusajs/medusa/pull/11467.

## What's Changed
### Features
* feat: query.index by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/11348
* feat(dashboard,admin-vite-plugin): Add support for outlet routes, loader, and handle by @kasperkristensen in https://github.com/medusajs/medusa/pull/11305
* feat: allow all NodeSDK options via registerOtel by @thetutlage in https://github.com/medusajs/medusa/pull/11460
* feat(dashboard): Pickup option changes by @fPolic in https://github.com/medusajs/medusa/pull/11306
* feat(): Backport metadata management by @adrien2p in https://github.com/medusajs/medusa/pull/11469
* feat(ui,dashboard): Move InlineTip to UI package by @kasperkristensen in https://github.com/medusajs/medusa/pull/11462
* feat: Add support for idempotency key in payments by @sradevski in https://github.com/medusajs/medusa/pull/11494
* feat(framework): Improve production structured logging with more valuable information as well by @adrien2p in https://github.com/medusajs/medusa/pull/11489
* feat(core-flows, dashboard, medusa, types): optional shipping profile by @fPolic in https://github.com/medusajs/medusa/pull/11434
* feat: Add support to update account holder by @sradevski in https://github.com/medusajs/medusa/pull/11499
* feat(medusa): Rollout index engine behind feature flag by @adrien2p in https://github.com/medusajs/medusa/pull/11431
* feat(core-flows, types): add has missing inventory flag when listing shipping options by @fPolic in https://github.com/medusajs/medusa/pull/11493
### Bugs
* fix(dashboard): secret key display by @fPolic in https://github.com/medusajs/medusa/pull/11365
* fix(utils): custom linkable keys by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/11400
* fix(admin-vite-plugin,admin-bundler,ui,icons,dashboard,framework,types): Update Vite dependencies by @kasperkristensen in https://github.com/medusajs/medusa/pull/11414
* fix: Remove unnecessary swc production dependency by @sradevski in https://github.com/medusajs/medusa/pull/11416
* fix(core-flows, types): reservation of shared inventory item by @fPolic in https://github.com/medusajs/medusa/pull/11403
* fix(payment): update payment session data by @fPolic in https://github.com/medusajs/medusa/pull/11410
* fix(medusa): Fix draft order validator, and endpoint by @kasperkristensen in https://github.com/medusajs/medusa/pull/11398
* fix(design-system): singleton prompt by @fPolic in https://github.com/medusajs/medusa/pull/11352
* fix: listVariantsList types by @thetutlage in https://github.com/medusajs/medusa/pull/11441
* fix: relationships to accept ids by @thetutlage in https://github.com/medusajs/medusa/pull/11399
* fix(medusa): Re throw error in instrumentation after reporting it by @adrien2p in https://github.com/medusajs/medusa/pull/11464
* fix(medusa): Allow filtering by handle and title as arrays by @kasperkristensen in https://github.com/medusajs/medusa/pull/11472
* fix(core-flows): Fix line item ids passed to deleteReservationsByLineItemsStep by @kasperkristensen in https://github.com/medusajs/medusa/pull/11465
* fix(types): fix shipping profile type optional in create type / method by @shahednasser in https://github.com/medusajs/medusa/pull/11453
* fix(dashboard): Fix size of buttons and use Link to navigate by @kasperkristensen in https://github.com/medusajs/medusa/pull/11366
* fix: generate posix paths for migrations by @thetutlage in https://github.com/medusajs/medusa/pull/11468
* fix(dashboard): Allow using the Enter key in product create Textarea by @kasperkristensen in https://github.com/medusajs/medusa/pull/11488
* fix(dashboard): Properly delete metadata keys, and fix number parsing by @kasperkristensen in https://github.com/medusajs/medusa/pull/11466
* fix(framework): add missing storefrontUrl from configuration type by @shahednasser in https://github.com/medusajs/medusa/pull/11511
* fix(core-flows): add no_notification to fulfillment created event by @riqwan in https://github.com/medusajs/medusa/pull/11507
* fix: allow setting DB_PORT and DATABASE_URL env variables by @thetutlage in https://github.com/medusajs/medusa/pull/11519
* fix: typings for list payment method were incorrect by @sradevski in https://github.com/medusajs/medusa/pull/11523
* fix(dashboard): Prevent overfetching data by @adrien2p in https://github.com/medusajs/medusa/pull/11532
* fix(utils): Handle 0 correctly in build query by @olivermrbl in https://github.com/medusajs/medusa/pull/11525
* fix(medusa,js-sdk,types): Add basic draft order operations to js-sdk by @kasperkristensen in https://github.com/medusajs/medusa/pull/11514
* fix(): handle empty q filters - allow to query deleted records from graph API - staled_at fixes by @adrien2p in https://github.com/medusajs/medusa/pull/11544
* fix(order): calculate taxes on order edit flows by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/11518
* fix(core-flows): Allow adding shipping methods through order edits by @kasperkristensen in https://github.com/medusajs/medusa/pull/11504
* fix(js-sdk): Export Draft Order methods by @kasperkristensen in https://github.com/medusajs/medusa/pull/11572
### Documentation
* docs: update default for medusa start by @shahednasser in https://github.com/medusajs/medusa/pull/11391
* docs: document payment changes + account holder by @shahednasser in https://github.com/medusajs/medusa/pull/11242
* docs: add documentation for product <> shipping profile link by @shahednasser in https://github.com/medusajs/medusa/pull/11397
* docs: general updates after 2.5.0 update by @shahednasser in https://github.com/medusajs/medusa/pull/11402
* docs: added express checkout guide by @shahednasser in https://github.com/medusajs/medusa/pull/10810
* docs: small fixes to workflow constraints chapter by @shahednasser in https://github.com/medusajs/medusa/pull/11421
* docs: fix managing relationship for hasOne by @shahednasser in https://github.com/medusajs/medusa/pull/11422
* docs: add section on validating module options by @shahednasser in https://github.com/medusajs/medusa/pull/11427
* docs-util: fix inline code escape in generated references by @shahednasser in https://github.com/medusajs/medusa/pull/11428
* docs: add section on middleware registration by @shahednasser in https://github.com/medusajs/medusa/pull/11433
* docs: add section on pagination for query context by @shahednasser in https://github.com/medusajs/medusa/pull/11432
* docs: Include `shipping_profile_id` in product creation request by @aceof10 in https://github.com/medusajs/medusa/pull/11436
* docs: add missing shipping_profile_id in create product snippets by @shahednasser in https://github.com/medusajs/medusa/pull/11443
* docs: fix link to troubleshooting by @shahednasser in https://github.com/medusajs/medusa/pull/11448
* docs: fix digital products recipe by adding shipping profile to snippets by @shahednasser in https://github.com/medusajs/medusa/pull/11452
* chore: improvements to provider docs by @shahednasser in https://github.com/medusajs/medusa/pull/11451
* docs: add how to upload files in tests by @shahednasser in https://github.com/medusajs/medusa/pull/11455
* docs: document configuring request body parsing by @shahednasser in https://github.com/medusajs/medusa/pull/11463
* docs: update user guide introduction page by @shahednasser in https://github.com/medusajs/medusa/pull/11474
* docs: update tips in user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11477
* docs: add array filter with comma in requests by @shahednasser in https://github.com/medusajs/medusa/pull/11478
* docs: update orders user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11498
* docs: update products user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11506
* docs: update inventory user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11509
* docs: update customers user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11512
* docs: add sections on predefined environment and global variables by @shahednasser in https://github.com/medusajs/medusa/pull/11510
* docs: add missing details in product import user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11527
* docs: update promotions user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11524
* docs: update price lists user guides by @shahednasser in https://github.com/medusajs/medusa/pull/11528
* docs: update store user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11530
* docs: update users user guide by @shahednasser in https://github.com/medusajs/medusa/pull/11531
* docs: many improvements to settings user guides by @shahednasser in https://github.com/medusajs/medusa/pull/11536
* docs: fix typos + clarify example in UI docs by @shahednasser in https://github.com/medusajs/medusa/pull/11543
* docs: fixes to wishlist plugin guide by @shahednasser in https://github.com/medusajs/medusa/pull/11551
### Chores
* chore(admin-sdk): Pin Zod version by @kasperkristensen in https://github.com/medusajs/medusa/pull/11413
* chore(core-flows): update TSDocs of createProductsWorkflow by @shahednasser in https://github.com/medusajs/medusa/pull/11439
* chore: add an action that generates documentation files in PRs by @shahednasser in https://github.com/medusajs/medusa/pull/11423
* chore: fix the generate action by passing the token by @shahednasser in https://github.com/medusajs/medusa/pull/11473
* chore: remove action to generate prep files for docs by @shahednasser in https://github.com/medusajs/medusa/pull/11475
* Chore(index): Sync logs management by @adrien2p in https://github.com/medusajs/medusa/pull/11522
* chore(cli): Prevent swallowing error in non production env by @adrien2p in https://github.com/medusajs/medusa/pull/11534
* chore: Force select-in strategy by passing pagination through by @olivermrbl in https://github.com/medusajs/medusa/pull/11556
### Other Changes
* feat: added hook for createApiKeysWorkflow by @IgorKhomenko in https://github.com/medusajs/medusa/pull/10909
* refactor(ui): rename folder for calendar components by @pnodet in https://github.com/medusajs/medusa/pull/11369
* docs: Fix typos in productsCreated hook by @martinerko in https://github.com/medusajs/medusa/pull/11276
* docs: fix incorrect path by @Ishrathh in https://github.com/medusajs/medusa/pull/11435
* Update page.mdx by @saranshisatgit in https://github.com/medusajs/medusa/pull/11459
* refactor: remove host from the server ready log by @thetutlage in https://github.com/medusajs/medusa/pull/11485
* feat(js-sdk): implement custom storage config to support react native by @ranjithkumar8352 in https://github.com/medusajs/medusa/pull/11467
* feat: Adding Bulgarian language to the admin dashboard. by @gbachev in https://github.com/medusajs/medusa/pull/11565

## New Contributors
* @martinerko made their first contribution in https://github.com/medusajs/medusa/pull/11276
* @aceof10 made their first contribution in https://github.com/medusajs/medusa/pull/11436
* @saranshisatgit made their first contribution in https://github.com/medusajs/medusa/pull/11459
* @gbachev made their first contribution in https://github.com/medusajs/medusa/pull/11565

**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.5.0...v2.5.1