@contentful/app-scripts 1.5.6 → 1.7.0

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/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);
@@ -22,12 +22,12 @@ NOTE: This will create an app definition in your Contentful organization.
22
22
  message: `Select where your app can be rendered:`,
23
23
  type: 'checkbox',
24
24
  choices: [
25
- { name: 'App configuration screen (app-config) ', value: 'app-config' },
26
- { name: 'Entry field (entry-field) ', value: 'entry-field' },
27
- { name: 'Entry sidebar (entry-sidebar) ', value: 'entry-sidebar' },
28
- { name: 'Entry editor (entry-editor)', value: 'entry-editor' },
29
- { name: 'Page (page) ', value: 'page' },
30
- { name: 'Home (home) ', value: 'home' },
25
+ { name: 'App configuration screen ', value: 'app-config' },
26
+ { name: 'Entry field', value: 'entry-field' },
27
+ { name: 'Entry sidebar', value: 'entry-sidebar' },
28
+ { name: 'Entry editor', value: 'entry-editor' },
29
+ { name: 'Page', value: 'page' },
30
+ { name: 'Home', value: 'home' },
31
31
  ],
32
32
  },
33
33
  {
@@ -94,7 +94,7 @@ async function createAppDefinition(accessToken, appDefinitionSettings = { locati
94
94
  });
95
95
 
96
96
  console.log(`
97
- ${chalk.cyan('Success!')} Created an app definition for ${chalk.bold(appName)} in ${chalk.bold(
97
+ ${chalk.greenBright('Success!')} Created an app definition for ${chalk.bold(appName)} in ${chalk.bold(
98
98
  selectedOrg.name
99
99
  )}.
100
100
 
@@ -102,11 +102,12 @@ async function createAppDefinition(accessToken, appDefinitionSettings = { locati
102
102
  ${chalk.underline(`https://app.contentful.com/deeplink?link=org`)}`)}
103
103
 
104
104
  ${chalk.bold('Next steps:')}
105
- 1. To develop, run ${chalk.cyan('`npm start`')} inside your app folder and open:
105
+ 1. Run your app with ${chalk.cyan('`npm start`')} inside of your app folder.
106
+ 2. Install this app definition to one of your spaces by opening:
106
107
  ${chalk.underline(
107
108
  `https://app.contentful.com/deeplink?link=apps&id=${createdAppDefinition.sys.id}`
108
109
  )}
109
- 2. To learn how to build your first Contentful app, visit:
110
+ 3. Learn how to build your first Contentful app:
110
111
  ${chalk.underline(`https://ctfl.io/app-tutorial`)}
111
112
  `);
112
113
  } catch (err) {
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.5.6",
3
+ "version": "1.7.0",
4
4
  "description": "A collection of scripts for building Contentful Apps",
5
5
  "author": "Contentful GmbH",
6
6
  "license": "MIT",
@@ -49,9 +49,10 @@
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.4.1",
55
+ "commander": "9.5.0",
55
56
  "contentful-management": "10.26.0",
56
57
  "dotenv": "16.0.3",
57
58
  "ignore": "5.2.4",
@@ -60,5 +61,5 @@
60
61
  "open": "8.4.0",
61
62
  "ora": "5.4.1"
62
63
  },
63
- "gitHead": "4845fec5b556319edc7a15bdda662a144f082190"
64
+ "gitHead": "dcb14be43822fc3c4afc168de83c7207adf64236"
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;