@eric-emg/symphiq-components 1.2.186 → 1.2.187

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.
@@ -57279,17 +57279,43 @@ function calculateMetricTargetsFromRevenue(revenueTarget, priorYearRevenue, funn
57279
57279
  const bRelated = b.relatedInd ?? 999;
57280
57280
  return aRelated - bRelated;
57281
57281
  });
57282
+ const funnelStages = new Set();
57283
+ const relatedMetricsPerStage = new Map();
57284
+ sortedFunnelMetrics.forEach((fm) => {
57285
+ const funnelInd = fm.funnelInd ?? 0;
57286
+ funnelStages.add(funnelInd);
57287
+ const isFunnelStage = fm.funnelMetric === fm.relatedMetric;
57288
+ if (!isFunnelStage) {
57289
+ relatedMetricsPerStage.set(funnelInd, (relatedMetricsPerStage.get(funnelInd) || 0) + 1);
57290
+ }
57291
+ });
57292
+ const numFunnelStages = funnelStages.size;
57293
+ const revenueMultiplier = 1 + revenuePercentageIncrease / 100;
57294
+ const perStageMultiplier = Math.pow(revenueMultiplier, 1 / numFunnelStages);
57295
+ const funnelStagePercentageIncrease = (perStageMultiplier - 1) * 100;
57282
57296
  sortedFunnelMetrics.forEach((funnelMetric) => {
57283
57297
  const metric = funnelMetric.relatedMetric;
57284
57298
  if (!metric)
57285
57299
  return;
57286
57300
  const currentValue = baselineValues.get(metric) || 0;
57287
- let percentageIncrease = revenuePercentageIncrease;
57288
57301
  const isFunnelStage = funnelMetric.funnelMetric === metric;
57289
- if (!isFunnelStage) {
57290
- percentageIncrease = revenuePercentageIncrease * 0.8;
57302
+ const funnelInd = funnelMetric.funnelInd ?? 0;
57303
+ const isBounceRate = metric === MetricEnum.BOUNCE_RATE;
57304
+ let percentageIncrease;
57305
+ let targetValue;
57306
+ if (isBounceRate) {
57307
+ percentageIncrease = -funnelStagePercentageIncrease;
57308
+ targetValue = currentValue * (1 + percentageIncrease / 100);
57309
+ }
57310
+ else if (isFunnelStage) {
57311
+ percentageIncrease = funnelStagePercentageIncrease;
57312
+ targetValue = currentValue * (1 + percentageIncrease / 100);
57313
+ }
57314
+ else {
57315
+ const numRelatedInStage = relatedMetricsPerStage.get(funnelInd) || 1;
57316
+ percentageIncrease = funnelStagePercentageIncrease / numRelatedInStage;
57317
+ targetValue = currentValue * (1 + percentageIncrease / 100);
57291
57318
  }
57292
- const targetValue = currentValue * (1 + percentageIncrease / 100);
57293
57319
  metricCalculations.push({
57294
57320
  metric,
57295
57321
  funnelMetric: funnelMetric.funnelMetric,