src/extensions/default/HealthData/HealthDataManager.js
function getHealthData() {
        var result = new $.Deferred(),
            oneTimeHealthData = {};

        oneTimeHealthData.snapshotTime = Date.now();
        oneTimeHealthData.os = brackets.platform;
        oneTimeHealthData.userAgent = window.navigator.userAgent;
        oneTimeHealthData.osLanguage = brackets.app.language;
        oneTimeHealthData.bracketsLanguage = brackets.getLocale();
        oneTimeHealthData.bracketsVersion = brackets.metadata.version;
        $.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
        HealthDataUtils.getUserInstalledExtensions()
            .done(function (userInstalledExtensions) {
                oneTimeHealthData.installedExtensions = userInstalledExtensions;
            })
            .always(function () {
                HealthDataUtils.getUserInstalledTheme()
                    .done(function (bracketsTheme) {
                        oneTimeHealthData.bracketsTheme = bracketsTheme;
                    })
                    .always(function () {
                        var userUuid  = PreferencesManager.getViewState("UUID");
                        var olderUuid = PreferencesManager.getViewState("OlderUUID");

                        if (userUuid && olderUuid) {
                            oneTimeHealthData.uuid      = userUuid;
                            oneTimeHealthData.olderuuid = olderUuid;
                            return result.resolve(oneTimeHealthData);
                        } else {

                            // So we are going to get the Machine hash in either of the cases.
                            if (appshell.app.getMachineHash) {
                                appshell.app.getMachineHash(function (err, macHash) {

                                    var generatedUuid;
                                    if (err) {
                                        generatedUuid = uuid.v4();
                                    } else {
                                        generatedUuid = macHash;
                                    }

                                    if (!userUuid) {
                                        // Could be a new user. In this case
                                        // both will remain the same.
                                        userUuid = olderUuid = generatedUuid;
                                    } else {
                                        // For existing user, we will still cache
                                        // the older uuid, so that we can improve
                                        // our reporting in terms of figuring out
                                        // the new users accurately.
                                        olderUuid = userUuid;
                                        userUuid  = generatedUuid;
                                    }

                                    PreferencesManager.setViewState("UUID", userUuid);
                                    PreferencesManager.setViewState("OlderUUID", olderUuid);

                                    oneTimeHealthData.uuid      = userUuid;
                                    oneTimeHealthData.olderuuid = olderUuid;
                                    return result.resolve(oneTimeHealthData);
                                });
                            } else {
                                // Probably running on older shell, in which case we will
                                // assign the same uuid to olderuuid.
                                if (!userUuid) {
                                    oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
                                } else {
                                    oneTimeHealthData.olderuuid = userUuid;
                                }

                                PreferencesManager.setViewState("UUID",      oneTimeHealthData.uuid);
                                PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
                                return result.resolve(oneTimeHealthData);
                            }
                        }
                    });

            });
        return result.promise();
    }
function getHealthData() {
        var result = new $.Deferred(),
            oneTimeHealthData = {};

        oneTimeHealthData.snapshotTime = Date.now();
        oneTimeHealthData.os = brackets.platform;
        oneTimeHealthData.userAgent = window.navigator.userAgent;
        oneTimeHealthData.osLanguage = brackets.app.language;
        oneTimeHealthData.bracketsLanguage = brackets.getLocale();
        oneTimeHealthData.bracketsVersion = brackets.metadata.version;
        $.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
        HealthDataUtils.getUserInstalledExtensions()
            .done(function (userInstalledExtensions) {
                oneTimeHealthData.installedExtensions = userInstalledExtensions;
            })
            .always(function () {
                HealthDataUtils.getUserInstalledTheme()
                    .done(function (bracketsTheme) {
                        oneTimeHealthData.bracketsTheme = bracketsTheme;
                    })
                    .always(function () {
                        var userUuid  = PreferencesManager.getViewState("UUID");
                        var olderUuid = PreferencesManager.getViewState("OlderUUID");

                        if (userUuid && olderUuid) {
                            oneTimeHealthData.uuid      = userUuid;
                            oneTimeHealthData.olderuuid = olderUuid;
                            return result.resolve(oneTimeHealthData);
                        } else {

                            // So we are going to get the Machine hash in either of the cases.
                            if (appshell.app.getMachineHash) {
                                appshell.app.getMachineHash(function (err, macHash) {

                                    var generatedUuid;
                                    if (err) {
                                        generatedUuid = uuid.v4();
                                    } else {
                                        generatedUuid = macHash;
                                    }

                                    if (!userUuid) {
                                        // Could be a new user. In this case
                                        // both will remain the same.
                                        userUuid = olderUuid = generatedUuid;
                                    } else {
                                        // For existing user, we will still cache
                                        // the older uuid, so that we can improve
                                        // our reporting in terms of figuring out
                                        // the new users accurately.
                                        olderUuid = userUuid;
                                        userUuid  = generatedUuid;
                                    }

                                    PreferencesManager.setViewState("UUID", userUuid);
                                    PreferencesManager.setViewState("OlderUUID", olderUuid);

                                    oneTimeHealthData.uuid      = userUuid;
                                    oneTimeHealthData.olderuuid = olderUuid;
                                    return result.resolve(oneTimeHealthData);
                                });
                            } else {
                                // Probably running on older shell, in which case we will
                                // assign the same uuid to olderuuid.
                                if (!userUuid) {
                                    oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
                                } else {
                                    oneTimeHealthData.olderuuid = userUuid;
                                }

                                PreferencesManager.setViewState("UUID",      oneTimeHealthData.uuid);
                                PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
                                return result.resolve(oneTimeHealthData);
                            }
                        }
                    });

            });
        return result.promise();
    }
