Gathering detailed insights and metrics for @loggists/logger
Gathering detailed insights and metrics for @loggists/logger
Gathering detailed insights and metrics for @loggists/logger
Gathering detailed insights and metrics for @loggists/logger
Comprehensive solution for event tracking in React applications
npm install @loggists/logger
Typescript
Module System
Node Version
NPM Version
TypeScript (98.93%)
JavaScript (1.07%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
81 Stars
82 Commits
7 Forks
2 Watchers
32 Branches
5 Contributors
Updated on Jul 04, 2025
Latest Version
0.3.2
Package Id
@loggists/logger@0.3.2
Unpacked Size
97.15 kB
Size
17.96 kB
File Count
19
NPM Version
10.8.2
Node Version
22.8.0
Published on
Jan 07, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
24
This package provides a simple integration with your analytics tool(e.g. Google Analytics, Amplitude) designed to handle various types of user events and context management in your React application. It is built with TypeScript, ensuring type safety and ease of integration.
If you're developing a web service with various experiments and iterations, user event tracking and logging is essential. However, logging during frontend development can sometimes be a painful process.
Maybe you have to create a custom hook, integrate your logging logic with your state management logic, and deal with all the hassle, making your code messy and hard to maintain.
logger
helps you track events with type-safe declarative APIs, and enhances your logging performance with batching.
Using npm:
1$ npm install @loggists/logger
Using yarn:
1$ yarn add @loggists/logger
Using pnpm:
1$ pnpm add @loggists/logger
1import ReactGA from "react-ga4"; 2import { createLogger } from "@loggists/logger"; 3import { SendParams, EventParams, GAContext, ImpressionParams, PageViewParams } from "./types"; 4 5export const [Log, useLog] = createLogger<GAContext, SendParams, EventParams, ImpressionParams, PageViewParams>({ 6 init: () => { 7 ReactGA.initialize("(your-ga-id)"); 8 }, 9 DOMEvents: { 10 onClick: (params, context) => { 11 ReactGA.event({ 12 ...params, 13 ...context, 14 action: "click", 15 }); 16 }, 17 }, 18 impression: { 19 onImpression: (params, context) => { 20 ReactGA.event({ 21 ...params, 22 ...context, 23 action: "impression", 24 }); 25 }, 26 }, 27 pageView: { 28 onView: ({ page }) => { 29 ReactGA.send({ 30 hitType: "pageview", 31 page, 32 }); 33 }, 34 }, 35}); 36
1import { useState } from "react"; 2import { Log } from "./logger"; 3 4function App() { 5 const [count, setCount] = useState(0); 6 7 return ( 8 <Log.Provider 9 initialContext={{ userId: "USERID", clientId: "CLIENTID" }} 10 > 11 <h1>Logger</h1> 12 <div className="card"> 13 <Log.Click 14 params={{ category: "button", label: "count", value: count + 1 }} 15 > 16 <button onClick={() => setCount((count) => count + 1)} > 17 count is {count} 18 </button> 19 </Log.Click> 20 </div> 21 <Log.Impression 22 params={{ category: "text", label: "Good morning" }} 23 > 24 <div>Good morning</div> 25 </Log.Impression> 26 <Log.PageView params={{page: "/home"}} /> 27 </Log.Provider> 28 ); 29} 30
No vulnerabilities found.
No security vulnerabilities found.