@copilotkit/web-inspector 1.64.2-canary.rc-1 → 1.64.2

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.
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ const DEFAULT_WINDOW_SIZE = {
39
39
  };
40
40
  const DOCKED_LEFT_WIDTH = 500;
41
41
  const MAX_AGENT_EVENTS = 200;
42
+ const MAX_PENDING_BANNER_VIEWED = 20;
42
43
  const MAX_TOTAL_EVENTS = 500;
43
44
  const INTELLIGENCE_SIGNUP_URL = "https://go.copilotkit.ai/intelligence-signup";
44
45
  const THREADS_INTELLIGENCE_SIGNIN_URL = "https://dashboard.operations.copilotkit.ai/sign-in";
@@ -3545,8 +3546,8 @@ var WebInspectorElement = class extends lit.LitElement {
3545
3546
  this.announcementPromise = null;
3546
3547
  this.showAnnouncementPreview = true;
3547
3548
  this.announcementExpanded = false;
3548
- this.viewedBannerTimestamps = /* @__PURE__ */ new Set();
3549
- this.pendingBannerViewed = null;
3549
+ this.viewedBannerSurfaces = /* @__PURE__ */ new Set();
3550
+ this.pendingBannerViewed = [];
3550
3551
  this.clickedBannerIds = /* @__PURE__ */ new Set();
3551
3552
  this.viewedThreadsTelemetryStates = /* @__PURE__ */ new Set();
3552
3553
  this.viewedExampleThreadIds = /* @__PURE__ */ new Set();
@@ -3658,7 +3659,7 @@ var WebInspectorElement = class extends lit.LitElement {
3658
3659
  this.hasCustomPosition.button = true;
3659
3660
  if (this.draggedDuringInteraction) this.ignoreNextButtonClick = true;
3660
3661
  }
3661
- } else if (context === "button" && !this.isOpen && !this.draggedDuringInteraction) this.openInspector();
3662
+ } else if (context === "button" && !this.isOpen && !this.draggedDuringInteraction) this.openInspector("floating_button");
3662
3663
  this.resetPointerTracking();
3663
3664
  };
3664
3665
  this.handlePointerCancel = (event) => {
@@ -3679,7 +3680,7 @@ var WebInspectorElement = class extends lit.LitElement {
3679
3680
  }
3680
3681
  if (!this.isOpen) {
3681
3682
  event.preventDefault();
3682
- this.openInspector();
3683
+ this.openInspector("floating_button");
3683
3684
  }
3684
3685
  };
