@@ -129,7 +129,14 @@ export class ServerAnalytics {
129129 * Track standardized MCP telemetry events
130130 */
131131 async track ( event : AnalyticsEvent ) : Promise < void > {
132- if ( ! this . enabled ) return ;
132+ console . log ( `[ANALYTICS] Attempting to track event: ${ event . event } ` ) ;
133+ console . log ( `[ANALYTICS] Analytics enabled: ${ this . enabled } ` ) ;
134+ console . log ( `[ANALYTICS] Write key present: ${ ! ! this . writeKey } ` ) ;
135+
136+ if ( ! this . enabled ) {
137+ console . log ( `[ANALYTICS] Analytics disabled, skipping event: ${ event . event } ` ) ;
138+ return ;
139+ }
133140
134141 try {
135142 const payload = {
@@ -146,6 +153,8 @@ export class ServerAnalytics {
146153 timestamp : new Date ( ) . toISOString ( )
147154 } ;
148155
156+ console . log ( `[ANALYTICS] Sending event to Segment:` , JSON . stringify ( payload , null , 2 ) ) ;
157+
149158 // Send to Segment's HTTP API
150159 const response = await fetch ( 'https://api.segment.io/v1/track' , {
151160 method : 'POST' ,
@@ -156,11 +165,17 @@ export class ServerAnalytics {
156165 body : JSON . stringify ( payload )
157166 } ) ;
158167
168+ console . log ( `[ANALYTICS] Segment API response: ${ response . status } ${ response . statusText } ` ) ;
169+
159170 if ( ! response . ok ) {
160- console . warn ( `Analytics tracking failed: ${ response . status } ${ response . statusText } ` ) ;
171+ const responseText = await response . text ( ) ;
172+ console . warn ( `[ANALYTICS] Tracking failed: ${ response . status } ${ response . statusText } ` ) ;
173+ console . warn ( `[ANALYTICS] Response body:` , responseText ) ;
174+ } else {
175+ console . log ( `[ANALYTICS] Successfully sent event: ${ event . event } ` ) ;
161176 }
162177 } catch ( error ) {
163- console . warn ( 'Analytics tracking error:' , error ) ;
178+ console . warn ( '[ANALYTICS] Tracking error:' , error ) ;
164179 }
165180 }
166181
0 commit comments