Loglib

Setting up tracker

Loglib tracker


this is the tracker package for loglib, it's a simple package that you can use to track events in your application.

Start by installing the package

pnpm i @loglib/tracker

React/NextJS

usage with nextjs

src/app/layout.tsx

import LogLib from "@loglib/tracker/react"; export default function RootLayout({ children, }: { children: React.ReactNode; }) { return ( <html lang="en"> <body> <LogLib config={ { id: //your website Id } } /> {children} </body> </html> ); }

Other Frameworks

if you're not using next js or react you can use the vanilla version of the tracker that works on any framework just call the record function on the entry point of your application here is example for astro.

<script> import {loglib} from '@loglib/tracker'; loglib.record( { id: //your website id, }) </script>

CDN

To use loglib via the CDN, simply copy the following code into your script tag and replace the host with your deployed version:

Note that if you don't want to collect development logs, you can pass the env parameter as isDev(your way to know if it's development server) ? "dev": "prod"

<head> <script src="https://cdn.jsdelivr.net/npm/@loglib/tracker@latest/dist/index.global.js" data-id="your website id"></script> </head>