Adding new markerAnnotateWithMap method

Summary:
## Changelog:
[Internal] [Added] - Adding new markerAnnotateWithMap to the QPL.

This is part of bigger effort to unify JS QPL interfaces across platforms.

Reviewed By: eddyerburgh

Differential Revision: D40796537

fbshipit-source-id: a75b97c20ca411653552228f7dc2fcbedd8ddca9
This commit is contained in:
Dmytro Voronkevych
2022-11-01 12:25:00 -07:00
committed by Facebook GitHub Bot
parent 58a1cd2367
commit e3eeadb63a
@@ -13,7 +13,7 @@
const AUTO_SET_TIMESTAMP = -1;
const DUMMY_INSTANCE_KEY = 0;
// Defines map of annotations for markEvent
// Defines map of annotations
// Use as following:
// {string: {key1: value1, key2: value2}}
export type AnnotationsMap = $Shape<{
@@ -68,6 +68,30 @@ const QuickPerformanceLogger = {
}
},
markerAnnotateWithMap(
markerId: number,
annotations: AnnotationsMap,
instanceKey: number = DUMMY_INSTANCE_KEY,
): void {
if (global.nativeQPLMarkerAnnotateWithMap) {
global.nativeQPLMarkerAnnotateWithMap(markerId, annotations, instanceKey);
} else if (global.nativeQPLMarkerAnnotate) {
for (var type of ['string']) {
var keyValsOfType = annotations[type];
if (keyValsOfType !== null && keyValsOfType !== undefined) {
for (var annotationKey of Object.keys(keyValsOfType)) {
global.nativeQPLMarkerAnnotate(
markerId,
instanceKey,
annotationKey,
keyValsOfType[annotationKey].toString(),
);
}
}
}
}
},
markerCancel(
markerId: number,
instanceKey?: number = DUMMY_INSTANCE_KEY,