3685
3686
  this.handleClosePointerDown = (event) => {
@@ -3834,11 +3835,7 @@ var WebInspectorElement = class extends lit.LitElement {
3834
3835
  };
3835
3836
  this.handleDismissAnnouncementPreview = (event) => {
3836
3837
  event.stopPropagation();
3837
- this.handleDismissAnnouncement();
3838
- };
3839
- this.handleDismissAnnouncement = () => {
3840
- this.trackBannerClickedOnce({ cta: "dismiss" });
3841
- this.markAnnouncementSeen();
3838
+ this.dismissAnnouncement("collapsed_preview");
3842
3839
  };
3843
3840
  this.copyResetTimeouts = /* @__PURE__ */ new WeakMap();
3844
3841
  this.handleAnnouncementContentClick = (event) => {
@@ -5989,12 +5986,15 @@ ${argsString}</pre
5989
5986
  this.setDragging(false);
5990
5987
  this.draggedDuringInteraction = false;
5991
5988
  }
5992
- openInspector() {
5989
+ openInspector(source) {
5993
5990
  if (this.isOpen) return;
5991
+ const hadUnseenAnnouncement = this.hasUnseenAnnouncement;
5994
5992
  this.showAnnouncementPreview = false;
5995
5993
  this.ensureAnnouncementLoading();
5996
5994
  this.isOpen = true;
5997
5995
  this.persistState();
5996
+ this.trackOpened(source, hadUnseenAnnouncement);
5997
+ this.maybeTrackBannerViewed();
5998
5998
  if (this.dockMode !== "floating") this.applyDockStyles();
5999
5999
  this.ensureWindowPlacement();
6000
6000
  this.requestUpdate();
@@ -6270,6 +6270,31 @@ ${argsString}</pre
6270
6270
  </div>
6271
6271
  `;
6272
6272
  }
6273
+ trackOpened(source, hadUnseenAnnouncement) {
6274
+ if (this.core?.telemetryDisabled) return;
6275
+ require_telemetry.trackInspectorOpened({
6276
+ open_source: source,
6277
+ ...this.runtimeStatus === "connected" ? {
6278
+ license_status: this.core?.licenseStatus ?? void 0,
6279
+ runtime_mode: this.core?.runtimeMode ?? void 0
6280
+ } : {},
6281
+ runtime_url_type: require_telemetry.getRuntimeUrlType(this.core?.runtimeUrl),
6282
+ has_unseen_announcement: hadUnseenAnnouncement
6283
+ });
6284
+ }
6285
+ trackBannerDismissedOnce(surface) {
6286
+ if (this.core?.telemetryDisabled) return;
6287
+ const id = this.announcementTimestamp;
6288
+ if (!id) return;
6289
+ const key = `${id}:dismissed:${surface}`;
6290
+ if (this.clickedBannerIds.has(key)) return;
6291
+ this.clickedBannerIds.add(key);
6292
+ require_telemetry.trackBannerDismissed({
6293
+ banner_id: id,
6294
+ surface,
6295
+ cta_label: this.announcementCtaLabel ?? void 0
6296
+ });
6297
+ }
6273
6298
  trackBannerClickedOnce(opts) {
6274
6299
  if (this.core?.telemetryDisabled) return;
6275
6300
  const id = this.announcementTimestamp;
@@ -8491,7 +8516,7 @@ ${prettyEvent}</pre
8491
8516
  <button
8492
8517
  class="announcement-dismiss ml-auto"
8493
8518
  type="button"
8494
- @click=${this.handleDismissAnnouncement}
8519
+ @click=${() => this.dismissAnnouncement("expanded_card")}
8495
8520
  aria-label="Dismiss announcement"
8496
8521
  >
8497
8522
  ${this.renderIcon("X")}
@@ -8522,14 +8547,48 @@ ${prettyEvent}</pre
8522
8547
  </button>
8523
8548
  </div>`;
8524
8549
  }
8550
+ /**
8551
+ * Which announcement surface is on screen right now, or null when the
8552
+ * announcement isn't visible. Mirrors the render gates in
8553
+ * `renderAnnouncementPreview` (bubble) and `renderAnnouncementBanner`
8554
+ * (in-panel card) — opening the panel clears `showAnnouncementPreview`, so
8555
+ * the two are mutually exclusive.
8556
+ */
8557
+ getVisibleBannerSurface() {
8558
+ if (!this.hasUnseenAnnouncement) return null;
8559
+ if (this.isOpen) return this.announcementHtml ? "expanded_card" : null;
8560
+ return this.showAnnouncementPreview && this.announcementPreviewText ? "collapsed_preview" : null;
8561
+ }
8562
+ /**
8563
+ * Records a `banner_viewed` impression for whichever surface is currently
8564
+ * visible, once per announcement per surface.
8565
+ */
8566
+ maybeTrackBannerViewed() {
8567
+ const id = this.announcementTimestamp;
8568
+ if (!id) return;
8569
+ const surface = this.getVisibleBannerSurface();
8570
+ if (!surface) return;
8571
+ const key = `${id}:${surface}`;
8572
+ if (this.viewedBannerSurfaces.has(key)) return;
8573
+ if (this.pendingBannerViewed.length >= MAX_PENDING_BANNER_VIEWED) return;
8574
+ this.viewedBannerSurfaces.add(key);
8575
+ this.pendingBannerViewed.push({
8576
+ banner_id: id,
8577
+ surface,
8578
+ cta_label: this.announcementCtaLabel ?? void 0
8579
+ });
8580
+ this.flushPendingBannerViewed();
8581
+ }
8525
8582
  flushPendingBannerViewed() {
8526
- if (!this.pendingBannerViewed || this.core?.telemetryDisabled) {
8527
- this.pendingBannerViewed = null;
8583
+ if (this.pendingBannerViewed.length === 0) return;
8584
+ if (this.core?.telemetryDisabled) {
8585
+ this.pendingBannerViewed = [];
8528
8586
  return;
8529
8587
  }
8530
8588
  if (this.runtimeStatus !== "connected") return;
8531
- require_telemetry.trackBannerViewed(this.pendingBannerViewed);
8532
- this.pendingBannerViewed = null;
8589
+ const queued = this.pendingBannerViewed;
8590
+ this.pendingBannerViewed = [];
8591
+ for (const props of queued) require_telemetry.trackBannerViewed(props);
8533
8592
  }
8534
8593
  ensureAnnouncementLoading() {
8535
8594
  if (this.announcementPromise || typeof window === "undefined" || typeof fetch === "undefined") return;
@@ -8557,7 +8616,12 @@ ${prettyEvent}</pre
8557
8616
  }
8558
8617
  handleAnnouncementPreviewClick() {
8559
8618
  this.showAnnouncementPreview = false;
8560
- this.openInspector();
8619
+ this.openInspector("announcement_preview");
8620
+ }
8621
+ dismissAnnouncement(surface) {
8622
+ this.trackBannerClickedOnce({ cta: "dismiss" });
8623
+ this.trackBannerDismissedOnce(surface);
8624
+ this.markAnnouncementSeen();
8561
8625
  }
8562
8626
  async fetchAnnouncement() {
8563
8627
  try {
@@ -8577,14 +8641,7 @@ ${prettyEvent}</pre
8577
8641
  this.showAnnouncementPreview = this.hasUnseenAnnouncement;
8578
8642
  this.announcementHtml = await this.convertMarkdownToHtml(markdown);
8579
8643
  this.announcementLoaded = true;
8580
- if (this.hasUnseenAnnouncement && !this.viewedBannerTimestamps.has(timestamp)) {
8581
- this.viewedBannerTimestamps.add(timestamp);
8582
- this.pendingBannerViewed = {
8583
- banner_id: timestamp,
8584
- cta_label: ctaLabel ?? void 0
8585
- };
8586
- this.flushPendingBannerViewed();
8587
- }
8644
+ this.maybeTrackBannerViewed();
8588
8645
  this.requestUpdate();
8589
8646
  } catch (error) {
8590
8647
  console.warn("[CopilotKit Inspector] Failed to load announcement", error);