@hexlet/analytics-plugin-n8n
v1.0.4
Published
plugin for analytics
Downloads
1,272
Readme
analytics-n8n
This library exports the n8n plugin for the analytics package.
Installation
npm install analytics @hexlet/analytics-plugin-n8n
How to use
import Analytics from 'analytics';
import N8nPlugin from '@hexlet/analytics-plugin-n8n';
const n8nConfig = {
event_one: 'https://workflows.hexlet.io/webhook/pathOne', // this must be n8n trigger url
event_two: 'https://workflows.hexlet.io/webhook/pathTwo',
};
const analytics = Analytics({
app: 'my-app',
plugins: [
N8nPlugin({
workflows: n8nConfig,
}),
],
});
// track an event
analytics.track('signed_up', { email: '[email protected]' });
In browser
<script src="https://unpkg.com/analytics/dist/analytics.min.js"></script>
<script src="https://unpkg.com/@hexlet/analytics-plugin-n8n/dist/main.js"></script>
<script>
var Analytics = _analytics.init({
app: 'my-app',
plugins: [
N8nPlugin({
workflows: n8nConfig,
}),
],
});
Analytics.track('signed_up', { email: '[email protected]' }); // track an event
</script>