cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabbage <...@git.apache.org>
Subject [GitHub] cordova-cli pull request: Telemetry
Date Tue, 10 May 2016 22:57:34 GMT
Github user purplecabbage commented on a diff in the pull request:

    https://github.com/apache/cordova-cli/pull/247#discussion_r62768428
  
    --- Diff: src/telemetry.js ---
    @@ -0,0 +1,132 @@
    +/**
    +    Licensed to the Apache Software Foundation (ASF) under one
    +    or more contributor license agreements.  See the NOTICE file
    +    distributed with this work for additional information
    +    regarding copyright ownership.  The ASF licenses this file
    +    to you under the Apache License, Version 2.0 (the
    +    "License"); you may not use this file except in compliance
    +    with the License.  You may obtain a copy of the License at
    +
    +    http://www.apache.org/licenses/LICENSE-2.0
    +
    +    Unless required by applicable law or agreed to in writing,
    +    software distributed under the License is distributed on an
    +    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +    KIND, either express or implied.  See the License for the
    +    specific language governing permissions and limitations
    +    under the License.
    +*/
    +
    +/* jshint node:true, bitwise:true, undef:true, trailing:true, quotmark:true,
    +          indent:4, unused:vars, latedef:nofunc,
    +          laxcomma:true
    +*/
    +
    +
    +
    +// For further details on telemetry, see:
    +// https://github.com/cordova/cordova-discuss/pull/43
    +
    +var Q = require('q');
    +
    +// Google Analytics tracking code
    +var GA_TRACKING_CODE = 'UA-64283057-7';
    +
    +var pkg = require('../package.json');
    +var Insight = require('insight');
    +var insight = new Insight({
    +    trackingCode: GA_TRACKING_CODE,
    +    pkg: pkg
    +});
    +
    +/**
    + * Returns true if the user opted in, and false otherwise
    + */
    +function showPrompt() {
    +
    +    var deferred = Q.defer();
    +    
    +    var msg = "May Cordova anonymously report usage statistics to improve the tool over
time?";
    +    insight.askPermission(msg, function (unused, optIn) {
    +        var EOL = require('os').EOL;
    +        if (optIn) {
    +            console.log(EOL + "Thanks for opting into telemetry to help us better cordova");
    +        } else {
    +            console.log(EOL + "You have been opted out of telemetry. To change this,
run: cordova telemetry on");
    +            // Always track telemetry opt-outs! (whether opted-in or opted-out)
    +            track('telemetry-opt-out', 'via-cli-prompt-choice');
    +        }
    +        
    +        deferred.resolve(optIn); 
    +    });
    +    
    +    return deferred.promise;
    +}
    +
    +function track() {
    +    insight.track.apply(insight, arguments);
    +}
    +
    +function trackEvent(category, action, label, value) {
    +    insight.trackEvent({
    +        category: category,
    +        action: action,
    +        label: label,
    +        value: value
    +    });
    +}
    +
    +function turnOn() {
    +    insight.optOut = false;
    +}
    +
    +function turnOff() {
    +    insight.optOut = true;
    +}
    +
    +/**
    + * Clears telemetry setting
    + * Has the same effect as if user never answered the telemetry prompt
    + * Useful for testing purposes
    + */
    +function clear() {
    +    insight.optOut = undefined;
    +}
    +
    +function isOptedIn() {
    +    return !insight.optOut;
    +}
    +
    +/**
    + * Has the user already answered the telemetry prompt? (thereby opting in or out?)
    + */
    +function hasUserOptedInOrOut() {
    +    return !(insight.optOut === undefined);
    --- End diff --
    
    ```
    > typeof null === 'undefined'
    < false
    ``` 
    My concern is only for clarity of intent. If someone decides to redefine undefined, I
would think things will break all over.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message