@grafana/scenes 6.28.2 → 6.28.3--canary.1195.16590049708.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
  });
@@ -1951,6 +1968,8 @@ class MultiValueVariable extends SceneObjectBase {
1951
1968
  }
1952
1969
  const stateChangeAction = () => this.setStateHelper({ value, text, loading: false });
1953
1970
  if (isUserAction) {
1971
+ const queryController = getQueryController(this);
1972
+ queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
1954
1973
  (_b = (_a = this._urlSync).performBrowserHistoryAction) == null ? void 0 : _b.call(_a, stateChangeAction);
1955
1974
  } else {
1956
1975
  stateChangeAction();
@@ -2553,6 +2572,7 @@ function wrapPromiseInStateObservable(promise) {
2553
2572
  }
2554
2573
 
2555
2574
  async function getDataSource(datasource, scopedVars) {
2575
+ var _a;
2556
2576
  if (datasource == null ? void 0 : datasource.uid) {
2557
2577
  const runtimeDataSource = runtimeDataSources.get(datasource.uid);
2558
2578
  if (runtimeDataSource) {
@@ -2568,7 +2588,7 @@ async function getDataSource(datasource, scopedVars) {
2568
2588
  if (queryControler && queryControler.state.enableProfiling) {
2569
2589
  wrapPromiseInStateObservable(dsPromise).pipe(
2570
2590
  registerQueryWithController({
2571
- type: "plugin",
2591
+ type: `plugin/${(_a = datasource == null ? void 0 : datasource.type) != null ? _a : "unknown"}`,
2572
2592
  origin: scopedVars.__sceneObject.value.valueOf()
2573
2593
  })
2574
2594
  ).subscribe(() => {
@@ -2910,7 +2930,7 @@ function VariableValueSelect({ model, state }) {
2910
2930
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2911
2931
  onChange: (newValue) => {
2912
2932
  model.changeValueTo(newValue.value, newValue.label, true);
2913
- queryController == null ? void 0 : queryController.startProfile("VariableValueSelect");
2933
+ queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
2914
2934
  if (hasCustomValue !== newValue.__isNew__) {
2915
2935
  setHasCustomValue(newValue.__isNew__);
2916
2936
  }
@@ -2935,7 +2955,6 @@ function VariableValueSelectMulti({
2935
2955
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2936
2956
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2937
2957
  const [inputValue, setInputValue] = React.useState("");
2938
- const queryController = sceneGraph.getQueryController(model);
2939
2958
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2940
2959
  React.useEffect(() => {
2941
2960
  setUncommittedValue(arrayValue);
@@ -2983,7 +3002,6 @@ function VariableValueSelectMulti({
2983
3002
  onInputChange,
2984
3003
  onBlur: () => {
2985
3004
  model.changeValueTo(uncommittedValue, void 0, true);
2986
- queryController == null ? void 0 : queryController.startProfile("VariableValueSelectMulti");
2987
3005
  },
2988
3006
  filterOption: filterNoOp$2,
2989
3007
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -4626,6 +4644,14 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4626
4644
  valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
4627
4645
  values.push(item.value);
4628
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
+ }
4629
4655
  model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
4630
4656
  setFilterMultiValues([]);
4631
4657
  }
@@ -4778,6 +4804,10 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4778
4804
  return;
4779
4805
  }
4780
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
+ }
4781
4811
  model._handleComboboxBackspace(filter);
4782
4812
  if (isAlwaysWip) {
4783
4813
  handleResetWip();
@@ -4842,16 +4872,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4842
4872
  handleLocalMultiValueChange(selectedItem);
4843
4873
  setInputValue("");
4844
4874
  } else {
4845
- model._updateFilter(
4875
+ const payload = generateFilterUpdatePayload({
4876
+ filterInputType,
4877
+ item: selectedItem,
4846
4878
  filter,
4847
- generateFilterUpdatePayload({
4848
- filterInputType,
4849
- item: selectedItem,
4850
- filter,
4851
- setFilterMultiValues,
4852
- onAddCustomValue
4853
- })
4854
- );
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);
4855
4887
  populateInputValueOnInputTypeSwitch({
4856
4888
  populateInputOnEdit,
4857
4889
  item: selectedItem,
@@ -5099,16 +5131,18 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
5099
5131
  setInputValue("");
5100
5132
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
5101
5133
  } else {
5102
- model._updateFilter(
5134
+ const payload = generateFilterUpdatePayload({
5135
+ filterInputType,
5136
+ item,
5103
5137
  filter,
5104
- generateFilterUpdatePayload({
5105
- filterInputType,
5106
- item,
5107
- filter,
5108
- setFilterMultiValues,
5109
- onAddCustomValue
5110
- })
5111
- );
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);
5112
5146
  populateInputValueOnInputTypeSwitch({
5113
5147
  populateInputOnEdit,
5114
5148
  item,
@@ -5834,6 +5868,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5834
5868
  original.valueLabels = originalFilter == null ? void 0 : originalFilter.value;
5835
5869
  original.operator = originalFilter == null ? void 0 : originalFilter.operator;
5836
5870
  original.nonApplicable = originalFilter == null ? void 0 : originalFilter.nonApplicable;
5871
+ const queryController = getQueryController(this);
5872
+ queryController == null ? void 0 : queryController.startProfile(FILTER_RESTORED_INTERACTION);
5837
5873
  this._updateFilter(filter, original);
5838
5874
  }
5839
5875
  }
@@ -5890,6 +5926,8 @@ class AdHocFiltersVariable extends SceneObjectBase {
5890
5926
  this.setState({ _wip: void 0 });
5891
5927
  return;
5892
5928
  }
5929
+ const queryController = getQueryController(this);
5930
+ queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
5893
5931
  this._setStateWithFiltersApplicabilityCheck({
5894
5932
  filters: this.state.filters.filter((f) => f !== filter),
5895
5933
  originFilters: this.state.originFilters
@@ -7532,6 +7570,8 @@ class ScopesVariable extends SceneObjectBase {
7532
7570
  const newScopes = state.value.map((scope) => scope.metadata.name);
7533
7571
  const scopesHaveChanged = !lodash.isEqual(oldScopes, newScopes);
7534
7572
  if (!loading && (scopesHaveChanged || newScopes.length === 0)) {
7573
+ const queryController = getQueryController(this);
7574
+ queryController == null ? void 0 : queryController.startProfile(SCOPES_CHANGED_INTERACTION);
7535
7575
  this.setState({ scopes: state.value, loading });
7536
7576
  this.publishEvent(new SceneVariableValueChangedEvent(this), true);
7537
7577
  } else {
@@ -8648,7 +8688,7 @@ class VizPanel extends SceneObjectBase {
8648
8688
  const panelPromise = importPanelPlugin(pluginId);
8649
8689
  const queryControler = sceneGraph.getQueryController(this);
8650
8690
  if (queryControler && queryControler.state.enableProfiling) {
8651
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
8691
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: `plugin/${pluginId}`, origin: this })).subscribe(() => {
8652
8692
  });
8653
8693
  }
8654
8694
  const result = await panelPromise;
@@ -12016,7 +12056,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12016
12056
  this._autoRefreshBlocked = false;
12017
12057
  this.onRefresh = () => {
12018
12058
  const queryController = sceneGraph.getQueryController(this);
12019
- queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12059
+ queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12020
12060
  if (queryController == null ? void 0 : queryController.state.isRunning) {
12021
12061
  queryController.cancelAll();
12022
12062
  return;
@@ -12073,7 +12113,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12073
12113
  this._intervalTimer = setInterval(() => {
12074
12114
  if (this.isTabVisible()) {
12075
12115
  const queryController = sceneGraph.getQueryController(this);
12076
- queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12116
+ queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12077
12117
  timeRange.onRefresh();
12078
12118
  } else {
12079
12119
  this._autoRefreshBlocked = true;