Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function queueLogScenarioActivation(scenario) {
var firstTime = !spyTargetsTriggered[scenario];
spyTargetsTriggered[scenario] = true;
// Fire queued event from last scenario
if (doLogLastActivation) {
doLogLastActivation();
}
// Log that we triggered it
analytics.event(analytics.E.SCROLL_SPY.ID, analytics.E.SCROLL_SPY.SCENARIO_TRIGGERED, scenario, firstTime ? 1 : 0);
// But also queue up an event that will fire with how long we stayed on it when we visit the next scenario...
var scenarioHitMs = Date.now();
doLogLastActivation = function() {
// cleanup
doLogLastActivation = null;
clearTimeout(doLogLastActivationTimeout);
// log the previous event
var timeSpentMs = Date.now() - scenarioHitMs;
analytics.event(analytics.E.SCROLL_SPY.ID, analytics.E.SCROLL_SPY.SCENARIO_DURATION, scenario, timeSpentMs);
// queue up a watchdog
doLogLastActivationTimeout = setTimeout(doLogLastActivation, 6 * 60 * 1000);
.on('slideStop', function(slideEndValue) {
analytics.event(
analytics.E.SLIDER.ID,
analytics.E.SLIDER.SLIDE_STOP,
SCROLLSPY_PROPS.id,
Date.now() - slideStartMs,
{
startValue: slideStartValue,
endValue: slideEndValue
}
);
});
},
switchToPercentage() {
analytics.event(
analytics.E.ROUND_CHART_BUTTON.ID,
analytics.E.ROUND_CHART_BUTTON.PERCENTAGE_VIEW,
SCROLLSPY_PROPS.id
);
actions.chart.selectMeasure('percentages');
},
.on('slideStop', function(slideEndValue) {
analytics.event(
analytics.E.SLIDER.ID,
analytics.E.SLIDER.SLIDE_STOP,
SCROLLSPY_PROPS.id,
Date.now() - slideStartMs,
{
startValue: slideStartValue,
endValue: slideEndValue
}
);
});
},
switchToPercentages() {
analytics.event(
analytics.E.ROUND_CHART_BUTTON.ID,
analytics.E.ROUND_CHART_BUTTON.PERCENTAGE_VIEW,
SCROLLSPY_PROPS.id
);
actions.chart.selectMeasure('percentages');
},
switchToValue() {
analytics.event(
analytics.E.ROUND_CHART_BUTTON.ID,
analytics.E.ROUND_CHART_BUTTON.VALUE_VIEW,
SCROLLSPY_PROPS.id
);
actions.chart.selectMeasure('values');
},
switchToValue() {
analytics.event(
analytics.E.ROUND_CHART_BUTTON.ID,
analytics.E.ROUND_CHART_BUTTON.VALUE_VIEW,
SCROLLSPY_PROPS.id
);
actions.chart.selectMeasure('values');
},
.on('slideStop', function(slideEndValue) {
analytics.event(
analytics.E.SLIDER.ID,
analytics.E.SLIDER.SLIDE_STOP,
SCROLLSPY_PROPS.id,
Date.now() - slideStartMs,
{
startValue: slideStartValue,
endValue: slideEndValue
}
);
});
},
switchToPercentage() {
analytics.event(
analytics.E.ROUND_CHART_BUTTON.ID,
analytics.E.ROUND_CHART_BUTTON.PERCENTAGE_VIEW,
SCROLLSPY_PROPS.id
);
actions.chart.selectMeasure('percentages');
},
.on('slideStop', function(slideEndValue) {
analytics.event(
analytics.E.SLIDER.ID,
analytics.E.SLIDER.SLIDE_STOP,
SCROLLSPY_PROPS.id,
Date.now() - slideStartMs,
{
startValue: slideStartValue,
endValue: slideEndValue
}
);
});
},