Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
11 changes: 5 additions & 6 deletions spec/metrics-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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

Expand All @@ -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)
})
})
})
Expand Down