From 2ba6e15ea7a7f76fd18ee05e63eadaabe3f72e9f Mon Sep 17 00:00:00 2001 From: Elliot Hesp Date: Wed, 18 Jul 2018 12:08:04 +0100 Subject: [PATCH] [perm][ts] Create performance monitoring types --- lib/index.d.ts | 132 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 131 insertions(+), 1 deletion(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 45c5d54b..0fc88b8b 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -54,7 +54,7 @@ declare module 'react-native-firebase' { RNFirebase.notifications.Notifications, RNFirebase.notifications.NotificationsStatics >; - // perf: FirebaseModuleAndStatics; + perf: FirebaseModuleAndStatics; storage: FirebaseModuleAndStatics; // utils: FirebaseModuleAndStatics; initializeApp(options: Firebase.Options, name: string): App; @@ -1567,6 +1567,136 @@ declare module 'react-native-firebase' { } } + namespace perf { + + type HttpMethod = + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + + interface Perf { + /** + * Globally enable or disable performance monitoring. + */ + setPerformanceCollectionEnabled(enabled: boolean): void; + + /** + * Returns a new Trace instance. + */ + newTrace(trace: string): Trace; + + /** + * Returns a new HTTP Metric instance. + */ + newHttpMetric(url: string, httpMethod: HttpMethod): HttpMetric; + } + + interface Trace { + /** + * Return an attribute by name, or null if it does not exist. + */ + getAttribute(attribute: string): Promise; + + /** + * Return an object of key-value attributes. + */ + getAttributes(): Promise; + + /** + * Get a metric by name. Returns 0 if it does not exist. + */ + getMetric(metricName: string): Promise; + + /** + * Increment a metric by name and value. + */ + incrementMetric(metricName: string, incrementBy: number): Promise; + + /** + * Set an attribute. Returns true if it was set, false if it was not. + */ + putAttribute(attribute: string, value: string): Promise; + + /** + * Set a metric. + */ + putMetric(metricName: string, value: number): Promise; + + /** + * Remove an attribute by name. + */ + removeAttribute(attribute: string): Promise; + + /** + * Start a Trace instance. + */ + start(): Promise; + + /** + * Stop a Trace instance. + */ + stop(): Promise; + } + + interface HttpMetric { + /** + * Return an attribute by name, or null if it does not exist. + */ + getAttribute(attribute: string): Promise; + + /** + * Return an object of key-value attributes. + */ + getAttributes(): Promise + + /** + * Set an attribute. Returns true if it was set, false if it was not. + */ + putAttribute(attribute: string, value: string): Promise; + + /** + * Remove an attribute by name. + */ + removeAttribute(attribute: string): Promise; + + /** + * Set the request HTTP response code. + */ + setHttpResponseCode(code: number): Promise; + + /** + * Set the request payload size, in bytes. + */ + setRequestPayloadSize(bytes: number): Promise; + + /** + * Set the response content type. + */ + setResponseContentType(type: string): Promise; + + /** + * Set the response payload size, in bytes. + */ + setResponsePayloadSize(bytes: number): Promise; + + /** + * Start a HttpMetric instance. + */ + start(): Promise; + + /** + * Stop a HttpMetric instance. + */ + stop(): Promise; + } + } + namespace crashlytics { interface Crashlytics { /**