Nebulous Puffy Marshmallows

    @logary/plugin-react
    TypeScript icon, indicating that this package has built-in type declarations

    6.0.0-beta.8 • Public • Published

    Logary JS — React Plugin

    A plugin for the popular React framework.

    npm add @logary/plugin-react
    

    Usage

    For details, see ./examples/with-nextjs in the repository.

    In your logary.ts:

    import react from '@logary/plugin-react'
    const logary = getLogary({ ... }) // configure targets and Logary Analytics ID here
    react(logary)
    // more plugins here
    export default logary

    You can now use the useLogary hook to get the Logary instance:

    import '../lib/logary' // ensure Logary is instantiated (best placed in App.tsx)
     
    // now you can use the hooks in your components:
    import { useLogary, useLogger } from '@logary/plugin-react'
     
    export default function Button({ onClick, children }) {
      const { event } = useLogger('MyApp', 'Button')
     
      function handleClick(e: Event) {
        event('Made purchase', { amount: 20.3, currency: 'USD' })
        onClick(e)
      }
     
      return (
        <button onClick={handleClick}>
          {children}
        </button>
      )
    }

    Install

    npm i @logary/plugin-react

    DownloadsWeekly Downloads

    22

    Version

    6.0.0-beta.8

    License

    GPL3 / commercial

    Unpacked Size

    8.08 kB

    Total Files

    12

    Last publish

    Collaborators

    • haf