You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report: customer.created Subscriber Not Triggering
Description
I've created a subscriber to trigger when a new customer is created using the customer.created event. It works fine when customers are created through the admin dashboard but does not trigger when customers are created via the API (Storefront).
In contrast, another subscriber I implemented for the order.placed event works as expected for all scenarios.
Code Examples
Here is the code for the customer.created subscriber:
importtype{SubscriberArgs,SubscriberConfig}from"@medusajs/medusa";import{Modules}from"@medusajs/utils";exportdefaultasyncfunctioncustomerCreatedHandler({event: { data },
container,}: SubscriberArgs<{id: string}>){constcustomerModuleService=container.resolve(Modules.CUSTOMER);constnotificationModuleService=container.resolve(Modules.NOTIFICATION);constcustomer=awaitcustomerModuleService.retrieveCustomer(data.id);// Your email sending logic hereconsole.log(`Customer created: ${customer.email}`);}exportconstconfig: SubscriberConfig={event: "customer.created",};
Expected Behavior
The customer.created event should trigger the subscriber when a customer is created via:
The admin dashboard.
The Storefront API.
Actual Behavior
The event only triggers when a customer is created using the admin dashboard. When creating a customer via the Storefront API:
The customer is created successfully.
Tokens are returned correctly.
The event is not triggered, and the subscriber does not run.
Steps to Reproduce
Implement the above customer.created subscriber in subscribers/test-sub.ts.
Create a customer using the admin dashboard → Event triggers correctly.
Create a customer via the Storefront API → Event does not trigger.
Additional Information
The following subscriber for order.placed works as expected in all scenarios:
import{Modules}from"@medusajs/utils";import{INotificationModuleService,IOrderModuleService}from"@medusajs/types";import{SubscriberArgs,SubscriberConfig}from"@medusajs/medusa";import{EmailTemplates}from"../modules/email-notifications/templates";exportdefaultasyncfunctionorderPlacedHandler({event: { data },
container,}: SubscriberArgs<any>){constnotificationModuleService: INotificationModuleService=container.resolve(Modules.NOTIFICATION);constorderModuleService: IOrderModuleService=container.resolve(Modules.ORDER);constorder=awaitorderModuleService.retrieveOrder(data.id,{relations: ["items","summary","shipping_address"],});constshippingAddress=await(orderModuleServiceasany).orderAddressService_.retrieve(order.shipping_address.id);try{awaitnotificationModuleService.createNotifications({to: order.email,channel: "email",template: EmailTemplates.ORDER_PLACED,data: {emailOptions: {replyTo: "[email protected]",subject: "Your order has been placed",},
order,
shippingAddress,preview: "Thank you for your order!",},});}catch(error){console.error("Error sending order confirmation notification:",error);}}exportconstconfig: SubscriberConfig={event: "order.placed",};
Questions
Is there a difference in how the customer.created event is emitted for the admin dashboard vs. Storefront API?
Am I missing any configuration for the subscriber to work with the Storefront API?
Environment
MedusaJS version: v2
Node.js version: v22.9.0
Storefront: Expo
How can this issue be resolved?
Ensure the Event is Emitted Correctly for customer.created via Stormfront API
if I'm Missing Something, please let me know
Are you interested in working on this issue?
I would like to fix this issue
The text was updated successfully, but these errors were encountered:
What Medusa version and documentation are you using?
v2
Preliminary Checks
Issue Summary
Bug Report:
customer.created
Subscriber Not TriggeringDescription
I've created a subscriber to trigger when a new customer is created using the
customer.created
event. It works fine when customers are created through the admin dashboard but does not trigger when customers are created via the API (Storefront).In contrast, another subscriber I implemented for the
order.placed
event works as expected for all scenarios.Code Examples
Here is the code for the
customer.created
subscriber:Expected Behavior
The
customer.created
event should trigger the subscriber when a customer is created via:Actual Behavior
The event only triggers when a customer is created using the admin dashboard. When creating a customer via the Storefront API:
Steps to Reproduce
customer.created
subscriber insubscribers/test-sub.ts
.Additional Information
The following subscriber for
order.placed
works as expected in all scenarios:Questions
customer.created
event is emitted for the admin dashboard vs. Storefront API?Environment
How can this issue be resolved?
customer.created
via Stormfront APIAre you interested in working on this issue?
The text was updated successfully, but these errors were encountered: