@@ -76,7 +76,7 @@ export class StepFunctionContextService {
76
76
if ( typeof event !== "object" ) return ;
77
77
78
78
// Extract Payload if available (Legacy lambda parsing)
79
- if ( typeof event . Payload === "object" ) {
79
+ if ( typeof event ? .Payload ?. _datadog === "object" || this . isValidContextObject ( event ?. Payload ) ) {
80
80
event = event . Payload ;
81
81
}
82
82
@@ -199,27 +199,26 @@ export class StepFunctionContextService {
199
199
state_entered_time : string ;
200
200
state_name : string ;
201
201
} | null {
202
- const execution = event . Execution ;
203
- const state = event . State ;
204
-
205
- if (
206
- typeof execution === "object" &&
207
- typeof execution . Id === "string" &&
208
- typeof state === "object" &&
209
- typeof state . EnteredTime === "string" &&
210
- typeof state . Name === "string"
211
- ) {
202
+ if ( this . isValidContextObject ( event ) ) {
212
203
return {
213
- execution_id : execution . Id ,
214
- state_entered_time : state . EnteredTime ,
215
- state_name : state . Name ,
204
+ execution_id : event . Execution . Id ,
205
+ state_entered_time : event . State . EnteredTime ,
206
+ state_name : event . State . Name ,
216
207
} ;
217
208
}
218
209
219
210
logDebug ( "Cannot extract StateMachine context! Invalid execution or state data." ) ;
220
211
return null ;
221
212
}
222
213
214
+ private isValidContextObject ( context : any ) : boolean {
215
+ return (
216
+ typeof context ?. Execution ?. Id === "string" &&
217
+ typeof context ?. State ?. EnteredTime === "string" &&
218
+ typeof context ?. State ?. Name === "string"
219
+ ) ;
220
+ }
221
+
223
222
/**
224
223
* Parse a list of trace tags such as [_dd.p.tid=66bcb5eb00000000,_dd.p.dm=-0] and return the
225
224
* value of the _dd.p.tid tag or an empty string if not found.
0 commit comments