Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Distinguish user classes when publishing events

Damian Legawiec53c42d529af9
diff --git a/core/app/models/concerns/spree/user_methods.rb b/core/app/models/concerns/spree/user_methods.rb
index a5f3e33f3e..108a2c13e6 100644
--- a/core/app/models/concerns/spree/user_methods.rb
+++ b/core/app/models/concerns/spree/user_methods.rb
@@ -167,7 +167,11 @@ module Spree
end
def event_prefix
- 'user'
+ if self.class == Spree.admin_user_class && Spree.admin_user_class != Spree.user_class
+ 'admin'
+ else
+ 'user'
+ end
end
private
diff --git a/docs/developer/customization/event-subscribers.mdx b/docs/developer/customization/event-subscribers.mdx
index 578ce0ea7b..72df3b8d48 100644
--- a/docs/developer/customization/event-subscribers.mdx
+++ b/docs/developer/customization/event-subscribers.mdx
@@ -201,6 +201,22 @@ Models with lifecycle events enabled include: `Order`, `Payment`, `Price`, `Ship
| `product.out_of_stock` | Product has no stock left for any variant |
| `product.back_in_stock` | Product was out of stock and now has stock again |
+### Customer Events
+
+| Event | Description |
+|-------|-------------|
+| `customer.created` | Customer was created |
+| `customer.updated` | Customer was updated |
+| `customer.deleted` | Customer was deleted |
+
+### Admin Events
+
+| Event | Description |
+|-------|-------------|
+| `admin.created` | Admin user was created |
+| `admin.updated` | Admin user was updated |
+| `admin.deleted` | Admin user was deleted |
+
### Product Events
| Event | Description |