Skip to content

Commit

Permalink
feat: remove telemetry feature
Browse files Browse the repository at this point in the history
  • Loading branch information
shajz committed Dec 14, 2023
1 parent 81a9f73 commit ef79cc4
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 684 deletions.
1 change: 0 additions & 1 deletion doc/cordova.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Synopsis
Global Commands
create ............................. Create a project
help ............................... Get help for a command
telemetry .......................... Turn telemetry collection on or off
config ............................. Set, get, delete, edit, and list global cordova options

Project Commands
Expand Down
34 changes: 0 additions & 34 deletions doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ These commands are available at all times.
|----------|--------------
| `create` | Create a project
| `help <command>` | Get help for a command
| `telemetry` | Turn telemetry collection on or off
| `config` | Set, get, delete, edit, and list global cordova options

## Project Command List
Expand Down Expand Up @@ -69,7 +68,6 @@ These options apply to all cordova-cli commands.
| -d or --verbose | Pipe out more verbose output to your shell. You can also subscribe to `log` and `warn` events if you are consuming `cordova-cli` as a node module by calling `cordova.on('log', function() {})` or `cordova.on('warn', function() {})`.
| -v or --version | Print out the version of your `cordova-cli` install.
|--nohooks | Suppress executing hooks (taking RegExp hook patterns as parameters)
| --no-telemetry | Disable telemetry collection for the current command.

## Platform-specific options

Expand Down Expand Up @@ -616,38 +614,6 @@ Run a local web server for www/ assets using specified `port` or default of 8000
cordova serve [port]
```
## `cordova telemetry` command
Turns telemetry collection on or off.
**Command Syntax:**
```bash
cordova telemetry [State]
```
| State | Description
|-------------|------------------
| on | Turn telemetry collection on.
| off | Turn telemetry collection off.
### Details
A timed prompt asking the user to opt-in or out is displayed the first time cordova is run.
It lasts for 30 seconds, after which the user is automatically opted-out if they don't provide any answer.
In CI environments, the `CI` environment variable can be set, which will prevent the prompt from showing up.
Telemetry collection can also be turned off on a single command by using the `--no-telemetry` flag.
**Usage Example:**
```bash
cordova telemetry on
cordova telemetry off
cordova build --no-telemetry
```
For details, see our privacy notice: https://cordova.apache.org/privacy
## `cordova help` command
Show syntax summary, or the help for a specific command.
Expand Down
23 changes: 0 additions & 23 deletions doc/telemetry.txt

This file was deleted.

103 changes: 0 additions & 103 deletions spec/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
const path = require('path');
const rewire = require('rewire');
const { events, cordova } = require('cordova-lib');
const telemetry = require('../src/telemetry');

describe('cordova cli', () => {
let cli, logger;
Expand All @@ -41,12 +40,6 @@ describe('cordova cli', () => {
]);
cli.__set__({ logger });
spyOn(console, 'log');

// Prevent accidentally turning telemetry on/off during testing
spyOn(telemetry, 'track');
spyOn(telemetry, 'turnOn');
spyOn(telemetry, 'turnOff');
spyOn(telemetry, 'showPrompt').and.returnValue(Promise.resolve());
});

describe('options', () => {
Expand Down Expand Up @@ -247,102 +240,6 @@ describe('cordova cli', () => {
});
});

describe('telemetry', () => {
const Insight = require('insight');
let isOptedOut;

beforeEach(() => {
// Allow testing if we _really_ would send tracking requests
telemetry.track.and.callThrough();
telemetry.turnOn.and.callThrough();
telemetry.turnOff.and.callThrough();
spyOn(Insight.prototype, 'track').and.callThrough();
spyOn(Insight.prototype, '_save');
spyOnProperty(Insight.prototype, 'optOut', 'get')
.and.callFake(() => isOptedOut);
spyOnProperty(Insight.prototype, 'optOut', 'set')
.and.callFake(x => { isOptedOut = x; });

// Set a normal opted-in user as default
spyOn(telemetry, 'isCI').and.returnValue(false);
isOptedOut = false;
});

it("Test#023 : skips prompt when user runs 'cordova telemetry X'", () => {
isOptedOut = undefined;

return Promise.resolve()
.then(_ => cli(['node', 'cordova', 'telemetry', 'on']))
.then(_ => cli(['node', 'cordova', 'telemetry', 'off']))
.then(() => {
expect(telemetry.showPrompt).not.toHaveBeenCalled();
});
});

it("Test#024 : is NOT collected when user runs 'cordova telemetry on' while NOT opted-in", () => {
isOptedOut = true;

return cli(['node', 'cordova', 'telemetry', 'on']).then(() => {
expect(Insight.prototype.track).not.toHaveBeenCalled();
});
});

it("Test#025 : is collected when user runs 'cordova telemetry off' while opted-in", () => {
return cli(['node', 'cordova', 'telemetry', 'off']).then(() => {
expect(telemetry.track).toHaveBeenCalledWith('telemetry', 'off', 'via-cordova-telemetry-cmd', 'successful');
expect(Insight.prototype.track).toHaveBeenCalled();
expect(Insight.prototype._save).toHaveBeenCalled();
});
});

it('Test#026 : tracks platforms/plugins subcommands', () => {
spyOn(cordova, 'platform').and.returnValue(Promise.resolve());

return cli(['node', 'cordova', 'platform', 'add', 'ios']).then(() => {
expect(telemetry.track).toHaveBeenCalledWith('platform', 'add', 'successful');
expect(Insight.prototype.track).toHaveBeenCalled();
expect(Insight.prototype._save).toHaveBeenCalled();
});
});

it('Test#027 : shows prompt if user neither opted in or out yet', () => {
isOptedOut = undefined;
spyOn(cordova, 'prepare').and.returnValue(Promise.resolve());

return cli(['node', 'cordova', 'prepare']).then(() => {
expect(telemetry.showPrompt).toHaveBeenCalled();
});
});

it('Test#029 : is NOT collected in CI environments', () => {
telemetry.isCI.and.returnValue(true);

return cli(['node', 'cordova', '--version']).then(() => {
expect(telemetry.track).not.toHaveBeenCalled();
});
});

it("Test#030 : is NOT collected when --no-telemetry flag found and doesn't prompt", () => {
isOptedOut = undefined;

return cli(['node', 'cordova', '--version', '--no-telemetry']).then(() => {
expect(telemetry.showPrompt).not.toHaveBeenCalled();
expect(Insight.prototype.track).not.toHaveBeenCalled();
});
});

it("Test#033 : track opt-out that happened via 'cordova telemetry off' even if user is NOT opted-in ", () => {
isOptedOut = true;

return cli(['node', 'cordova', 'telemetry', 'off']).then(() => {
expect(telemetry.isOptedIn()).toBeFalsy();
expect(telemetry.track).toHaveBeenCalledWith('telemetry', 'off', 'via-cordova-telemetry-cmd', 'successful');
expect(Insight.prototype.track).toHaveBeenCalled();
expect(Insight.prototype._save).toHaveBeenCalled();
});
});
});

describe('platform', () => {
beforeEach(() => {
spyOn(cordova, 'platform').and.returnValue(Promise.resolve());
Expand Down
Loading

0 comments on commit ef79cc4

Please sign in to comment.