From 98cdc4df1fc7f19f4f415ffb8edd72733b22bab4 Mon Sep 17 00:00:00 2001 From: Salakar Date: Sat, 20 Apr 2019 20:05:12 +0100 Subject: [PATCH] [perf] remove unreleased non-standard apis --- CHANGELOG.md | 2 - packages/perf/e2e/HttpMetric.e2e.js | 66 +++++++++++------------ packages/perf/e2e/Trace.e2e.js | 66 +++++++++++------------ packages/perf/lib/MetricWithAttributes.js | 12 ----- packages/perf/lib/index.d.ts | 12 ----- packages/perf/lib/index.js.flow | 12 ----- 6 files changed, 66 insertions(+), 104 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfccb6fb..fac25cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,8 +165,6 @@ await analytics().setUserId('12345678'); - [BREAKING] `firebase.perf.Trace.incrementMetric` will now create a metric if it could not be found - [BREAKING] `firebase.perf.Trace.getMetric` will now return 0 if a metric could not be found - [NEW] Added support for `firebase.perf().isPerformanceCollectionEnabled: boolean` -- [NEW] Added support for `firebase.perf.Trace.removeMetric(metricName: string)` -- [NEW] Added support for `firebase.perf.Trace.getMetrics(): { [key: string]: number }` - [NEW] Added `firebase.perf().startTrace(identifier: string): Promise;` as a convenience method to create and immediately start a Trace ## Remote Config (config) diff --git a/packages/perf/e2e/HttpMetric.e2e.js b/packages/perf/e2e/HttpMetric.e2e.js index c0a9835e..8cb07ee1 100644 --- a/packages/perf/e2e/HttpMetric.e2e.js +++ b/packages/perf/e2e/HttpMetric.e2e.js @@ -64,29 +64,29 @@ describe('perf()', () => { }); }); - describe('removeAttribute()', async () => { - it('errors if not a string', async () => { - const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); - try { - httpMetric.putAttribute('inver', 'tase'); - httpMetric.removeAttribute(13377331); - return Promise.reject(new Error('Did not throw')); - } catch (e) { - e.message.should.containEql('must be a string'); - return Promise.resolve(); - } - }); - - it('removes an attribute', async () => { - const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); - httpMetric.putAttribute('inver', 'tase'); - const value = httpMetric.getAttribute('inver'); - should.equal(value, 'tase'); - httpMetric.removeAttribute('inver'); - const value2 = httpMetric.getAttribute('inver'); - should.equal(value2, null); - }); - }); + // describe('removeAttribute()', async () => { + // it('errors if not a string', async () => { + // const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); + // try { + // httpMetric.putAttribute('inver', 'tase'); + // httpMetric.removeAttribute(13377331); + // return Promise.reject(new Error('Did not throw')); + // } catch (e) { + // e.message.should.containEql('must be a string'); + // return Promise.resolve(); + // } + // }); + // + // it('removes an attribute', async () => { + // const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); + // httpMetric.putAttribute('inver', 'tase'); + // const value = httpMetric.getAttribute('inver'); + // should.equal(value, 'tase'); + // httpMetric.removeAttribute('inver'); + // const value2 = httpMetric.getAttribute('inver'); + // should.equal(value2, null); + // }); + // }); describe('getAttribute()', async () => { it('should return null if attribute does not exist', async () => { @@ -185,16 +185,16 @@ describe('perf()', () => { }); }); - it('getAttributes()', async () => { - const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); - httpMetric.putAttribute('inver', 'tase'); - httpMetric.putAttribute('tase', 'baz'); - const value = httpMetric.getAttributes(); - JSON.parse(JSON.stringify(value)).should.deepEqual({ - inver: 'tase', - tase: 'baz', - }); - }); + // it('getAttributes()', async () => { + // const httpMetric = firebase.perf().newHttpMetric(aCoolUrl, 'GET'); + // httpMetric.putAttribute('inver', 'tase'); + // httpMetric.putAttribute('tase', 'baz'); + // const value = httpMetric.getAttributes(); + // JSON.parse(JSON.stringify(value)).should.deepEqual({ + // inver: 'tase', + // tase: 'baz', + // }); + // }); describe('setHttpResponseCode()', async () => { it('sets number value', async () => { diff --git a/packages/perf/e2e/Trace.e2e.js b/packages/perf/e2e/Trace.e2e.js index 1b33e93e..57d58676 100644 --- a/packages/perf/e2e/Trace.e2e.js +++ b/packages/perf/e2e/Trace.e2e.js @@ -60,29 +60,29 @@ describe('perf()', () => { }); }); - describe('removeAttribute()', async () => { - it('errors if not a string', async () => { - const trace = firebase.perf().newTrace('invertase'); - try { - trace.putAttribute('inver', 'tase'); - trace.removeAttribute(13377331); - return Promise.reject(new Error('Did not throw')); - } catch (e) { - e.message.should.containEql('must be a string'); - return Promise.resolve(); - } - }); - - it('removes an attribute', async () => { - const trace = firebase.perf().newTrace('invertase'); - trace.putAttribute('inver', 'tase'); - const value = trace.getAttribute('inver'); - should.equal(value, 'tase'); - trace.removeAttribute('inver'); - const value2 = trace.getAttribute('inver'); - should.equal(value2, null); - }); - }); + // describe('removeAttribute()', async () => { + // it('errors if not a string', async () => { + // const trace = firebase.perf().newTrace('invertase'); + // try { + // trace.putAttribute('inver', 'tase'); + // trace.removeAttribute(13377331); + // return Promise.reject(new Error('Did not throw')); + // } catch (e) { + // e.message.should.containEql('must be a string'); + // return Promise.resolve(); + // } + // }); + // + // it('removes an attribute', async () => { + // const trace = firebase.perf().newTrace('invertase'); + // trace.putAttribute('inver', 'tase'); + // const value = trace.getAttribute('inver'); + // should.equal(value, 'tase'); + // trace.removeAttribute('inver'); + // const value2 = trace.getAttribute('inver'); + // should.equal(value2, null); + // }); + // }); describe('getAttribute()', async () => { it('should return null if attribute does not exist', async () => { @@ -181,16 +181,16 @@ describe('perf()', () => { }); }); - it('getAttributes()', async () => { - const trace = firebase.perf().newTrace('invertase'); - trace.putAttribute('inver', 'tase'); - trace.putAttribute('tase', 'baz'); - const value = trace.getAttributes(); - JSON.parse(JSON.stringify(value)).should.deepEqual({ - inver: 'tase', - tase: 'baz', - }); - }); + // it('getAttributes()', async () => { + // const trace = firebase.perf().newTrace('invertase'); + // trace.putAttribute('inver', 'tase'); + // trace.putAttribute('tase', 'baz'); + // const value = trace.getAttributes(); + // JSON.parse(JSON.stringify(value)).should.deepEqual({ + // inver: 'tase', + // tase: 'baz', + // }); + // }); }); // ----------- diff --git a/packages/perf/lib/MetricWithAttributes.js b/packages/perf/lib/MetricWithAttributes.js index 4bfb9dea..e649ccda 100644 --- a/packages/perf/lib/MetricWithAttributes.js +++ b/packages/perf/lib/MetricWithAttributes.js @@ -33,10 +33,6 @@ export default class MetricWithAttributes { return this._attributes[attribute] || null; } - getAttributes() { - return Object.assign({}, this._attributes); - } - putAttribute(attribute, value) { // TODO(VALIDATION): attribute: no leading or trailing whitespace, no leading underscore '_' if (!isString(attribute) || attribute.length > 40) { @@ -59,12 +55,4 @@ export default class MetricWithAttributes { this._attributes[attribute] = value; } - - removeAttribute(attribute) { - if (!isString(attribute)) { - throw new Error(`firebase.perf.*.removeAttribute(*) 'attribute' must be a string.`); - } - - delete this._attributes[attribute]; - } } diff --git a/packages/perf/lib/index.d.ts b/packages/perf/lib/index.d.ts index c7c5be70..0b712281 100644 --- a/packages/perf/lib/index.d.ts +++ b/packages/perf/lib/index.d.ts @@ -49,11 +49,6 @@ export namespace Perf { */ getAttribute(attribute: string): string | null; - /** - * Returns an object of all the currently added attributes and their string values. - */ - getAttributes(): { [key: string]: string }; - /** * Sets a String value for the specified attribute. Updates the value of the attribute if it already exists. * The maximum number of attributes that can be added is 5. @@ -63,13 +58,6 @@ export namespace Perf { */ putAttribute(attribute: string, value: string); - /** - * Removes an already added attribute. Does nothing if attribute does not exist. - * - * @param attribute Name of the attribute to be removed. - */ - removeAttribute(attribute: string); - /** * Gets the value of the metric with the given name in the current trace. If the metric doesn't exist, it will not be created and a 0 is returned. * diff --git a/packages/perf/lib/index.js.flow b/packages/perf/lib/index.js.flow index 8fac395b..4c37d8fa 100644 --- a/packages/perf/lib/index.js.flow +++ b/packages/perf/lib/index.js.flow @@ -42,11 +42,6 @@ export interface Trace { */ getAttribute(attribute: string): string | null; - /** - * Returns an object of all the currently added attributes and their string values. - */ - getAttributes(): { [key: string]: string }; - /** * Sets a String value for the specified attribute. Updates the value of the attribute if it already exists. * The maximum number of attributes that can be added is 5. @@ -56,13 +51,6 @@ export interface Trace { */ putAttribute(attribute: string, value: string): void; - /** - * Removes an already added attribute. Does nothing if attribute does not exist. - * - * @param attribute Name of the attribute to be removed. - */ - removeAttribute(attribute: string): void; - /** * Gets the value of the metric with the given name in the current trace. If the metric doesn't exist, it will not be created and a 0 is returned. *