Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][TS migration] Migrate 'Timing.js' lib to TypeScript #27705

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/libs/actions/Timing.js → src/libs/actions/Timing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ import Firebase from '../Firebase';
import * as API from '../API';
import Log from '../Log';

let timestampData = {};
type TimestampData = {
startTime: number;
shouldUseFirebase: boolean;
};

let timestampData: Record<string, TimestampData> = {};

/**
* Start a performance timing measurement
*
* @param {String} eventName
* @param {Boolean} shouldUseFirebase - adds an additional trace in Firebase
* @param eventName
* @param shouldUseFirebase - adds an additional trace in Firebase
*/
function start(eventName, shouldUseFirebase = false) {
function start(eventName: string, shouldUseFirebase = false) {
timestampData[eventName] = {startTime: Date.now(), shouldUseFirebase};

if (!shouldUseFirebase) {
Expand All @@ -25,11 +30,11 @@ function start(eventName, shouldUseFirebase = false) {
/**
* End performance timing. Measure the time between event start/end in milliseconds, and push to Grafana
*
* @param {String} eventName - event name used as timestamp key
* @param {String} [secondaryName] - optional secondary event name, passed to grafana
* @param {number} [maxExecutionTime] - optional amount of time (ms) to wait before logging a warn
* @param eventName - event name used as timestamp key
* @param [secondaryName] - optional secondary event name, passed to grafana
* @param [maxExecutionTime] - optional amount of time (ms) to wait before logging a warn
*/
function end(eventName, secondaryName = '', maxExecutionTime = 0) {
function end(eventName: string, secondaryName = '', maxExecutionTime = 0) {
if (!timestampData[eventName]) {
return;
}
Expand Down
Loading