sanity 5.25.0-next.20 → 5.25.0-next.22

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.
@@ -1,4 +1,4 @@
1
- var version = "5.25.0-next.20";
1
+ var version = "5.25.0-next.22";
2
2
  let buildVersion;
3
3
  try {
4
4
  buildVersion = process.env.PKG_BUILD_VERSION;
@@ -7,7 +7,7 @@ try {
7
7
  try {
8
8
  buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
9
9
  // and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
10
- "5.25.0-next.20";
10
+ "5.25.0-next.22";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
package/lib/index.js CHANGED
@@ -7421,9 +7421,9 @@ function createBatchedGetDocumentExists(client) {
7421
7421
  return exists2;
7422
7422
  };
7423
7423
  }
7424
- const requestIdleCallbackShim = function(callback, options) {
7424
+ const requestIdleCallbackShim = function(callback, _options) {
7425
7425
  const start = Date.now();
7426
- return window.setTimeout(() => {
7426
+ return globalThis.setTimeout(() => {
7427
7427
  callback({
7428
7428
  didTimeout: !1,
7429
7429
  timeRemaining() {
@@ -7432,7 +7432,7 @@ const requestIdleCallbackShim = function(callback, options) {
7432
7432
  });
7433
7433
  }, 0);
7434
7434
  }, cancelIdleCallbackShim = function(handle) {
7435
- return window.clearTimeout(handle);
7435
+ return globalThis.clearTimeout(handle);
7436
7436
  }, win = typeof window > "u" ? void 0 : window, requestIdleCallback$1 = win?.requestIdleCallback || requestIdleCallbackShim, cancelIdleCallback = win?.cancelIdleCallback || cancelIdleCallbackShim, unknownFieldsValidator = (type) => (value) => {
7437
7437
  if (typeof value != "object" || !value) return !0;
7438
7438
  const fieldNames = new Set(type.fields?.map((field) => field.name));
@@ -91078,14 +91078,29 @@ const debugLoggingStore = {
91078
91078
  },
91079
91079
  sendBeacon: (batch) => (logTelemetryBatch(batch), !0)
91080
91080
  }, sessionId = createSessionId(), isClient = typeof window < "u";
91081
+ function countPlugins(plugins) {
91082
+ return plugins ? plugins.reduce((count2, plugin) => count2 + 1 + countPlugins(plugin.plugins), 0) : 0;
91083
+ }
91084
+ function getConnection() {
91085
+ if (!isClient) return null;
91086
+ const nav = navigator, connection = nav.connection || nav.mozConnection || nav.webkitConnection;
91087
+ return connection ? {
91088
+ effectiveType: connection.effectiveType ?? null,
91089
+ downlink: typeof connection.downlink == "number" ? connection.downlink : null,
91090
+ rtt: typeof connection.rtt == "number" ? connection.rtt : null,
91091
+ saveData: typeof connection.saveData == "boolean" ? connection.saveData : null
91092
+ } : null;
91093
+ }
91081
91094
  function StudioTelemetryProvider(props2) {
91082
91095
  const client = useClient({
91083
91096
  apiVersion: "v2023-12-18"
91084
- }), projectId = client.config().projectId, workspace = useWorkspace(), {
91097
+ }), projectId = client.config().projectId, workspace = useWorkspace(), workspaceCount = useWorkspaces().length, workspacePlugins = workspace.__internal.options.plugins, workspaceSchema = workspace.schema, {
91085
91098
  value: orgId
91086
91099
  } = useProjectOrganizationId(), activeTool = useRouterState(useCallback((routerState) => typeof routerState.tool == "string" ? routerState.tool : void 0, [])), contextRef = useRef(null);
91087
91100
  useEffect(() => {
91088
- isClient && (contextRef.current = {
91101
+ if (!isClient) return;
91102
+ const pluginCount = countPlugins(workspacePlugins), schemaTypeCount = workspaceSchema.getTypeNames().length;
91103
+ contextRef.current = {
91089
91104
  // Static values
91090
91105
  userAgent: navigator.userAgent,
91091
91106
  screen: {
@@ -91098,14 +91113,18 @@ function StudioTelemetryProvider(props2) {
91098
91113
  studioVersion: SANITY_VERSION,
91099
91114
  reactVersion: version,
91100
91115
  environment: isProd ? "production" : "development",
91116
+ connection: getConnection(),
91101
91117
  // Dynamic values
91102
91118
  orgId: orgId || null,
91103
91119
  activeTool,
91120
+ workspaceCount,
91104
91121
  activeWorkspace: workspace.name,
91105
91122
  activeProjectId: workspace.projectId,
91106
- activeDataset: workspace.dataset
91107
- });
91108
- }, [orgId, activeTool, workspace.name, workspace.projectId, workspace.dataset]);
91123
+ activeDataset: workspace.dataset,
91124
+ pluginCount,
91125
+ schemaTypeCount
91126
+ };
91127
+ }, [orgId, activeTool, workspaceCount, workspace.name, workspace.projectId, workspace.dataset, workspacePlugins, workspaceSchema]);
91109
91128
  const storeOptions = useMemo(() => import.meta && import.meta.env?.SANITY_STUDIO_DEBUG_TELEMETRY === "true" ? debugLoggingStore : {
91110
91129
  flushInterval: 3e4,
91111
91130
  resolveConsent: () => client.request({