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:
import type { SubscriberArgs, SubscriberConfig } from "@medusajs/medusa";
import { Modules } from "@medusajs/utils";
export default async function customerCreatedHandler({
event: { data },
container,
}: SubscriberArgs<{ id: string }>) {
const customerModuleService = container.resolve(Modules.CUSTOMER);
const notificationModuleService = container.resolve(Modules.NOTIFICATION);
const customer = await customerModuleService.retrieveCustomer(data.id);
// Your email sending logic here
console.log(`Customer created: ${customer.email}`);
}
export const config: 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";
export default async function orderPlacedHandler({
event: { data },
container,
}: SubscriberArgs<any>) {
const notificationModuleService: INotificationModuleService = container.resolve(Modules.NOTIFICATION);
const orderModuleService: IOrderModuleService = container.resolve(Modules.ORDER);
const order = await orderModuleService.retrieveOrder(data.id, {
relations: ["items", "summary", "shipping_address"],
});
const shippingAddress = await (orderModuleService as any).orderAddressService_.retrieve(order.shipping_address.id);
try {
await notificationModuleService.createNotifications({
to: order.email,
channel: "email",
template: EmailTemplates.ORDER_PLACED,
data: {
emailOptions: {
replyTo: "info@example.com",
subject: "Your order has been placed",
},
order,
shippingAddress,
preview: "Thank you for your order!",
},
});
} catch (error) {
console.error("Error sending order confirmation notification:", error);
}
}
export const config: 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
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?