Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const trackTiming = async eventData => {
setUserDimensions();
ReactGA.timing(
merge(
{
category: null,
variable: null,
value: 0, // in milliseconds
label: null,
},
eventData,
),
);
};
it("Able to make timing calls", () => {
ga.timing({
category: 'string',
variable: 'string',
value: 1,
label: 'string'
});
});
it("Able to make exception calls", () => {
endBenchmark(msg) {
var t2 = performance.now();
let benchmark = this.state.benchmark[msg];
let et = (t2 - benchmark.t1) || 0;
if (DEBUG) console.log(this.props.name + ": benchmark - "+ benchmark.msg +": took " + et.toFixed(3) + " milliseconds.")
ReactGA.timing({
category: 'Backend',
variable: benchmark.msg,
value: et,
label: this.props.name
});
}
const newPackageString = `${results.name}@${results.version}`
this.setState({
inputInitialValue: newPackageString,
results,
}, () => {
Router.replace(`/result?p=${newPackageString}`)
Analytics.pageview(window.location.pathname)
})
Analytics.event({
category: 'Search',
action: 'Search Success',
label: packageString.replace(/@/g, '[at]'),
})
Analytics.timing({
category: 'Search',
variable: 'result',
value: Date.now() - startTime,
label: packageString.replace(/@/g, '[at]'),
});
})
.catch(err => {
function sendGaTimingEvent(category: string, action: string, timeInMs: number) {
if (analyticsEnabled && isProduction) {
ReactGA.timing(
{
category,
variable: action,
value: timeInMs,
},
[SECOND_TRACKER_NAME]
);
}
}
export const timing = (args: ReactGA.TimingArgs) => ReactGA.timing(args);
description: 'Invalid session key',
fatal: true
});
this.props.logOut({
type: 'warning',
message: 'loginAgain',
persistent: true,
showErrorNumber: true,
errorNumber: 401,
});
break;
default:
break;
}
if (response.config.timing) {
ReactGA.timing({
category: 'Client response time',
variable: response.config.url,
value: Math.round(response.config.timing.elapsedTime)
});
}
if (response.data.error) {
axiosErrorHandler(response);
}
}
return response;
},
(error) => {
Router.onRouteChangeComplete = url => {
window.performance.mark('onRouteChangeEnd');
window.performance.measure(
'onRouteChange',
'onRouteChangeStart',
'onRouteChangeEnd'
);
const measure = window.performance.getEntriesByName('onRouteChange')[0];
ReactGA.timing({
category: 'Navigation',
variable: 'routeChange',
value: Math.round(measure.duration),
label: url
});
window.performance.clearMarks();
window.performance.clearMeasures();
};