Skip to content

Commit 1209cd7

Browse files
committed
fix(posthog): correctly classify SSO auth_method, fix phantom empty-string workspace groups
1 parent 419b1f5 commit 1209cd7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

apps/sim/app/api/workflows/[id]/duplicate/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
6969
new_workflow_id: result.id,
7070
workspace_id: workspaceId ?? '',
7171
},
72-
{ groups: { workspace: workspaceId ?? '' } }
72+
workspaceId ? { groups: { workspace: workspaceId } } : undefined
7373
)
7474

7575
const elapsed = Date.now() - startTime

apps/sim/app/api/workflows/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export async function POST(req: NextRequest) {
280280
'workflow_created',
281281
{ workflow_id: workflowId, workspace_id: workspaceId ?? '', name },
282282
{
283-
groups: { workspace: workspaceId ?? '' },
283+
groups: workspaceId ? { workspace: workspaceId } : undefined,
284284
setOnce: { first_workflow_created_at: new Date().toISOString() },
285285
}
286286
)

apps/sim/lib/auth/auth.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,19 @@ export const auth = betterAuth({
377377
.where(eq(schema.account.userId, account.userId))
378378

379379
if (accountCount === 1) {
380-
const isOAuth = account.providerId !== 'credential'
380+
const { providerId } = account
381+
const authMethod =
382+
providerId === 'credential'
383+
? 'email'
384+
: SSO_TRUSTED_PROVIDERS.includes(providerId)
385+
? 'sso'
386+
: 'oauth'
381387
captureServerEvent(
382388
account.userId,
383389
'user_created',
384390
{
385-
auth_method: isOAuth ? 'oauth' : 'email',
386-
...(isOAuth ? { provider: account.providerId } : {}),
391+
auth_method: authMethod,
392+
...(providerId !== 'credential' ? { provider: providerId } : {}),
387393
},
388394
{ setOnce: { signup_at: new Date().toISOString() } }
389395
)

0 commit comments

Comments
 (0)