@telazer/zilana_client_sdk
Advanced tools
Comparing version
{ | ||
"name": "@telazer/zilana_client_sdk", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
123
README.md
@@ -15,123 +15,4 @@ # Zilana SDK | ||
## Configuration | ||
## Documentation | ||
The SDK requires configuration details such as `userId`, `gameId`, and a mapping of event names to `eventId`s. | ||
--- | ||
## Initialization | ||
### Method: `initialize` | ||
Initializes the SDK, setting up sessions and enabling event tracking. | ||
**Parameters**: | ||
- `config`: An object containing: | ||
- `userId`: The unique identifier for the user. | ||
- `gameId`: The unique identifier for the game. | ||
- `eventMap`: A key-value pair mapping event names to their corresponding IDs. | ||
- `debug` (optional): Enables debug logging if set to `true`. | ||
**Example**: | ||
```typescript | ||
import { Zilana } from './zilana-sdk'; | ||
const config = { | ||
userId: '<UUID>', | ||
gameId: '<UUID>', | ||
}; | ||
const eventMap = { | ||
USER_LOGGED_IN: '<UUID>', | ||
LEVEL_COMPLETED: '<UUID>', | ||
ITEM_PURCHASED: '<UUID>', | ||
}; | ||
// Initialize the SDK | ||
Zilana.initialize({ config, eventMap, debug: true }); | ||
``` | ||
--- | ||
## Public Methods | ||
### 1. `recordEvent` | ||
Records an event for the current active session. | ||
**Parameters**: | ||
- `eventName`: The name of the event to be recorded. Must exist in the `eventMap` provided during initialization. | ||
**Example**: | ||
```typescript | ||
Zilana.recordEvent('LEVEL_COMPLETED'); | ||
``` | ||
--- | ||
## Features | ||
1. **Automatic | ||
Session Management**: Sessions are automatically created when the SDK initializes. | ||
2. **Event Tracking**: Record custom events and associate them with active sessions. | ||
3. **Health Checks**: Regular integrity checks for session and player data. | ||
4. **Debug Logging**: Detailed logs for debugging when `debug` is enabled. | ||
--- | ||
## Local Storage | ||
The SDK uses the browser's `localStorage` to persist session data under the key `com.telazer.zilana-data`. | ||
--- | ||
## Debugging | ||
Enable debug mode during initialization: | ||
```typescript | ||
Zilana.initialize({ config, eventMap, debug: true }); | ||
``` | ||
This will log all informational and warning messages to the console. | ||
--- | ||
## Example Usage | ||
```typescript | ||
import { Zilana } from './zilana-sdk'; | ||
const config = { | ||
userId: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
gameId: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
}; | ||
const eventMap = { | ||
USER_LOGGED_IN: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
LEVEL_COMPLETED: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
ITEM_PURCHASED: '3fa85f64-5717-4562-b3fc-2c963f66afa6', | ||
}; | ||
// Initialize the SDK | ||
Zilana.initialize({ config, eventMap, debug: true }); | ||
// Record a user login event | ||
Zilana.recordEvent('USER_LOGGED_IN'); | ||
// Record a level completion event | ||
Zilana.recordEvent('LEVEL_COMPLETED'); | ||
``` | ||
--- | ||
## Support | ||
For assistance or to report issues, contact the development team at | ||
**dev@telazer.com**. | ||
### [Official Zilana SDK Documentation](https://zilana.io/docs/sdk/javascript) |
74155
-3.23%18
-86.86%