npm @medusajs/medusa 2.8.3
v2.8.3

latest releases: 2.10.2-preview-20250906120152, 2.10.2-preview-20250906090150, 2.10.2-preview-20250906060156...
3 months ago

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:

 /**
   * 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:

  ...
  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 modules, @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.

The provider is installed like so:

  ...
  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.

Features

  • feat(index): Only run the synchronisation in worker/shared mode by @adrien2p in #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 #12508
  • feat: Add an analytics module and local and posthog providers by @sradevski in #12505
  • feat: process import from pre-processed chunks by @thetutlage in #12527
  • feat: add presignedUrl method to upload sdk by @christiananese in #12569

Bugs

Documentation

Chores

Other Changes

New Contributors

Full Changelog: v2.8.2...v2.8.3

Don't miss a new medusa release

NewReleases is sending notifications on new releases.