Gamanza Engage Web Client SDK
Overview
The Gamanza Engage Web Client SDK empowers developers to build rich, customizable user interfaces that integrate seamlessly with the Gamanza Engage Platform. Designed for flexibility and performance, this SDK provides a structured, modular interface for interacting with key engagement features such as player profiles, missions, tournaments, rewards, and more.
By leveraging this SDK, you can:
- Access real-time data and events for the authenticated player.
- Listen for live updates from the Gamanza Player Engagement Platform.
- Build custom loyalty and gamification components tailored to your product’s needs.
- Maintain a clean and consistent integration using a singleton-based architecture.
Whether you're building from scratch or enhancing an existing frontend, the SDK simplifies communication with the Gamanza Engage Frontend API, helping you deliver engaging experiences with ease and efficiency.
Quickstart
Before you begin
Install the SDK
npm install --save @gamanza-engage/web-client-sdk
Using the SDK
import { GamanzaEngageWebClientSDK } from "@gamanza-engage/web-client-sdk";
export const initSDK = async () => {
await GamanzaEngageWebClientSDK.init({
clientId: 'your client id',
identityToken: 'player identity token',
serviceUrl: '[https://fontend-api-[your-instance].gamanzaengage.com]'
});
const { Player } = GamanzaEngageWebClientSDK.getInstance();
const playerInfo = await Player.getPlayer();
console.log(playerInfo);
}
Static Methods
init(config: AuthConfig): Promise<GamanzaEngageWebClientSDK>
Initializes the SDK with the provided authentication configuration. This method must be called before using any SDK functionality.
Parameters:
config
(AuthConfig
): Authentication configuration object containing:clientId
(string): Client ID generated in your Gamanza Engage Admin InstanceidentityToken
(string): The identity token for authenticationserviceUrl
(string): The base URL for the Gamanza Engage service
Returns:
Promise<GamanzaEngageWebClientSDK>
: A promise that resolves to the initialized SDK instance
Example:
const config = {
clientId: 'your-client-id',
identityToken: 'your-identity-token',
serviceUrl: '[https://fontend-api-[your-instance].gamanzaengage.com]'
};
const sdk = await GamanzaEngageWebClientSDK.init(config);
getInstance(): GamanzaEngageWebClientSDK
Returns the singleton instance of the SDK. The SDK must be initialized using init()
before calling this method.
Returns:
GamanzaEngageWebClientSDK
: The singleton SDK instance
Throws:
SDKNotInitializedException
: When called before SDK initialization or after session closure
Example:
const sdk = GamanzaEngageWebClientSDK.getInstance();
or
const { Player } = GamanzaEngageWebClientSDK.getInstance();
Instance Methods
closeSession(): Promise<void>
[MANDATORY] Destroys the SDK instance and cleans up all resources. This method:
- Clears the current user session
- Deletes all data required for API communication
- Closes all active connections
- Destroys the SDK instance (requiring re-initialization)
Returns:
Promise<void>
: A promise that resolves when the session is closed
Example:
await sdk.closeSession();
Public Modules
The SDK provides access to the following modules through public properties:
Events: RtmEventsModule
Real-time messaging and event handling functionality. Documentation
Player: PlayerModule
Player data management, including profile information and virtual currency. Documentation
RewardShop: RewardShopModule
Reward shop functionality for browsing and purchasing rewards. Documentation
Missions: MissionsModule
Mission management and tracking functionality. Documentation
Tournaments: TournamentsModule
Tournament participation and management features. Documentation
RewardsProcessor: RewardsProcessorModule
Reward processing and redemption functionality. Documentation
Crm: CrmModule
Customer relationship management features. Documentation
FeatureFlags: FeatureFlagsModule
Feature flag management for dynamic feature control. Documentation
Catalog: CatalogModule
Game catalog browsing and management functionality. Documentation
Usage Example
import { GamanzaEngageWebClientSDK } from '@gamanza-engage/web-client-sdk';
// Initialize the SDK const config = { identityToken: 'your-identity-token', serviceUrl: '[https://api.gamanzaengage.com](https://api.gamanzaengage.com)' };
try {
const sdk = await GamanzaEngageWebClientSDK.init(config);
}catch (e: SDKNotInitializedException) {}
// Use SDK modules const playerData = await sdk.Player.getPlayerData(); const missions = await sdk.Missions.getActiveMissions();
// Always close the session when done await sdk.closeSession(); } catch (error) { console.error('SDK initialization failed:', error); }
Error Handling
The SDK throws the following exceptions:
SDKNotInitializedException
Thrown when attempting to get the SDK instance before initialization or after session closure.
Global Configuration
The SDK supports the following global configuration options:
window.GMZ_ENG_DEBUG
Set to true
to enable debug logging throughout the SDK.
window.GMZ_ENG_DEBUG = true;
Important Notes
-
Singleton Pattern: The SDK uses a singleton pattern. Only one instance can exist at a time.
-
Initialization Required: Always call
init()
before using any SDK functionality. -
Session Management: Always call
closeSession()
when finished to properly clean up resources and avoid issues with the player session data. -
Error Handling: Implement proper error handling for all async operations.
Type Definitions
The SDK exports comprehensive type definitions for all interfaces and data structures. Import them alongside the main SDK class:
import {
GamanzaEngageWebClientSDK,
SimpleResponse,
PaginationResponse,
// ... other types
} from '@gamanza-engage/web-client-sdk'
📢 This SDK is proprietary. Use is governed by the Gamanza Engage SDK License Agreement. Redistribution or modification is strictly prohibited.