Skip to content

Commit b234480

Browse files
committed
slug name detection
1 parent d625184 commit b234480

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/main.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,23 @@ func onStop() {
155155

156156
output := getLastOutput(state)
157157
ts := isoNow()
158-
if err := api.Patch("/traces/"+state.TraceID, map[string]interface{}{
158+
finalUpdate := map[string]interface{}{
159159
"project_name": config.Project,
160160
"end_time": ts,
161161
"output": map[string]string{"text": output},
162-
}); err != nil {
162+
}
163+
164+
// If slug was never sent, try one more time in the final update
165+
if !state.SlugSent {
166+
allEntries, err := ReadTranscript(state.Transcript, 0)
167+
if err == nil {
168+
if slug := findSlug(allEntries); slug != "" {
169+
finalUpdate["name"] = slug
170+
}
171+
}
172+
}
173+
174+
if err := api.Patch("/traces/"+state.TraceID, finalUpdate); err != nil {
163175
debugLog("update trace: %v", err)
164176
}
165177

@@ -295,7 +307,7 @@ func flush(state *State) {
295307
if len(updates) > 1 { // More than just project_name
296308
if err := api.Patch("/traces/"+state.TraceID, updates); err != nil {
297309
debugLog("update trace metadata: %v", err)
298-
} else {
310+
} else if slug != "" {
299311
state.SlugSent = true
300312
}
301313
}

0 commit comments

Comments
 (0)