@grafana/scenes 6.28.2--canary.1196.16518846434.0 → 6.28.2--canary.1195.16567768943.0

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.js CHANGED
@@ -646,7 +646,7 @@ class SceneRenderProfiler {
646
646
  );
647
647
  __privateSet$3(this, _trailAnimationFrameId, null);
648
648
  const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
649
- performance.measure("DashboardInteraction", {
649
+ performance.measure(`DashboardInteraction ${__privateGet$3(this, _profileInProgress).origin}`, {
650
650
  start: profileStartTs,
651
651
  end: profileEndTs
652
652
  });
@@ -664,6 +664,7 @@ class SceneRenderProfiler {
664
664
  // @ts-ignore
665
665
  totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
666
666
  });
667
+ __privateSet$3(this, _profileInProgress, null);
667
668
  }
668
669
  if (window.__runs) {
669
670
  window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
@@ -676,14 +677,22 @@ class SceneRenderProfiler {
676
677
  };
677
678
  }
678
679
  startProfile(name) {
679
- if (__privateGet$3(this, _trailAnimationFrameId)) {
680
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
681
- __privateSet$3(this, _trailAnimationFrameId, null);
682
- writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
680
+ if (__privateGet$3(this, _profileInProgress)) {
681
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
682
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
683
+ __privateSet$3(this, _trailAnimationFrameId, null);
684
+ writeSceneLog(this.constructor.name, "New profile: Stopped recording frames ");
685
+ __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
686
+ __privateSet$3(this, _profileStartTs, performance.now());
687
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
688
+ } else {
689
+ this.addCrumb(name);
690
+ }
691
+ } else {
692
+ __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
693
+ __privateSet$3(this, _profileStartTs, performance.now());
694
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
683
695
  }
684
- __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
685
- __privateSet$3(this, _profileStartTs, performance.now());
686
- writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
687
696
  }
