fix: allow cross subdomain cookies at posthog

This commit is contained in:
Sabiha Khan 2026-04-17 11:31:10 +05:30
parent 1d0a7cd2d8
commit c930af181c
6 changed files with 39 additions and 7 deletions

View file

@ -315,11 +315,15 @@ class OrganizationUsageClient(BaseDBClient):
total_tokens += dograh_tokens
total_duration_seconds += int(round(call_duration))
# Extract phone number from initial_context
# Outbound calls store it as "phone_number"; inbound calls store it as "caller_number"
phone_number = None
if run.initial_context:
phone_number = run.initial_context.get("phone_number") or run.initial_context.get("caller_number")
# Extract phone number from initial_context based on call_type.
# Inbound runs only have caller_number/called_number; the
# caller_number is the customer. Outbound runs use the
# phone_number key written by the dispatchers.
ic = run.initial_context or {}
if run.call_type == "inbound":
phone_number = ic.get("caller_number")
else:
phone_number = ic.get("phone_number")
# Extract disposition from gathered_context
disposition = None
@ -337,6 +341,7 @@ class OrganizationUsageClient(BaseDBClient):
"recording_url": run.recording_url,
"transcript_url": run.transcript_url,
"phone_number": phone_number,
"call_type": run.call_type,
"disposition": disposition,
"initial_context": run.initial_context,
"gathered_context": run.gathered_context,

View file

@ -48,6 +48,7 @@ class WorkflowRunUsageResponse(BaseModel):
recording_url: Optional[str] = None
transcript_url: Optional[str] = None
phone_number: Optional[str] = None
call_type: Optional[str] = None
disposition: Optional[str] = None
initial_context: Optional[Dict[str, Any]] = None
gathered_context: Optional[Dict[str, Any]] = None

4
ui/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "ui",
"version": "1.21.0",
"version": "1.24.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ui",
"version": "1.21.0",
"version": "1.24.0",
"dependencies": {
"@dagrejs/dagre": "^1.1.4",
"@nangohq/frontend": "^0.69.47",

View file

@ -457,6 +457,7 @@ export default function UsagePage() {
<TableRow className="bg-muted/50">
<TableHead className="font-semibold">Run ID</TableHead>
<TableHead className="font-semibold">Agent Name</TableHead>
<TableHead className="font-semibold">Call Type</TableHead>
<TableHead className="font-semibold">Phone Number</TableHead>
<TableHead className="font-semibold">Disposition</TableHead>
<TableHead className="font-semibold">Date</TableHead>
@ -479,6 +480,15 @@ export default function UsagePage() {
#{run.id}
</TableCell>
<TableCell>{run.workflow_name || 'Unknown'}</TableCell>
<TableCell>
{run.call_type ? (
<Badge variant={run.call_type === 'inbound' ? "secondary" : "default"}>
{run.call_type === 'inbound' ? 'Inbound' : 'Outbound'}
</Badge>
) : (
<span className="text-sm text-muted-foreground">-</span>
)}
</TableCell>
<TableCell className="text-sm">
{run.phone_number || '-'}
</TableCell>

View file

@ -3344,6 +3344,16 @@ export type ValidationError = {
* Error Type
*/
type: string;
/**
* Input
*/
input?: unknown;
/**
* Context
*/
ctx?: {
[key: string]: unknown;
};
};
/**
@ -3818,6 +3828,10 @@ export type WorkflowRunUsageResponse = {
* Phone Number
*/
phone_number?: string | null;
/**
* Call Type
*/
call_type?: string | null;
/**
* Disposition
*/

View file

@ -53,6 +53,7 @@ const initPostHog = () => {
capture_pageview: 'history_change',
capture_pageleave: true,
capture_exceptions: true,
cross_subdomain_cookie: true,
debug: process.env.NEXT_PUBLIC_NODE_ENV === 'development',
});
console.log('PostHog initialized from NEXT_PUBLIC config');
@ -68,6 +69,7 @@ const initPostHog = () => {
capture_pageview: 'history_change',
capture_pageleave: true,
capture_exceptions: true,
cross_subdomain_cookie: true,
debug: process.env.NEXT_PUBLIC_NODE_ENV === 'development',
});
console.log('PostHog initialized from API config');