6.46.8 • Published 5 days ago

@gasket/plugin-metrics v6.46.8

Weekly downloads
29
License
MIT
Repository
github
Last release
5 days ago

@gasket/plugin-metrics

Enables plugins to collect metrics about an project when Gasket commands are invoked.

NOTE: Metrics are not collected by gasket. The metrics lifecycle exists so that you can track metrics and usage of gasket within your own organization.

Installation

New apps

gasket create <app-name> --plugins @gasket/plugin-metrics

Existing apps

npm i @gasket/plugin-metrics

Modify plugins section of your gasket.config.js:

module.exports = {
  plugins: [
    add: [
+      '@gasket/plugin-metrics'
    ]
  ]
}

Command Flags

--no-record

Metrics are available for all Gasket project commands. However, if you wish to not invoke the metrics lifecycle for certain commands or situations, such as a during a CICD process, you can run the command with the --no-record flag.

Lifecycles

metrics

The usage of gasket commands can be tracked by a plugin using the metrics lifecycle hook. It is important to note that this does not block the execution of the command.

const fetch = require('@gasket/fetch');

module.exports = {
  name: 'example',
  hooks: {
    /**
     * Hook the metrics lifecycle and pushed data to a collection endpoint
     *
     * @param {Gasket} gasket - The Gasket API
     * @param {Object} data - Collected metrics
     * @returns {Object} 
     */
    async metrics(gasket, data) {
      const url = 'https://some.example.api/endpoint';

      await fetch(url, {
        method: 'POST',
        body: JSON.stringify(data),
        headers: {
          'Content-Type': 'application/json'
        }
      });
    }
  }
}

The collected metrics data consists of the following information:

{
  "name": "name in package.json",
  "version": "version in package.json",
  "gasket": {
    "@gasket/literally-any-repo": "that is installed"
  },
  "repository": "git repository",
  "branch": "git branch",
  "config": {
    "additional keys": "used in gasket.config.js"
  },
  "system": {
    "platform": "os.platform()",
    "release": "os.release()",
    "arch": "os.arch()"
  },
  "env": "NODE_ENV",
  "argv": "Literally the args that you passed to gasket",
  "time": "Date.now()",
  "cmd": "The Gasket command that was run"
}

License

MIT

7.0.0-next.21

5 days ago

7.0.0-next.9

10 days ago

7.0.0-next.10

10 days ago

7.0.0-next.7

10 days ago

7.0.0-next.11

10 days ago

7.0.0-next.8

10 days ago

7.0.0-next.12

10 days ago

7.0.0-next.13

10 days ago

7.0.0-next.6

10 days ago

7.0.0-next.20

9 days ago

7.0.0-next.5

11 days ago

6.46.8

12 days ago

7.0.0-next.4

13 days ago

7.0.0-next.3

17 days ago

7.0.0-next.2

24 days ago

7.0.0-next.1

25 days ago

7.0.0-next.0

25 days ago

6.46.7

1 month ago

7.0.0-cli.7

2 months ago

7.0.0-cli.6

2 months ago

6.46.1-cli.0

2 months ago

7.0.0-cli.5

2 months ago

7.0.0-cli.4

2 months ago

7.0.0-cli.1

2 months ago

7.0.0-cli.0

2 months ago

7.0.0-cli.3

2 months ago

7.0.0-cli.2

2 months ago

6.46.3-cli.0

2 months ago

6.46.2

2 months ago

7.0.0-canary.1

2 months ago

6.46.2-esm.0

3 months ago

6.45.2

3 months ago

6.45.0

4 months ago

6.43.0

7 months ago

6.39.3

11 months ago

6.39.0

12 months ago

6.38.8

12 months ago

6.38.5

1 year ago

6.38.1

1 year ago

6.36.1

1 year ago

6.38.0

1 year ago

6.34.6

2 years ago

6.36.0

1 year ago

6.34.3

2 years ago

6.34.4

2 years ago

6.34.2

2 years ago

6.26.1

2 years ago

6.21.0

2 years ago

6.24.2

2 years ago

6.24.0

2 years ago

6.20.4

2 years ago

6.20.3

2 years ago

6.20.2

2 years ago

6.19.0

2 years ago

6.10.1

2 years ago

6.10.0

2 years ago

6.14.0

2 years ago

6.17.0

2 years ago

6.15.2

2 years ago

6.0.12

3 years ago

6.0.0

3 years ago

6.0.0-canary.13

3 years ago

6.0.0-canary.0

4 years ago

5.6.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-canary.4

4 years ago

5.0.0-canary.3

4 years ago

5.0.0-canary.2

4 years ago

5.0.0-canary.1

4 years ago

5.0.0-canary.0

4 years ago