React

SaasHound client for React applications

Installation

To install the saashound react.js library, run the following command:

Using npm

Terminal window
npm install saashound-react

Using yarn

Terminal window
yarn add saashound-react

Using pnpm

Terminal window
pnpm install saashound-react

Usage

Context Provider

import React from 'react'
import { SaasHoundProvider } from 'saashound-react'
const App: React.FC = () => (
<SaasHoundProvider token="API_TOKEN" project="PROJECT_NAME">
{/* <App /> */}
</SaasHoundProvider>
)

Hooks

Component.tsx
import React from 'react'
import { useSaasHound } from 'saashound-react'
const YourComponent: React.FC = () => {
const { logEvent, sendMetric, identify } = useSaasHound()
const yourFunction = async () => {
await logEvent({
channel: "payments",
title: "New Customer",
userId: "user-123",
icon: "💰",
notify: true,
tags: {
plan: "premium",
cycle: "onetime",
trial: false
}
});
// Send Metric
await sendMetric({
title: "Users",
value: 1254,
icon: "👥",
increment: false,
});
// Identify user
await identify({
userId: "user-987",
properties: {
name: "Al Beback",
email: "al@beb.com",
plan: "premium",
referrals: 12,
}
});
}
return (
// Your component code here
)
}