mirror of
https://github.com/adobe/brackets.git
synced 2024-11-20 18:02:54 +01:00
Changes to send data only once per 24 hours (#14695)
* Changes to send data only once per 24 hours * Update HealthLogger.js
This commit is contained in:
parent
379a26b649
commit
6f80d3c8c2
@ -308,22 +308,16 @@ define(function (require, exports, module) {
|
||||
isHDTracking = prefs.get("healthDataTracking"),
|
||||
isEventDataAlreadySent;
|
||||
|
||||
var options = {
|
||||
location: {
|
||||
scope: "default"
|
||||
}
|
||||
};
|
||||
|
||||
if (isHDTracking) {
|
||||
isEventDataAlreadySent = PreferencesManager.getViewState(Eventparams.eventName);
|
||||
PreferencesManager.setViewState(Eventparams.eventName, 1, options);
|
||||
isEventDataAlreadySent = HealthLogger.analyticsEventMap.get(Eventparams.eventName);
|
||||
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
|
||||
if (!isEventDataAlreadySent || forceSend) {
|
||||
sendAnalyticsDataToServer(Eventparams)
|
||||
.done(function () {
|
||||
PreferencesManager.setViewState(Eventparams.eventName, 1, options);
|
||||
HealthLogger.analyticsEventMap.set(Eventparams.eventName, true);
|
||||
result.resolve();
|
||||
}).fail(function () {
|
||||
PreferencesManager.setViewState(Eventparams.eventName, 0, options);
|
||||
HealthLogger.analyticsEventMap.set(Eventparams.eventName, false);
|
||||
result.reject();
|
||||
});
|
||||
} else {
|
||||
@ -336,6 +330,17 @@ define(function (require, exports, module) {
|
||||
return result.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is auto called after 24 hours to empty the map
|
||||
* Map is used to make sure that we send an event only once per 24 hours
|
||||
**/
|
||||
|
||||
function emptyAnalyticsMap() {
|
||||
HealthLogger.analyticsEventMap.clear();
|
||||
setTimeout(emptyAnalyticsMap, ONE_DAY);
|
||||
}
|
||||
setTimeout(emptyAnalyticsMap, ONE_DAY);
|
||||
|
||||
// Expose a command to test data sending capability, but limit it to dev environment only
|
||||
CommandManager.register("Sends health data and Analytics data for testing purpose", "sendHealthData", function() {
|
||||
if (brackets.config.environment === "stage") {
|
||||
|
@ -24,6 +24,7 @@
|
||||
/**
|
||||
* Utilities functions related to Health Data logging
|
||||
*/
|
||||
/*global Map*/
|
||||
define(function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
@ -36,7 +37,8 @@ define(function (require, exports, module) {
|
||||
EventDispatcher = require("utils/EventDispatcher"),
|
||||
|
||||
HEALTH_DATA_STATE_KEY = "HealthData.Logs",
|
||||
logHealthData = true;
|
||||
logHealthData = true,
|
||||
analyticsEventMap = new Map();
|
||||
|
||||
var commonStrings = { USAGE: "usage",
|
||||
FILE_OPEN: "fileOpen",
|
||||
@ -319,9 +321,10 @@ define(function (require, exports, module) {
|
||||
* needs to be logged- should be a js var compatible string
|
||||
*/
|
||||
function sendAnalyticsData(eventName, eventCategory, eventSubCategory, eventType, eventSubType) {
|
||||
var isEventDataAlreadySent = PreferencesManager.getViewState(eventName),
|
||||
var isEventDataAlreadySent = analyticsEventMap.get(eventName),
|
||||
isHDTracking = PreferencesManager.getExtensionPrefs("healthData").get("healthDataTracking"),
|
||||
eventParams = {};
|
||||
|
||||
if (isHDTracking && !isEventDataAlreadySent && eventName && eventCategory) {
|
||||
eventParams = {
|
||||
eventName: eventName,
|
||||
@ -363,4 +366,5 @@ define(function (require, exports, module) {
|
||||
// A new search context on search bar up-Gives an idea of number of times user did a discrete search
|
||||
exports.SEARCH_NEW = "searchNew";
|
||||
exports.commonStrings = commonStrings;
|
||||
exports.analyticsEventMap = analyticsEventMap;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user