@indigoai-us/hq-cloud 6.14.3 → 6.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/bin/sync-runner-company.d.ts +1 -0
  2. package/dist/bin/sync-runner-company.d.ts.map +1 -1
  3. package/dist/bin/sync-runner-company.js +44 -19
  4. package/dist/bin/sync-runner-company.js.map +1 -1
  5. package/dist/bin/sync-runner.d.ts.map +1 -1
  6. package/dist/bin/sync-runner.js +25 -36
  7. package/dist/bin/sync-runner.js.map +1 -1
  8. package/dist/bin/sync-runner.test.js +128 -4
  9. package/dist/bin/sync-runner.test.js.map +1 -1
  10. package/dist/cli/reindex.d.ts.map +1 -1
  11. package/dist/cli/reindex.js +209 -29
  12. package/dist/cli/reindex.js.map +1 -1
  13. package/dist/cli/reindex.test.js +116 -37
  14. package/dist/cli/reindex.test.js.map +1 -1
  15. package/dist/cli/rescue-clone-diagnostics.test.d.ts +2 -0
  16. package/dist/cli/rescue-clone-diagnostics.test.d.ts.map +1 -0
  17. package/dist/cli/rescue-clone-diagnostics.test.js +101 -0
  18. package/dist/cli/rescue-clone-diagnostics.test.js.map +1 -0
  19. package/dist/cli/rescue-core.d.ts.map +1 -1
  20. package/dist/cli/rescue-core.js +28 -6
  21. package/dist/cli/rescue-core.js.map +1 -1
  22. package/dist/cli/share.js +11 -22
  23. package/dist/cli/share.js.map +1 -1
  24. package/dist/cli/share.test.js +40 -0
  25. package/dist/cli/share.test.js.map +1 -1
  26. package/dist/cli/sync.d.ts.map +1 -1
  27. package/dist/cli/sync.js +16 -14
  28. package/dist/cli/sync.js.map +1 -1
  29. package/dist/cli/sync.test.js +73 -0
  30. package/dist/cli/sync.test.js.map +1 -1
  31. package/dist/watcher.d.ts +1 -1
  32. package/dist/watcher.d.ts.map +1 -1
  33. package/dist/watcher.js +5 -6
  34. package/dist/watcher.js.map +1 -1
  35. package/dist/watcher.test.js +54 -0
  36. package/dist/watcher.test.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/bin/sync-runner-company.ts +50 -22
  39. package/src/bin/sync-runner.test.ts +147 -4
  40. package/src/bin/sync-runner.ts +49 -54
  41. package/src/cli/reindex.test.ts +130 -37
  42. package/src/cli/reindex.ts +198 -28
  43. package/src/cli/rescue-clone-diagnostics.test.ts +120 -0
  44. package/src/cli/rescue-core.ts +32 -8
  45. package/src/cli/share.test.ts +47 -0
  46. package/src/cli/share.ts +16 -26
  47. package/src/cli/sync.test.ts +90 -0
  48. package/src/cli/sync.ts +16 -14
  49. package/src/watcher.test.ts +59 -0
  50. package/src/watcher.ts +6 -8
package/src/cli/sync.ts CHANGED
@@ -722,18 +722,20 @@ export async function reportNewFilesToNotify(
722
722
  }),
723
723
  signal: controller.signal,
724
724
  });
725
- void emitCloudTelemetry(telemetryClient, {
726
- eventName: "new_files_notification_reported",
727
- source: "hq-sync",
728
- companyUid,
729
- properties: {
730
- result: response.ok ? "success" : "failure",
731
- fileCount: batch.length,
732
- batchIndex,
733
- batchCount,
734
- statusCode: response.status,
735
- },
736
- }, { claims: telemetryClaims });
725
+ if (!response.ok) {
726
+ void emitCloudTelemetry(telemetryClient, {
727
+ eventName: "new_files_notification_reported",
728
+ source: "hq-sync",
729
+ companyUid,
730
+ properties: {
731
+ status: "failure",
732
+ fileCount: batch.length,
733
+ batchIndex,
734
+ batchCount,
735
+ statusCode: response.status,
736
+ },
737
+ }, { claims: telemetryClaims });
738
+ }
737
739
  } catch (err) {
738
740
  // Best-effort per chunk: never let notification reporting affect the sync
739
741
  // result, and a failed chunk must not abort the remaining chunks.
@@ -743,11 +745,11 @@ export async function reportNewFilesToNotify(
743
745
  source: "hq-sync",
744
746
  companyUid,
745
747
  properties: {
746
- result: "failure",
748
+ status: "failure",
747
749
  fileCount: batch.length,
748
750
  batchIndex,
749
751
  batchCount,
750
- errorCode: safeErrorName(err),
752
+ errorClass: safeErrorName(err),
751
753
  },
752
754
  }, { claims: telemetryClaims });
