Skip to content

Commit 065c884

Browse files
authored
Merge pull request #29 from jcberquist/v2
Update the Sentry event structure to match Sentry's current design
2 parents e71e39a + b9ab0ce commit 065c884

8 files changed

Lines changed: 762 additions & 572 deletions

File tree

.cfformat.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"array.empty_padding": false,
3+
"array.padding": true,
4+
"array.multiline.min_length": 50,
5+
"array.multiline.element_count": 2,
6+
"array.multiline.leading_comma.padding": true,
7+
"array.multiline.leading_comma": false,
8+
"alignment.consecutive.assignments": true,
9+
"alignment.consecutive.properties": true,
10+
"alignment.consecutive.params": true,
11+
"alignment.doc_comments" : true,
12+
"brackets.padding": true,
13+
"comment.asterisks": "align",
14+
"binary_operators.padding": true,
15+
"for_loop_semicolons.padding": true,
16+
"function_call.empty_padding": false,
17+
"function_call.padding": true,
18+
"function_call.multiline.leading_comma.padding": true,
19+
"function_call.casing.builtin": "cfdocs",
20+
"function_call.casing.userdefined": "camel",
21+
"function_call.multiline.element_count": 3,
22+
"function_call.multiline.leading_comma": false,
23+
"function_call.multiline.min_length": 50,
24+
"function_declaration.padding": true,
25+
"function_declaration.empty_padding": false,
26+
"function_declaration.multiline.leading_comma": false,
27+
"function_declaration.multiline.leading_comma.padding": true,
28+
"function_declaration.multiline.element_count": 3,
29+
"function_declaration.multiline.min_length": 50,
30+
"function_declaration.group_to_block_spacing": "compact",
31+
"function_anonymous.empty_padding": false,
32+
"function_anonymous.group_to_block_spacing": "compact",
33+
"function_anonymous.multiline.element_count": 3,
34+
"function_anonymous.multiline.leading_comma": false,
35+
"function_anonymous.multiline.leading_comma.padding": true,
36+
"function_anonymous.multiline.min_length": 50,
37+
"function_anonymous.padding": true,
38+
"indent_size": 4,
39+
"keywords.block_to_keyword_spacing": "spaced",
40+
"keywords.group_to_block_spacing": "spaced",
41+
"keywords.padding_inside_group": true,
42+
"keywords.spacing_to_block": "spaced",
43+
"keywords.spacing_to_group": true,
44+
"keywords.empty_group_spacing": false,
45+
"max_columns": 115,
46+
"metadata.multiline.element_count": 3,
47+
"metadata.multiline.min_length": 50,
48+
"method_call.chain.multiline" : 3,
49+
"newline":"\n",
50+
"property.multiline.element_count": 3,
51+
"property.multiline.min_length": 30,
52+
"parentheses.padding": true,
53+
"strings.quote": "double",
54+
"strings.attributes.quote": "double",
55+
"struct.separator": " : ",
56+
"struct.padding": true,
57+
"struct.empty_padding": false,
58+
"struct.multiline.leading_comma": false,
59+
"struct.multiline.leading_comma.padding": true,
60+
"struct.multiline.element_count": 2,
61+
"struct.multiline.min_length": 60,
62+
"tab_indent": true
63+
}

ModuleConfig.cfc

Lines changed: 93 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,99 @@
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+
*/
88
component {
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
}

box.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name":"Sentry",
33
"author":"Ortus Solutions <info@ortussolutions.com>",
4-
"version":"1.5.24",
4+
"version":"2.0.0",
55
"slug":"sentry",
66
"type":"modules",
77
"homepage":"https://github.com/coldbox-modules/sentry",
@@ -34,4 +34,4 @@
3434
"scripts":{
3535
"toMaster":"recipe build/toMaster.boxr"
3636
}
37-
}
37+
}

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
## 1.0.0
44

5-
* Create first module version
5+
* Create first module version
6+
7+
## 2.0.0
8+
9+
* Update the event structure to the new format Sentry has adopted for their official SDKs
10+
* Add support for the new `/api/{project_id}/envelope` endpoint Sentry has adopted for sending events
11+
* Don't send cookie and form scope data by default

0 commit comments

Comments
 (0)