npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lifecycle-notifier

v0.0.15

Published

This is the description of the plugin.

Downloads

25

Readme

Strapi Plugin - Lifecycle Notifier

The Lifecycle Notifier Strapi plugin is designed to add a lifecycle notification feature to your Strapi application. It allows you to track and receive notifications about important events happening in your application.

Features

  • Email notification when a new entity is created.
  • Email notification when an entity is updated.
  • Email notification when an entity is deleted.
  • Customization of email templates for notifications.
  • Easy and intuitive configuration via the Strapi administration interface.

Installation

To install the Lifecycle Notifier plugin, follow the steps below:

Make sure you have Strapi installed in your project.

Run the following command to install the plugin:

npm install lifecycle-notifier --save

Restart your Strapi server to apply the changes.

Log in to the Strapi administration interface, go to the "Lifecycle Notifier" section. Plugin item in the sidebar menu

Start adding subscriptions

To add a subscription form the admin interface, click on the "Add Subscription" button. Add fill the form in the modal.

| Field | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------- | | Subject | The subject of the subscription. It is used as Subject while sending the notification mail. | | Related collection | The name of the collection for which the subscription is created. | | Event to listen | The type of event for which the subscription will trigger (e.g., 'create', 'update', 'delete'). | | Recipient | Contains recipient information to receive the subscription notifications. | | Template | The content of the subscription notification. It can be in plain text or HTML template format. You can include the listened collection data using this syntax: <%= fieldName %> | | File to join | Contains information about media fields (fields of the listened collection) to include in the subscription. |

Template customization

The Template field allows you to define the content of the subscription notification. You can provide either plain text or an HTML template. The template can include dynamic placeholders that will be replaced with actual data from the listened collection when the notification is triggered.

Example: Let's say you have a subscription for the 'Product' collection to receive notifications when new products are created. Your template could look like this:

<h2>New Product Created!</h2>
<p>Hello <%= clientName %>,</p>
<p>We are excited to inform you that a new product has been added to our collection.</p>
<p>Product Details:</p>
<ul>
  <li><strong>Name:</strong> <%= productName %></li>
  <li><strong>Price:</strong> $<%= productPrice %></li>
  <li><strong>Category:</strong> <%= productCategory %></li>
</ul>
<p>Thank you for using our service!</p>

In this example, we have used placeholders like <%= clientName %>, <%= productName %>, <%= productPrice %>, and <%= productCategory %> in the HTML template. When the notification is triggered, these placeholders will be dynamically replaced with the actual data from the new product that triggered the event. For instance, if a new product with the name "Super Widget" and the price "$19.99" is added, the notification email will look like:

<h2>New Product Created!</h2>
<p>Hello John,</p>
<p>We are excited to inform you that a new product has been added to our collection.</p>
<p>Product Details:</p>
<ul>
  <li><strong>Name:</strong> Super Widget</li>
  <li><strong>Price:</strong> $19.99</li>
  <li><strong>Category:</strong> Electronics</li>
</ul>
<p>Thank you for using our service!</p>

Once the subscription is created, the plugin will automatically send the notification email when the event is triggered.

You cant also manage ( update, delete) subscriptions form the plugin home page.

Contribution Contributions are welcome! If you want to improve the Lifecycle Notifier plugin, please follow the steps below:

Fork this repository and clone it to your machine.

Install dependencies using npm install.

Make your modifications and improvements.

Test the changes with Strapi.

Submit a pull request with a detailed description of the changes made.

Recipient Types

The Recipient field can have three types: ENV, MODEL, and CUSTOM.

  • ENV (Environment Variable) Recipient: Recipients of type ENV are defined in the plugin configurations and must reference an environment variable that contains the email address. This allows you to dynamically set the recipient email based on the value of the specified environment variable. You can add it using the envRecipients config field. See example below
{
  // ...
  "lifecycle-notifier": {
    enabled: true,
    resolve: "../plugin",
    config: {
      envRecipients: ["TEST_RECIPIENT_EMAIL"],
    },
  },
  // ...
}
  • MODEL Recipient: Recipients of type MODEL reference the email field on the collection being listened to. This means that the email address for the recipient will be fetched from the email fields of the respective collection entry that triggered the notification. You can specify these fields within Recipient field in the subscription creation form.

  • CUSTOM Recipient: You can use this type when you add subscriptions in the plugins configurations. Learn more about how to add subscriptions in the plugins configurations below.

Adding subscriptions from plugin configurations

You can also add subscriptions from the plugin configuration. This allows you to keep subscription in you base code make independents on your database.

{
  // ...
  "lifecycle-notifier": {
    enabled: true,
    resolve: "../plugin",
    config: {
      subscriptions: [
        {
          collectionName: "api::planet.planet",
          eventType: "afterCreate",
          recipients: [
            {
              type: "CUSTOM",
              value: "[email protected]",
            },
          ],
          content: "Just send the name: <%= name =>",
          mediaFields: ["image"],
          createdAt: "2023-07-23T19:34:24.654Z",
          updatedAt: "2023-07-23T20:01:03.075Z",
          subject: "Testing subs in config",
        },
      ],
    },
  }
  // ...
}

Plugin configurations

Example configuration

// ...
{
  // Define environment variable recipients for the plugin. The plugin will fetch the email address from the environment variable "TEST_RECIPIENT_EMAIL".
  envRecipients: ["TEST_RECIPIENT_EMAIL"],

  // Set the default sender email address for the notifications using the value from the environment variable "DEFAULT_MAIL_FROM".
  defaultFrom: env("DEFAULT_MAIL_FROM"),

  // Define the list of subscriptions.
  subscriptions: [] 
}
// ...

Contributions

License

This plugin is distributed under the MIT license. See the LICENSE file for more information.