fix: avoid skill file telemetry detail lookup

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Nicky LeachandPaperclip committed 2026-07-15 00:39:09 +00:00
1 parent 9d693d796f
commit c695f00fe4
2 files changed
+32 -8

No files matched your search

@@ -1117,6 +1117,10 @@ describe("company skill mutation permissions", () => {
type: "user",
userId: "user-1",
});
expect(mockCompanySkillService.detail).toHaveBeenCalledWith("company-1", "skill-1", {
type: "user",
userId: "user-1",
});
expect(mockTrackSkillVersionSaved).toHaveBeenCalledWith(expect.anything(), {
skill_id: "skill-1",
revision_number: 7,
@@ -1124,6 +1128,23 @@ describe("company skill mutation permissions", () => {
});
});
it("does not load skill detail for file saves when telemetry is disabled", async () => {
mockGetTelemetryClient.mockReturnValue(null);
const app = await createApp({ type: "board", source: "local_implicit", userId: "user-1" });
await request(app)
.patch("/api/companies/company-1/skills/skill-1/files")
.send({ path: "SKILL.md", content: "# Updated" })
.expect(200);
expect(mockCompanySkillService.updateFile).toHaveBeenCalledWith("company-1", "skill-1", "SKILL.md", "# Updated", {
type: "user",
userId: "user-1",
});
expect(mockCompanySkillService.detail).not.toHaveBeenCalled();
expect(mockTrackSkillVersionSaved).not.toHaveBeenCalled();
});
it("deletes skill files and logs the mutation", async () => {
const app = await createApp({ type: "board", source: "local_implicit", userId: "user-1" });
+11 -8
View File
@@ -980,14 +980,17 @@ export function companySkillRoutes(db: Db) {
markdown: result.markdown,
},
});
const updatedSkill = await svc.detail(companyId, skillId, skillActor(req));
const currentVersion = updatedSkill?.currentVersion ?? null;
if (currentVersion) {
emitSkillTelemetry((client) => trackSkillVersionSaved(client, {
skill_id: skillId,
revision_number: currentVersion.revisionNumber,
file_type: result.kind,
}));
const telemetryClient = getTelemetryClient();
if (telemetryClient) {
const updatedSkill = await svc.detail(companyId, skillId, skillActor(req));
const currentVersion = updatedSkill?.currentVersion ?? null;
if (currentVersion) {
trackSkillVersionSaved(telemetryClient, {
skill_id: skillId,
revision_number: currentVersion.revisionNumber,
file_type: result.kind,
});
}
}
res.json(result);