mwg API
    Preparing search index...

    Class TelemetryClient

    An injectable transport for automatic, structured analytics events - FeedbackClient's own shape, for a different question. FeedbackClient is a player choosing to write something and send it; this is a game deciding on its own to send something, which needs its own consent gate before anything ever leaves the machine, unlike a player action that already consents to sending just by happening. send is a silent no-op, not an error, until setConsent(true) has been called - automatic collection defaults off.

    mwg stays opinion-free on what an event actually contains, what "consent" means for a given game (a settings toggle, a first-launch prompt, a platform-level flag), and where the endpoint lives - the same boundary FeedbackClient's own doc comment draws for manual reports.

    import { TelemetryClient } from '@datamoc/mw_games/core';

    const telemetry = new TelemetryClient({ endpoint: 'https://example.com/api/telemetry' });

    // nothing sends until a game's own consent flow grants it
    telemetry.setConsent(true);
    await telemetry.send({ name: 'level_started', properties: { level: 3 } });

    Hierarchy

    • HttpTransport
      • TelemetryClient
    Index
    endpoint: string
    fetchFn: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    timeoutMs: number
    • get hasConsent(): boolean

      whether send will actually transmit anything right now

      Returns boolean

    • a game calls this from its own consent flow; not read from anywhere mwg controls

      Parameters

      • granted: boolean

      Returns void

    • Type Parameters

      • T

      Parameters

      • run: (signal: AbortSignal) => Promise<T>

      Returns Promise<T>