v2.8.3

medusajs/medusav2.8.3May 22, 2025by olivermrbl

AI Summary

This release introduces a new Analytics module with official Posthog and local providers for server-side tracking of events and users.

Key Highlights

  • New Analytics module with `track` and `identify` methods.
  • Official Posthog provider integration for production tracking.
  • Local analytics provider for development environments.

New Features

  • Analytics module with Posthog provider.
  • Local analytics provider for development.

Full Release Notes

<!-- 
![2-8-3](https://gh-release-images.s3.eu-north-1.amazonaws.com/v2-8-3.png)

# v2.8.3: New Analytics module and a Posthog provider

This release introduces a new Analytics module for server-side tracking. The module comes with an official Posthog provider.

CMS_BREAK -->

## Highlights

### New Analytics module and Posthog provider

This release introduces a new Analytics module, allowing you to easily set up server-side tracking of events and users.

The module comes with two methods:
```ts
 /**
   * This method tracks an event in the analytics provider.
   *
   * @param {TrackAnalyticsEventDTO} data - The event's details.
   * @returns {Promise<void>} Resolves when the event is tracked successfully.
   *
   * @example
   * await analyticsModuleService.track({
   *   event: "order_placed",
   *   properties: {
   *     order_id: "order_123",
   *     customer_id: "customer_456",
   *     total: 100,
   *   }
   * })
   */
track(data: TrackAnalyticsEventDTO): Promise<void>

 /**
   * This method identifies an actor or group in the analytics provider.
   *
   * @param {IdentifyAnalyticsEventDTO} data - The details of the actor or group.
   * @returns {Promise<void>} Resolves when the actor or group is identified successfully.
   *
   * @example
   * await analyticsModuleService.identify({
   *   actor_id: "123",
   *   properties: {
   *     name: "John Doe"
   *   }
   * })
   */
identify(data: IdentifyAnalyticsEventDTO): Promise<void>
```

To configure the Analytics module, register it in the `modules` of your `medusa-config.ts`:
```ts
  ...
  modules: [
    ...,
    {
      resolve: "@medusajs/medusa/analytics",
      options: {
        providers: [{ ... }],
      },
    },
  ],
  ...
```

The Analytics module does not do much as is. You need to configure a provider responsible for handling the tracking. This release comes with two moduNopeles, `@medusajs/analytics-local` and `@medusajs/analytics-posthog`. The former will log the events and can be used for local development. The latter is an official integration with [Posthog](https://posthog.com/). 

The provider is installed like so:
```ts
  ...
  modules: [
    ...,
    {
      resolve: "@medusajs/medusa/analytics",
      options: {
        providers: [ 
          {
            resolve: "@medusajs/analytics-posthog",
            options: {
              posthogEventsKey: "<your-api-key>",
              posthogHost: "<your host>",
            }
          }
      }],
    },
  ],
  ...
```

Read more about the new module and providers in our [documentation](https://docs.medusajs.com/resources/infrastructure-modules/analytics).

## Features
* feat(index): Only run the synchronisation in worker/shared mode by @adrien2p in https://github.com/medusajs/medusa/pull/12530
* chore(product, modules-sdk): Add missing index for select-in strategy + allow to pass top level strategy to force the behaviour by @adrien2p in https://github.com/medusajs/medusa/pull/12508
* feat: Add an analytics module and local and posthog providers by @sradevski in https://github.com/medusajs/medusa/pull/12505
* feat: process import from pre-processed chunks by @thetutlage in https://github.com/medusajs/medusa/pull/12527
* feat: add presignedUrl method to upload sdk by @christiananese in https://github.com/medusajs/medusa/pull/12569

## Bugs
* fix: Skip migration if module is not installed by @sradevski in https://github.com/medusajs/medusa/pull/12507
* test: remove snapshots usage by @thetutlage in https://github.com/medusajs/medusa/pull/12516
* fix(utils): Missing zod deps by @adrien2p in https://github.com/medusajs/medusa/pull/12518
* fix(dashboard): refund payment formatting by @fPolic in https://github.com/medusajs/medusa/pull/12476
* fix(medusa): add estimate count to admin products by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/12467
* fix(index): Apply various fixes to the index engine by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/12501
* fix: Correctly import MedusaError in the analytics module by @sradevski in https://github.com/medusajs/medusa/pull/12542
* fix(product): Deep update data retrieval bottleneck by @adrien2p in https://github.com/medusajs/medusa/pull/12538
* fix: mark posthog-node as a peer dependency by @thetutlage in https://github.com/medusajs/medusa/pull/12539
* fix(js-sdk): allow passing custom request body parameters in auth.register method by @shahednasser in https://github.com/medusajs/medusa/pull/12545
* fix(core-flows): skip location check if inventory is not managed by @fPolic in https://github.com/medusajs/medusa/pull/12540
* fix(core-flows, types): export steps and types related to credit lines by @shahednasser in https://github.com/medusajs/medusa/pull/12567
* fix(product, utils): handle metadata key deletion on product update by @fPolic in https://github.com/medusajs/medusa/pull/12478

## Documentation
* docs: update recipe contents by @shahednasser in https://github.com/medusajs/medusa/pull/12515
* docs: add vale rule for Next.js Starter Storefront by @shahednasser in https://github.com/medusajs/medusa/pull/12517
* docs: change recipes on homepage by @shahednasser in https://github.com/medusajs/medusa/pull/12520
* docs: fix timeout in order-related workflows reference by @shahednasser in https://github.com/medusajs/medusa/pull/12533
* docs: added re-order guide by @shahednasser in https://github.com/medusajs/medusa/pull/12363
* chore(docs): Update npm command by @kashifaris in https://github.com/medusajs/medusa/pull/12547
* docs: show hooks in when condition in workflows reference by @shahednasser in https://github.com/medusajs/medusa/pull/12552
* docs-util: extract feature flags in generated OAS by @shahednasser in https://github.com/medusajs/medusa/pull/12554
* Fix: Incorrect Example File Name in Subscriber Section by @adityaerlangga in https://github.com/medusajs/medusa/pull/12560
* docs: improve module isolation chapter by @shahednasser in https://github.com/medusajs/medusa/pull/12565
* docs: show when condition in workflows reference by @shahednasser in https://github.com/medusajs/medusa/pull/12566

## Chores
* test(workflow-engine-redist): Update tests to ensure behaviour validation properly by @adrien2p in https://github.com/medusajs/medusa/pull/12514
* chore(test-cli-with-database): Update cli tag from latest to preview by @adrien2p in https://github.com/medusajs/medusa/pull/12529
* chore(index): return ids only by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/12543
* chore(core-flows): add tsdocs for hooks in complete cart by @shahednasser in https://github.com/medusajs/medusa/pull/12555
* chore(types, utils): update TSDocs related to analytics module by @shahednasser in https://github.com/medusajs/medusa/pull/12564
* chore(index): Few adjustments by @adrien2p in https://github.com/medusajs/medusa/pull/12557

## Other Changes
* Typo/index logs by @adrien2p in https://github.com/medusajs/medusa/pull/12528
* fix: Fix garbled characters in zhCN.json translation file by @imhuso in https://github.com/medusajs/medusa/pull/12537

## New Contributors
* @imhuso made their first contribution in https://github.com/medusajs/medusa/pull/12537
* @kashifaris made their first contribution in https://github.com/medusajs/medusa/pull/12547
* @adityaerlangga made their first contribution in https://github.com/medusajs/medusa/pull/12560

**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.8.2...v2.8.3