Skip to main content
Account context is designed for B2B applications where you need to know which customer organization is affected by an error, not just which individual user.

Why Account Context Matters for B2B

In B2B applications, impact analysis is about customers, not just users:
  • “Acme Corp is experiencing checkout failures” is more urgent than “3 users saw errors”
  • Enterprise customers need different SLAs than free tier users
  • Account-level patterns reveal integration issues specific to certain customers

Setting Account Context

import Proliferate from '@proliferate/sdk';

// After determining the user's organization/workspace
Proliferate.setAccount({
  id: 'acct_456',
  name: 'Acme Corporation',  // Optional but helpful
});

// All subsequent errors include this account context

Account Context Schema

interface AccountContext {
  id: string;     // Required: Unique account identifier
  name?: string;  // Optional: Human-readable account name
}
id
string
required
A unique identifier for the account/organization. This should be your internal account ID, workspace ID, tenant ID, or organization ID. Good choices:
  • "acct_456"
  • "org_abc123"
  • "workspace_xyz"
name
string
A human-readable name for the account. Makes the dashboard more readable:
  • "Acme Corporation"
  • "Startup Inc"
  • "Enterprise Customer #1"

When to Set Account Context

Multi-Tenant SaaS

// After user selects workspace
async function selectWorkspace(workspaceId) {
  const workspace = await api.getWorkspace(workspaceId);

  // Set account context
  Proliferate.setAccount({
    id: workspace.id,
    name: workspace.name,
  });

  loadWorkspace(workspace);
}

B2B with Organizations

// After login, when you know the user's org
async function handleLogin(credentials) {
  const { user, organization } = await authService.login(credentials);

  // Set both user and account context
  Proliferate.setUser({ id: user.id, email: user.email });
  Proliferate.setAccount({ id: organization.id, name: organization.name });
}

Multi-Org Users

When users can belong to multiple organizations:
// On org switch
function switchOrganization(orgId) {
  const org = user.organizations.find(o => o.id === orgId);

  // Update account context
  Proliferate.setAccount({ id: org.id, name: org.name });

  reloadDashboard(org);
}

FastAPI Middleware (Python)

from fastapi import Request
import proliferate

@app.middleware("http")
async def add_context(request: Request, call_next):
    # Extract tenant from subdomain, header, or token
    tenant_id = extract_tenant(request)
    tenant = await get_tenant(tenant_id)

    if tenant:
        proliferate.set_account({
            'id': str(tenant.id),
            'name': tenant.name,
        })

    response = await call_next(request)
    return response

Dashboard Features

Affected Accounts View

In the issue list:
Issue: TypeError: Cannot read property 'data' of null
─────────────────────────────────────────────────────
Events: 234    Users: 89    Accounts: 12

Affected Accounts:
├── Acme Corp (acct_456)         - 89 events
├── Startup Inc (acct_789)       - 67 events
├── Enterprise Co (acct_123)     - 45 events
└── ... 9 more

Account-Based Filtering

Filter errors by account:
  • “Show me all errors for Acme Corp”
  • “Compare error rates across accounts”
  • “Which accounts are most affected by this release?”

Impact Prioritization

The dashboard helps you prioritize based on account impact:
High Priority Issues (by account impact):
─────────────────────────────────────────
1. Checkout failure - Affects 5 enterprise accounts
2. API timeout - Affects 12 accounts (mostly small)
3. UI glitch - Affects 100+ free tier accounts

Use Cases

For Slack-style apps with multiple workspaces:
// User can be in multiple workspaces
function loadWorkspace(workspaceId) {
  const workspace = workspaces.find(w => w.id === workspaceId);

  Proliferate.setAccount({
    id: workspace.id,
    name: workspace.name,
  });
}

Best Practices

// Set when workspace is selected
onWorkspaceSelected(workspace => {
  Proliferate.setAccount({ id: workspace.id, name: workspace.name });
});

// Update when switching workspaces
onWorkspaceChanged(newWorkspace => {
  Proliferate.setAccount({ id: newWorkspace.id, name: newWorkspace.name });
});
// Good - consistent format
Proliferate.setAccount({ id: `org_${org.id}` });

// Bad - inconsistent
Proliferate.setAccount({ id: org.id });      // Sometimes number
Proliferate.setAccount({ id: `org_${id}` }); // Sometimes prefixed string
// Good - easy to identify in dashboard
Proliferate.setAccount({
  id: 'acct_xyz',
  name: 'Acme Corporation',
});

// Less useful - just an ID
Proliferate.setAccount({
  id: 'acct_xyz',
});
function switchTenant(newTenantId) {
  if (newTenantId) {
    const tenant = getTenant(newTenantId);
    Proliferate.setAccount({ id: tenant.id, name: tenant.name });
  } else {
    Proliferate.setAccount(null);  // Clear if no tenant
  }
}
Include tier information for prioritization:
Proliferate.setAccount({
  id: account.id,
  name: `${account.name} (${account.tier})`,  // "Acme Corp (Enterprise)"
});

// Or set as a tag
Proliferate.setAccount({ id: account.id, name: account.name });
Proliferate.setTag('account_tier', account.tier);

Combining with User Context

For full context, set both:
// After login and workspace selection
Proliferate.setUser({
  id: user.id,
  email: user.email,
});

Proliferate.setAccount({
  id: workspace.id,
  name: workspace.name,
});

// Error detail shows:
// User: [email protected] (user_123)
// Account: Acme Corporation (acct_456)
See User Context for more details.