Skip to content
This repository was archived by the owner on Mar 7, 2023. It is now read-only.

Commit b76adc0

Browse files
author
Justin Tormey
committedAug 16, 2017
fix(Api): better names for metrics
1 parent 2bd216f commit b76adc0

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed
 

‎src/api.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,9 @@ API.prototype.incrementLoginViaQrStats = function () {
309309
};
310310

Has conversations. Original line has conversations.
311311
API.prototype.incrementBtcEthUsageStats = function (btcBalance, ethBalance) {
312-
let base = this.ROOT_URL + 'event?name=wallet_login_balance_';
313-
let makeEventUrl = (curr, cond) => base + curr + '_' + (cond ? 1 : 0);
314-
fetch(makeEventUrl('btc', btcBalance > 0));
315-
fetch(makeEventUrl('eth', ethBalance > 0));
316-
fetch(makeEventUrl('btceth', btcBalance > 0 && ethBalance > 0));
312+
let base = this.ROOT_URL + 'event?name=wallet_login_balance';
313+
let makeEventUrl = (btc, eth) => `${base}_btc_${btc ? 1 : 0}_eth_${eth ? 1 : 0}`;
314+
fetch(makeEventUrl(btcBalance > 0, ethBalance > 0));
317315
};
318316

319317
API.prototype.getBlockchainAddress = function () {

‎tests/api_spec.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,29 @@ describe('API', () => {
2626
spyOn(window, 'fetch')
2727
})
2828

29-
it('should make three requests, one for each stat', () => {
29+
it('should make one request', () => {
3030
API.incrementBtcEthUsageStats(0, 0)
31-
expect(window.fetch).toHaveBeenCalledTimes(3)
31+
expect(window.fetch).toHaveBeenCalledTimes(1)
3232
})
3333

3434
it('should record correctly for btc=0, eth=0', () => {
3535
API.incrementBtcEthUsageStats(0, 0)
36-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0'))
37-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('eth_0'))
38-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btceth_0'))
36+
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_0'))
3937
})
4038

4139
it('should record correctly for btc>0, eth=0', () => {
4240
API.incrementBtcEthUsageStats(1, 0)
43-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1'))
44-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('eth_0'))
45-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btceth_0'))
41+
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_0'))
4642
})
4743

4844
it('should record correctly for btc=0, eth>0', () => {
4945
API.incrementBtcEthUsageStats(0, 1)
50-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0'))
51-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('eth_1'))
52-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btceth_0'))
46+
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_0_eth_1'))
5347
})
5448

5549
it('should record correctly for btc>0, eth>0', () => {
5650
API.incrementBtcEthUsageStats(1, 1)
57-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1'))
58-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('eth_1'))
59-
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btceth_1'))
51+
expect(window.fetch).toHaveBeenCalledWith(eventUrl('btc_1_eth_1'))
6052
})
6153
})
6254
});

1 commit comments

Comments
 (1)

Artic2019 commented on Jun 18, 2018

@Artic2019

Тест

This repository has been archived.