New event topics: mechanic/scheduler/15min, 30min

Our existing mechanic/scheduler/10min topic is now joined by mechanic/scheduler/15min and mechanic/scheduler/30min, for schedules that require running every 15 minutes or every half hour. :)

Read more

New filter: "match", for regular expressions

We introduce the "match" filter, which accepts a Ruby-compatible regular expression, and returns the matching string. Use {{ match.captures }} and {{ match.named_captures }} to retrieve captured values.

{{ "It's a lovely day!" | match: "(?<=a ).*(?= day)" }}
=> "lovely"

{% assign match = "It's a lovely day!" | match: "a (bucolic|lovely) day" %}
{{ match.captures }}
=> ["lovely"]

{% assign match = "It's a lovely day!" | match: "a (?<adjective>bucolic|lovely) day" %}
{{ match.named_captures.adjective }}
=> {"adjective"=>"lovely"}

{% assign match = "It's a lovely day!" | match: "a (?i:LOVELY) day" %}
{{ match }}
=> "a lovely day"

Read more

Updated filter: "date" now supports a "tz" option

To format dates in a timezone other than that of the current store, add the "tz" option.

{{ "now" | date: "%Y-%m-%d %H:%M %z" }}
=> "2019-01-01 09:00 +0900"

{{ "now" | date: "%Y-%m-%d %H:%M %z", tz: "UTC" }}
=> "2019-01-01 00:00 +0000"

Read more

New filter: sample

Use the "sample" filter to pull a random value or several random values from an array.

{{ "1,2,3" | split: "," | sample }} => "2"
{{ "1,2,3" | split: "," | sample: 2 | join: "," }} => "3,1"

Read more

New file generator: "base64"

Mechanic's file generators, used in both "email" and "ftp" actions, now support supplying arbitrary data when pre-encoded in base64. This fills the gap that occurred when file data could not be represented as a JSON string, as is the case with most images.

With this update, use this usage to supply an image or other file whose contents cannot be represented in UTF-8:

{% action "email" %}
    "attachments": {
      "helloworld.png": {
{% endaction %}

Read more

Past "run_at" values now allowed for "event" actions

Previously, a "run_at" value with a past datetime was not permitted for "event" actions. Because Mechanic's run system is not synchronous, this had the potential to cause issues when "run_at" was set to the current time, or to a value within a few seconds of the current time. In those cases, any delay between event creation and the performance of the event run gave rise to a "[time] is in the past, and can't be scheduled" error.

To bring the "run_at" mechanism into alignment with how Mechanic more broadly thinks about time and scheduling, we now allow "run_at" values to be set in the past. When an event is scheduled for the past, it will simply be run immediately, as if no "run_at" value was set.

Read more

Send a copy of email previews

A tiny useful feature: when viewing expanded previews for "email" actions, you may now send a copy of the previewed email to the address of your choice.

Useful for ensuring that emails render properly in your own email client, or for manually re-sending a message to the appropriate recipient. :)

New filter: graphql_arguments

To ease composition of GraphQL queries and mutations, we offer graphql_arguments. This filter formats values in the style of GraphQL arguments. These values can be used for the entirety of a GraphQL field's arguments, though it's also useful for building individual argument values.

Read more

Respond to action results with the "mechanic/actions/perform" event

It is now possible to feed the results of actions back into a task, allowing for a subsequent set of actions to be generated. By subscribing your task to the "mechanic/actions/perform" event, your task will run again for every action that that same task generates. This allows for varying behavior, based on the results of performed actions.

We anticipate common use cases to include reporting, and multi-stage Shopify API commands (notably, order editing).

Read more

Custom "from" addresses are now self-serviceable

Previously, configuring custom "from" email addresses required a fair amount of communication with customer support. Now, everything but an initial approval is fully self-serviceable, including DNS record configuration and verification.

Read more