688
697
  recordProfileTail(measurementStartTime, profileStartTs) {
689
698
  __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
@@ -709,6 +718,7 @@ class SceneRenderProfiler {
709
718
  }
710
719
  addCrumb(crumb) {
711
720
  if (__privateGet$3(this, _profileInProgress)) {
721
+ writeSceneLog(this.constructor.name, "Adding crumb:", crumb);
712
722
  __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
713
723
  }
714
724
  }
@@ -757,6 +767,13 @@ function calculateNetworkTime(requests) {
757
767
  totalNetworkTime += currentEnd - currentStart;
758
768
  return totalNetworkTime;
759
769
  }
770
+ const REFRESH_INTERACTION = "refresh";
771
+ const TIME_RANGE_CHANGE_INTERACTION = "time_range_change";
772
+ const FILTER_REMOVED_INTERACTION = "filter_removed";
773
+ const FILTER_CHANGED_INTERACTION = "filter_changed";
774
+ const FILTER_RESTORED_INTERACTION = "filter_restored";
775
+ const VARIABLE_VALUE_CHANGED_INTERACTION = "variable_value_changed";
776
+ const SCOPES_CHANGED_INTERACTION = "scopes_changed";
760
777
 
761
778
  var __typeError$2 = (msg) => {
762
779
  throw TypeError(msg);
@@ -1038,7 +1055,7 @@ class SceneTimeRange extends SceneObjectBase {
1038
1055
  );
1039
1056
  if (update.from !== this.state.from || update.to !== this.state.to) {
1040
1057
  const queryController = getQueryController(this);
1041
- queryController == null ? void 0 : queryController.startProfile("SceneTimeRange");
1058
+ queryController == null ? void 0 : queryController.startProfile(TIME_RANGE_CHANGE_INTERACTION);
1042
1059
  this._urlSync.performBrowserHistoryAction(() => {
1043
1060
  this.setState(update);
1044
1061
  });
@@ -2401,21 +2418,13 @@ const macrosIndex = /* @__PURE__ */ new Map([
2401
2418
  ["__interval", IntervalMacro],
2402
2419
  ["__interval_ms", IntervalMacro]
2403
2420
  ]);
2404
- function registerVariableMacro(name, macro, replace = false) {
2405
- if (macrosIndex.get(name) && !replace) {
2421
+ function registerVariableMacro(name, macro) {
2422
+ if (macrosIndex.get(name)) {
2406
2423
  throw new Error(`Macro already registered ${name}`);
2407
2424
  }
2408
- let replacedMacro;
2409
- if (macrosIndex.has(name) && !replace) {
2410
- replacedMacro = macrosIndex.get(name);
2411
- }
2412
2425
  macrosIndex.set(name, macro);
2413
2426
  return () => {
2414
- if (replacedMacro) {
2415
- macrosIndex.set(name, replacedMacro);
2416
- } else {
2417
- macrosIndex.delete(name);
2418
- }
2427
+ macrosIndex.delete(name);
2419
2428
  };
2420
2429
  }
2421
2430
 
@@ -2561,6 +2570,7 @@ function wrapPromiseInStateObservable(promise) {
2561
2570
  }
2562
2571
 
2563
2572
  async function getDataSource(datasource, scopedVars) {
2573
+ var _a;
2564
2574
  if (datasource == null ? void 0 : datasource.uid) {
2565
2575
  const runtimeDataSource = runtimeDataSources.get(datasource.uid);
2566
2576
  if (runtimeDataSource) {
@@ -2576,7 +2586,7 @@ async function getDataSource(datasource, scopedVars) {
2576
2586
  if (queryControler && queryControler.state.enableProfiling) {
2577
2587
  wrapPromiseInStateObservable(dsPromise).pipe(
2578
2588
  registerQueryWithController({
2579
- type: "plugin",
2589
+ type: `plugin/${(_a = datasource == null ? void 0 : datasource.type) != null ? _a : "unknown"}`,
2580
2590
  origin: scopedVars.__sceneObject.value.valueOf()
2581
2591
  })
2582
2592
  ).subscribe(() => {
@@ -2918,7 +2928,7 @@ function VariableValueSelect({ model, state }) {
2918
2928
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2919
2929
  onChange: (newValue) => {
2920
2930
  model.changeValueTo(newValue.value, newValue.label, true);
2921
- queryController == null ? void 0 : queryController.startProfile("VariableValueSelect");
2931
+ queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
2922
2932
  if (hasCustomValue !== newValue.__isNew__) {
2923
2933
  setHasCustomValue(newValue.__isNew__);
2924
2934
  }
@@ -2991,7 +3001,7 @@ function VariableValueSelectMulti({
2991
3001
  onInputChange,
2992
3002
  onBlur: () => {
2993
3003
  model.changeValueTo(uncommittedValue, void 0, true);
2994
- queryController == null ? void 0 : queryController.startProfile("VariableValueSelectMulti");
3004
+ queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
2995
3005
  },
2996
3006
  filterOption: filterNoOp$2,
2997
3007
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -4634,6 +4644,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4634
4644
  valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
4635
4645
  values.push(item.value);
4636
4646
  });
4647
+ let shouldUpdate = true;
4648
+ if (Array.isArray(filter2.values) && filter2.values.length === values.length) {
4649
+ shouldUpdate = !filter2.values.every((v, i) => v === values[i]);
4650
+ }
4651
+ if (shouldUpdate) {
4652
+ const queryController = getQueryController(model2);
4653
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
4654
+ }
4637
4655
  model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
4638
4656
  setFilterMultiValues([]);
4639
4657
  }
@@ -4786,6 +4804,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4786
4804
  return;
4787
4805
  }
4788
4806
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4807
+ if (isFilterComplete(filter)) {
4808
+ const queryController = getQueryController(model);
4809
+ queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
4810
+ }
4789
4811
  model._handleComboboxBackspace(filter);
4790
4812
  if (isAlwaysWip) {
4791
4813
  handleResetWip();
@@ -4850,16 +4872,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4850
4872
  handleLocalMultiValueChange(selectedItem);
4851
4873
  setInputValue("");
4852
4874
  } else {
4853
- model._updateFilter(
4875
+ const payload = generateFilterUpdatePayload({
4876
+ filterInputType,
4877
+ item: selectedItem,
4854
4878
  filter,
4855
- generateFilterUpdatePayload({
4856
- filterInputType,
4857
- item: selectedItem,
4858
- filter,
4859
- setFilterMultiValues,
4860
- onAddCustomValue
4861
- })
4862
- );
4879
+ setFilterMultiValues,
4880
+ onAddCustomValue
4881
+ });
4882
+ if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
4883
+ const queryController = getQueryController(model);
4884
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
4885
+ }
4886
+ model._updateFilter(filter, payload);
4863
4887
  populateInputValueOnInputTypeSwitch({
4864
4888
  populateInputOnEdit,
4865
4889
  item: selectedItem,
@@ -5107,16 +5131,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
5107
5131
  setInputValue("");
5108
5132
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
5109
5133
  } else {
5110
- model._updateFilter(
5134
+ const payload = generateFilterUpdatePayload({
5135
+ filterInputType,
5136
+ item,
5111
5137
  filter,
5112
- generateFilterUpdatePayload({
5113
- filterInputType,
5114
- item,
5115
- filter,
5116
- setFilterMultiValues,
5117
- onAddCustomValue
5118
- })
5119
- );
5138
+ setFilterMultiValues,
5139
+ onAddCustomValue
5140
+ });
5141
+ if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
5142
+ const queryController = getQueryController(model);
5143
+ queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
5144
+ }
5145
+ model._updateFilter(filter, payload);
5120
5146
  populateInputValueOnInputTypeSwitch({
5121
5147
  populateInputOnEdit,
5122
5148
  item,
@@ -5842,6 +5868,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5842
5868
  original.valueLabels = originalFilter == null ? void 0 : originalFilter.value;
5843
5869
  original.operator = originalFilter == null ? void 0 : originalFilter.operator;
5844
5870
  original.nonApplicable = originalFilter == null ? void 0 : originalFilter.nonApplicable;
5871
+ const queryController = getQueryController(this);
5872
+ queryController == null ? void 0 : queryController.startProfile(FILTER_RESTORED_INTERACTION);
5845
5873
  this._updateFilter(filter, original);
5846
5874
  }
5847
5875
  }
@@ -5898,6 +5926,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5898
5926
  this.setState({ _wip: void 0 });
5899
5927
  return;
5900
5928
  }
5929
+ const queryController = getQueryController(this);
5930
+ queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
5901
5931
  this._setStateWithFiltersApplicabilityCheck({
5902
5932
  filters: this.state.filters.filter((f) => f !== filter),
5903
5933
  originFilters: this.state.originFilters
@@ -7540,6 +7570,8 @@ class ScopesVariable extends SceneObjectBase {
7540
7570
  const newScopes = state.value.map((scope) => scope.metadata.name);
7541
7571
  const scopesHaveChanged = !lodash.isEqual(oldScopes, newScopes);
7542
7572
  if (!loading && (scopesHaveChanged || newScopes.length === 0)) {
7573
+ const queryController = getQueryController(this);
7574
+ queryController == null ? void 0 : queryController.startProfile(SCOPES_CHANGED_INTERACTION);
7543
7575
  this.setState({ scopes: state.value, loading });
7544
7576
  this.publishEvent(new SceneVariableValueChangedEvent(this), true);
7545
7577
  } else {
@@ -8656,7 +8688,7 @@ class VizPanel extends SceneObjectBase {
8656
8688
  const panelPromise = importPanelPlugin(pluginId);
8657
8689
  const queryControler = sceneGraph.getQueryController(this);
8658
8690
  if (queryControler && queryControler.state.enableProfiling) {
8659
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
8691
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: `plugin/${pluginId}`, origin: this })).subscribe(() => {
8660
8692
  });
8661
8693
  }
8662
8694
  const result = await panelPromise;
@@ -12023,7 +12055,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12023
12055
  this._autoRefreshBlocked = false;
12024
12056
  this.onRefresh = () => {
12025
12057
  const queryController = sceneGraph.getQueryController(this);
12026
- queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12058
+ queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12027
12059
  if (queryController == null ? void 0 : queryController.state.isRunning) {
12028
12060
  queryController.cancelAll();
12029
12061
  return;
@@ -12080,7 +12112,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12080
12112
  this._intervalTimer = setInterval(() => {
12081
12113
  if (this.isTabVisible()) {
12082
12114
  const queryController = sceneGraph.getQueryController(this);
12083
- queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12115
+ queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12084
12116
  timeRange.onRefresh();
12085
12117
  } else {
12086
12118
  this._autoRefreshBlocked = true;