@quillsql/react 2.16.91 → 2.16.93

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 (3) hide show
  1. package/dist/index.cjs +401 -110
  2. package/dist/index.js +401 -110
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -17183,6 +17183,79 @@ var init_paginationProcessing = __esm({
17183
17183
  }
17184
17184
  });
17185
17185
 
17186
+ // src/utils/dashboardProfiler.ts
17187
+ function profilingEnabled() {
17188
+ if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE === "true") {
17189
+ return true;
17190
+ }
17191
+ if (typeof window === "undefined") return false;
17192
+ return Boolean(window.__QUILL_DASHBOARD_PROFILE__);
17193
+ }
17194
+ function profileStore() {
17195
+ if (typeof window !== "undefined") {
17196
+ const profileWindow = window;
17197
+ profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
17198
+ return profileWindow.__QUILL_DASHBOARD_TRACE__;
17199
+ }
17200
+ const globalStore = globalThis;
17201
+ globalStore.__QUILL_DASHBOARD_TRACE__ ??= [];
17202
+ return globalStore.__QUILL_DASHBOARD_TRACE__;
17203
+ }
17204
+ function queryKeyFamily(queryKey) {
17205
+ const head = String(queryKey[0] ?? "");
17206
+ const next = String(queryKey[1] ?? "");
17207
+ if (head === "quill" && next === "dashboard-report") {
17208
+ return "quill/dashboard-report";
17209
+ }
17210
+ if (head === "useReport") {
17211
+ return `useReport/${next || "unknown"}`;
17212
+ }
17213
+ return head || "other";
17214
+ }
17215
+ function summarizeEngineRequest(input) {
17216
+ const metadata = input.metadata ?? {};
17217
+ return {
17218
+ task: input.task ?? null,
17219
+ shareRequest: Boolean(input.shareRequest),
17220
+ reuseExisting: input.reuseExisting ?? null,
17221
+ settled: input.settled ?? null,
17222
+ reportId: metadata.reportId ?? null,
17223
+ metadataKeys: Object.keys(metadata).sort(),
17224
+ dashboardName: metadata.dashboardName ?? null,
17225
+ dashboardItemId: metadata.dashboardItemId ?? null,
17226
+ useNewNodeSql: metadata.useNewNodeSql ?? null,
17227
+ dateBucket: metadata.dateBucket ?? null,
17228
+ hasPivot: Boolean(metadata.pivot),
17229
+ hasReportBuilderState: Boolean(metadata.reportBuilderState),
17230
+ additionalProcessing: metadata.additionalProcessing ?? null,
17231
+ filterCount: Array.isArray(metadata.filters) ? metadata.filters.length : null
17232
+ };
17233
+ }
17234
+ function profileDashboard(event, data) {
17235
+ if (!profilingEnabled()) return;
17236
+ const entry = {
17237
+ at: Math.round(performance.now() * 10) / 10,
17238
+ event,
17239
+ data
17240
+ };
17241
+ profileStore().push(entry);
17242
+ if (typeof window !== "undefined") {
17243
+ const profileWindow = window;
17244
+ profileWindow.__QUILL_DASHBOARD_PROFILE__ = true;
17245
+ profileWindow.__QUILL_DUMP_DASHBOARD_PROFILE__ = () => profileWindow.__QUILL_DASHBOARD_TRACE__ ?? [];
17246
+ }
17247
+ if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE_CONSOLE === "true" && CONSOLE_EVENT_PATTERN.test(event)) {
17248
+ console.log(`[quill-profile] ${event}`, data ?? {});
17249
+ }
17250
+ }
17251
+ var CONSOLE_EVENT_PATTERN;
17252
+ var init_dashboardProfiler = __esm({
17253
+ "src/utils/dashboardProfiler.ts"() {
17254
+ "use strict";
17255
+ CONSOLE_EVENT_PATTERN = /cache|initial-load|use-report-loading|network|unique-values|table-refresh|pivot|shared-request|engine-fetch|generate-pivot/;
17256
+ }
17257
+ });
17258
+
17186
17259
  // src/utils/pivotConstructor.ts
