Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Order
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 May 2020 at 14:08 UTC
Updated:
15 Jun 2020 at 16:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jsacksick commentedThe attached patch adds 2 log templates (one for when the email fails to be sent, and the other one on success).
I'm wondering whether we should create a log template per email sent? vs reusing a "generic" one, although we only send the order receipt from Commerce.
Also, the event subscriber that reacts to the email being sent just checks whether the mail id starts with "order_", so any other integration sending an email with an ID starting with "order_" is going to be logged.
The log templates could be improved, as well as the naming of the event introduced when an email is sent through the Commerce mail handler. (currently called
PostMailSend), since it's fired AFTER the email is sent.These are 2 log templates that were created:
Comment #3
mglamanWe could provide specific logs for known email key IDs and fallback to this if none exists.
Maybe follow a pattern of `mail_${key}`? That way users can also provide log templates for custom emails they send through our mail handler.
So provide a default `mail_order_receipt`, then someone could provide `mail_order_shipped` if they send an `order_shipped` email through our service (I currently do this.)
So we can check if the definition exists and use that or the fallback for the SUCCESS, and the generic failure on any failure.
This only handles order mail, so maybe we should rename it as such?
I've stopped grabbing entity storage in constructors, as it adds a little bit of overhead fetching the storage when it may not be used.
When collecting event subscribers, this will always be constructed and always fetch and instantiate the log storage.
Comment #4
jsacksick commentedAttached patch is addressing the feedbacks from #3.
Comment #5
mglaman🥳 looks great to me, this will definitely help customer support users
Comment #6
rszrama commentedI like the idea of logging failures, but it may be confusing what success or failure means in this context. A log message of:
Makes me wonder why the log says it was sent if the result was a failure; did it actually send? was the failure a lack of receipt by the customer? an error from an external email service? In reality, it just didn't send. I'm open to suggestions, but it seems better to have:
The problem is that seems to violate the expectation of log message templates. I can't tell if we'd have to register two templates per mail (successful send vs. failure) or perhaps just implement a single failure template for any email:
Using a specific template for failures may make it easier to add contextual links to log messages in the future (e.g. a link or button to attempt to redeliver that email in the stream), though I'm dependent on you to know what's really possible there.
Comment #7
jsacksick commentedMakes sense! Attached patch addresses the comment from #6 and also introduces a generic log template for "generic" order emails so that we still provide a message if no log template exists, both in case of failure and success.
Comment #8
rinasek commentedLooking good to me.
Comment #9
rszrama commented+1
Comment #11
mglaman🥳 Committed!