Skip to content

Commit

Permalink
Add useEdgeeDataCollection React SDK Hook Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jer1605 authored and SachaMorard committed Feb 12, 2025
1 parent 8dac7ba commit 3225536
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 402 deletions.
21 changes: 21 additions & 0 deletions getting-started/react-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ export default App;

Replace `<YOUR_SDK_URL>` with the URL provided in the Edgee console, in the project overview section.

## 🔥 Using the React Hook (`useEdgeeDataCollection`)

The `useEdgeeDataCollection` hook simplifies event tracking by providing direct access to the Edgee [Data Collection SDK methods](https://www.edgee.cloud/docs/services/data-collection/overview).

```js
import { useEdgeeDataCollection } from 'react-edgee';

const MyComponent = () => {
const { track, user, page, consent } = useEdgeeDataCollection();

return (
<>
<button onClick={() => track({ name: 'button_click' })}>Click Me</button>
<button onClick={() => user({ user_id: '12345', edgee_id: 'edgee-abc' })}>Identify User</button>
<button onClick={() => page({ name: 'HomePage', url: 'https://example.com' })}>Track Page</button>
<button onClick={() => consent('granted')}>Accept Consent</button>
</>
);
};
```

## Next Steps

For more details about the Edgee SDK, visit the [React-Edgee repository](https://github.com/edgee-cloud/react-edgee).
Expand Down
Loading

0 comments on commit 3225536

Please sign in to comment.