Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add window size and heap usage #67

Merged
merged 5 commits into from Aug 4, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -8,10 +8,11 @@ If you do not want this information reported, you can disable this package. Open
### Collected data

* A unique UUID v4 random identifier is generated according to [RFC4122][RFC4122]
* Screen width and height
* Screen and window width and height
* Version of Atom being used
* Name of each Atom view class or Atom configuration file opened in a pane, e.g. `EditorView`, `SettingsView`, `MarkdownPreviewView`, and `UserKeymap`. **No other pane item information is collected.**
* Exception messages (without paths)
* Heap memory used as MB and %
* Commands run (save core commands)
* Amount of time the current window was open for
* Amount of time the current window took to load
Expand Down
9 changes: 8 additions & 1 deletion lib/reporter.coffee
Expand Up @@ -74,7 +74,10 @@ module.exports =
params =
t: 'appview'
cd: @viewNameForPaneItem(item)
dt: item.getGrammar?()?.name

grammarName = item.getGrammar?()?.name
if grammarName?
params.dt = grammarName
@send(params)

@sendCommand: (commandName) ->
Expand All @@ -101,6 +104,9 @@ module.exports =
@defaultParams: ->
params = {}
params.cd1 = startDate if startDate = localStorage.getItem('metrics.sd')
memUse = process.memoryUsage()
params.cm1 = memUse.heapUsed >> 20 # Convert bytes to megabytes
params.cm2 = Math.round((memUse.heapUsed / memUse.heapTotal) * 100)

# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
extend params,
Expand All @@ -111,4 +117,5 @@ module.exports =
an: 'atom'
av: atom.getVersion()
sr: "#{screen.width}x#{screen.height}"
vp: "#{innerWidth}x#{innerHeight}"
aiid: getReleaseChannel()
36 changes: 36 additions & 0 deletions spec/metrics-spec.coffee
Expand Up @@ -63,6 +63,42 @@ describe "Metrics", ->
[url] = Reporter.request.mostRecentCall.args
expect(url).toContain('&aip=1&')

it "specifies screen resolution", ->
waitsForPromise ->
atom.packages.activatePackage('metrics')

waitsFor ->
Reporter.request.callCount > 0

runs ->
[url] = Reporter.request.mostRecentCall.args
expect(url).toContain("&sr=#{screen.width}x#{screen.height}&")

it "specifies window resolution", ->
waitsForPromise ->
atom.packages.activatePackage('metrics')

waitsFor ->
Reporter.request.callCount > 0

runs ->
[url] = Reporter.request.mostRecentCall.args
expect(url).toContain("&vp=#{innerWidth}x#{innerHeight}&")

it "specifies heap usage in MB and %", ->
spyOn(process, 'memoryUsage').andReturn {heapTotal: 234567890, heapUsed: 123456789}

waitsForPromise ->
atom.packages.activatePackage('metrics')

waitsFor ->
Reporter.request.callCount > 0

runs ->
[url] = Reporter.request.mostRecentCall.args
expect(url).toContain("&cm1=117&")
expect(url).toContain("&cm2=53&")

describe "reporting release channel", ->
beforeEach ->
localStorage.setItem('metrics.userId', 'a')
Expand Down