mcp-use 1.11.0-canary.17 → 1.11.0-canary.19

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.
@@ -92,7 +92,7 @@ function generateUUID() {
92
92
  __name(generateUUID, "generateUUID");
93
93
 
94
94
  // src/version.ts
95
- var VERSION = "1.11.0-canary.17";
95
+ var VERSION = "1.11.0-canary.19";
96
96
  function getPackageVersion() {
97
97
  return VERSION;
98
98
  }
@@ -610,12 +610,26 @@ var Telemetry = class _Telemetry {
610
610
  "Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
611
611
  );
612
612
  this._posthogLoading = this._initPostHog();
613
- try {
614
- this._scarfClient = new ScarfEventLogger(this.SCARF_GATEWAY_URL, 3e3);
615
- } catch (e) {
616
- logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
613
+ if (this._runtimeEnvironment !== "browser") {
614
+ try {
615
+ this._scarfClient = new ScarfEventLogger(
616
+ this.SCARF_GATEWAY_URL,
617
+ 3e3
618
+ );
619
+ } catch (e) {
620
+ logger.warn(`Failed to initialize Scarf telemetry: ${e}`);
621
+ this._scarfClient = null;
622
+ }
623
+ } else {
617
624
  this._scarfClient = null;
618
625
  }
626
+ if (this._storageCapability === "filesystem" && this._scarfClient) {
627
+ setTimeout(() => {
628
+ this.trackPackageDownload({ triggered_by: "initialization" }).catch(
629
+ (e) => logger.debug(`Failed to track package download: ${e}`)
630
+ );
631
+ }, 0);
632
+ }
619
633
  }
620
634
  }
621
635
  _checkTelemetryDisabled() {
@@ -740,47 +754,65 @@ var Telemetry = class _Telemetry {
740
754
  break;
741
755
  case "session-only":
742
756
  default:
743
- this._currUserId = `session-${generateUUID()}`;
744
- logger.debug(
745
- `Using session-based user ID (${this._runtimeEnvironment} environment)`
746
- );
757
+ try {
758
+ this._currUserId = `session-${generateUUID()}`;
759
+ } catch (uuidError) {
760
+ this._currUserId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
761
+ }
747
762
  break;
748
763
  }
749
- if (this._storageCapability === "filesystem" && this._currUserId) {
750
- this._trackPackageDownloadInternal(this._currUserId, {
751
- triggered_by: "user_id_property"
752
- }).catch((e) => logger.debug(`Failed to track package download: ${e}`));
753
- }
754
764
  } catch (e) {
755
- logger.debug(`Failed to get/create user ID: ${e}`);
756
765
  this._currUserId = this.UNKNOWN_USER_ID;
757
766
  }
758
767
  return this._currUserId;
759
768
  }
760
769
  /**
761
770
  * Get or create user ID from filesystem (Node.js/Bun)
771
+ * Falls back to session ID if filesystem operations fail
762
772
  */
