From 082c709602384af0244e956875514b658565b75a Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jun 2018 14:43:52 -0400 Subject: [PATCH 1/5] Add failing assertion to demonstrate bug --- spec/metrics-spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/metrics-spec.js b/spec/metrics-spec.js index 21ffe03..effdffc 100644 --- a/spec/metrics-spec.js +++ b/spec/metrics-spec.js @@ -340,7 +340,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 +349,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) }) }) }) From daff8811258b769eb461ef0212bffb2969b9dbcc Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jun 2018 14:49:29 -0400 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=90=9B=20Fix=20"TypeError:=20this.vie?= =?UTF-8?q?wNameForPaneItem=20is=20not=20a=20function"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/reporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporter.js b/lib/reporter.js index 8fe4abe..b413757 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -150,7 +150,7 @@ class Reporter { } // Private - viewNameForPaneItem (item) { + static 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 From fa8d7c02e7aee3a65f51807ec7331b14c64c03e8 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jun 2018 14:50:53 -0400 Subject: [PATCH 3/5] :art: Remove unncessary test setup steps --- spec/metrics-spec.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/metrics-spec.js b/spec/metrics-spec.js index effdffc..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,8 +338,6 @@ describe('Metrics', async () => { describe('when the user IS chosen to send events', async () => { beforeEach(async () => { - global.localStorage.setItem('metrics.userId', 'd') - const {mainModule} = await atom.packages.activatePackage('metrics') mainModule.shouldIncludePanesAndCommands = true From 3c872aaa98ad71619d9d55c7702bb540d704a7af Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jun 2018 15:00:53 -0400 Subject: [PATCH 4/5] :art: Tidy up code generated by `decaffeinate` --- lib/reporter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index b413757..9bd5efe 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -151,9 +151,8 @@ class Reporter { // Private static 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 + const 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 } From d7fd79808cc98a2b3a54e0790f2ac81ed9e493f1 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 13 Jun 2018 15:05:03 -0400 Subject: [PATCH 5/5] :shirt: --- lib/reporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/reporter.js b/lib/reporter.js index 9bd5efe..02b7814 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -151,7 +151,7 @@ class Reporter { // Private static viewNameForPaneItem (item) { - const name = (item.getViewClass && item.getViewClass().name) || item.constructor.name + 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 }