diff --git a/lib/reporter.js b/lib/reporter.js index 8fe4abe..02b7814 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -150,10 +150,9 @@ class Reporter { } // Private - viewNameForPaneItem (item) { - let left - let name = (left = (typeof item.getViewClass === 'function' ? item.getViewClass().name : undefined)) != null ? left : item.constructor.name - const itemPath = typeof item.getPath === 'function' ? item.getPath() : undefined + static viewNameForPaneItem (item) { + let name = (item.getViewClass && item.getViewClass().name) || item.constructor.name + const itemPath = item.getPath && item.getPath() if ((itemPath == null) || (path.dirname(itemPath) !== atom.getConfigDirPath())) { return name } diff --git a/spec/metrics-spec.js b/spec/metrics-spec.js index 21ffe03..23be1f2 100644 --- a/spec/metrics-spec.js +++ b/spec/metrics-spec.js @@ -321,7 +321,6 @@ describe('Metrics', async () => { describe('reporting pane items', async () => { describe('when the user is NOT chosen to send events', async () => { beforeEach(async () => { - global.localStorage.setItem('metrics.userId', 'a') spyOn(Reporter, 'sendPaneItem') const {mainModule} = await atom.packages.activatePackage('metrics') @@ -339,9 +338,6 @@ describe('Metrics', async () => { describe('when the user IS chosen to send events', async () => { beforeEach(async () => { - global.localStorage.setItem('metrics.userId', 'd') - spyOn(Reporter, 'sendPaneItem') - const {mainModule} = await atom.packages.activatePackage('metrics') mainModule.shouldIncludePanesAndCommands = true @@ -350,8 +346,11 @@ describe('Metrics', async () => { it('will report pane items', async () => { await atom.workspace.open('file1.txt') - - expect(Reporter.sendPaneItem.callCount).toBe(1) + const paneItemCalls = Reporter.request.calls.filter((call) => { + const url = call.args[0] + return url.includes('t=appview') && url.includes('cd=TextEditor') + }) + expect(paneItemCalls.length).toBe(1) }) }) })