6.0.0-beta.8 • Published 4 years ago
@logary/plugin-react v6.0.0-beta.8
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>
)
}
6.0.0-beta.8
4 years ago
6.0.0-beta.7
4 years ago
6.0.0-beta.3
4 years ago
6.0.0-beta.4
4 years ago
6.0.0-beta.2
4 years ago
6.0.0-beta.1
4 years ago
6.0.0-beta.0
4 years ago
6.0.0-alpha.3
4 years ago
6.0.0-alpha.5
4 years ago
6.0.0-alpha.1
4 years ago