This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Expand file tree Collapse file tree 4 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ import * as perf from "./performance" ;
2+ export const performance = perf ;
Original file line number Diff line number Diff line change 1+ declare const com : any ;
2+
3+ const FirebasePerformance = com . google . firebase . perf . FirebasePerformance ;
4+
5+ export function startTrace ( name : string ) : FirebaseTrace {
6+ const trace = FirebasePerformance . getInstance ( ) . newTrace ( name ) ;
7+ trace . start ( ) ;
8+ return new FirebaseTrace ( trace ) ;
9+ }
10+
11+ export class FirebaseTrace {
12+ constructor ( private nativeTrace : any /* com.google.firebase.perf.metrics.Trace */ ) {
13+ }
14+
15+ setValue ( attribute : string , value : string ) : void {
16+ this . nativeTrace . putAttribute ( attribute , value ) ;
17+ }
18+
19+ getValue ( attribute : string ) : string {
20+ return this . nativeTrace . getAttribute ( attribute ) ;
21+ }
22+
23+ // TODO this is a Java map I guess
24+ getAttributes ( ) : Map < string , string > {
25+ return this . nativeTrace . getAttributes ( ) ;
26+ }
27+
28+ removeAttribute ( attribute : string ) : void {
29+ this . nativeTrace . removeAttribute ( attribute ) ;
30+ }
31+
32+ incrementMetric ( metric : string , by : number ) : void {
33+ this . nativeTrace . incrementMetric ( metric , by ) ;
34+ }
35+
36+ stop ( ) : void {
37+ this . nativeTrace . stop ( ) ;
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ export declare class FirebaseTrace {
2+ setValue ( attribute : string , value : string ) : void ;
3+ getValue ( attribute : string ) : string ;
4+ getAttributes ( ) : Map < string , string > ;
5+ removeAttribute ( attribute : string ) : void ;
6+ incrementMetric ( metric : string , by : number ) : void ;
7+ stop ( ) : void ;
8+ }
9+
10+ export declare function startTrace ( name : string ) : FirebaseTrace ;
Original file line number Diff line number Diff line change 1+ import { firebaseUtils } from "../utils" ;
2+
3+ export function startTrace ( name : string ) : FirebaseTrace {
4+ return new FirebaseTrace ( FIRPerformance . sharedInstance ( ) . traceWithName ( name ) ) ;
5+ }
6+
7+ export class FirebaseTrace {
8+ constructor ( private nativeTrace : FIRTrace ) {
9+ }
10+
11+ setValue ( attribute : string , value : string ) : void {
12+ this . nativeTrace . setValueForAttribute ( value , attribute ) ;
13+ }
14+
15+ getValue ( attribute : string ) : string {
16+ return this . nativeTrace . valueForAttribute ( attribute ) ;
17+ }
18+
19+ getAttributes ( ) : Map < string , string > {
20+ return firebaseUtils . toJsObject ( this . nativeTrace . attributes ) ;
21+ }
22+
23+ removeAttribute ( attribute : string ) : void {
24+ this . nativeTrace . removeAttribute ( attribute ) ;
25+ }
26+
27+ incrementMetric ( metric : string , by : number ) : void {
28+ this . nativeTrace . incrementMetricByInt ( metric , by ) ;
29+ }
30+
31+ stop ( ) : void {
32+ this . nativeTrace . stop ( ) ;
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments