Analytics plugin for analytics, powered by @dittofeed/sdk-web.
Supports identify, track, and page methods.
npm i @hexlet/analytics-plugin-dittofeedimport Analytics from 'analytics';
import dittofeed from '@hexlet/analytics-plugin-dittofeed';
const analytics = Analytics({
app: 'test-app',
plugins: [
dittofeed({
sdkInit: {
writeKey: 'Basic abcdefg...', // Public write key from Dittofeed dashboard
// apiHost: 'https://app.dittofeed.com' // Can be overridden for self-host
},
enable: process.env.NODE_ENV === 'production', // Enable only in production
}),
],
});
// page
analytics.page(); // page event (defaults with document.title)
// identify
analytics.identify('user_123', {
email: '[email protected]',
firstName: 'John',
});
// track
analytics.track('Made Purchase', {
itemId: 'abc123',
price: 49.9,
});Releases are managed through release-it (see make release). The flow now publishes the package to both npm and GitHub Packages:
- Ensure the build passes (
npm run build). - Export authentication tokens before running the release command:
Optionally wire them in
export NPM_TOKEN=xxxx # Token for registry.npmjs.org export NODE_AUTH_TOKEN=yyyy # PAT for npm.pkg.github.com
.npmrc://registry.npmjs.org/:_authToken=${NPM_TOKEN} //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} - Run
make release(ornpx release-it). This will build, publish to npm, then automatically runnpm run publish:githubwhich publishes the same tarball tohttps://npm.pkg.github.com.