763
773
  _getUserIdFromFilesystem() {
764
- const fs = __require("fs");
765
- const os = __require("os");
766
- const path = __require("path");
767
- if (!this._userIdPath) {
768
- this._userIdPath = path.join(
769
- this._getCacheHome(os, path),
770
- "mcp_use_3",
771
- "telemetry_user_id"
772
- );
773
- }
774
- const isFirstTime = !fs.existsSync(this._userIdPath);
775
- if (isFirstTime) {
776
- logger.debug(`Creating user ID path: ${this._userIdPath}`);
777
- fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
778
- const newUserId = generateUUID();
779
- fs.writeFileSync(this._userIdPath, newUserId);
780
- logger.debug(`User ID path created: ${this._userIdPath}`);
781
- return newUserId;
774
+ try {
775
+ let fs, os, path;
776
+ try {
777
+ fs = __require("fs");
778
+ os = __require("os");
779
+ path = __require("path");
780
+ } catch (requireError) {
781
+ try {
782
+ const sessionId = `session-${generateUUID()}`;
783
+ return sessionId;
784
+ } catch (uuidError) {
785
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
786
+ }
787
+ }
788
+ if (!this._userIdPath) {
789
+ this._userIdPath = path.join(
790
+ this._getCacheHome(os, path),
791
+ "mcp_use_3",
792
+ "telemetry_user_id"
793
+ );
794
+ }
795
+ const isFirstTime = !fs.existsSync(this._userIdPath);
796
+ if (isFirstTime) {
797
+ fs.mkdirSync(path.dirname(this._userIdPath), { recursive: true });
798
+ let newUserId;
799
+ try {
800
+ newUserId = generateUUID();
801
+ } catch (uuidError) {
802
+ newUserId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
803
+ }
804
+ fs.writeFileSync(this._userIdPath, newUserId);
805
+ return newUserId;
806
+ }
807
+ const userId = fs.readFileSync(this._userIdPath, "utf-8").trim();
808
+ return userId;
809
+ } catch (e) {
810
+ try {
811
+ return `session-${generateUUID()}`;
812
+ } catch (uuidError) {
813
+ return `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
814
+ }
782
815
  }
783
- return fs.readFileSync(this._userIdPath, "utf-8").trim();
784
816
  }
785
817
  /**
786
818
  * Get or create user ID from localStorage (Browser)
@@ -789,14 +821,22 @@ var Telemetry = class _Telemetry {
789
821
  try {
790
822
  let userId = localStorage.getItem(USER_ID_STORAGE_KEY);
791
823
  if (!userId) {
792
- userId = generateUUID();
824
+ try {
825
+ userId = generateUUID();
826
+ } catch (uuidError) {
827
+ userId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
828
+ }
793
829
  localStorage.setItem(USER_ID_STORAGE_KEY, userId);
794
- logger.debug(`Created new browser user ID`);
795
830
  }
796
831
  return userId;
797
832
  } catch (e) {
798
- logger.debug(`localStorage access failed: ${e}`);
799
- return `session-${generateUUID()}`;
833
+ let sessionId;
834
+ try {
835
+ sessionId = `session-${generateUUID()}`;
836
+ } catch (uuidError) {
837
+ sessionId = `session-${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
838
+ }
839
+ return sessionId;
800
840
  }
801
841
  }
802
842
  _getCacheHome(os, path) {
@@ -825,6 +865,7 @@ var Telemetry = class _Telemetry {
825
865
  if (!this._posthogNodeClient && !this._posthogBrowserClient && !this._scarfClient) {
826
866
  return;
827
867
  }
868
+ const currentUserId = this.userId;
828
869
  const properties = { ...event.properties };
829
870
  properties.mcp_use_version = getPackageVersion();
830
871
  properties.language = "typescript";
@@ -832,9 +873,8 @@ var Telemetry = class _Telemetry {
832
873
  properties.runtime = this._runtimeEnvironment;
833
874
  if (this._posthogNodeClient) {
834
875
  try {
835
- logger.debug(`CAPTURE: PostHog Node Event ${event.name}`);
836
876
  this._posthogNodeClient.capture({
837
- distinctId: this.userId,
877
+ distinctId: currentUserId,
838
878
  event: event.name,
839
879
  properties
840
880
  });
@@ -844,10 +884,9 @@ var Telemetry = class _Telemetry {
844
884
  }
845
885
  if (this._posthogBrowserClient) {
846
886
  try {
847
- logger.debug(`CAPTURE: PostHog Browser Event ${event.name}`);
848
887
  this._posthogBrowserClient.capture(event.name, {
849
888
  ...properties,
850
- distinct_id: this.userId
889
+ distinct_id: currentUserId
851
890
  });
852
891
  } catch (e) {
853
892
  logger.debug(
@@ -859,7 +898,7 @@ var Telemetry = class _Telemetry {
859
898
  try {
860
899
  const scarfProperties = {
861
900
  ...properties,
862
- user_id: this.userId,
901
+ user_id: currentUserId,
863
902
  event: event.name
864
903
  };
865
904
  await this._scarfClient.logEvent(scarfProperties);
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Tel,
3
3
  Telemetry
4
- } from "./chunk-JQMHLTXF.js";
4
+ } from "./chunk-2CX2RMGM.js";
5
5
  import {
6
6
  logger
7
7
  } from "./chunk-FRUZDWXH.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BaseMCPClient,
3
3
  HttpConnector
4
- } from "./chunk-QEEFUZ22.js";
4
+ } from "./chunk-5QAH2BZN.js";
5
5
  import {
6
6
  Tel,
7
7
  getPackageVersion
8
- } from "./chunk-JQMHLTXF.js";
8
+ } from "./chunk-2CX2RMGM.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-FRUZDWXH.js";
@@ -4,11 +4,11 @@ import {
4
4
  ConnectionManager,
5
5
  HttpConnector,
6
6
  MCPSession
7
- } from "./chunk-QEEFUZ22.js";
7
+ } from "./chunk-5QAH2BZN.js";
8
8
  import {
9
9
  Tel,
10
10
  getPackageVersion
11
- } from "./chunk-JQMHLTXF.js";
11
+ } from "./chunk-2CX2RMGM.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-FRUZDWXH.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  BrowserMCPClient
3
- } from "./chunk-NTB5TTZW.js";
4
- import {
5
- Tel
6
- } from "./chunk-JQMHLTXF.js";
3
+ } from "./chunk-7KWUIU7I.js";
7
4
  import {
8
5
  BrowserOAuthClientProvider,
9
6
  sanitizeUrl
10
7
  } from "./chunk-J75I2C26.js";
8
+ import {
9
+ Tel
10
+ } from "./chunk-2CX2RMGM.js";
11
11
  import {
12
12
  __name
13
13
  } from "./chunk-3GQAWCBQ.js";