11/**
2- *********************************************************************************
3- * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4- * www.ortussolutions.com
5- * ---
6- * Module Config.
7- */
2+ *********************************************************************************
3+ * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
4+ * www.ortussolutions.com
5+ * ---
6+ * Module Config.
7+ */
88component {
99
1010 // Module Properties
11- this .title = ' sentry' ;
12- this .author = ' Ortus Solutions' ;
13- this .webURL = ' https://www.ortussolutions.com' ;
14- this .description = ' A module to log and send bug reports to Sentry' ;
15- this .version = ' @build.version@+@build.number@' ;
11+ this .title = " sentry" ;
12+ this .author = " Ortus Solutions" ;
13+ this .webURL = " https://www.ortussolutions.com" ;
14+ this .description = " A module to log and send bug reports to Sentry" ;
15+ this .version = " @build.version@+@build.number@" ;
1616 // If true, looks for views in the parent first, if not found, then in the module. Else vice-versa
17- this .viewParentLookup = true ;
17+ this .viewParentLookup = true ;
1818 // If true, looks for layouts in the parent first, if not found, then in module. Else vice-versa
1919 this .layoutParentLookup = true ;
20- this .cfmapping = " sentry" ;
21- this .dependencies = [ ' funclinenums' ];
20+ this .cfmapping = " sentry" ;
21+ this .dependencies = [ " funclinenums" ];
2222
2323 // STATIC SCRUB FIELDS
24- variables .SCRUB_FIELDS = [ ' passwd' , ' password' , ' password_confirmation' , ' secret' , ' confirm_password' , ' secret_token' , ' APIToken' , ' x-api-token' , ' fwreinit' ];
25- variables .SCRUB_HEADERS = [ ' x-api-token' , ' Authorization' ];
24+ variables .SCRUB_FIELDS = [
25+ " passwd" ,
26+ " password" ,
27+ " password_confirmation" ,
28+ " secret" ,
29+ " confirm_password" ,
30+ " secret_token" ,
31+ " APIToken" ,
32+ " x-api-token" ,
33+ " fwreinit"
34+ ];
35+ variables .SCRUB_HEADERS = [ " x-api-token" , " Authorization" ];
2636
2737 /**
28- * Configure
29- */
38+ * Configure
39+ */
3040 function configure (){
3141 settings = {
3242 // Sentry token
33- ' ServerSideToken' = ' ' ,
34- // Enable the Sentry LogBox Appender Bridge
35- ' enableLogBoxAppender' = true ,
36- ' async' = true ,
37- // Min/Max levels for appender
38- ' levelMin' = ' FATAL' ,
39- ' levelMax' = ' ERROR' ,
40- // Enable/disable error logging
41- ' enableExceptionLogging' = true ,
42- // Data sanitization, scrub fields and headers, replaced with "[Filtered]" at runtime
43- ' scrubFields' = [],
44- ' scrubHeaders' = [],
45- ' release' = ' ' ,
46- ' environment' = (! isNull ( controller ) ? controller .getSetting ( ' environment' ) : ' ' ),
47- ' DSN' = ' ' ,
48- ' publicKey' = ' ' ,
49- ' privateKey' = ' ' ,
50- ' projectID' = 0 ,
51- ' sentryUrl' = ' https://sentry.io' ,
52- ' serverName' = cgi .server_name ,
53- ' appRoot' = expandPath (' /' ),
54- ' sentryVersion' = 7 ,
43+ " ServerSideToken" : " " ,
44+ // Enable the Sentry LogBox Appender Bridge
45+ " enableLogBoxAppender" : true ,
46+ " async" : true ,
47+ // Min/Max levels for appender
48+ " levelMin" : " FATAL" ,
49+ " levelMax" : " ERROR" ,
50+ // Enable/disable error logging
51+ " enableExceptionLogging" : true ,
52+ // Sentry recommends not sending cookie and form data by default
53+ " sendCookies" : false ,
54+ " sendPostData" : false ,
55+ // Data sanitization, scrub fields and headers, replaced with "[Filtered]" at runtime
56+ " scrubFields" : [],
57+ " scrubHeaders" : [],
58+ " release" : " " ,
59+ " environment" : ( ! isNull ( controller ) ? controller .getSetting ( " environment" ) : " " ),
60+ " DSN" : " " ,
61+ " publicKey" : " " ,
62+ " privateKey" : " " ,
63+ " projectID" : 0 ,
64+ " sentryUrl" : " https://sentry.io" ,
65+ // posting to "#sentryUrl#/api/#projectID#/store" is deprecated, but backward compatible
66+ // set to "envelope" to send events to modern "#sentryUrl#/api/#projectID#/envelope"
67+ " sentryEventEndpoint" : " store" ,
68+ " serverName" : cgi .server_name ,
69+ " appRoot" : expandPath ( " /" ),
70+ " sentryVersion" : 7 ,
5571 // This is not arbitrary but must be a specific value. Leave as "cfml"
5672 // https://docs.sentry.io/development/sdk-dev/attributes/
57- ' platform' = ' cfml' ,
58- ' logger' = ( ! isNull ( controller ) ? controller .getSetting ( ' appName' ) : ' sentry' ),
59- ' userInfoUDF' = ' ' ,
60- ' extraInfoUDFs' = {}
73+ " platform" : " cfml" ,
74+ " logger" : ( ! isNull ( controller ) ? controller .getSetting ( " appName" ) : " sentry" ),
75+ " userInfoUDF" : " " ,
76+ " extraInfoUDFs" : {}
6177 };
62-
78+
6379 // Try to look up the release based on a box.json
64- if ( ! isNull ( appmapping ) ) {
65- var boxJSONPath = expandPath ( ' / ' & appmapping & ' /box.json' );
66- if ( fileExists ( boxJSONPath ) ) {
80+ if ( ! isNull ( appmapping ) ) {
81+ var boxJSONPath = expandPath ( " / " & appmapping & " /box.json" );
82+ if ( fileExists ( boxJSONPath ) ) {
6783 var boxJSONRaw = fileRead ( boxJSONPath );
68- if ( isJSON ( boxJSONRaw ) ) {
84+ if ( isJSON ( boxJSONRaw ) ) {
6985 var boxJSON = deserializeJSON ( boxJSONRaw );
70- if ( boxJSON .keyExists ( ' version' ) ) {
86+ if ( boxJSON .keyExists ( " version" ) ) {
7187 settings .release = boxJSON .version ;
72- if ( boxJSON .keyExists ( ' slug' ) ) {
73- settings .release = boxJSON .slug & ' @ ' & settings .release ;
74- } else if ( boxJSON .keyExists ( ' name' ) ) {
75- settings .release = boxJSON .name & ' @ ' & settings .release ;
88+ if ( boxJSON .keyExists ( " slug" ) ) {
89+ settings .release = boxJSON .slug & " @ " & settings .release ;
90+ } else if ( boxJSON .keyExists ( " name" ) ) {
91+ settings .release = boxJSON .name & " @ " & settings .release ;
7692 }
7793 }
7894 }
79- }
95+ }
8096 }
81-
8297 }
8398
8499 /**
@@ -88,9 +103,9 @@ component {
88103 // Incorporate defaults into settings
89104 settings .scrubFields .addAll ( SCRUB_FIELDS );
90105 settings .scrubHeaders .addAll ( SCRUB_HEADERS );
91-
106+
92107 // Load the LogBox Appenders
93- if ( settings .enableLogBoxAppender ){
108+ if ( settings .enableLogBoxAppender ) {
94109 loadAppenders ();
95110 }
96111 }
@@ -99,27 +114,23 @@ component {
99114 * Fired when the module is unregistered and unloaded
100115 */
101116 function onUnload (){
102-
103117 }
104118
105119 /**
106120 * Trap exceptions and send them to Sentry
107121 */
108122 function onException ( event , interceptData , buffer ){
109- if ( ! settings .enableExceptionLogging ){
123+ if ( ! settings .enableExceptionLogging ) {
110124 return ;
111125 }
112- if ( wirebox .containsInstance ( ' SentryService@sentry' ) ) {
113- var sentryService = wirebox .getInstance ( ' SentryService@sentry' );
114-
115- sentryService .captureException (
116- exception = interceptData .exception ,
117- level = ' error'
118- );
126+ if ( wirebox .containsInstance ( " SentryService@sentry" ) ) {
127+ var sentryService = wirebox .getInstance ( " SentryService@sentry" );
128+
129+ sentryService .captureException ( exception = interceptData .exception , level = " error" );
119130 }
120131 }
121132
122- // **************************************** PRIVATE ************************************************//
133+ // **************************************** PRIVATE ************************************************//
123134
124135 /**
125136 * Load LogBox Appenders
@@ -131,13 +142,13 @@ component {
131142
132143 // Register tracer appender
133144 rootConfig = logBoxConfig.getRoot();
134- logBoxConfig.appender(
135- name = 'sentry_appender',
145+ logBoxConfig.appender(
146+ name = 'sentry_appender',
136147 class = '#moduleMapping#.models.SentryAppender',
137148 levelMin = settings.levelMin,
138149 levelMax = settings.levelMax
139150 );
140- logBoxConfig.root(
151+ logBoxConfig.root(
141152 levelMin = rootConfig.levelMin,
142153 levelMax = rootConfig.levelMax,
143154 appenders= listAppend( rootConfig.appenders, 'sentry_appender')
@@ -146,17 +157,17 @@ component {
146157 // Store back config
147158 logBox.configure( logBoxConfig );*/
148159
149- logBox .registerAppender (
150- name = ' sentry_appender' ,
151- class = ' #moduleMapping #.models.SentryAppender' ,
152- levelMin = logBox .logLevels [ settings .levelMin ],
153- levelMax = logBox .logLevels [ settings .levelMax ]
154- );
155-
156- var appenders = logBox .getAppendersMap ( ' sentry_appender' );
157- // Register the appender with the root loggger, and turn the logger on.
158- var root = logBox .getRootLogger ();
159- root .addAppender ( appenders [ ' sentry_appender' ] );
160+ logBox .registerAppender (
161+ name = " sentry_appender" ,
162+ class = " #moduleMapping #.models.SentryAppender" ,
163+ levelMin = logBox .logLevels [ settings .levelMin ],
164+ levelMax = logBox .logLevels [ settings .levelMax ]
165+ );
166+
167+ var appenders = logBox .getAppendersMap ( " sentry_appender" );
168+ // Register the appender with the root loggger, and turn the logger on.
169+ var root = logBox .getRootLogger ();
170+ root .addAppender ( appenders [ " sentry_appender" ] );
160171 }
161172
162173}
0 commit comments