UNPKG

nativescript-plugin-firebase-updated

Version:
36 lines (35 loc) 1.05 kB
export function startTrace(name) { const trace = com.google.firebase.perf.FirebasePerformance.getInstance().newTrace(name); trace.start(); return new FirebaseTrace(trace); } export class FirebaseTrace { constructor(nativeTrace) { this.nativeTrace = nativeTrace; } setValue(attribute, value) { this.nativeTrace.putAttribute(attribute, value); } getValue(attribute) { return this.nativeTrace.getAttribute(attribute); } getAttributes() { const attributes = this.nativeTrace.getAttributes(); const node = {}; const iterator = attributes.entrySet().iterator(); while (iterator.hasNext()) { const item = iterator.next(); node[item.getKey()] = item.getValue(); } return node; } removeAttribute(attribute) { this.nativeTrace.removeAttribute(attribute); } incrementMetric(metric, by) { this.nativeTrace.incrementMetric(metric, by); } stop() { this.nativeTrace.stop(); } }