@salesforce/plugin-analyticsdeprecated

Command usage and error analytics for the Salesforce CLI

Usage no npm install needed!

<script type="module">
  import salesforcePluginAnalytics from 'https://cdn.skypack.dev/@salesforce/plugin-analytics';
</script>

README

@salesforce/plugin-analytics [DEPRECATED]

As of 1/25/2021 this package has been deprecated in favor of the new telemetry plugin. Please use that plugin instead.

Logs command execution and error information to app insights using @salesforce/telemetry. All logs are recorded to a local file in the CLI cache directory. Before the CLI process exists, a new process will be spawned up to read the local file and send logs to app insights. This saves ~1-3 seconds of time it can take to spin up and tear down the telemetry services.

During the CLI process, other plugins and CLI code also record custom events to the local file to be sent in the spawned process. To do so, simply instantiate the Analytics class.

const analytics = await Analytics.create({});
analytics.record({
  eventName: 'SOME_EVENT_NAME',
  ...
});

To not output the acknowledgement warning, set SFDX_TELEMETRY_DISABLE_ACKNOWLEDGEMENT to true.

export SFDX_TELEMETRY_DISABLE_ACKNOWLEDGEMENT=true

Development

To set up the project, just run yarn && yarn test.

To debug the project, it is helpful to link it in the CLI.

# In sfdx-plugin-analytics
yarn link

# In sfdx-cli
yarn link @salesforce/plugin-analytics
DEBUG=sfdx:analytics ./bin/run force

To debug the spawned process, set the telemetry in debug mode.

SFDX_TELEMETRY_DEBUG=true DEBUG=sfdx:analytics ./bin/run