Merge Clerk User Profile with Posthog Feature Flags
Parallel PostHog fetch merged before Frontend / Web hydrates
Instead of Frontend / Web firing serial fetches to PostHog and Clerk, one pipeline hits https://us.posthog.com/api/projects/{{query.projectId}}/feature_flags (and sibling steps) in parallel and returns mapped JSON.
Waterfall latency from multiple PostHog and Clerk requests
Frontend / Web widgets often await PostHog and Clerk sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.
- Race conditions between parallel manual fetches
- Higher mobile data usage from redundant JSON
- Timeouts when any upstream exceeds cellular RTT
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Store POSTHOG_PERSONAL_API_KEY, CLERK_SECRET_KEY in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token.
Target the real upstream URL
Use GET against https://us.posthog.com/api/projects/{{query.projectId}}/feature_flags. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache).
Call from Frontend / Web
Call https://realcomposer.com/v1/workspace/merge-clerk-and-posthog-feature-flags with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.
const res = await fetch('https://realcomposer.com/v1/workspace/merge-clerk-and-posthog-feature-flags', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_merge-cl",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "merge-clerk-and-posthog-feature-flags"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"posthog_flagKey": "sample",
"posthog_active": "sample",
"clerk_userId": "sample",
"clerk_email": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 2
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 4
- Payload
- 256 B to 101 B (-61%)
curl -X GET "https://realcomposer.com/v1/workspace/merge-clerk-and-posthog-feature-flags" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
Is it safe to log PostHog responses in Frontend / Web?
Use scoped tokens where the vendor allows them on merge-clerk-and-posthog-feature-flags. Admin keys stay {{secrets.*}} references only.
When does edge caching apply to this recipe?
merge-clerk-and-posthog-feature-flags POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.
What happens if an upstream step times out?
Upstream steps in merge-clerk-and-posthog-feature-flags honor timeoutMs and optional fallback JSON without leaking secrets.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + PostHog, Clerk Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.