Socket
Socket
Sign inDemoInstall

@souranalytics/react

Package Overview
Dependencies
5
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @souranalytics/react

Pickle for React


Version published
Maintainers
1
Created

Readme

Source

Pickle for React

React package for Pickle analytics.

Install

yarn add @souranalytics/react

Usage

Wrap your root component with PickleProvider.

  • Next.js app router: app/layout.tsx
  • Next.js pages router: pages/_app.tsx
  • CRA / Vite: index.tsx
import { PickleProvider } from '@souranalytics/react'

export default function MyApp() {
  return (
    <PickleProvider key="API_KEY">
      {/* your app contents go here */}
    </PickleProvider>
  )
}

Then use the usePickle hook anywhere in your app.

import { usePickle } from '@souranalytics/react'

export default function Page() {
  const pickle = usePickle()

  return (
    <div>
      <button onClick={() => pickle.event('hello')}>Event</button>
    </div>
  )
}

API

PickleProvider

Props
OptionTypeDescriptionRequiredDefault
keystringProject API keyYes-
urlstringOverride Pickle API endpointNohttps://pickle.sh/api
anonymousIdstringOverride anonymous user idNocuid2

usePickle

const pickle = usePickle()
identify
pickle.identify(user: User | null, data?: UserProps)
OptionTypeDescriptionRequired
user.idstringUser idYes
user.namestringUser nameNo
user.emailstringUser emailNo
dataobjectUser propertiesNo
event
pickle.event(name: string | null, data?: EventProps)
OptionTypeDescriptionRequired
namestringEvent nameYes
dataobjectEvent propertiesNo
view
pickle.view(name: string | null, data?: ViewProps)
OptionTypeDescriptionRequired
namestringView nameYes
dataobjectView propertiesNo

TypeScript

If you have created a plan for your project on Pickle, you can use the Pickle CLI to generate TypeScript types for this library.

This will give you strong types for identify, event, and view methods exposed by usePickle.

Keywords

FAQs

Last updated on 21 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc