fix onboarding
This commit is contained in:
@@ -3,7 +3,7 @@ import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc';
|
||||
import { db } from '@/server/db';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword } from '@openpanel/common';
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
|
||||
export const clientRouter = createTRPCRouter({
|
||||
list: protectedProcedure
|
||||
@@ -71,7 +71,7 @@ export const clientRouter = createTRPCRouter({
|
||||
project_id: input.projectId,
|
||||
name: input.name,
|
||||
secret: input.cors ? null : await hashPassword(secret),
|
||||
cors: input.cors || undefined,
|
||||
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createTRPCRouter, protectedProcedure } from '@/server/api/trpc';
|
||||
import { clerkClient } from '@clerk/nextjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword } from '@openpanel/common';
|
||||
import { hashPassword, stripTrailingSlash } from '@openpanel/common';
|
||||
import { db } from '@openpanel/db';
|
||||
|
||||
export const onboardingRouter = createTRPCRouter({
|
||||
@@ -35,7 +35,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
name: `${project.name} Client`,
|
||||
organization_slug: org.slug,
|
||||
project_id: project.id,
|
||||
cors: input.cors ?? '*',
|
||||
cors: input.cors ? stripTrailingSlash(input.cors) : '*',
|
||||
secret: input.cors ? null : await hashPassword(secret),
|
||||
},
|
||||
});
|
||||
@@ -43,7 +43,7 @@ export const onboardingRouter = createTRPCRouter({
|
||||
return {
|
||||
client: {
|
||||
...client,
|
||||
secret,
|
||||
secret: input.cors ? null : secret,
|
||||
},
|
||||
project,
|
||||
organization: org,
|
||||
|
||||
@@ -60,7 +60,6 @@ import {
|
||||
setProfile,
|
||||
setProfileId,
|
||||
trackEvent,
|
||||
trackScreenView,
|
||||
} from '@openpanel/nextjs';
|
||||
|
||||
// Sends an event with payload foo: bar
|
||||
@@ -189,6 +188,13 @@ clear();
|
||||
|
||||
If you want to track server-side events, you should create an instance of our Javascript SDK. It's exported from `@openpanel/nextjs`
|
||||
|
||||
<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.
|
||||
|
||||
`Openpanel Dashboard -> Setting -> Clients -> Create client`
|
||||
|
||||
</Callout>
|
||||
|
||||
```typescript
|
||||
import { OpenpanelSdk } from '@openpanel/nextjs';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user