Cold Fusion

Documentation - Raygun4cmfl - ColdFusion Error Reporting

The raygun4cfml provider

Raygun4cfml is a library that you can add to your ColdFusion/CFML application. Once installed it will transmit all exceptions to your Raygun.io dashboard. Installation only takes a few minutes so you can start receiving error and crash reports right away.

Supported CFML engines:

  • Adobe ColdFusion 9+
  • Railo 4.0+
  • Lucee 4.5+

How do I get started with raygun4cfml?

Installation

The preferred method for getting this library is with the CommandBox package manager and ForgeBox:

box install raygun4cfml 

You can also download the library manually or by using git - see the instructions at the GitHub repository (linked below).

Instantiation

Pick one of the following options to use the code:

  • Put the content of /src into your webroot and instantiate RaygunClient through something like the following:
    raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
        apiKey = "YOURAPIKEYHERE"
    );
  • Put the contents of /src into any other place of your choice and create a mapping to /nz in your server administrator or through code and then use the instantiation code as above.
  • Put the contents of the raygun4cfml into a place of your choice where your CFML has some sort of a mapping pointing towards and and just instantiate RaygunClient like this:
    raygun = createObject("component","RaygunClient").init(
        apiKey = "YOURAPIKEYHERE"
    );

Example error handler

The following is an example for use in a global error handler template e.g cferror. It also demonstrates how you can add custom data to every message delivered to Raygun.

<cfscript>
    raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
        apiKey = "YOURAPIKEYHERE"
    );

    result = raygun.send(error);
</cfscript>

Configuration

Tags

Tags can be sent with each error like this:

tags = ["coding","db","sqlfail"];
raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
	apiKey = variables.RAYGUNAPIKEY
);

result = raygun.send(issueDataStruct=error,tags=tags);

Custom Data

Custom data objects can be created and sent with each error:

customUserDataStruct = {"session" = {"memberID" = "5747854", "memberFirstName" = "Kai"}, "params" = {"currentAction" = "IwasDoingThis", "justAnotherParam" = "test"}};
customUserData = createObject("nz.co.ventego-creative.raygun4cfml.RaygunUserCustomData").init(customUserDataStruct);

raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
	apiKey = variables.RAYGUNAPIKEY
);
result = raygun.send(issueDataStruct=error,userCustomData=customUserData);

Sending user data

Data for the affected user which experienced the error can be attached like this:

userIdentifier = createObject("nz.co.ventego-creative.raygun4cfml.RaygunIdentifierMessage").init(Identifier="test@test.com",isAnonymous=false,UUID="47e432fff11",FirstName="Test",Fullname="Tester");
    
raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
	apiKey = variables.RAYGUNAPIKEY
);

result = raygun.send(issueDataStruct=error,user=userIdentifier);

Filtering sensitive data

You can remove sensitive data (e.g financial data or credentials) from error payloads using a content filter:

filter = [{filter = "password", replacement = "__password__"}, {filter = "creditcard", replacement = "__ccnumber__"}];
contentFilter = createObject("nz.co.ventego-creative.raygun4cfml.RaygunContentFilter").init(filter);

raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
    apiKey =  variables.RAYGUNAPIKEY,
    contentFilter = contentFilter
);

result = raygun.send(error);

Raygun4cfml GitHub Repository

To get the source code, visit the GitHub repository here.

Documentation missing?

If we don't have documentation about your desired topic, send us a message and we'll create it for you.