in src/config/glean-base.js [146:222]
async fetchData(params, appStore) {
await getProbeInfo(appStore.getState().product, params.probe).then((r) => {
const newProbe = { ...r, loaded: true };
appStore.setField('probe', newProbe);
});
const metricType = appStore.getState().probe.type;
const histogramType = appStore.getState().probe.histogram_type;
let probeView = this.getViewFromMetricType(metricType)
? this.getViewFromMetricType(metricType)
: this.probeViewFromHistogramTypeMap[histogramType];
if (metricType === 'labeled_counter') {
const isStatic =
appStore.getState().probe.labels !== null &&
appStore.getState().probe.labels.length > 0;
probeView = this.getViewFromMetricType(metricType, isStatic);
}
noUnknownMetrics(metricType, SUPPORTED_METRICS);
return getProbeData(params).then((payload) => {
const { aggregationLevel } = appStore.getState().productDimensions;
validate(payload, (p) => {
noResponse(p);
noUnknownMetrics(metricType, SUPPORTED_METRICS);
});
const viewType = probeView === 'categorical' ? 'proportion' : 'quantile';
let data = payload.response;
appStore.setField('viewType', viewType);
appStore.setField('aggMethod', data[0].client_agg_type);
// Attach labels to histogram if appropriate type.
if (probeView === 'categorical') {
const labels = {
...appStore.getState().probe.labels,
};
if (metricType === 'labeled_counter') {
data = transformLabeledCounterToCategoricalHistogramSampleCount(
data,
labels
);
}
data = produce(data, (draft) =>
draft.map((point) => ({
...point,
histogram: Object.entries(point.histogram).reduce(
(acc, [bin, value]) => {
const intBin = Math.floor(bin);
if (intBin in labels) {
acc[labels[intBin]] = value;
}
return acc;
},
{}
),
non_norm_histogram: Object.entries(point.non_norm_histogram).reduce(
(acc, [bin, value]) => {
const intBin = Math.floor(bin);
if (intBin in labels) {
acc[labels[intBin]] = value;
}
return acc;
},
{}
),
}))
);
}
data = transformAPIResponse[viewType](data, aggregationLevel, metricType);
return {
data,
probeType: probeView,
viewType,
};
});
},