[perf] remove unreleased non-standard apis

This commit is contained in:
Salakar
2019-04-20 20:05:12 +01:00
parent bb5341888e
commit 98cdc4df1f
6 changed files with 66 additions and 104 deletions

View File

@@ -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<Trace>;` as a convenience method to create and immediately start a Trace
## Remote Config (config)

View File

@@ -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 () => {

View File

@@ -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',
// });
// });
});
// -----------

View File

@@ -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];
}
}

View File

@@ -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.
*

View File

@@ -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.
*