This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
metrics-spec.js
656 lines (528 loc) · 23.4 KB
/
metrics-spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
/** @babel */
import {it, fit, ffit, fffit, beforeEach, afterEach, conditionPromise} from './helpers/async-spec-helpers' // eslint-disable-line no-unused-vars
import Reporter from '../lib/reporter'
import fs from 'fs-plus'
import grim from 'grim'
import path from 'path'
import temp from 'temp'
temp.track()
const telemetry = require('telemetry-github')
const store = new telemetry.StatsStore('atom', '1.2.3', true)
describe('Metrics', () => {
let workspaceElement = []
const assertCommandNotReported = (commandName, additionalArgs) => {
atom.commands.dispatch(workspaceElement, commandName, additionalArgs)
expect(Reporter.addCustomEvent).not.toHaveBeenCalled()
}
const eventReportedPromise = ({category, action, value}) => {
return conditionPromise(() => {
return Reporter.addCustomEvent.calls.find((call) => {
const eventType = call.args[0]
const eventObject = call.args[1]
return eventType === category &&
eventObject.t === 'event' &&
eventObject.ea === action &&
eventObject.ev === value
})
})
}
beforeEach(() => {
workspaceElement = atom.views.getView(atom.workspace)
spyOn(Reporter, 'addCustomEvent').andCallThrough()
spyOn(Reporter, 'getStore').andCallFake(() => store)
let storage = {}
spyOn(global.localStorage, 'setItem').andCallFake((key, value) => { storage[key] = value })
spyOn(global.localStorage, 'getItem').andCallFake(key => storage[key])
Reporter.commandCount = undefined
spyOn(Reporter, 'consented').andReturn(true)
})
afterEach(async () => {
atom.packages.deactivatePackage('metrics')
})
it('reports consent opt-out changes', async () => {
await atom.packages.activatePackage('metrics')
spyOn(store, 'setOptOut')
spyOn(Reporter, 'sendEvent')
await atom.config.set('core.telemetryConsent', 'no')
expect(Reporter.sendEvent.mostRecentCall.args).toEqual(['setting', 'core.telemetryConsent', 'no'])
expect(store.setOptOut.mostRecentCall.args[0]).toEqual(true)
})
it('reports consent opt-in changes', async () => {
await atom.packages.activatePackage('metrics')
spyOn(store, 'setOptOut')
spyOn(Reporter, 'sendEvent')
await atom.config.set('core.telemetryConsent', 'limited')
expect(Reporter.sendEvent.mostRecentCall.args).toEqual(['setting', 'core.telemetryConsent', 'limited'])
expect(store.setOptOut.mostRecentCall.args[0]).toEqual(false)
})
describe('event metadata', async () => {
beforeEach(() => {
spyOn(store, 'addTiming')
})
const assertMetadataSent = async (expectedName, expectedValue) => {
await atom.packages.activatePackage('metrics')
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
let metadata = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(metadata[expectedName]).toEqual(expectedValue)
await conditionPromise(() => store.addTiming.callCount > 0)
metadata = store.addTiming.mostRecentCall.args[2]
expect(metadata[expectedName]).toEqual(expectedValue)
}
it('reports actual processor architecture', async () => {
const expectedArch = process.env.PROCESSOR_ARCHITEW6432 === 'AMD64' ? 'x64' : process.arch
await assertMetadataSent('cd2', expectedArch)
})
it('specifies screen resolution', async () => {
const expectedScreenResolution = `${window.screen.width}x${window.screen.height}`
await assertMetadataSent('sr', expectedScreenResolution)
})
it('specifies window resolution', async () => {
const expectedWindowResolution = `${window.innerWidth}x${window.innerHeight}`
await assertMetadataSent('vp', expectedWindowResolution)
})
it('specifies heap usage in MB and %', async () => {
spyOn(process, 'memoryUsage').andReturn({heapTotal: 234567890, heapUsed: 123456789})
const heapUsedInMb = 117
const heapUsedPercentage = 53
await assertMetadataSent('cm1', heapUsedInMb)
await assertMetadataSent('cm2', heapUsedPercentage)
})
})
describe('reporting release channel', async () => {
beforeEach(() => global.localStorage.setItem('metrics.userId', 'a'))
it('reports the dev release channel', async () => {
spyOn(atom, 'getVersion').andReturn('1.0.2-dev-dedbeef')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('dev')
})
it('reports the beta release channel', async () => {
spyOn(atom, 'getVersion').andReturn('1.0.2-beta1')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('beta')
})
it('reports the stable release channel', async () => {
spyOn(atom, 'getVersion').andReturn('1.0.2')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('stable')
})
it('reports the nightly release channel', async () => {
spyOn(atom, 'getVersion').andReturn('1.0.2-nightly55')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('nightly')
})
it('reports an arbitrary release channel', async () => {
spyOn(atom, 'getVersion').andReturn('1.0.2-sushi1')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('sushi')
})
it('reports an unrecognized release channel', async () => {
spyOn(atom, 'getVersion').andReturn('wat.0.2')
await atom.packages.activatePackage('metrics')
let event = Reporter.addCustomEvent.mostRecentCall.args[1]
expect(event.aiid).toEqual('unrecognized')
})
})
describe('reporting commands', async () => {
describe('when shouldIncludePanesAndCommands is false', async () => {
beforeEach(async () => {
global.localStorage.setItem('metrics.userId', 'a')
await atom.packages.activatePackage('metrics')
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
const {mainModule} = atom.packages.getLoadedPackage('metrics')
mainModule.shouldIncludePanesAndCommands = false
})
it('does not watch for commands', async () => {
let command = 'some-package:a-command'
atom.commands.dispatch(workspaceElement, command, null)
expect(Reporter.commandCount).toBeUndefined()
})
})
describe('when shouldIncludePanesAndCommands is true', async () => {
beforeEach(async () => {
global.localStorage.setItem('metrics.userId', 'd')
await atom.packages.activatePackage('metrics')
const {mainModule} = atom.packages.getLoadedPackage('metrics')
mainModule.shouldIncludePanesAndCommands = true
Reporter.addCustomEvent.reset()
})
it('reports commands dispatched via atom.commands', () => {
let command = 'some-package:a-command'
atom.commands.dispatch(workspaceElement, command, null)
expect(Reporter.commandCount[command]).toBe(1)
const args = Reporter.addCustomEvent.mostRecentCall.args
expect(args[0]).toEqual('command')
let event = args[1]
expect(event.t).toEqual('event')
expect(event.ec).toEqual('command')
expect(event.ea).toEqual('some-package')
expect(event.el).toEqual('some-package:a-command')
atom.commands.dispatch(workspaceElement, command, null)
expect(Reporter.commandCount[command]).toBe(2)
expect(Reporter.addCustomEvent.mostRecentCall.args[1].ev).toEqual(2)
})
it('does not report editor: and core: commands', () => {
assertCommandNotReported('core:move-up')
assertCommandNotReported('editor:move-to-end-of-line')
})
it('does not report non-namespaced commands', () => {
assertCommandNotReported('dragover')
})
it('does not report vim-mode:* movement commands', () => {
assertCommandNotReported('vim-mode:move-up')
assertCommandNotReported('vim-mode:move-down')
assertCommandNotReported('vim-mode:move-left')
assertCommandNotReported('vim-mode:move-right')
})
it('does not report commands triggered via jquery', () => {
assertCommandNotReported('some-package:a-command', {jQueryTrigger: 'trigger'})
})
})
})
describe('reporting timings', async () => {
it('reports timing metrics', async () => {
spyOn(Reporter, 'addTiming')
await atom.packages.activatePackage('metrics')
const expectedLoadTime = atom.getWindowLoadTime()
const addTimingArgs = Reporter.addTiming.calls[0].args
expect(addTimingArgs[0]).toEqual('load')
expect(addTimingArgs[1]).toEqual(expectedLoadTime)
expect(addTimingArgs[2]).toEqual({ec: 'core'})
})
})
describe('reporting exceptions', async () => {
const assertException = function (args, expectedMessage) {
expect(args[0]).toEqual('exception')
const event = args[1]
expect(event.exd).toContain(expectedMessage)
}
beforeEach(async () => {
spyOn(atom, 'openDevTools').andReturn(Promise.resolve())
spyOn(atom, 'executeJavaScriptInDevTools')
await atom.packages.activatePackage('metrics')
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
})
it('reports an exception with the correct type', () => {
let message = "Uncaught TypeError: Cannot call method 'getScreenRow' of undefined"
window.onerror(message, 'abc', 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'TypeError')
})
describe('when the message has no clear type', () =>
it('reports an exception with the correct type', () => {
let message = ''
window.onerror(message, 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'Unknown')
})
)
describe('when there are paths in the exception', () => {
it('strips unix paths surrounded in quotes', () => {
let message = "Error: ENOENT, unlink '/Users/someuser/path/file.js'"
window.onerror(message, 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'Error: ENOENT, unlink <path>')
})
it('strips unix paths without quotes', () => {
let message = 'Uncaught Error: spawn /Users/someuser.omg/path/file-09238_ABC-Final-Final.js ENOENT'
window.onerror(message, 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'Error: spawn <path> ENOENT')
})
it('strips windows paths without quotes', () => {
let message = 'Uncaught Error: spawn c:\\someuser.omg\\path\\file-09238_ABC-Fin%%$#()al-Final.js ENOENT'
window.onerror(message, 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'Error: spawn <path> ENOENT')
})
it('strips windows paths surrounded in quotes', () => {
let message = "Uncaught Error: EACCES 'c:\\someuser.omg\\path\\file-09238_ABC-Fin%%$#()al-Final.js'"
window.onerror(message, 2, 3, {ok: true})
assertException(Reporter.addCustomEvent.mostRecentCall.args, 'Error: EACCES <path>')
})
})
})
describe('reporting deprecations', async () => {
beforeEach(async () => {
await atom.packages.activatePackage('metrics')
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
})
it('reports a deprecation with metadata specified', async () => {
jasmine.snapshotDeprecations()
const deprecationMessage = 'bad things are bad'
grim.deprecate(deprecationMessage, {packageName: 'somepackage'})
jasmine.restoreDeprecationsSnapshot()
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
const args = Reporter.addCustomEvent.mostRecentCall.args
expect(args[0]).toEqual('deprecation-v3')
const eventObject = args[1]
expect(eventObject.t).toEqual('event')
expect(eventObject.ec).toEqual('deprecation-v3')
expect(eventObject.ea).toEqual('somepackage@unknown')
expect(eventObject.el).toEqual(deprecationMessage)
})
it('reports a deprecation without metadata specified', async () => {
jasmine.snapshotDeprecations()
let stack = [
{
fileName: '/Applications/Atom.app/pathwatcher.js',
functionName: 'foo',
location: '/Applications/Atom.app/pathwatcher.js:10:5'
},
{
fileName: '/Users/me/.atom/packages/metrics/lib/metrics.js',
functionName: 'bar',
location: '/Users/me/.atom/packages/metrics/lib/metrics.js:161:5'
}
]
let deprecation = {
message: 'bad things are bad',
stacks: [stack]
}
grim.addSerializedDeprecation(deprecation)
spyOn(atom.packages.getLoadedPackage('metrics').mainModule, 'getPackagePathsByPackageName').andReturn({
metrics: '/Users/me/.atom/packages/metrics'})
jasmine.restoreDeprecationsSnapshot()
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
const args = Reporter.addCustomEvent.mostRecentCall.args
expect(args[0]).toEqual('deprecation-v3')
const event = args[1]
expect(event.ec).toEqual('deprecation-v3')
expect(event.el).toEqual('bad things are bad')
})
})
describe('reporting pane items', async () => {
describe('when shouldIncludePanesAndCommands is false', async () => {
beforeEach(async () => {
spyOn(Reporter, 'sendPaneItem')
spyOn(Reporter, 'sendEvent')
const {mainModule} = await atom.packages.activatePackage('metrics')
mainModule.shouldIncludePanesAndCommands = false
})
it('will not report pane items', async () => {
Reporter.addCustomEvent.reset()
Reporter.sendEvent.reset()
Reporter.sendPaneItem.reset()
await atom.packages.emitter.emit('did-add-pane')
expect(Reporter.sendPaneItem.callCount).toBe(0)
expect(Reporter.sendEvent.callCount).toBe(0)
expect(Reporter.addCustomEvent.callCount).toBe(0)
})
})
describe('when shouldIncludePanesAndCommands is true', async () => {
beforeEach(async () => {
const {mainModule} = await atom.packages.activatePackage('metrics')
mainModule.shouldIncludePanesAndCommands = true
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
})
it('will report pane items', async () => {
await atom.workspace.open('file1.txt')
const paneItemCalls = Reporter.addCustomEvent.calls.filter((call) => {
const eventType = call.args[0]
const event = call.args[1]
return eventType === 'appview' && event.cd === 'TextEditor'
})
expect(paneItemCalls.length).toBe(1)
})
})
})
describe('reporting repositories', () => {
it('reports when a repository gets opened', async () => {
// TODO Once atom.project.observeRepositories ships to Atom's stable
// channel (likely in Atom 1.30), remove this guard, and update the atom
// engine version in package.json to the first Atom version that includes
// atom.project.observeRepositories
if (atom.project.observeRepositories == null) return
await atom.packages.activatePackage('metrics')
Reporter.addCustomEvent.reset()
const repositoryPath = path.join(__dirname, '..')
atom.project.addPath(repositoryPath)
await conditionPromise(() => {
return Reporter.addCustomEvent.calls.find((call) => {
const eventType = call.args[0]
const eventObject = call.args[1]
return eventType === 'repository' &&
eventObject.action === 'open' &&
eventObject.domain === 'github.com'
})
})
})
})
describe('reporting activation of optional packages', () => {
describe('when optional packages are present', () => {
let originalPackageDirPaths = atom.packages.packageDirPaths
beforeEach(() => {
const packageFixturePath = path.join(__dirname, 'fixtures', 'packages')
atom.packages.packageDirPaths.push(packageFixturePath)
})
it('reports the number of optional packages activated at startup', async () => {
await atom.packages.activatePackage('metrics')
expect(atom.packages.isBundledPackage('metrics')).toBe(true)
await atom.packages.activatePackage('example')
expect(atom.packages.isBundledPackage('example')).toBe(false)
// Mimic the event that is emitted when Atom finishes loading all
// packages at startup. (We don't want to weigh down this test with the
// overhead of actually load _all_ packages.)
atom.packages.emitter.emit('did-activate-initial-packages')
await eventReportedPromise({
'category': 'package',
'action': 'numberOptionalPackagesActivatedAtStartup',
'value': 1
})
})
afterEach(() => {
atom.packages.packageDirPaths = originalPackageDirPaths
})
})
describe('when only bundled packages are present', () => {
it('reports a quantity of zero when the user has no optional packages enabled', async () => {
await atom.packages.activatePackage('metrics')
expect(atom.packages.isBundledPackage('metrics')).toBe(true)
// Mimic the event that is emitted when Atom finishes loading all
// packages at startup. (We don't want to weigh down this test with the
// overhead of actually load _all_ packages.)
atom.packages.emitter.emit('did-activate-initial-packages')
await eventReportedPromise({
'category': 'package',
'action': 'numberOptionalPackagesActivatedAtStartup',
'value': 0
})
})
})
})
describe('reporting presence of user-defined key bindings', () => {
describe('when user-defined key bindings are present', () => {
it('reports the number of user-defined key bindings loaded at startup', async () => {
await atom.packages.activatePackage('metrics')
// Manually trigger the keymap loading that Atom performs at startup.
// (We don't want to weigh down this test with running through the
// entire Atom startup process.)
const keymapFixturePath = path.join(__dirname, 'fixtures', 'keymaps', 'custom-keymap.cson')
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn(keymapFixturePath)
atom.keymaps.loadUserKeymap()
await eventReportedPromise({
'category': 'key-binding',
'action': 'numberUserDefinedKeyBindingsLoadedAtStartup',
'value': 3
})
})
afterEach(() => {
atom.keymaps.destroy()
})
})
describe('when no user-defined key bindings are present', () => {
it('reports that zero user-defined key bindings were loaded', async () => {
await atom.packages.activatePackage('metrics')
// Manually trigger the keymap loading that Atom performs at startup.
// (We don't want to weigh down this test with running through the
// entire Atom startup process.)
const keymapFixturePath = path.join(__dirname, 'fixtures', 'keymaps', 'default-keymap.cson')
spyOn(atom.keymaps, 'getUserKeymapPath').andReturn(keymapFixturePath)
atom.keymaps.loadUserKeymap()
await eventReportedPromise({
'category': 'key-binding',
'action': 'numberUserDefinedKeyBindingsLoadedAtStartup',
'value': 0
})
})
afterEach(() => {
atom.keymaps.destroy()
})
})
})
describe('reporting customization of user init script', () => {
it('reports event when init script changes', async () => {
const tempDir = fs.realpathSync(temp.mkdirSync())
const userInitScriptPath = path.join(tempDir, 'init.js')
fs.writeFileSync(userInitScriptPath, '')
spyOn(atom, 'getUserInitScriptPath').andReturn(userInitScriptPath)
await atom.packages.activatePackage('metrics')
const editor = await atom.workspace.open(userInitScriptPath)
editor.setText("console.log('hello world')")
editor.save()
await eventReportedPromise({
'category': 'customization',
'action': 'userInitScriptChanged'
})
})
})
describe('reporting customization of user stylesheet', () => {
it('reports event when stylesheet changes', async () => {
const tempDir = fs.realpathSync(temp.mkdirSync())
const userStylesheetPath = path.join(tempDir, 'styles.less')
fs.writeFileSync(userStylesheetPath, '')
spyOn(atom.styles, 'getUserStyleSheetPath').andReturn(userStylesheetPath)
await atom.packages.activatePackage('metrics')
const editor = await atom.workspace.open(userStylesheetPath)
editor.setText('atom-pane:not(.active) { opacity: 0.75; }')
editor.save()
await eventReportedPromise({
'category': 'customization',
'action': 'userStylesheetChanged'
})
})
})
describe('when deactivated', async () =>
it('stops reporting pane items', async () => {
global.localStorage.setItem('metrics.userId', 'd')
spyOn(Reporter, 'sendPaneItem')
const {mainModule} = await atom.packages.activatePackage('metrics')
mainModule.shouldIncludePanesAndCommands = true
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
await atom.workspace.open('file1.txt')
await conditionPromise(() => Reporter.addCustomEvent.callCount > 0)
Reporter.sendPaneItem.reset()
Reporter.addCustomEvent.reset()
await atom.packages.deactivatePackage('metrics')
await atom.workspace.open('file2.txt')
expect(Reporter.sendPaneItem.callCount).toBe(0)
expect(Reporter.addCustomEvent.callCount).toBe(0)
})
)
describe('the metrics-reporter service', async () => {
let reporterService = null
beforeEach(async () => {
await atom.packages.activatePackage('metrics').then(pack => {
reporterService = pack.mainModule.provideReporter()
})
})
describe('::sendEvent', () =>
it('sends an event', () => {
reporterService.sendEvent('cat', 'action', 'label')
expect(Reporter.addCustomEvent).toHaveBeenCalled()
})
)
describe('::addCustomEvent', () =>
it('adds a custom event to the StatsStore', () => {
spyOn(store, 'addCustomEvent')
const args = ['yass queen!', { woo: 'hoo' }]
reporterService.addCustomEvent(...args)
expect(store.addCustomEvent).toHaveBeenCalledWith(...args)
})
)
describe('::incrementCounter', () =>
it('increments a counter', () => {
spyOn(store, 'incrementCounter')
const counterName = 'commits'
reporterService.incrementCounter(counterName)
expect(store.incrementCounter).toHaveBeenCalledWith(counterName)
})
)
describe('::addTiming', () =>
it('sends timing to StatsStore', () => {
spyOn(store, 'addTiming')
const eventType = 'appStart'
const timingInMilliseconds = 42
const metadata = {glitter: 'beard'}
const args = [eventType, timingInMilliseconds, metadata]
reporterService.addTiming(eventType, timingInMilliseconds, metadata)
expect(store.addTiming).toHaveBeenCalledWith(...args)
})
)
describe('::sendException', () =>
it('sends an exception', () => {
reporterService.sendException('desc')
expect(Reporter.addCustomEvent).toHaveBeenCalled()
})
)
})
})