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
- fix: Skip migration if module is not installed by @sradevski in #12507
- test: remove snapshots usage by @thetutlage in #12516
- fix(utils): Missing zod deps by @adrien2p in #12518
- fix(dashboard): refund payment formatting by @fPolic in #12476
- fix(medusa): add estimate count to admin products by @carlos-r-l-rodrigues in #12467
- fix(index): Apply various fixes to the index engine by @carlos-r-l-rodrigues in #12501
- fix: Correctly import MedusaError in the analytics module by @sradevski in #12542
- fix(product): Deep update data retrieval bottleneck by @adrien2p in #12538
- fix: mark posthog-node as a peer dependency by @thetutlage in #12539
- fix(js-sdk): allow passing custom request body parameters in auth.register method by @shahednasser in #12545
- fix(core-flows): skip location check if inventory is not managed by @fPolic in #12540
- fix(core-flows, types): export steps and types related to credit lines by @shahednasser in #12567
- fix(product, utils): handle metadata key deletion on product update by @fPolic in #12478
Documentation
- docs: update recipe contents by @shahednasser in #12515
- docs: add vale rule for Next.js Starter Storefront by @shahednasser in #12517
- docs: change recipes on homepage by @shahednasser in #12520
- docs: fix timeout in order-related workflows reference by @shahednasser in #12533
- docs: added re-order guide by @shahednasser in #12363
- chore(docs): Update npm command by @kashifaris in #12547
- docs: show hooks in when condition in workflows reference by @shahednasser in #12552
- docs-util: extract feature flags in generated OAS by @shahednasser in #12554
- Fix: Incorrect Example File Name in Subscriber Section by @adityaerlangga in #12560
- docs: improve module isolation chapter by @shahednasser in #12565
- docs: show when condition in workflows reference by @shahednasser in #12566
Chores
- test(workflow-engine-redist): Update tests to ensure behaviour validation properly by @adrien2p in #12514
- chore(test-cli-with-database): Update cli tag from latest to preview by @adrien2p in #12529
- chore(index): return ids only by @carlos-r-l-rodrigues in #12543
- chore(core-flows): add tsdocs for hooks in complete cart by @shahednasser in #12555
- chore(types, utils): update TSDocs related to analytics module by @shahednasser in #12564
- chore(index): Few adjustments by @adrien2p in #12557
Other Changes
- Typo/index logs by @adrien2p in #12528
- fix: Fix garbled characters in zhCN.json translation file by @imhuso in #12537
New Contributors
- @imhuso made their first contribution in #12537
- @kashifaris made their first contribution in #12547
- @adityaerlangga made their first contribution in #12560
Full Changelog: v2.8.2...v2.8.3