diff --git a/changelog.md b/changelog.md index 1408a17..8627281 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed - [Issue #37](https://github.com/coldbox-modules/sentry/issues/37) - Fix var-scoping inside conditional + ## [2.1.4] - 2024-12-24 ### Fixed - [Issue #37](https://github.com/coldbox-modules/sentry/issues/37) - Resolves an ACF incompat issue where traceparent variable was not available in threaded logging diff --git a/models/SentryService.cfc b/models/SentryService.cfc index e75d1c7..cf47fe7 100644 --- a/models/SentryService.cfc +++ b/models/SentryService.cfc @@ -647,6 +647,7 @@ component accessors=true singleton { var header = ""; var timeVars = getTimeVars(); var httpRequestData = getHTTPDataForRequest(); + var traceParent = httpRequestData.headers.traceParent ?: ""; // Add global metadata arguments.captureStruct[ "event_id" ] = lCase( replace( createUUID(), "-", "", "all" ) ); @@ -673,7 +674,6 @@ component accessors=true singleton { var thisUserInfo = { "ip_address" : getRealIP() }; var userInfoUDF = getUserInfoUDF(); - var traceParent = ""; // If there is a closure to produce user info, call it if ( isCustomFunction( userInfoUDF ) ) { // Check for a non-ColdBox context @@ -691,8 +691,7 @@ component accessors=true singleton { ); } - // Assemble any trace parent data - var traceParent = httpRequestData.headers.traceParent ?: ""; + // Assemble any trace parent data from coldbox if ( !len( traceParent ) && !isNull( coldbox ) ) { // Append any trace information which might be provided the `cbotel` module var prc = coldbox