17187
17260
  function normalizeLegacyPivotSortFieldValue(sortField) {
17188
17261
  if (sortField === void 0) {
@@ -17295,6 +17368,22 @@ async function generatePivotWithSQL({
17295
17368
  rowLimit: pivot.rowLimit,
17296
17369
  dateBucket: resolvedDateBucket
17297
17370
  };
17371
+ profileDashboard(
17372
+ "generate-pivot-sql",
17373
+ summarizeEngineRequest({
17374
+ task: "pivot-template",
17375
+ shareRequest: false,
17376
+ metadata: {
17377
+ reportId: report?.id,
17378
+ dashboardName,
17379
+ dateBucket: resolvedDateBucket,
17380
+ additionalProcessing,
17381
+ pivot: pivotConfig,
17382
+ reportBuilderState,
17383
+ filters: dashboardFilters
17384
+ }
17385
+ })
17386
+ );
17298
17387
  const resp = await quillFetch({
17299
17388
  client,
17300
17389
  task: "pivot-template",
@@ -17673,6 +17762,7 @@ var init_pivotConstructor = __esm({
17673
17762
  init_columnType();
17674
17763
  init_dataFetcher();
17675
17764
  init_dataProcessing();
17765
+ init_dashboardProfiler();
17676
17766
  init_dates();
17677
17767
  init_textProcessing();
17678
17768
  }
@@ -20094,6 +20184,20 @@ async function getOrFetchSharedRequest({
20094
20184
  }) {
20095
20185
  if (signal?.aborted) throw createAbortError(signal);
20096
20186
  let entry = entries.get(key);
20187
+ const reuseExisting = Boolean(entry);
20188
+ profileDashboard("shared-request", {
20189
+ ...summarizeEngineRequest({
20190
+ task: void 0,
20191
+ shareRequest: true,
20192
+ reuseExisting,
20193
+ settled: entry?.settled,
20194
+ metadata: { reportId }
20195
+ }),
20196
+ reportId: reportId ?? null,
20197
+ reuseExisting,
20198
+ settled: entry?.settled ?? false,
20199
+ keyLength: key.length
20200
+ });
20097
20201
  if (!entry) {
20098
20202
  const controller = new AbortController();
20099
20203
  entry = {
@@ -20169,6 +20273,7 @@ var ORPHAN_GRACE_MS, COMPLETED_TTL_MS, entries;
20169
20273
  var init_reportRequestPool = __esm({
20170
20274
  "src/utils/reportRequestPool.ts"() {
20171
20275
  "use strict";
20276
+ init_dashboardProfiler();
20172
20277
  ORPHAN_GRACE_MS = 100;
20173
20278
  COMPLETED_TTL_MS = 15e3;
20174
20279
  entries = /* @__PURE__ */ new Map();
@@ -20731,6 +20836,7 @@ var init_dataFetcher = __esm({
20731
20836
  init_dates();
20732
20837
  init_changelogNotify();
20733
20838
  init_reportRequestPool();
20839
+ init_dashboardProfiler();
20734
20840
  quillFetch = async ({
20735
20841
  client,
20736
20842
  task,
@@ -20791,6 +20897,14 @@ var init_dataFetcher = __esm({
20791
20897
  return { error: "Failed to fetch data" };
20792
20898
  }
20793
20899
  };
20900
+ profileDashboard(
20901
+ "engine-fetch",
20902
+ summarizeEngineRequest({
20903
+ task,
20904
+ shareRequest,
20905
+ metadata
20906
+ })
20907
+ );
20794
20908
  if (!shareRequest) {
20795
20909
  return execute(abortSignal);
20796
20910
  }
@@ -21362,22 +21476,7 @@ init_dates();
21362
21476
  init_pivotConstructor();
21363
21477
  init_columnProcessing();
21364
21478
  init_paginationProcessing();
21365
-
21366
- // src/utils/dashboardProfiler.ts
21367
- function profileDashboard(event, data) {
21368
- if (typeof window === "undefined") return;
21369
- const profileWindow = window;
21370
- if (!profileWindow.__QUILL_DASHBOARD_PROFILE__) return;
21371
- const entry = {
21372
- at: Math.round(performance.now() * 10) / 10,
21373
- event,
21374
- data
21375
- };
21376
- profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
21377
- profileWindow.__QUILL_DASHBOARD_TRACE__.push(entry);
21378
- }
21379
-
21380
- // src/utils/dashboard.ts
21479
+ init_dashboardProfiler();
21381
21480
  var defaultDashboardItem = {
21382
21481
  id: "",
21383
21482
  name: "",
@@ -22790,6 +22889,7 @@ init_tableProcessing();
22790
22889
  init_textProcessing();
22791
22890
  init_valueFormatter();
22792
22891
  init_astFilterProcessing();
22892
+ init_dashboardProfiler();
22793
22893
  init_reportBuilder();
22794
22894
  init_astProcessing();
22795
22895
 
@@ -26573,6 +26673,7 @@ function normalizePSTRanges(start, end) {
26573
26673
 
26574
26674
  // src/Context.tsx
26575
26675
  init_changelogNotify();
26676
+ init_dashboardProfiler();
26576
26677
 
26577
26678
  // src/reportStore.ts
26578
26679
  import { createContext, useContext, useSyncExternalStore } from "react";
@@ -32354,7 +32455,7 @@ function QuillTable({
32354
32455
  setSortColumn(sort?.field || "");
32355
32456
  setSortDirection(sort?.direction || "desc");
32356
32457
  }, [sort]);
32357
- const holdFullPageLoader = rows?.length === 0 && isLoading;
32458
+ const holdFullPageLoader = Boolean(isLoading);
32358
32459
  const pageCountUnknown = manualPagination && pageCount === -1;
32359
32460
  const { activeRows, maxPage } = useMemo4(() => {
32360
32461
  const start = currentPage * rowsPerPage;
@@ -37282,6 +37383,7 @@ function getDashboardReportProcessing(report, serverPagination) {
37282
37383
  }
37283
37384
 
37284
37385
  // src/hooks/useDashboard.ts
37386
+ init_dashboardProfiler();
37285
37387
  var DEFAULT_DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
37286
37388
  var useDashboardConfigInternal = (dashboardName) => {
37287
37389
  const { dashboardConfig, isLoading: dashboardsLoading } = useContext13(
@@ -38391,6 +38493,14 @@ var useDashboard = (dashboardName, config) => {
38391
38493
  additionalProcessing
38392
38494
  );
38393
38495
  const usePivotTask = !cacheEnabled && !!reportInfo.pivot;
38496
+ profileDashboard("dashboard-report-cache-path", {
38497
+ reportId,
38498
+ cacheEnabled,
38499
+ cacheCabCacheable: cacheCab.isCacheable(reportId),
38500
+ usePivotTask,
38501
+ forceCacheToRefresh,
38502
+ hasPivot: Boolean(reportInfo.pivot)
38503
+ });
38394
38504
  const allFilters = dashboardFilters2.concat(customFilters).concat(customReportFiltersArray);
38395
38505
  const applyInMemoryPivotIfNeeded = (report2) => {
38396
38506
  const pivotToApply = reportInfo.pivot ?? report2.pivot;
@@ -38624,7 +38734,9 @@ var useDashboard = (dashboardName, config) => {
38624
38734
  pivotColumns: pivotData.columns,
38625
38735
  pivotRowCount: pivotData.rowCount,
38626
38736
  pivotQuery: pivotData.pivotQuery,
38627
- comparisonPivotQuery: pivotData.comparisonPivotQuery
38737
+ comparisonPivotQuery: pivotData.comparisonPivotQuery,
38738
+ pivotResultRowField: pivotData.rowField,
38739
+ pivotResultSourceRowField: reportInfo.pivot?.rowField
38628
38740
  },
38629
38741
  error: void 0
38630
38742
  };
@@ -38654,6 +38766,26 @@ var useDashboard = (dashboardName, config) => {
38654
38766
  shareRequest: !forceCacheToRefresh
38655
38767
  });
38656
38768
  };
38769
+ const existingState = queryClient.getQueryState(queryKey);
38770
+ const existingData = queryClient.getQueryData(queryKey);
38771
+ const dataUpdatedAt = existingState?.dataUpdatedAt ?? 0;
38772
+ const ageMs = dataUpdatedAt ? Date.now() - dataUpdatedAt : null;
38773
+ const isStale = dataUpdatedAt === 0 || Date.now() - dataUpdatedAt >= reportStaleTimeMs;
38774
+ profileDashboard("dashboard-report-tanstack-cache", {
38775
+ reportId,
38776
+ keyFamily: "quill/dashboard-report",
38777
+ cacheEnabled,
38778
+ usePivotTask,
38779
+ forceCacheToRefresh,
38780
+ staleTimeMs: reportStaleTimeMs,
38781
+ status: existingState?.status ?? "missing",
38782
+ fetchStatus: existingState?.fetchStatus ?? "idle",
38783
+ hasData: existingData !== void 0,
38784
+ dataUpdatedAt,
38785
+ ageMs,
38786
+ isStale,
38787
+ willReuseTanstack: !forceCacheToRefresh && existingData !== void 0 && !isStale
38788
+ });
38657
38789
  const result = forceCacheToRefresh ? await fetchDashboardReport() : await queryClient.fetchQuery({
38658
38790
  queryKey,
38659
38791
  queryFn: fetchDashboardReport,
@@ -39056,6 +39188,7 @@ var useDashboardReport = (reportId, config) => {
39056
39188
  };
39057
39189
 
39058
39190
  // src/components/Dashboard/DataLoader.tsx
39191
+ init_dashboardProfiler();
39059
39192
  import { Fragment as Fragment5, jsx as jsx46 } from "react/jsx-runtime";
39060
39193
  var constructReportFromItem = (item) => {
39061
39194
  return {
@@ -41471,6 +41604,7 @@ function QuillTableDashboardComponent({
41471
41604
 
41472
41605
  // src/Chart.tsx
41473
41606
  init_valueFormatter();
41607
+ init_dashboardProfiler();
41474
41608
  import { Fragment as Fragment6, jsx as jsx50, jsxs as jsxs38 } from "react/jsx-runtime";
41475
41609
  function Chart({
41476
41610
  colors,
@@ -45462,6 +45596,7 @@ init_Filter();
45462
45596
 
45463
45597
  // src/StaticChart.tsx
45464
45598
  import { useEffect as useEffect20, useMemo as useMemo21 } from "react";
45599
+ init_dashboardProfiler();
45465
45600
  import { jsx as jsx60 } from "react/jsx-runtime";
45466
45601
  var CHART_TYPE_STYLES = {
45467
45602
  metric: { height: "100px", width: "200px" },
@@ -62428,6 +62563,7 @@ function resolveReportFromCacheCab({
62428
62563
  }
62429
62564
 
62430
62565
  // src/hooks/useForm.tsx
62566
+ init_dashboardProfiler();
62431
62567
  init_reportRequestPool();
62432
62568
 
62433
62569
  // src/hooks/useForm.queries.ts
@@ -62473,6 +62609,15 @@ function createUseFormInitialLoadQueryKey(input) {
62473
62609
  input.additionalSchemaHash
62474
62610
  ];
62475
62611
  }
62612
+ var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62613
+ function findCachedDashboardReportQuery(queryClient, reportId) {
62614
+ const id = String(reportId ?? "").trim();
62615
+ if (!id) return void 0;
62616
+ return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62617
+ const data = query.state.data;
62618
+ return Boolean(data?.report) && !data?.error;
62619
+ });
62620
+ }
62476
62621
  function shouldBootstrapUseFormInitialLoad(input) {
62477
62622
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62478
62623
  }
@@ -63455,6 +63600,11 @@ function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pi
63455
63600
  }
63456
63601
  return cols[aggIndex + 1];
63457
63602
  }
63603
+ function pivotRowKey(chart) {
63604
+ return String(
63605
+ chart?.pivotResultRowField ?? chart?.pivot?.rowField ?? ""
63606
+ ).trim();
63607
+ }
63458
63608
  function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63459
63609
  if (!chart?.pivot) return false;
63460
63610
  if (String(chart.chartType ?? "").toLowerCase() !== "table") return false;
@@ -63463,7 +63613,8 @@ function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63463
63613
  }
63464
63614
  const rowField = String(chart.pivot.rowField ?? "").trim();
63465
63615
  const xf = String(xAxisField ?? "").trim();
63466
- if (!rowField || xf !== rowField) return false;
63616
+ const rowKey = pivotRowKey(chart);
63617
+ if (!rowField || xf !== rowField && xf !== rowKey) return false;
63467
63618
  return isDateType(String(chart.pivot.rowFieldType ?? ""));
63468
63619
  }
63469
63620
  var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set([
@@ -63477,22 +63628,24 @@ function resolvePivotDateBucketXAxisFormat(chart, xAxisField) {
63477
63628
  const dateBucket = String(chart?.pivot?.dateBucket ?? "").trim().toLowerCase();
63478
63629
  if (!RESOLVABLE_X_AXIS_DATE_BUCKETS.has(dateBucket)) return null;
63479
63630
  const rowField = String(chart?.pivot?.rowField ?? "").trim();
63480
- if (!rowField || String(xAxisField ?? "").trim() !== rowField) return null;
63631
+ const xf = String(xAxisField ?? "").trim();
63632
+ const rowKey = pivotRowKey(chart);
63633
+ if (!rowField || xf !== rowField && xf !== rowKey) return null;
63481
63634
  if (!isDateType(String(chart?.pivot?.rowFieldType ?? ""))) return null;
63482
63635
  return getDateFormatFromBucket(dateBucket);
63483
63636
  }
63484
63637
  function chartDetailRowsMissingPivotRowBucket(chart) {
63485
63638
  if (!chart?.pivot) return false;
63486
- const rowField = String(chart.pivot.rowField ?? "").trim();
63487
- if (!rowField) return false;
63639
+ const rowKey = pivotRowKey(chart);
63640
+ if (!rowKey) return false;
63488
63641
  const rows = chart.rows;
63489
63642
  if (!Array.isArray(rows) || rows.length === 0) return false;
63490
63643
  const first = rows.find(
63491
63644
  (r) => r && typeof r === "object" && Object.keys(r).length > 0
63492
63645
  );
63493
63646
  if (!first) return false;
63494
- if (!Object.prototype.hasOwnProperty.call(first, rowField)) return true;
63495
- const v = first[rowField];
63647
+ if (!Object.prototype.hasOwnProperty.call(first, rowKey)) return true;
63648
+ const v = first[rowKey];
63496
63649
  return v === void 0 || v === null;
63497
63650
  }
63498
63651
  function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat) {
@@ -63528,7 +63681,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63528
63681
  } : chart;
63529
63682
  if (!config) return config;
63530
63683
  if (!config.pivot) return config;
63531
- const pivotRowFieldEarly = String(config.pivot?.rowField ?? "").trim();
63684
+ const pivotRowFieldEarly = pivotRowKey(config);
63532
63685
  const rowColumn = (config.pivotColumns ?? config.columns ?? []).find(
63533
63686
  (col) => String(col.field ?? "").trim() === pivotRowFieldEarly
63534
63687
  );
@@ -63551,7 +63704,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63551
63704
  (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63552
63705
  ) : [];
63553
63706
  const pivotValueFields = pivotRowFields.filter(
63554
- (field) => field !== withResolvedXAxis.pivot?.rowField
63707
+ (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63555
63708
  );
63556
63709
  const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
63557
63710
  const yAxisFormatByField = new Map(
@@ -63668,7 +63821,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63668
63821
  const normalizedPivotColumns = pivotColumnFields.length > 0 ? pivotColumnFields.map((field) => {
63669
63822
  const knownColumn = knownColumnsByField.get(field);
63670
63823
  const yAxis = yAxisFields.find((axis) => axis.field === field);
63671
- const format9 = yAxis?.format ?? knownColumn?.format ?? (field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63824
+ const format9 = yAxis?.format ?? knownColumn?.format ?? (field === pivotRowKey(withResolvedXAxis) || field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63672
63825
  return {
63673
63826
  field,
63674
63827
  label: yAxis?.label ?? knownColumn?.label ?? field,
@@ -63681,7 +63834,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63681
63834
  const slotCol = getPivotTableSlotReportColumn(
63682
63835
  pivotTableSlotColumns,
63683
63836
  aggregations,
63684
- withResolvedXAxis.pivot?.rowField,
63837
+ pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
63685
63838
  col.field
63686
63839
  );
63687
63840
  if (!slotCol) return col;
@@ -63703,9 +63856,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63703
63856
  const normalizedXAxisFormat = normalizedXAxisField === withResolvedXAxis.xAxisField ? withResolvedXAxis.xAxisFormat : yAxisFields.find((axis) => axis.field === normalizedXAxisField)?.format ?? pivotTableDisplayColumns.find(
63704
63857
  (column) => column.field === normalizedXAxisField
63705
63858
  )?.format ?? withResolvedXAxis.xAxisFormat;
63706
- const pivotDisplayRowField = String(
63707
- withResolvedXAxis.pivot?.rowField ?? ""
63708
- ).trim();
63859
+ const pivotDisplayRowField = pivotRowKey(withResolvedXAxis);
63709
63860
  const pivotDisplayRowFieldType = String(
63710
63861
  withResolvedXAxis.pivot?.rowFieldType ?? ""
63711
63862
  ).trim();
@@ -66106,6 +66257,19 @@ async function loadViaReportBuilderState({
66106
66257
  dashboardName: report?.dashboardName ?? dashboardName,
66107
66258
  name: report?.name ?? reportId
66108
66259
  };
66260
+ const processing = pagination ? {
66261
+ page: {
66262
+ page: pagination.pageIndex,
66263
+ rowsPerPage: pagination.pageSize,
66264
+ rowsPerRequest: pagination.pageSize
66265
+ },
66266
+ ...paginationSort?.field ? { sort: paginationSort } : {}
66267
+ } : {
66268
+ page: {
66269
+ ...DEFAULT_PAGINATION,
66270
+ rowsPerRequest: DEFAULT_USE_REPORT_ROWS_PER_REQUEST
66271
+ }
66272
+ };
66109
66273
  const reportBuilderInfo = await fetchReportBuilderDataFromState({
66110
66274
  reportBuilderState,
66111
66275
  schema,
@@ -66120,19 +66284,7 @@ async function loadViaReportBuilderState({
66120
66284
  skipRowCount: rowsOnly,
66121
66285
  rowCountOnly,
66122
66286
  previousRelevant: previousRelevantWhenSkippingInlineUniqueFetch(report),
66123
- processing: pagination ? {
66124
- page: {
66125
- page: pagination.pageIndex,
66126
- rowsPerPage: pagination.pageSize,
66127
- rowsPerRequest: pagination.pageSize
66128
- },
66129
- ...paginationSort?.field ? { sort: paginationSort } : {}
66130
- } : {
66131
- page: {
66132
- ...DEFAULT_PAGINATION,
66133
- rowsPerRequest: DEFAULT_USE_REPORT_ROWS_PER_REQUEST
66134
- }
66135
- },
66287
+ processing,
66136
66288
  dashboardName,
66137
66289
  getToken,
66138
66290
  eventTracking: null,
@@ -66668,19 +66820,30 @@ function useReport(reportIdArg, options = {}) {
66668
66820
  )
66669
66821
  });
66670
66822
  const diagnostics = globalThis.__QUILL_CACHECAB_DIAGNOSTICS__;
66823
+ const durationMs = performance.now() - startedAt;
66824
+ const outcome = resolution.resolved ? "hit" : "fallback";
66671
66825
  if (Array.isArray(diagnostics)) {
66672
66826
  diagnostics.push({
66673
66827
  reportId: effectiveReportId,
66674
66828
  operation,
66675
- outcome: resolution.resolved ? "hit" : "fallback",
66829
+ outcome,
66676
66830
  reason: resolution.resolved ? "complete" : resolution.reason,
66677
66831
  details: resolution.resolved ? void 0 : resolution.details,
66678
66832
  snapshotReason: snapshot?.reason ?? "cache_miss",
66679
66833
  forcedIncompleteSnapshot: Boolean(snapshot) && !snapshot?.complete && forceIncompleteCacheCabForParity,
66680
66834
  rowCount: snapshot?.rowCount ?? 0,
66681
- durationMs: performance.now() - startedAt
66835
+ durationMs
66682
66836
  });
66683
66837
  }
66838
+ profileDashboard("use-report-cachecab", {
66839
+ reportId: effectiveReportId,
66840
+ operation,
66841
+ outcome,
66842
+ reason: resolution.resolved ? "complete" : resolution.reason,
66843
+ snapshotReason: snapshot?.reason ?? "cache_miss",
66844
+ rowCount: snapshot?.rowCount ?? 0,
66845
+ durationMs: Math.round(durationMs * 10) / 10
66846
+ });
66684
66847
  return resolution.resolved ? resolution.report : null;
66685
66848
  },
66686
66849
  [
@@ -67254,9 +67417,15 @@ function useReport(reportIdArg, options = {}) {
67254
67417
  if (alias) localValues[alias] = values;
67255
67418
  }
67256
67419
  if (hasEveryColumn) {
67420
+ profileDashboard("use-report-unique-values-cachecab-hit", {
67421
+ reportId: effectiveReportId
67422
+ });
67257
67423
  return { uniqueValuesByColumn: localValues };
67258
67424
  }
67259
67425
  }
67426
+ profileDashboard("use-report-unique-values-network", {
67427
+ reportId: effectiveReportId
67428
+ });
67260
67429
  const tablesForUniqueValues = filterUniqueValuesRequest.reportBuilderState?.tables?.map(
67261
67430
  (table2) => String(table2?.name ?? "").trim()
67262
67431
  ) ?? filterUniqueValuesRequest.stringColumnsByTable.map((column) => String(column.table ?? "").trim()).filter(Boolean);
@@ -67775,6 +67944,29 @@ function useReport(reportIdArg, options = {}) {
67775
67944
  const initialLoadQuery = useQuery({
67776
67945
  queryKey: initialLoadQueryKey,
67777
67946
  queryFn: createUseFormQueryFn(async (signal) => {
67947
+ const tanstackState = queryClient.getQueryState(initialLoadQueryKey);
67948
+ const dashboardReportQueries = queryClient.getQueryCache().getAll().filter(
67949
+ (query) => queryKeyFamily(query.queryKey) === "quill/dashboard-report"
67950
+ );
67951
+ const matchingDashboardReport = dashboardReportQueries.find(
67952
+ (query) => String(query.queryKey[2] ?? "") === String(effectiveReportId)
67953
+ );
67954
+ profileDashboard("use-report-initial-load-queryfn", {
67955
+ reportId: effectiveReportId,
67956
+ reason: "TanStack ran this queryFn, so useReport/initial-load had no fresh cached data",
67957
+ keyFamily: "useReport/initial-load",
67958
+ status: tanstackState?.status ?? "missing",
67959
+ hasData: tanstackState?.data !== void 0,
67960
+ dataUpdatedAt: tanstackState?.dataUpdatedAt ?? 0,
67961
+ staleTime: 0,
67962
+ dashboardReportQueryCount: dashboardReportQueries.length,
67963
+ matchingDashboardReport: matchingDashboardReport ? {
67964
+ hasData: matchingDashboardReport.state.data !== void 0,
67965
+ status: matchingDashboardReport.state.status,
67966
+ staleTime: matchingDashboardReport.options?.staleTime ?? 0,
67967
+ unusedByUseReport: true
67968
+ } : null
67969
+ });
67778
67970
  let cachedReportBuilderState = initialReportBuilderStateForLoad ?? void 0;
67779
67971
  if (!cachedReportBuilderState) {
67780
67972
  const snapshot = await cacheCab.getReportSnapshot(
@@ -67799,6 +67991,9 @@ function useReport(reportIdArg, options = {}) {
67799
67991
  operation: "initial"
67800
67992
  });
67801
67993
  if (cachedReport) {
67994
+ profileDashboard("use-report-initial-load-served-from-cachecab", {
67995
+ reportId: effectiveReportId
67996
+ });
67802
67997
  return { report: cachedReport };
67803
67998
  }
67804
67999
  const allowReportTaskBootstrap = shouldBootstrapUseFormInitialLoad({
@@ -67813,6 +68008,12 @@ function useReport(reportIdArg, options = {}) {
67813
68008
  const formFiltersBelongToLoadTarget = Boolean(loadTargetId) && sourceReportIdentity === loadTargetId;
67814
68009
  const rulesForLoad = useInMemoryEngines || !formFiltersBelongToLoadTarget ? EMPTY_QUERY_FILTERS : queryFilters;
67815
68010
  const shareInitialRequest = sharedInitialRequestUsedForReportIdRef.current !== effectiveReportId;
68011
+ profileDashboard("use-report-initial-load-network", {
68012
+ reportId: effectiveReportId,
68013
+ path: "loadReportForUseForm",
68014
+ hasCachedReportBuilderState: Boolean(cachedReportBuilderState)
68015
+ });
68016
+ const networkStartedAt = performance.now();
67816
68017
  const loadResult = await loadReportForUseForm({
67817
68018
  reportId: effectiveReportId,
67818
68019
  initialReportBuilderState: initialReportBuilderStateForLoad,
@@ -67832,6 +68033,12 @@ function useReport(reportIdArg, options = {}) {
67832
68033
  rowsOnly: isCreatedReportBootstrapLoad,
67833
68034
  abortSignal: signal
67834
68035
  });
68036
+ profileDashboard("use-report-initial-load-network-done", {
68037
+ reportId: effectiveReportId,
68038
+ durationMs: Math.round(performance.now() - networkStartedAt),
68039
+ hasReport: Boolean(loadResult.report),
68040
+ error: loadResult.error ?? null
68041
+ });
67835
68042
  if (loadResult.report && !loadResult.error) {
67836
68043
  if (allowReportTaskBootstrap) {
67837
68044
  bootstrapReportTaskUsedForInitialLoadRef.current = initialLoadIdentityHash;
@@ -67843,7 +68050,17 @@ function useReport(reportIdArg, options = {}) {
67843
68050
  return loadResult;
67844
68051
  }),
67845
68052
  enabled: Boolean(effectiveReportId) && Boolean(client) && !reportOverride,
67846
- retry: false
68053
+ retry: false,
68054
+ initialData: () => {
68055
+ const cached = findCachedDashboardReportQuery(
68056
+ queryClient,
68057
+ effectiveReportId
68058
+ );
68059
+ const data = cached?.state.data;
68060
+ return data?.report ? { report: data.report, error: data.error } : void 0;
68061
+ },
68062
+ initialDataUpdatedAt: () => findCachedDashboardReportQuery(queryClient, effectiveReportId)?.state.dataUpdatedAt,
68063
+ staleTime: DASHBOARD_REPORT_STALE_TIME_MS
67847
68064
  });
67848
68065
  const reportNameQueryReportId = String(effectiveReportId ?? "").trim();
67849
68066
  const reportNameQuery = useQuery({
@@ -67894,15 +68111,6 @@ function useReport(reportIdArg, options = {}) {
67894
68111
  const shouldPromoteColumnToRowFromPendingFlag = pendingPromoteColumnToRow && !String(prev.groupRowsBy ?? "").trim();
67895
68112
  const sourceReportBuilderTables = (sourceReport.reportBuilderState?.tables ?? []).filter((table2) => Boolean(String(table2?.name ?? "").trim()));
67896
68113
  const sourceReportBuilderTableNames = sourceReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
67897
- const sourceQueryColumns = normalizeReportBuilderColumns(
67898
- sourceReport.reportBuilderState?.columns ?? (sourceReport.columns ?? []).map((column) => ({
67899
- field: column.field,
67900
- table: column.table ?? resolveColumnTableFromReportMetadata(
67901
- sourceReport,
67902
- column.field
67903
- )
67904
- }))
67905
- );
67906
68114
  const nextQueryFilters = prev.queryFilters.rules.length ? prev.queryFilters : rulesFromReport(sourceReport);
67907
68115
  const pivotAggregationsFromSource = Array.isArray(sourceReport.pivot?.aggregations) ? sourceReport.pivot.aggregations : sourceReport.pivot?.aggregationType ? [
67908
68116
  {
@@ -67969,6 +68177,9 @@ function useReport(reportIdArg, options = {}) {
67969
68177
  tables: tableScopeForDisplayColumns,
67970
68178
  schemaTables: schemaForReportBuilderState
67971
68179
  });
68180
+ const sourceQueryColumns = normalizeReportBuilderColumns(
68181
+ sourceReport.reportBuilderState?.columns?.length ? sourceReport.reportBuilderState.columns : sourceDisplayColumnsFromSchema
68182
+ );
67972
68183
  const savedDisplayColumns = normalizeReportBuilderColumns(
67973
68184
  (sourceReport.columns ?? []).map((column) => ({
67974
68185
  ...column,
@@ -68482,13 +68693,12 @@ function useReport(reportIdArg, options = {}) {
68482
68693
  tables: effectiveReportBuilderState.tables,
68483
68694
  schemaTables: schemaForReportBuilderState
68484
68695
  });
68485
- const columnsToFetch = allColumnsBySelectedTable.length > 0 ? allColumnsBySelectedTable : effectiveReportBuilderState.columns;
68486
- if (columnsToFetch.length === 0) {
68696
+ if (allColumnsBySelectedTable.length === 0) {
68487
68697
  return void 0;
68488
68698
  }
68489
68699
  return {
68490
68700
  ...effectiveReportBuilderState,
68491
- columns: columnsToFetch,
68701
+ columns: allColumnsBySelectedTable,
68492
68702
  pivot: null,
68493
68703
  sort: [],
68494
68704
  limit: null
@@ -68531,6 +68741,29 @@ function useReport(reportIdArg, options = {}) {
68531
68741
  refreshDecision.shouldRefresh,
68532
68742
  queryFilters
68533
68743
  ]);
68744
+ const shouldSkipRedundantPivotTableDataQuery = useMemo33(() => {
68745
+ if (!sourceReport || !pivotState) {
68746
+ return false;
68747
+ }
68748
+ if (tableRefreshVersion !== 0 || pivotRefreshVersion !== 0) {
68749
+ return false;
68750
+ }
68751
+ if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
68752
+ return false;
68753
+ }
68754
+ if (refreshDecision.shouldRefresh) {
68755
+ return false;
68756
+ }
68757
+ const sourceRules = sourceReport.reportBuilderState?.rules ?? EMPTY_QUERY_FILTERS;
68758
+ return stableSerializeForQueryKey(queryFilters) === stableSerializeForQueryKey(sourceRules);
68759
+ }, [
68760
+ sourceReport,
68761
+ pivotState,
68762
+ tableRefreshVersion,
68763
+ pivotRefreshVersion,
68764
+ refreshDecision.shouldRefresh,
68765
+ queryFilters
68766
+ ]);
68534
68767
  const shouldForceTableRefreshFromFilters = !useInMemoryEngines && !pivotState;
68535
68768
  const immediateTableRefreshInput = useMemo33(
68536
68769
  () => ({
@@ -68579,8 +68812,14 @@ function useReport(reportIdArg, options = {}) {
68579
68812
  operation: "table"
68580
68813
  });
68581
68814
  if (cachedReport) {
68815
+ profileDashboard("use-report-table-refresh-cachecab-hit", {
68816
+ reportId: effectiveReportId
68817
+ });
68582
68818
  return { report: cachedReport };
68583
68819
  }
68820
+ profileDashboard("use-report-table-refresh-network", {
68821
+ reportId: effectiveReportId
68822
+ });
68584
68823
  return loadViaReportBuilderState({
68585
68824
  reportId: effectiveReportId,
68586
68825
  reportBuilderState: tableRefreshInput.reportBuilderState,
@@ -69193,31 +69432,9 @@ function useReport(reportIdArg, options = {}) {
69193
69432
  shouldSkipPivotRefreshForUnchangedPivot,
69194
69433
  sourceReport
69195
69434
  ]);
69196
- const shouldSkipRedundantPivotTableDataReportBuilderQuery = useMemo33(() => {
69197
- if (!sourceReport || !nextPivot) {
69198
- return false;
69199
- }
69200
- if (tableRefreshVersion !== 0 || pivotRefreshVersion !== 0) {
69201
- return false;
69202
- }
69203
- if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
69204
- return false;
69205
- }
69206
- if (refreshDecision.shouldRefresh) {
69207
- return false;
69208
- }
69209
- const sourceRules = sourceReport.reportBuilderState?.rules ?? EMPTY_QUERY_FILTERS;
69210
- return stableSerializeForQueryKey(queryFilters) === stableSerializeForQueryKey(sourceRules);
69211
- }, [
69212
- sourceReport,
69213
- nextPivot,
69214
- tableRefreshVersion,
69215
- pivotRefreshVersion,
69216
- refreshDecision.shouldRefresh,
69217
- queryFilters
69218
- ]);
69219
69435
  const pivotRefreshQueryEnabled = !reportOverride && pendingPivotRefresh && !shouldSkipPivotRefreshForUnchangedPivot && Boolean(sourceReport) && Boolean(client) && Boolean(effectiveReportBuilderState) && Boolean(nextPivot) && sourceReportMatchesEffectiveReportId;
69220
- const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId && !shouldSkipRedundantPivotTableDataReportBuilderQuery;
69436
+ const initialLoadSettled = Boolean(reportOverride) || !effectiveReportId || Boolean(client) && !initialLoadQuery.isPending && !initialLoadQuery.isFetching;
69437
+ const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId && initialLoadSettled && !shouldSkipRedundantPivotTableDataQuery;
69221
69438
  const pivotRefreshQuery = useQuery({
69222
69439
  queryKey: createUseFormPivotRefreshQueryKey({
69223
69440
  reportId: effectiveReportId,
@@ -69331,7 +69548,7 @@ function useReport(reportIdArg, options = {}) {
69331
69548
  const paginationRangeStart = pagination.pageIndex * pagination.pageSize;
69332
69549
  const paginationRangeEnd = paginationRangeStart + pagination.pageSize;
69333
69550
  const pageWithinBaseWindow = paginationRangeEnd <= baseWindowRowsLength || trustedSourceRowCount !== void 0 && trustedSourceRowCount <= baseWindowRowsLength;
69334
- const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh;
69551
+ const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh && initialLoadSettled;
69335
69552
  const tablePageQuery = useQuery({
69336
69553
  queryKey: createUseFormTablePageQueryKey({
69337
69554
  reportId: effectiveReportId,
@@ -69503,21 +69720,17 @@ function useReport(reportIdArg, options = {}) {
69503
69720
  if (!sourceReport) return void 0;
69504
69721
  const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
69505
69722
  const chartPivot = pendingPivotChangesDimensions ? sourceReport.pivot ?? null : nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
69506
- const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
69507
- ...chartPivot,
69508
- rowField: sourceReport.pivotResultRowField
69509
- } : chartPivot;
69510
- const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69723
+ const rowCountForChart = chartPivot ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69511
69724
  const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
69512
69725
  const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
69513
- const rowCountForChartResolved = chartPivotForDisplay ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69726
+ const rowCountForChartResolved = chartPivot ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69514
69727
  const chartDataPayload = {
69515
69728
  ...sourceReport,
69516
69729
  rows: rowsForChart,
69517
69730
  rowCount: rowCountForChartResolved,
69518
69731
  chartType: chartType ?? sourceReport.chartType,
69519
69732
  reportBuilderState: effectiveReportBuilderState,
69520
- pivot: chartPivotForDisplay,
69733
+ pivot: chartPivot,
69521
69734
  referencedTables: referencedTablesForChart && referencedTablesForChart.length > 0 ? referencedTablesForChart : sourceReport.referencedTables,
69522
69735
  pivotRows: pivotRowsForChart,
69523
69736
  pivotColumns: sourceReport.pivotColumns,
@@ -69598,7 +69811,7 @@ function useReport(reportIdArg, options = {}) {
69598
69811
  const xAxisOptions = useMemo33(() => {
69599
69812
  if (!chartAxesBaseChart) return chartAxisOptions;
69600
69813
  const pivot = chartAxesBaseChart.pivot;
69601
- const pivotRowField = String(pivot?.rowField ?? "").trim();
69814
+ const pivotRowField = pivotRowKey(chartAxesBaseChart);
69602
69815
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69603
69816
  if (pivot && pivotRowField) {
69604
69817
  if (["metric", "gauge"].includes(chartType2)) {
@@ -69719,9 +69932,7 @@ function useReport(reportIdArg, options = {}) {
69719
69932
  const resolvedXAxisField = useMemo33(() => {
69720
69933
  if (!chartAxesBaseChart) return "";
69721
69934
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69722
- const pivotRowField = String(
69723
- chartAxesBaseChart.pivot?.rowField ?? ""
69724
- ).trim();
69935
+ const pivotRowField = pivotRowKey(chartAxesBaseChart);
69725
69936
  if (pivotRowField) {
69726
69937
  const rowColumn = (chartAxesBaseChart.pivotColumns ?? chartAxesBaseChart.columns ?? []).find((col) => String(col.field ?? "").trim() === pivotRowField);
69727
69938
  if (shouldUsePivotRowFieldAsXAxis(
@@ -69857,11 +70068,11 @@ function useReport(reportIdArg, options = {}) {
69857
70068
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69858
70069
  columns: columns2 ?? baseChart.columns,
69859
70070
  yAxisFields: resolvedYAxisFieldsForDisplay,
69860
- pivotRowField: String(baseChart.pivot.rowField ?? ""),
70071
+ pivotRowField: pivotRowKey(baseChart),
69861
70072
  xAxisLabel: resolvedXAxisLabel
69862
70073
  });
69863
70074
  } else {
69864
- const pivotRowField = String(baseChart.pivot.rowField ?? "").trim();
70075
+ const pivotRowField = pivotRowKey(baseChart);
69865
70076
  const pivotLabelByField = new Map(
69866
70077
  (baseChart.pivotColumns ?? []).map((column) => [
69867
70078
  String(column.field ?? "").trim(),
@@ -69926,7 +70137,10 @@ function useReport(reportIdArg, options = {}) {
69926
70137
  const key = String(raw);
69927
70138
  const timestamp = new Date(key).getTime();
69928
70139
  if (Number.isNaN(timestamp)) continue;
69929
- labelsByRaw.set(key, String(record[rowField] ?? key));
70140
+ labelsByRaw.set(
70141
+ key,
70142
+ String(record[pivotRowKey(chart)] ?? record[rowField] ?? key)
70143
+ );
69930
70144
  const cachedMin = pivotDateFilterRangeCacheRef.current.min;
69931
70145
  const cachedMax = pivotDateFilterRangeCacheRef.current.max;
69932
70146
  if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
@@ -70227,9 +70441,7 @@ function useReport(reportIdArg, options = {}) {
70227
70441
  sourceReport,
70228
70442
  includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
70229
70443
  });
70230
- const pivotRowFieldForTable = String(
70231
- sourceReport?.pivot?.rowField ?? ""
70232
- ).trim();
70444
+ const pivotRowFieldForTable = pivotRowKey(sourceReport);
70233
70445
  const pivotRowTableUsesAxisFormat = chartAxisEdits.xAxisFormat !== void 0;
70234
70446
  const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
70235
70447
  (column) => column.field === pivotRowFieldForTable ? {
@@ -70241,7 +70453,7 @@ function useReport(reportIdArg, options = {}) {
70241
70453
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70242
70454
  columns: columns2,
70243
70455
  yAxisFields: resolvedYAxisFieldsForDisplay,
70244
- pivotRowField: String(sourceReport.pivot.rowField ?? ""),
70456
+ pivotRowField: pivotRowKey(sourceReport),
70245
70457
  xAxisLabel: resolvedXAxisLabel
70246
70458
  }) ?? columns2 : columns2;
70247
70459
  const tableColumnsWithPivotDisplayLabels = pivotLabeledColumns.map(
@@ -70490,7 +70702,7 @@ function useReport(reportIdArg, options = {}) {
70490
70702
  if (slotFormatting) {
70491
70703
  const aggregations = slotFormatting.aggregations;
70492
70704
  const hasMultiple = aggregations.length > 1;
70493
- const rowField = String(pivotState?.rowField ?? "").trim();
70705
+ const rowField = pivotRowKey(chart);
70494
70706
  const firstValueColumnFormat = String(
70495
70707
  (chart.columns ?? []).find(
70496
70708
  (c) => String(c.field ?? "").trim() !== rowField
@@ -70526,9 +70738,7 @@ function useReport(reportIdArg, options = {}) {
70526
70738
  }
70527
70739
  }
70528
70740
  }
70529
- const pivotRowFieldForSettings = String(
70530
- chart?.pivot?.rowField ?? ""
70531
- ).trim();
70741
+ const pivotRowFieldForSettings = pivotRowKey(chart);
70532
70742
  const rowAxisLabel = String(resolvedXAxisLabel ?? "").trim();
70533
70743
  for (const columnId of activeTableColumnIds) {
70534
70744
  const option = columnOptionById.get(columnId);
@@ -70588,7 +70798,7 @@ function useReport(reportIdArg, options = {}) {
70588
70798
  tableColumnSettingsCoalesceRef.current = new Map(tableColumnSettingsById);
70589
70799
  }, [tableColumnSettingsById]);
70590
70800
  const tableColumnItems = useMemo33(() => {
70591
- const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70801
+ const pivotRowFieldForFormat = pivotRowKey(chart);
70592
70802
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70593
70803
  const items = activeTableColumnIds.map((columnId) => {
70594
70804
  const option = columnOptionById.get(columnId);
@@ -70627,7 +70837,7 @@ function useReport(reportIdArg, options = {}) {
70627
70837
  return new Map(tableColumnItems.map((item) => [item.id, item]));
70628
70838
  }, [tableColumnItems]);
70629
70839
  const tableColumnValues = useMemo33(() => {
70630
- const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70840
+ const pivotRowFieldForFormat = pivotRowKey(chart);
70631
70841
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70632
70842
  return tableColumnItems.map((item) => {
70633
70843
  const coerced = coerceTableColumnFormatToAxisValue(item.format);
@@ -70648,8 +70858,89 @@ function useReport(reportIdArg, options = {}) {
70648
70858
  const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
70649
70859
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
70650
70860
  const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70651
- const tableLoading = initialLoadInProgress || pendingPivotRefresh || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70861
+ const awaitingPivotDetailRows = Boolean(nextPivot || sourceReport?.pivot) && !reportOverride && Boolean(sourceReport) && sourceReportMatchesEffectiveReportId && (!Array.isArray(sourceReport?.rows) || sourceReport.rows.length === 0) && pivotTableDataRefreshQuery.status !== "error";
70862
+ const tableLoading = initialLoadInProgress || pendingPivotRefresh || awaitingPivotDetailRows || tablePageFetching && pagination.pageIndex > 0 || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70652
70863
  const loading = chartLoading || tableLoading;
70864
+ const lastUseReportLoadingLogRef = useRef24("");
70865
+ useEffect33(() => {
70866
+ const snapshot = {
70867
+ reportId: effectiveReportId,
70868
+ chartLoading,
70869
+ tableLoading,
70870
+ loading,
70871
+ initialLoadInProgress,
70872
+ initialLoad: {
70873
+ status: initialLoadQuery.status,
70874
+ fetchStatus: initialLoadQuery.fetchStatus,
70875
+ isPending: initialLoadQuery.isPending,
70876
+ isFetching: initialLoadQuery.isFetching,
70877
+ hasData: initialLoadQuery.data !== void 0,
70878
+ dataUpdatedAt: initialLoadQuery.dataUpdatedAt,
70879
+ staleTime: 0
70880
+ },
70881
+ pendingPivotRefresh,
70882
+ pivotRefresh: {
70883
+ enabled: pivotRefreshQueryEnabled,
70884
+ isFetching: pivotRefreshQuery.isFetching
70885
+ },
70886
+ tableRefresh: {
70887
+ enabled: tableRefreshQueryEnabled,
70888
+ isFetching: tableRefreshQuery.isFetching
70889
+ },
70890
+ pivotTableData: {
70891
+ enabled: pivotTableDataRefreshQueryEnabled,
70892
+ isFetching: pivotTableDataRefreshQuery.isFetching
70893
+ },
70894
+ tablePage: {
70895
+ enabled: tablePageQueryEnabled,
70896
+ isFetching: tablePageQuery.isFetching
70897
+ },
70898
+ uniqueValues: {
70899
+ enabled: filterUniqueValuesEnabled,
70900
+ isFetching: filterUniqueValuesQuery.isFetching,
70901
+ isPending: filterUniqueValuesQuery.isPending
70902
+ },
70903
+ whyChartLoading: {
70904
+ noClient: !client,
70905
+ initialPending: initialLoadQuery.isPending,
70906
+ initialFetching: initialLoadQuery.isFetching,
70907
+ pendingPivotRefresh,
70908
+ pivotRefreshFetching: Boolean(nextPivot) && pivotRefreshQuery.isFetching,
70909
+ tableRefreshFetching: !nextPivot && tableRefreshQuery.isFetching
70910
+ }
70911
+ };
70912
+ const serialized = JSON.stringify(snapshot);
70913
+ if (serialized === lastUseReportLoadingLogRef.current) return;
70914
+ lastUseReportLoadingLogRef.current = serialized;
70915
+ profileDashboard("use-report-loading", snapshot);
70916
+ }, [
70917
+ client,
70918
+ chartLoading,
70919
+ effectiveReportId,
70920
+ filterUniqueValuesEnabled,
70921
+ filterUniqueValuesQuery.fetchStatus,
70922
+ filterUniqueValuesQuery.isFetching,
70923
+ filterUniqueValuesQuery.isPending,
70924
+ initialLoadInProgress,
70925
+ initialLoadQuery.data,
70926
+ initialLoadQuery.dataUpdatedAt,
70927
+ initialLoadQuery.fetchStatus,
70928
+ initialLoadQuery.isFetching,
70929
+ initialLoadQuery.isPending,
70930
+ initialLoadQuery.status,
70931
+ loading,
70932
+ nextPivot,
70933
+ pendingPivotRefresh,
70934
+ pivotRefreshQuery.isFetching,
70935
+ pivotRefreshQueryEnabled,
70936
+ pivotTableDataRefreshQuery.isFetching,
70937
+ pivotTableDataRefreshQueryEnabled,
70938
+ tableLoading,
70939
+ tablePageQuery.isFetching,
70940
+ tablePageQueryEnabled,
70941
+ tableRefreshQuery.isFetching,
70942
+ tableRefreshQueryEnabled
70943
+ ]);
70653
70944
  const buildSetReportColumnsFromIds = (nextColumnIds, settingsById) => {
70654
70945
  const normalizedNextIds = nextColumnIds.map((columnId) => String(columnId ?? "").trim()).filter(Boolean);
70655
70946
  return normalizedNextIds.map((columnId) => {
@@ -70689,7 +70980,7 @@ function useReport(reportIdArg, options = {}) {
70689
70980
  const option = columnOptionById.get(normalizedId);
70690
70981
  const pivotField = String(option?.field ?? normalizedId).trim();
70691
70982
  const pivotModel = chartAxesBaseChart.pivot;
70692
- const rowField = String(pivotModel?.rowField ?? "").trim();
70983
+ const rowField = pivotRowKey(chartAxesBaseChart);
70693
70984
  if (!pivotModel) return null;
70694
70985
  const isPivotRowColumn = Boolean(
70695
70986
  pivotField && rowField && pivotField === rowField