@vizzly/dashboard 0.14.4-dev-bba43aecbb9d5b65a950ef259163441af1041848 → 0.14.4-dev-76edeccc1decaf049cbb0c1cdae16c74c5959d4f

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.
@@ -3684,6 +3684,10 @@ var usedMeasures = function usedMeasures(attrs) {
3684
3684
  if ('yMeasure' in attrs && attrs.yMeasure) {
3685
3685
  usedMeasures = [].concat(usedMeasures, [attrs.yMeasure]);
3686
3686
  }
3687
+ if ('zMeasure' in attrs && attrs.zMeasure) {
3688
+ var newMeasures = Array.isArray(attrs.zMeasure) ? attrs.zMeasure : [attrs.zMeasure];
3689
+ usedMeasures = [].concat(usedMeasures, newMeasures);
3690
+ }
3687
3691
  return usedMeasures;
3688
3692
  };
3689
3693
  var usedDimensions = function usedDimensions(attrs) {
@@ -3702,18 +3706,34 @@ var usedDimensions = function usedDimensions(attrs) {
3702
3706
  var usedFields = function usedFields(attrs) {
3703
3707
  var usedFields = [];
3704
3708
  usedMeasures(attrs).forEach(function (measure) {
3705
- usedFields = [].concat(usedFields, [measure.field]);
3709
+ usedFields = [].concat(usedFields, [{
3710
+ fieldId: measure.field,
3711
+ "function": measure["function"],
3712
+ dataSetId: attrs.dataSetId
3713
+ }]);
3706
3714
  });
3707
3715
  usedDimensions(attrs).forEach(function (dimension) {
3708
- usedFields = [].concat(usedFields, [dimension.field]);
3716
+ usedFields = [].concat(usedFields, [{
3717
+ fieldId: dimension.field,
3718
+ "function": dimension["function"],
3719
+ dataSetId: attrs.dataSetId
3720
+ }]);
3709
3721
  });
3710
3722
  if ('order' in attrs && attrs.order) {
3711
3723
  usedFields = [].concat(usedFields, [].concat(attrs.order).map(function (d) {
3712
- return d.field;
3724
+ return {
3725
+ fieldId: d.field,
3726
+ "function": d["function"],
3727
+ dataSetId: attrs.dataSetId
3728
+ };
3713
3729
  }));
3714
3730
  }
3715
3731
  if ('timeDimension' in attrs && attrs.timeDimension) {
3716
- usedFields = [].concat(usedFields, [attrs.timeDimension.field]);
3732
+ usedFields = [].concat(usedFields, [{
3733
+ fieldId: attrs.timeDimension.field,
3734
+ "function": attrs.timeDimension.truncate,
3735
+ dataSetId: attrs.dataSetId
3736
+ }]);
3717
3737
  }
3718
3738
  return usedFields;
3719
3739
  };
@@ -3734,7 +3754,9 @@ var validateView = (function (attrs, dataSets, queryEngineConfig) {
3734
3754
  // Check the data set for the view exists
3735
3755
  var dataSet = find(dataSets, attrs.dataSetId);
3736
3756
  if (!dataSet) return [new DataSetNotFound(dataSets, attrs.dataSetId)];
3737
- var requiredFields = usedFields(attrs);
3757
+ var requiredFields = usedFields(attrs).map(function (field) {
3758
+ return field.fieldId;
3759
+ });
3738
3760
  try {
3739
3761
  requiredFields.forEach(function (requiredField) {
3740
3762
  findField(dataSet, requiredField);
@@ -23052,6 +23074,7 @@ var getDataSetsUsedOnDisplay = function getDataSetsUsedOnDisplay(dashboard) {
23052
23074
  if (!isComponentEmpty(component) && !isComponent(component)) {
23053
23075
  usedDataSetIds = [].concat(usedDataSetIds, [component.attributes.dataSetId]);
23054
23076
  }
23077
+ return;
23055
23078
  });
23056
23079
  });
23057
23080
  return _.uniq(usedDataSetIds).flatMap(function (dataSetId) {
@@ -23232,6 +23255,83 @@ var checkAndReturnProgrammaticDashboardId = function checkAndReturnProgrammaticD
23232
23255
  }
23233
23256
  return programmaticDashboards[0].id;
23234
23257
  };
23258
+ var getFieldUsage = function getFieldUsage(dashboardDefinition, dataSets) {
23259
+ var fieldUsageFields = [];
23260
+
23261
+ // TODO; look through the fields used in custom metrics
23262
+ // and add those to the list of used fields
23263
+
23264
+ // TODO; look through the component library and
23265
+ // add those fields to the list of those used by the dashboard
23266
+ // NOTE; initial plan was to store fields used in the library on the library
23267
+ // field usage, however at this point, we get the component library and the
23268
+ // dashboard manager updates them separately, meaning we'd need to pass through
23269
+ // the field usage individually for the dashboard or the component library, but we
23270
+ // only allow one pass through of used fields at the moment.
23271
+
23272
+ // Add fields from the global filters
23273
+ dashboardDefinition.globalFilters.forEach(function (globalFilter) {
23274
+ globalFilter.appliesToFields.forEach(function (field) {
23275
+ try {
23276
+ var dataSet = find(dataSets, field.dataSetId);
23277
+ if (!dataSet) {
23278
+ logDebug('Did not find data set when finding field usage', field.dataSetId);
23279
+ return;
23280
+ }
23281
+ var fieldInDataSet = findField(dataSet, field.fieldId);
23282
+ fieldUsageFields = [].concat(fieldUsageFields, [{
23283
+ data_set_id: field.dataSetId,
23284
+ field_id: field.fieldId,
23285
+ "function": 'none',
23286
+ name: fieldInDataSet.publicName
23287
+ }]);
23288
+ } catch (e) {
23289
+ if (e instanceof FieldNotFoundInDataSet) {
23290
+ logDebug("Did not find field in data set, assuming custom metric. " + field.fieldId);
23291
+ } else {
23292
+ logError(e);
23293
+ }
23294
+ return;
23295
+ }
23296
+ });
23297
+ });
23298
+
23299
+ // Add fields from the views on the dashboard
23300
+ dashboardDefinition.display.forEach(function (row) {
23301
+ row.components.forEach(function (component) {
23302
+ if (!('attributes' in component)) return;
23303
+ var dataSet = find(dataSets, component.attributes.dataSetId);
23304
+ if (!dataSet) {
23305
+ logDebug('Did not find field in data set, assuming custom metric. ', component.attributes.dataSetId);
23306
+ return;
23307
+ }
23308
+ var fields = usedFields(component.attributes).flatMap(function (usedField) {
23309
+ try {
23310
+ var field = findField(dataSet, usedField.fieldId);
23311
+ return [{
23312
+ data_set_id: usedField.dataSetId,
23313
+ field_id: usedField.fieldId,
23314
+ "function": usedField["function"],
23315
+ name: field.publicName
23316
+ }];
23317
+ } catch (e) {
23318
+ if (e instanceof FieldNotFoundInDataSet) {
23319
+ logDebug("Did not find field in data set, assuming custom metric. " + usedField.fieldId);
23320
+ } else {
23321
+ logError(e);
23322
+ }
23323
+ }
23324
+ return [];
23325
+ });
23326
+ fieldUsageFields = [].concat(fieldUsageFields, fields);
23327
+ return;
23328
+ });
23329
+ });
23330
+ return {
23331
+ lowest_date_granularity_function: null,
23332
+ fields: fieldUsageFields
23333
+ };
23334
+ };
23235
23335
 
23236
23336
  // type RawGlobalFilter = Omit<GlobalFilter, 'context'>;
23237
23337
  var Dashboard;
@@ -23266,6 +23366,7 @@ var DashboardLogic = {
23266
23366
  updateWithProgrammaticDashboard: updateWithProgrammaticDashboard,
23267
23367
  addUniqueLibraryComponents: addUniqueLibraryComponents,
23268
23368
  checkAndReturnProgrammaticDashboardId: checkAndReturnProgrammaticDashboardId,
23369
+ getFieldUsage: getFieldUsage,
23269
23370
  colSpanSchema: colSpanSchema,
23270
23371
  saveableDashboardDefinitionSchema: saveableDashboardDefinitionSchema,
23271
23372
  displaySchema: displaySchema,
@@ -26261,7 +26362,9 @@ var filterStyles = /*#__PURE__*/Object.assign(function () {
26261
26362
  /** Returns a key to be used in an useEffect dependency, that changes if there's any change to a field in a data set. */
26262
26363
  var watchDataSetFieldChanges = function watchDataSetFieldChanges(dataSet, queryable) {
26263
26364
  if ('dataSetId' in queryable) {
26264
- var watchFields = usedFields(queryable);
26365
+ var watchFields = usedFields(queryable).map(function (field) {
26366
+ return field.fieldId;
26367
+ });
26265
26368
 
26266
26369
  // Custom fields are the only ones that can have their definition changed. So
26267
26370
  // we only need to watch them.
@@ -26383,7 +26486,9 @@ var useVariablesInDataSet = function useVariablesInDataSet(dataSet, queryable, v
26383
26486
  setNoOfVariableChanges = _useState3[1];
26384
26487
  React.useEffect(function () {
26385
26488
  if ('dataSetId' in queryable) {
26386
- var watchFields = usedFields(queryable);
26489
+ var watchFields = usedFields(queryable).map(function (field) {
26490
+ return field.fieldId;
26491
+ });
26387
26492
  if (variables && variables.changes) {
26388
26493
  Object.keys(variables.changes).forEach(function (variableId) {
26389
26494
  var watchedCustomFields = checkFieldsForVariableInValues(watchFields, dataSet, variableId, findField, function (filterValue) {
@@ -26401,7 +26506,9 @@ var useVariablesInDataSet = function useVariablesInDataSet(dataSet, queryable, v
26401
26506
  }, [JSON.stringify(variables)]);
26402
26507
  React.useEffect(function () {
26403
26508
  if ('dataSetId' in queryable) {
26404
- var watchFields = usedFields(queryable);
26509
+ var watchFields = usedFields(queryable).map(function (field) {
26510
+ return field.fieldId;
26511
+ });
26405
26512
  if (variables && variables.variables) {
26406
26513
  watchFields.forEach(function (fieldId) {
26407
26514
  var dataSetField = findField(dataSet, fieldId);
@@ -73094,7 +73201,8 @@ var VizzlyServices = /*#__PURE__*/function () {
73094
73201
  parentDashboardId: params.parentDashboardId,
73095
73202
  permissions: [{
73096
73203
  scope: 'read_write'
73097
- }]
73204
+ }],
73205
+ usage_metadata: params.definition ? getFieldUsage(params.definition, this.dataSets) : undefined
73098
73206
  });
73099
73207
  case 5:
73100
73208
  _yield$dashboardManag = _context3.sent;
@@ -73130,7 +73238,8 @@ var VizzlyServices = /*#__PURE__*/function () {
73130
73238
  definition: params.definition,
73131
73239
  deleted: params.deleted,
73132
73240
  abortSignal: params.abortSignal,
73133
- name: params.name
73241
+ name: params.name,
73242
+ usage_metadata: params.definition ? getFieldUsage(params.definition, this.dataSets) : undefined
73134
73243
  });
73135
73244
  case 5:
73136
73245
  dashboard = _context4.sent;
@@ -73637,7 +73746,9 @@ if (typeof window !== 'undefined' && !window.Vizzly) {
73637
73746
  // @ts-ignore
73638
73747
  var Vizzly$1 =
73639
73748
  // @ts-ignore
73640
- typeof window !== 'undefined' ? window.Vizzly || VizzlyServices : VizzlyServices;
73749
+ typeof window !== 'undefined' ?
73750
+ // @ts-ignore
73751
+ window.Vizzly || VizzlyServices : VizzlyServices;
73641
73752
 
73642
73753
  function pushGlobalLibraryCustomFieldsIntoDashboardFields(preparedDataSets, customFields) {
73643
73754
  [].concat(preparedDataSets).forEach(function (dataset) {