0.1.33 • Published 6 months ago

@react-hook-observability/hooks v0.1.33

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

About

react-hook-observability is a library that provides Observability as React Hooks in React.

react-hook-observability provides the following React Hooks.

Hook NameDescriptionREADME
useBrowserEventSpansGet spans when web browser event occurs.useBrowserEventSpans
useClientConsoleTracerGet tracer in web browser console.useClientConsoleTracer

Getting Started

Install the library.

npm

npm install @react-hook-observability/hooks

yarn

yarn add @react-hook-observability/hooks

pnpm

pnpm add @react-hook-observability/hooks

bun

bun add @react-hook-observability/hooks

Usage

useBrowserEventSpans + useClientConsoleExporter

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  // 1. Setup Interactor and return following properties.
  // - watchRef: <html> tag ref
  // - spans: trace spans
  // - resetSpans: reset trace spans
  const { watchRef, spans, resetSpans } = useBrowserEventSpans({
    eventKinds: ["click"],
    batchConfig: {
      scheduledDelayMillis: 100,
    },
  });
  // 2. Setup Exporter. In this case, useClientConsoleExporter.
  useClientConsoleExporter({ spans, resetSpans, intervalDuration: 100 });
  // 3. Rendering html tag with watchRef.
  return (
    <html lang="en" ref={watchRef}>
      <body className={inter.className}>{children}</body>
    </html>
  );
}

Contributing

see CONTRIBUTING.md

0.1.33

6 months ago

0.1.32

6 months ago

0.1.31

6 months ago

0.1.23

7 months ago

0.1.22

7 months ago

0.1.21

7 months ago

0.1.20

7 months ago

0.1.14

7 months ago

0.1.2

7 months ago

0.1.0

7 months ago