update nextjs docs
This commit is contained in:
@@ -189,9 +189,9 @@ clear();
|
|||||||
If you want to track server-side events, you should create an instance of our Javascript SDK. It's exported from `@openpanel/nextjs`
|
If you want to track server-side events, you should create an instance of our Javascript SDK. It's exported from `@openpanel/nextjs`
|
||||||
|
|
||||||
<Callout>
|
<Callout>
|
||||||
When using server events it's important to create a new client (with a secret). Since it's backend we cannot authorize the request with cors headers.
|
When using server events it's important that you use a secret to authenticate the request. This is to prevent unauthorized requests since we cannot use cors headers.
|
||||||
|
|
||||||
`Openpanel Dashboard -> Setting -> Clients -> Create client`
|
You can use the same clientId but you should pass the associated client secret to the SDK.
|
||||||
|
|
||||||
</Callout>
|
</Callout>
|
||||||
|
|
||||||
@@ -214,6 +214,7 @@ opServer.event('my_server_event', { profileId: '123', ok: '✅' });
|
|||||||
With `createNextRouteHandler` you can proxy your events through your server, this will ensure all events are tracked since there is a lot of adblockers that block requests to third party domains.
|
With `createNextRouteHandler` you can proxy your events through your server, this will ensure all events are tracked since there is a lot of adblockers that block requests to third party domains.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
// file: /app/api/op/[...op]/route.ts
|
||||||
import { createNextRouteHandler } from '@openpanel/nextjs';
|
import { createNextRouteHandler } from '@openpanel/nextjs';
|
||||||
|
|
||||||
export const { POST } = createNextRouteHandler({
|
export const { POST } = createNextRouteHandler({
|
||||||
@@ -221,3 +222,13 @@ export const { POST } = createNextRouteHandler({
|
|||||||
clientSecret: '{YOUR_CLIENT_SECRET}',
|
clientSecret: '{YOUR_CLIENT_SECRET}',
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Remember to change the `url` in the `OpenpanelProvider` to your own server.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
<OpenpanelProvider
|
||||||
|
url="/api/op" // <---
|
||||||
|
clientId="your-client-id"
|
||||||
|
trackScreenViews={true}
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user