RealComposer
Frontend / WebPostHogClerkMulti-API Aggregation

Merge Clerk User Profile with Posthog Feature Flags

Parallel PostHog fetch merged before Frontend / Web hydrates

Direct Answer & Architecture Summary

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.

Security LevelAES-256-GCM Vault
Edge LatencySub-10ms Response
InfrastructureZero Server Maintenance
The Problem Solved

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.

Critical Security & Operational Risks:
  • Race conditions between parallel manual fetches
  • Higher mobile data usage from redundant JSON
  • Timeouts when any upstream exceeds cellular RTT
Architecture & Step-by-Step Implementation

How RealComposer Solves This at the Edge

1

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.

2

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).

3

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' }
});
                  
Payload Slimming Comparison
61% Bandwidth Reduction
Raw Upstream Response256 B
              {
  "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"
    }
  }
}
            
RealComposer Slimmed Edge Payload101 B
              {
  "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%)
Call from Terminal or Client
curl -X GET "https://realcomposer.com/v1/workspace/merge-clerk-and-posthog-feature-flags" \
  -H "Authorization: Bearer rc_live_client_token"
Frequently Asked Questions

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

Instant Deployment

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.

CLONE THIS RECIPE
Related Architecture Recipes