How to Log a Custom Event Error and send an Email Notifier How to Log a Custom Event Error and send an Email Notifier

How to Log a Custom Event Error and send an Email Notifier

Chandra Bergmann Chandra Bergmann

In this document, we'll walk through the process of creating a Web Page that allows users to submit custom errors that are then logged as a Custom Event and flagged via an Email Notifier. 

The concepts covered in this document are relevant to the practicalities of using the Log Custom Event Action as well as publishing an app so that errors that occur within it are not only logged but also submitted via Email Notifier. Similar concepts are covered in Configuring App Error Notifications to Slack, which discusses Slack Notifiers as opposed to Email Notifiers and Application Errors as opposed to Custom Event Errors.

This guide walks through the following steps:

Build the app

This section assumes you have already created an app and are working on it within the Activity Builder in the Airkit Studio. The UI described can stand on its own if connected to a link in Journey Builder, or it can be part of a larger application flow (perhaps as a modal). 

1. Create a new Web Page and call it "Submit Error Web Page":

Screen_Shot_2021-10-20_at_3.08.42_PM.png

2. Add Text Area Input Box Web Control to the Submit Error Web Page. This is where users will submit their custom error messages. Note that, upon creation, the input is bound to the variable name text_area. Leave this as it is:

2021-10-20_15-12-34.png

3. Add a Button Web Control and change the associated text to "Submit Error":

Screen_Shot_2021-10-20_at_3.14.00_PM.png

4. While still inspecting the Submit Error Button, open the Actions tab in the Inspector to open the Action Builder. Click on the '+' icon to the right of the Clicked branch and add a Custom Log Event Action.

2021-10-20_15-16-18__1_.gif

5. Change the Event Message to "User submitted custom error", the Log Level to ERROR, and the Metadata to "User submitted the following message: {{text_area}}". Note the presence of quotation marks to designate strings, and the presence of double brackets to designate variables within those strings; this is required to be Airscript-parsable, and both Event Message and Metadata expect information in the form of Airscript:

:     Screen_Shot_2021-10-20_at_3.18.38_PM.png

Upon completing the steps in this section, it is possible to publish this app as-is. The submitted error will be logged with other the other Airkit Events; it can be accessed in the Console, under the Activity section.

Set up Email Notifier

1. Save your changes, exit the Studio, and return to the Console. Access Settings -> Logs and Notifiers.

       Screen_Shot_2021-10-20_at_3.19.58_PM.png

2. Scroll down to the Notifiers section and click on the associated Create New button.

2021-10-20_15-21-35.png

3. Clicking on this button will open the Inspector, which will contain the tools to define the details of the new notifier being created. Name this new notifier "error_email_notification":

Screen_Shot_2021-10-20_at_3.24.43_PM.png

4. Under Destination, select Email:

 Screen_Shot_2021-10-20_at_3.25.18_PM.png

5. Once Email is selected under Destination, a new input box labeled Email will appear beneath it. Enter the email address that you want to send custom error notifications to. (You will need to check this email address to see related notifications, so make sure you enter an email address that you can easily access.)

Screen_Shot_2021-10-20_at_3.26.05_PM.png

6. Click on the Create button on the bottom right.

Screen_Shot_2021-10-20_at_3.26.42_PM.png

7. Once a notifier is set up, you can test it by inspecting it and clicking on the Send Test button at the bottom of the Inspector. If properly set up, a test email should appear in the inbox of the designated email account.

Screen_Shot_2021-10-20_at_3.27.57_PM.png

Upon completing the steps in this section, you have created an Email Notifier. All apps within your Organization will have access to this notifier. It can be used by any app to send errors of any kind. There are no limits to the number of errors types that can be associated with a single notifier.

Publish Application

Most components of of Airkit apps can be tested by previewing them, but this is not the case with notifiers, because notifiers are set up as part of the publishing process. In order to confirm that an Email Notifier is properly sent when a Custom Event Error is logged, the following publishing procedure must be done first:

1. Return to accessing your App in the Airkit Studio and publish your application by clicking on the Publish button on the upper right. This will open the following window:

Screen_Shot_2021-10-20_at_4.26.18_PM.png

2. Expand the Notifications section:

Screen_Shot_2021-10-20_at_4.27.12_PM.png

3. Under Custom Log Error Event, select error_email_notification.

Screen_Shot_2021-10-20_at_4.27.44_PM.png

4. Click the Publish button on the bottom left of the window.

Screen_Shot_2021-10-20_at_4.28.25_PM.png

Upon completing the steps in this section, the application will be published, and any error submitted through the Log Custom Event Action will not only be logged with other the other Airkit Events, it will also be sent to the designated email address.

Test it out!

1. Access the published application via the designated link. This will appear in the window that opens upon publication:

Screen_Shot_2021-10-20_at_4.31.34_PM.png

It can also be found by inspecting the app in the Console:

Screen_Shot_2021-10-20_at_4.35.07_PM.png

2. Enter some test information in the text box and press the Submit Error button:

Screen_Shot_2021-10-20_at_4.32.47_PM.png

3. Check the relevant email inbox and look for the error message. Note how the message appears so that you can see the Event Message ("User submitted custom error") associated with the Log Custom Event Action, as well as the Metadata ("User submitted the following message: {{text_area}}"), which contains the test information as text_area.

image.png

Was this article helpful?

0 out of 0 found this helpful