Skip to content

[integrations-posthog] Make PostHogClient resolvable through Croco DI with explicit configuration #1705

Description

@kang-heewon

Priority: P1

Problem

PostHogClient is marked as a Croco component but its constructor requires an erased TypeScript interface and no configuration token or factory is exported. Normal Container resolution cannot provide its required configuration.

Evidence

packages/integrations-posthog/src/libs/PostHogClient.ts:10-17 declares @Component() with constructor(config: PostHogConfig); the package index and README expose direct construction but no DI configuration token or factory.

Desired outcome

The public component integration surface works through Croco DI with a validated configuration contract.

Implementation path

  1. Export a configuration token and provider/factory.
  2. Validate and register configuration before resolving the client.
  3. Inject the runtime value through the token.
  4. Add container resolution and missing-configuration tests.

Acceptance criteria

  • Container.get(PostHogClient) resolves after documented setup.
  • Missing or invalid configuration yields a stable diagnostic.
  • Direct construction remains intentional or is explicitly deprecated.

Validation

  • pnpm --filter @croco/integrations-posthog test
  • pnpm --filter @croco/integrations-posthog typecheck

Scope boundaries

Does not add new PostHog event features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1 issueadapterExternal framework, runtime, and provider adaptersruntimeRuntime behavior, lifecycle, and environment capability work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions