Skip to content

Commit 41e6332

Browse files
authored
Merge pull request #25 from metrik-tech/feature/ENG-175
feature/eng 175: Fix /Error/Batch errors
2 parents dc26775 + 37f9267 commit 41e6332

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

Src/Services/LogCaptureService.luau

+20-12
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,17 @@ function LogCaptureService.OnMessageError(self: LogCaptureService, source: strin
130130
table.insert(self.MessageQueue, {
131131
["message"] = self:OmitUUIDsFromSource(message),
132132
["placeVersion"] = game.PlaceVersion,
133+
["placeId"] = game.PlaceId,
133134
["serverId"] = ApiService.JobId,
134135
["script"] = filePath,
135136
["trace"] = trace,
136137
["ancestors"] = ancestors,
137138
["breadcrumbs"] = breadcrumbs,
138-
["context"] = HttpService:JSONEncode(context)
139+
["context"] = context
139140
})
140141
end
141142

142143
function LogCaptureService.OnStart(self: LogCaptureService)
143-
ApiService.OnAuthenticated:Connect(function(readyPayload)
144-
for _, pattern in readyPayload.issues.customFilters do
145-
table.insert(self.RegexFilters.Custom, LuauRegex(pattern, "m"))
146-
end
147-
148-
for _, pattern in readyPayload.issues.presetFilters do
149-
table.insert(self.RegexFilters.Preset, LuauRegex(pattern, "m"))
150-
end
151-
end)
152-
153144
ScriptContext.Error:Connect(function(message: string, trace: string)
154145
self:OnMessageError(message, trace)
155146
end)
@@ -170,13 +161,30 @@ function LogCaptureService.OnStart(self: LogCaptureService)
170161

171162
ApiService:PostAsync(string.format(ApiPaths.ServerLogBatch, ApiService.ProjectId), {
172163
items = self.MessageQueue,
173-
})
164+
}):catch(function(error)
165+
-- todo: requeue errors
166+
167+
self.Reporter:Warn(`Failed to send log batch - `)
168+
self.Reporter:Warn(error)
169+
end)
174170

175171
self.MessageQueue = {}
176172
end
177173
end)
178174
end
179175

176+
function LogCaptureService.OnInit(self: LogCaptureService)
177+
ApiService.OnAuthenticated:Connect(function(readyPayload)
178+
for _, pattern in readyPayload.issues.customFilters do
179+
table.insert(self.RegexFilters.Custom, LuauRegex(pattern, "m"))
180+
end
181+
182+
for _, pattern in readyPayload.issues.presetFilters do
183+
table.insert(self.RegexFilters.Preset, LuauRegex(pattern, "m"))
184+
end
185+
end)
186+
end
187+
180188
export type LogCaptureService = typeof(LogCaptureService)
181189

182190
return LogCaptureService

0 commit comments

Comments
 (0)