753
755
  } finally {
@@ -12,6 +12,7 @@ import {
12
12
  import { StaticFlagProvider } from "./sync/feature-flags.js";
13
13
  import type { PushEvent } from "./sync/push-event.js";
14
14
  import type { PushTransport } from "./sync/push-transport.js";
15
+ import type { TelemetryEventsBatch } from "./vault-client.js";
15
16
 
16
17
  /**
17
18
  * US-001 — Phase 1 test harness: watch-triggered push seam + latency assertion.
@@ -736,4 +737,62 @@ describe("PushEventEmitter — directory and delete tombstone handling", () => {
736
737
  expect(published[0]).not.toHaveProperty("contentHash");
737
738
  expect(published[0]).not.toHaveProperty("mtime");
738
739
  });
740
+
741
+ it("emits push telemetry only when publication fails", async () => {
742
+ const posts: TelemetryEventsBatch[] = [];
743
+ const telemetryClient = {
744
+ postTelemetryEvents: vi.fn(async (batch: TelemetryEventsBatch) => {
745
+ posts.push(batch);
746
+ return { ok: true, written: batch.events.length, skipped: [] };
747
+ }),
748
+ };
749
+ const changed = path.join(dir, "changed.md");
750
+ fs.writeFileSync(changed, "changed");
751
+ const success = new PushEventEmitter({
752
+ originTenantId: "tenant-indigo",
753
+ originDeviceId: "device-a",
754
+ transport: {
755
+ start: async () => {},
756
+ dispose: async () => {},
757
+ connected: true,
758
+ publish: async () => {},
759
+ },
760
+ flagProvider: new StaticFlagProvider(["tenant-indigo"]),
761
+ telemetryClient,
762
+ });
763
+
764
+ await success.emitForBatch({ paths: new Map([[changed, "changed.md"]]) });
765
+ await flushImmediate();
766
+ expect(posts).toEqual([]);
767
+
768
+ const failed = new PushEventEmitter({
769
+ originTenantId: "tenant-indigo",
770
+ originDeviceId: "device-a",
771
+ transport: {
772
+ start: async () => {},
773
+ dispose: async () => {},
774
+ connected: true,
775
+ publish: async () => {
776
+ throw new Error("network down");
777
+ },
778
+ },
779
+ flagProvider: new StaticFlagProvider(["tenant-indigo"]),
780
+ telemetryClient,
781
+ onError: vi.fn(),
782
+ });
783
+
784
+ await failed.emitForBatch({ paths: new Map([[changed, "changed.md"]]) });
785
+ await flushImmediate();
786
+ expect(posts.flatMap((post) => post.events)).toEqual([
787
+ expect.objectContaining({
788
+ eventName: "push_event_failed",
789
+ properties: {
790
+ kind: "upsert",
791
+ count: 1,
792
+ status: "failure",
793
+ stage: "publish",
794
+ },
795
+ }),
796
+ ]);
797
+ });
739
798
  });
package/src/watcher.ts CHANGED
@@ -989,7 +989,7 @@ export class PushEventEmitter {
989
989
  this.onError(err instanceof Error ? err : new Error(String(err)), {
990
990
  relativePath,
991
991
  });
992
- this.emitPublishTelemetry("push_event_failed", "unknown", "capture");
992
+ this.emitPublishFailureTelemetry("unknown", "capture");
993
993
  return;
994
994
  }
995
995
 
@@ -1025,31 +1025,29 @@ export class PushEventEmitter {
1025
1025
 
1026
1026
  try {
1027
1027
  await this.transport.publish(event);
1028
- this.emitPublishTelemetry("push_event_published", event.kind, "publish");
1029
1028
  } catch (err) {
1030
1029
  // Push failure (network / non-2xx / timeout). The cadence poll is the
1031
1030
  // safety net — log + continue, never throw.
1032
1031
  this.onError(err instanceof Error ? err : new Error(String(err)), {
1033
1032
  relativePath,
1034
1033
  });
1035
- this.emitPublishTelemetry("push_event_failed", event.kind, "publish");
1034
+ this.emitPublishFailureTelemetry(event.kind, "publish");
1036
1035
  }
1037
1036
  }
1038
1037
 
1039
- private emitPublishTelemetry(
1040
- eventName: "push_event_published" | "push_event_failed",
1038
+ private emitPublishFailureTelemetry(
1041
1039
  kind: string,
1042
- stage: string,
1040
+ stage: "capture" | "publish",
1043
1041
  ): void {
1044
1042
  void emitCloudTelemetry(
1045
1043
  this.telemetryClient,
1046
1044
  {
1047
- eventName,
1045
+ eventName: "push_event_failed",
1048
1046
  source: "watcher",
1049
1047
  properties: {
1050
1048
  kind,
1051
1049
  count: 1,
1052
- result: eventName === "push_event_published" ? "success" : "failure",
1050
+ status: "failure",
1053
1051
  stage,
1054
1052
  },
1055
1053
  },