86 lines
6.3 KiB
TypeScript
86 lines
6.3 KiB
TypeScript
/** The npm package's own shipped types (node_modules/gameanalytics/dist/GameAnalytics.d.ts) don't
|
|
* compile under strict mode: `module gameanalytics { ... }` (repeated for every nested namespace)
|
|
* should be `namespace gameanalytics { ... }` (TS1540), and its export modifiers are inconsistent
|
|
* across the merged `gameanalytics` declaration, which TS rejects outright (TS2395) — so the
|
|
* declared `GameAnalytics` member becomes unreachable even in the shipped file's own eyes
|
|
* (TS2339). This file replaces those types entirely (an ambient `declare module "gameanalytics"`
|
|
* shadows the package's own types for any import of that specifier).
|
|
*
|
|
* It also fixes a real shape mismatch, not just a syntax one: dist/GameAnalytics.esm.js — the
|
|
* build "gameanalytics"'s package.json "exports" actually resolves to for `import` — runs
|
|
* `gameanalytics.GameAnalytics.init()` at load and rebinds its own top-level `GameAnalytics` to
|
|
* `gaCommand` before exporting, i.e. `export default GameAnalytics` ends up exporting that
|
|
* *command-queue function*, not the class. The class with real, individually-typed methods only
|
|
* exists on the separate named export `gameanalytics.GameAnalytics`. Concretely:
|
|
*
|
|
* import GameAnalytics from 'gameanalytics'; // (command: string, ...args) => void
|
|
* GameAnalytics('initialize', gameKey, gameSecret);
|
|
*
|
|
* import { gameanalytics } from 'gameanalytics'; // the real class, real methods
|
|
* gameanalytics.GameAnalytics.initialize(gameKey, gameSecret);
|
|
*/
|
|
declare module 'gameanalytics' {
|
|
export enum EGAErrorSeverity { Undefined = 0, Debug = 1, Info = 2, Warning = 3, Error = 4, Critical = 5 }
|
|
export enum EGAProgressionStatus { Undefined = 0, Start = 1, Complete = 2, Fail = 3 }
|
|
export enum EGAResourceFlowType { Undefined = 0, Source = 1, Sink = 2 }
|
|
export enum EGAAdAction { Undefined = 0, Clicked = 1, Show = 2, FailedShow = 3, RewardReceived = 4 }
|
|
export enum EGAAdError { Undefined = 0, Unknown = 1, Offline = 2, NoFill = 3, InternalError = 4, InvalidRequest = 5, UnableToPrecache = 6 }
|
|
export enum EGAAdType { Undefined = 0, Video = 1, RewardedVideo = 2, Playable = 3, Interstitial = 4, OfferWall = 5, Banner = 6 }
|
|
|
|
export namespace gameanalytics {
|
|
export class GameAnalytics {
|
|
static init(): void;
|
|
static configureAvailableCustomDimensions01(customDimensions?: string[]): void;
|
|
static configureAvailableCustomDimensions02(customDimensions?: string[]): void;
|
|
static configureAvailableCustomDimensions03(customDimensions?: string[]): void;
|
|
static configureAvailableResourceCurrencies(resourceCurrencies?: string[]): void;
|
|
static configureAvailableResourceItemTypes(resourceItemTypes?: string[]): void;
|
|
static configureBuild(build?: string): void;
|
|
static configureSdkGameEngineVersion(sdkGameEngineVersion?: string): void;
|
|
static configureGameEngineVersion(gameEngineVersion?: string): void;
|
|
static configureUserId(uId?: string): void;
|
|
static setExtUserId(uId?: string): void;
|
|
static getExtUserId(): string;
|
|
static getUserId(): string;
|
|
static initialize(gameKey?: string, gameSecret?: string): void;
|
|
static addBusinessEvent(currency?: string, amount?: number, itemType?: string, itemId?: string, cartType?: string, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addResourceEvent(flowType?: EGAResourceFlowType, currency?: string, amount?: number, itemType?: string, itemId?: string, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addProgressionEvent(progressionStatus?: EGAProgressionStatus, progression01?: string, progression02?: string, progression03?: string, score?: number, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addDesignEvent(eventId: string, value?: number, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addErrorEvent(severity?: EGAErrorSeverity, message?: string, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addAdEventWithNoAdReason(adAction?: EGAAdAction, adType?: EGAAdType, adSdkName?: string, adPlacement?: string, noAdReason?: EGAAdError, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addAdEventWithDuration(adAction?: EGAAdAction, adType?: EGAAdType, adSdkName?: string, adPlacement?: string, duration?: number, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static addAdEvent(adAction?: EGAAdAction, adType?: EGAAdType, adSdkName?: string, adPlacement?: string, customFields?: Record<string, unknown>, mergeFields?: boolean): void;
|
|
static setEnabledInfoLog(flag?: boolean): void;
|
|
static setEnabledVerboseLog(flag?: boolean): void;
|
|
static setEnabledManualSessionHandling(flag?: boolean): void;
|
|
static setEnabledEventSubmission(flag?: boolean): void;
|
|
static enableHealthEvent(flag?: boolean): void;
|
|
static setCustomDimension01(dimension?: string): void;
|
|
static setCustomDimension02(dimension?: string): void;
|
|
static setCustomDimension03(dimension?: string): void;
|
|
static setGlobalCustomEventFields(customFields?: Record<string, unknown>): void;
|
|
static setEventProcessInterval(intervalInSeconds: number): void;
|
|
static startSession(): void;
|
|
static endSession(): void;
|
|
static onStop(): void;
|
|
static onResume(): void;
|
|
static getRemoteConfigsValueAsString(key: string, defaultValue?: string): string;
|
|
static getRemoteConfigsValueAsJSON(key: string, defaultValue?: unknown): unknown;
|
|
static isRemoteConfigsReady(): boolean;
|
|
static addRemoteConfigsListener(listener: { onRemoteConfigsUpdated: () => void }): void;
|
|
static removeRemoteConfigsListener(listener: { onRemoteConfigsUpdated: () => void }): void;
|
|
static getRemoteConfigsContentAsString(): string;
|
|
static getABTestingId(): string;
|
|
static getABTestingVariantId(): string;
|
|
static addOnBeforeUnloadListener(listener: { onBeforeUnload: () => void }): void;
|
|
static removeOnBeforeUnloadListener(listener: { onBeforeUnload: () => void }): void;
|
|
}
|
|
}
|
|
|
|
/** The default export — see the file header: this is the command-queue dispatcher, not the
|
|
* `GameAnalytics` class. Call as `GameAnalyticsCommand('methodName', ...args)`. */
|
|
const GameAnalyticsCommand: (command: string, ...args: unknown[]) => void;
|
|
export default GameAnalyticsCommand;
|
|
}
|