function getHealthData ( ) { var result = new $ . Deferred ( ) , oneTimeHealthData = { } ; oneTimeHealthData . snapshotTime = Date . now ( ) ; oneTimeHealthData . os = brackets . platform ; oneTimeHealthData . userAgent = window . navigator . userAgent ; oneTimeHealthData . osLanguage = brackets . app . language ; oneTimeHealthData . bracketsLanguage = brackets . getLocale ( ) ; oneTimeHealthData . bracketsVersion = brackets . metadata . version ; $ . extend ( oneTimeHealthData , HealthLogger . getAggregatedHealthData ( ) ) ; HealthDataUtils . getUserInstalledExtensions ( ) . done ( function ( userInstalledExtensions ) { oneTimeHealthData . installedExtensions = userInstalledExtensions ; } ) . always ( function ( ) { HealthDataUtils . getUserInstalledTheme ( ) . done ( function ( bracketsTheme ) { oneTimeHealthData . bracketsTheme = bracketsTheme ; } ) . always ( function ( ) { var userUuid = PreferencesManager . getViewState ( "UUID" ) ; var olderUuid = PreferencesManager . getViewState ( "OlderUUID" ) ; if ( userUuid && olderUuid ) { oneTimeHealthData . uuid = userUuid ; oneTimeHealthData . olderuuid = olderUuid ; return result . resolve ( oneTimeHealthData ) ; } else { // So we are going to get the Machine hash in either of the cases. if ( appshell . app . getMachineHash ) { appshell . app . getMachineHash ( function ( err , macHash ) { var generatedUuid ; if ( err ) { generatedUuid = uuid . v4 ( ) ; } else { generatedUuid = macHash ; } if ( ! userUuid ) { // Could be a new user. In this case // both will remain the same. userUuid = olderUuid = generatedUuid ; } else { // For existing user, we will still cache // the older uuid, so that we can improve // our reporting in terms of figuring out // the new users accurately. olderUuid = userUuid ; userUuid = generatedUuid ; } PreferencesManager . setViewState ( "UUID" , userUuid ) ; PreferencesManager . setViewState ( "OlderUUID" , olderUuid ) ; oneTimeHealthData . uuid = userUuid ; oneTimeHealthData . olderuuid = olderUuid ; return result . resolve ( oneTimeHealthData ) ; } ) ; } else { // Probably running on older shell, in which case we will // assign the same uuid to olderuuid. if ( ! userUuid ) { oneTimeHealthData . uuid = oneTimeHealthData . olderuuid = uuid . v4 ( ) ; } else { oneTimeHealthData . olderuuid = userUuid ; } PreferencesManager . setViewState ( "UUID" , oneTimeHealthData . uuid ) ; PreferencesManager . setViewState ( "OlderUUID" , oneTimeHealthData . olderuuid ) ; return result . resolve ( oneTimeHealthData ) ; } } } ) ; } ) ; return result . promise ( ) ; }
Get the Health Data which will be sent to the server. Initially it is only one time data.
Get the Health Data which will be sent to the server . Initially it is only one time data .