mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
import { useInsights } from '@hanzo/insights/react'
|
|
|
|
const events = [
|
|
{
|
|
name: 'Product Added',
|
|
properties: {
|
|
product_id: 'SomeProductID',
|
|
name: 'SomeProductName',
|
|
price: 42,
|
|
quantity: 1,
|
|
},
|
|
},
|
|
{
|
|
name: 'Products Searched',
|
|
properties: {
|
|
products: [
|
|
{
|
|
product_id: 'SomeProductID',
|
|
name: 'SomeProductName',
|
|
price: 42,
|
|
},
|
|
{
|
|
product_id: 'OtherProductID',
|
|
name: 'OtherProductName',
|
|
price: 43,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
name: 'Product Added to Wishlist',
|
|
properties: {
|
|
product_id: 'SomeProductID',
|
|
name: 'SomeProductName',
|
|
price: 42,
|
|
quantity: 1,
|
|
wishlist_id: 'SomeWishlistID',
|
|
wishlist_name: 'SomeWishlistName',
|
|
},
|
|
},
|
|
{
|
|
name: 'Order Completed',
|
|
properties: {
|
|
products: [
|
|
{
|
|
product_id: 'SomeProductID',
|
|
name: 'SomeProductName',
|
|
price: 42,
|
|
},
|
|
{
|
|
product_id: 'OtherProductID',
|
|
name: 'OtherProductName',
|
|
price: 43,
|
|
},
|
|
],
|
|
total: 83,
|
|
currency: 'USD',
|
|
},
|
|
},
|
|
{
|
|
name: 'Custom Event',
|
|
properties: {
|
|
foo: 'bar',
|
|
},
|
|
},
|
|
]
|
|
|
|
export default function Ecommerce() {
|
|
const insights = useInsights()
|
|
|
|
return (
|
|
<div className="flex items-center gap-2 flex-wrap">
|
|
{events.map((event) => (
|
|
<button key={event.name} onClick={() => insights.capture(event.name, event.properties)}>
|
|
{event.name}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|