@contentful/app-scripts 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/bin/app-scripts +5 -1
- package/lib/index.js +2 -0
- package/package.json +5 -4
- package/utils/analytics.js +33 -0
package/README.md
CHANGED
|
@@ -217,3 +217,13 @@ When passing the `--ci` argument adding all variables as arguments is required
|
|
|
217
217
|
| `--host` | Optional, the Contentful CMA-endpoint to use |
|
|
218
218
|
|
|
219
219
|
**Note:** You can also pass all arguments in interactive mode to skip being asked for it.
|
|
220
|
+
|
|
221
|
+
### Tracking
|
|
222
|
+
|
|
223
|
+
We gather depersonalized usage data of our CLI tools in order to improve experience. If you do not want your data to be gathered, you can opt out by providing an env variable `DISABLE_ANALYTICS` set to any value:
|
|
224
|
+
|
|
225
|
+
> **Example**
|
|
226
|
+
>
|
|
227
|
+
> ```
|
|
228
|
+
> DISABLE_ANALYTICS=true npx create-contentful-app
|
|
229
|
+
> ```
|
package/bin/app-scripts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { program } = require('commander');
|
|
4
4
|
const { version } = require('../package.json');
|
|
5
5
|
|
|
6
|
-
const { createAppDefinition, upload, activate, cleanup, open } = require('../');
|
|
6
|
+
const { createAppDefinition, upload, activate, cleanup, open, track } = require('../');
|
|
7
7
|
|
|
8
8
|
async function runCommand(command, options) {
|
|
9
9
|
const { ci } = program.opts();
|
|
@@ -64,6 +64,10 @@ async function runCommand(command, options) {
|
|
|
64
64
|
await runCommand(cleanup, options);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
+
program.hook('preAction', (thisCommand) => {
|
|
68
|
+
track({ command: thisCommand.args[0], ci: thisCommand._optionValues.ci })
|
|
69
|
+
})
|
|
70
|
+
|
|
67
71
|
await program.parseAsync(process.argv);
|
|
68
72
|
})().catch((e) => {
|
|
69
73
|
console.error(e);
|
package/lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const upload = require('./upload');
|
|
|
3
3
|
const activate = require('./activate');
|
|
4
4
|
const cleanup = require('./clean-up');
|
|
5
5
|
const open = require('./open');
|
|
6
|
+
const track = require('../utils/analytics');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
createAppDefinition,
|
|
@@ -10,4 +11,5 @@ module.exports = {
|
|
|
10
11
|
activate,
|
|
11
12
|
cleanup,
|
|
12
13
|
open,
|
|
14
|
+
track,
|
|
13
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/app-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A collection of scripts for building Contentful Apps",
|
|
5
5
|
"author": "Contentful GmbH",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,10 +49,11 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"adm-zip": "0.5.9",
|
|
52
|
+
"analytics-node": "^6.2.0",
|
|
52
53
|
"bottleneck": "2.19.5",
|
|
53
54
|
"chalk": "4.1.2",
|
|
54
|
-
"commander": "9.
|
|
55
|
-
"contentful-management": "10.
|
|
55
|
+
"commander": "9.5.0",
|
|
56
|
+
"contentful-management": "10.27.0",
|
|
56
57
|
"dotenv": "16.0.3",
|
|
57
58
|
"ignore": "5.2.4",
|
|
58
59
|
"inquirer": "8.2.5",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"open": "8.4.0",
|
|
61
62
|
"ora": "5.4.1"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "6bc2e2e5a1c2764debb87bfbfde1b234e667771e"
|
|
64
65
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const Analytics = require('analytics-node');
|
|
2
|
+
|
|
3
|
+
// Public write key scoped to data source
|
|
4
|
+
const SEGMENT_WRITE_KEY = 'IzCq3j4dQlTAgLdMykRW9oBHQKUy1xMm';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {object} properties tracking properties
|
|
9
|
+
* @param {string} properties.command triggered command e.g create-app-definition, upload, etc.
|
|
10
|
+
* @param {boolean} properties.ci value if --ci flag has been set
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function track(properties) {
|
|
14
|
+
if (process.env.DISABLE_ANALYTICS) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const client = new Analytics(SEGMENT_WRITE_KEY);
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
client.track({
|
|
22
|
+
event: 'app-cli-app-scripts',
|
|
23
|
+
properties,
|
|
24
|
+
anonymousId: Date.now(), // generate a random id
|
|
25
|
+
timestamp: new Date(),
|
|
26
|
+
});
|
|
27
|
+
// eslint-disable-next-line no-empty
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// ignore any error, to not block the call
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = track;
|