-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from GoogleChrome/sendErrorsToAnalytics2
Send the exceptions to Analytics
- Loading branch information
Showing
3 changed files
with
42 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,47 @@ | ||
/** | ||
* @constructor | ||
* @param {boolean} enabled | ||
*/ | ||
function Analytics() { | ||
this.service_ = null; | ||
} | ||
function Analytics(enabled) { | ||
this.hasReportedSettings_ = false; | ||
this.setEnabled(enabled); | ||
|
||
Analytics.prototype.start = function(settings) { | ||
if (this.service_) { | ||
throw 'Analytics should be started only once per session.'; | ||
} | ||
|
||
this.service_ = analytics.getService('text_app'); | ||
var service = analytics.getService('text_app'); | ||
var propertyId = 'UA-48886257-2'; | ||
if (chrome.runtime.id === 'mmfbcljfglbokpmkimbfghdkjmjhdgbg') { | ||
propertyId = 'UA-48886257-1'; | ||
} | ||
this.tracker_ = this.service_.getTracker(propertyId); | ||
|
||
this.reportSettings_(settings); | ||
this.tracker_ = service.getTracker(propertyId); | ||
|
||
this.tracker_.sendAppView('main'); | ||
$(document).bind('settingschange', this.onSettingsChange_.bind(this)); | ||
}; | ||
|
||
Analytics.prototype.reportSettings_ = function(settings) { | ||
Analytics.prototype.reportSettings = function(settings) { | ||
if (!this.enabled_ || this.hasReportedSettings_) | ||
return; // Settings should be reported only once per session. | ||
|
||
this.tracker_.set('dimension1', settings.get('spacestab').toString()); | ||
this.tracker_.set('dimension2', settings.get('tabsize').toString()); | ||
this.tracker_.set('dimension3', | ||
Math.round(settings.get('fontsize')).toString()); | ||
this.tracker_.set('dimension4', settings.get('sidebaropen').toString()); | ||
this.tracker_.set('dimension5', settings.get('theme')); | ||
|
||
this.tracker_.sendAppView('main', function() { | ||
this.hasReportedSettings_ = true; | ||
}.bind(this)); | ||
}; | ||
|
||
Analytics.prototype.reportError = function(message, error) { | ||
if (this.enabled_) | ||
this.tracker_.sendEvent('error', message, error); | ||
}; | ||
|
||
Analytics.prototype.setEnabled = function(enabled) { | ||
this.enabled_ = enabled; | ||
}; | ||
|
||
Analytics.prototype.onSettingsChange_ = function(e, key, value) { | ||
if (key === 'analytics') | ||
this.setEnabled(value); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters