Skip to content

Commit 259e1fd

Browse files
committed
fix: add build ID to sent captures
1 parent a507359 commit 259e1fd

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/core/encryption.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ export async function decrypt(privateKeyString: string, ciphertext: string) {
241241
export async function encryptCapture(
242242
functions: CapturedFunction[],
243243
calls: CapturedCall[],
244+
buildId: string,
244245
publicKey: string,
245246
projectId: string,
246247
capturedUserId?: string,
@@ -287,6 +288,7 @@ export async function encryptCapture(
287288
outputs: encryptedOutputs,
288289
calls: linkedCalls,
289290
functions: linkedFunctions,
291+
buildId,
290292
...(encryptedError && {
291293
error: encryptedError
292294
})

src/core/storage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,20 @@ export async function saveCapture(
139139
}
140140
}
141141

142+
if (!config.buildId) {
143+
return Err(
144+
createHumanLog({
145+
events: ['capture_failed'],
146+
explanations: ['build_id_undefined'],
147+
solutions: ['configuration_fix']
148+
})
149+
)
150+
}
151+
142152
const encryptedCaptureResult = await encryptCapture(
143153
functions,
144154
calls,
155+
config.buildId,
145156
config.publicApiKey,
146157
config.projectId,
147158
getUserId(),

src/core/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export type DatabaseCapture = {
259259
capturedUserId?: string
260260
source?: SourceType
261261

262-
buildId?: string
262+
buildId: string
263263
}
264264

265265
export type CaptureDecrypted = Omit<DatabaseCapture, 'args' | 'outputs'> & {

test/excludes.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ describe('captureIgnores', () => {
157157
error: 'encrypted',
158158
functions: [],
159159
calls: [],
160-
projectId: 'mock-project-id'
160+
projectId: 'mock-project-id',
161+
buildId: 'mock-build-id'
161162
})
162163

163164
const mockCapturePayload = createMockCapturePayload({})

0 commit comments

Comments
 (0)