Logging Custom Event Errors
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.
Build the app
This section assumes you have already created an app and are working on it within the Web Flows 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.
- Create a new Web Page and call it "Submit Error Web Page":
- 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:
- Add a Button Web Control and change the associated text to "Submit Error":
- 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.
- 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:
Upon completing the steps in this section, it is possible to publish this app as-is. The submitted error will be logged withthe other Airkit Events; it can be accessed in the Console, under the Activity section.
Set up Email Notifier
- Save your changes, exit theย Studio, and return to the Console. Access Settings > Logs and Notifiers.
- Scroll down to the Notifiers section and click on the associatedย Create new button.
- 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":
- Underย Destination, selectย Email:
- 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.)
- Click on theย Create button on the bottom right.
- 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.
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:
- 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:
- Expand the Notifications section:
- Underย Custom Log Error Event, select error_email_notification.
- Click theย Publish button on the bottom left of the window.
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!
- Access the published application via the designated link. This will appear in the window that opens upon publication:
It can also be found by inspecting the app in the Console:
- Enter some test information in the text box and press theย "Submit Error" button:
- 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.
Updated almost 3 years ago