algino
v1.1.8
Published
Dead simple analytics SDK for React and Next.js
Maintainers
Readme
Algino Analytics SDK
Drop-in, session-aware analytics that works the same way in every modern web stack.
npm install alginoOne Setup Per Framework
Vanilla JavaScript
import { AnalyticsClient } from 'algino';
const analytics = new AnalyticsClient({
apiKey: 'your_key',
projectId: 'your_project',
});
await analytics.init();
analytics.trackPageview();
analytics.track('cta_click', { id: 'hero-button' });React
import { AlginoProvider, useAnalytics } from 'algino/react';
export function App() {
return (
<AlginoProvider apiKey="your_key" projectId="your_project">
<Routes />
</AlginoProvider>
);
}
function CTA() {
const { track } = useAnalytics();
return <button onClick={() => track('cta_click')}>Start</button>;
}Next.js (App or Pages Router)
import { Algino } from 'algino/next';
export default function RootLayout({ children }) {
return (
<Algino apiKey={process.env.NEXT_PUBLIC_ALGINO_KEY!} projectId={process.env.NEXT_PUBLIC_ALGINO_PROJECT!}>
{children}
</Algino>
);
}Vue 3
import { createApp } from 'vue';
import { createAlginoVuePlugin } from 'algino/vue';
import router from './router';
const { plugin } = createAlginoVuePlugin({
apiKey: 'your_key',
projectId: 'your_project',
router,
});
createApp(App).use(router).use(plugin).mount('#app');Angular
import { AlginoAngularAdapter } from 'algino/angular';
@Injectable({ providedIn: 'root' })
export class AnalyticsService {
private readonly analytics = new AlginoAngularAdapter({
apiKey: 'your_key',
projectId: 'your_project',
router: this.router,
});
constructor(private router: Router) {}
track(name: string, data?: Record<string, any>) {
void this.analytics.track(name, data);
}
}Track Anything
analytics.trackPageview('/dashboard');
analytics.track('plan_selected', { plan: 'pro' });Config Options
apiKey(required) – API key tied to the projectprojectId(required) – Project identifierapiUrl– Override the defaulthttps://analytics.example.com/api/v1debug– Log every call in the consoleautoTrack– Disable automatic pageview tracking (defaulttrue)
What You Get
- Session init, event batching, and heartbeats handled for you
- Per-session rate limit awareness and backoff built in
- Final heartbeats + queue flush on page hide/unload with
keepalive - One SDK that covers Vanilla JS, React, Next.js, Vue 3, and Angular
License
MIT © Algino
