@hyve-sdk/js 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -165,9 +165,7 @@ await client.sendTelemetry(
165
165
  'attack', // Event sub-action (optional)
166
166
  { // Event details - auto-stringified (optional)
167
167
  button: 'attack-btn',
168
- screenPosition: { x: 100, y: 200 }
169
- },
170
- { // Custom data - auto-stringified (optional)
168
+ screenPosition: { x: 100, y: 200 },
171
169
  damage: 100,
172
170
  targetId: 'enemy-123',
173
171
  weaponType: 'sword',
@@ -190,7 +188,8 @@ await client.sendTelemetry(
190
188
 
191
189
  **Features:**
192
190
  - Automatically includes `session_id` and `game_id` from client
193
- - Objects in `event_details` and `custom_data` are auto-stringified to JSON
191
+ - Objects in `event_details` are auto-stringified to JSON
192
+ - Validates `event_details` is valid JSON before sending (returns false if invalid)
194
193
  - All events tied to authenticated user identity
195
194
 
196
195
  ## API Integration
@@ -772,7 +771,7 @@ uiLogger.debug('Button clicked');
772
771
  - `getInventoryItem(itemId)` - Get specific inventory item
773
772
 
774
773
  ### Telemetry
775
- - `sendTelemetry(location, category, action, subCategory?, subAction?, details?, customData?, platformId?)` - Send JWT-authenticated analytics event (uses game ID from URL)
774
+ - `sendTelemetry(location, category, action, subCategory?, subAction?, details?, platformId?)` - Send JWT-authenticated analytics event (uses game ID from URL)
776
775
  - `updateTelemetryConfig(config)` - Update telemetry settings
777
776
 
778
777
  ### Ads
@@ -841,6 +840,14 @@ bun run build
841
840
 
842
841
  For complete documentation and examples, visit [https://docs.hyve.gg](https://docs.hyve.gg)
843
842
 
843
+ ### Additional Guides
844
+
845
+ - [Telemetry Guide](./docs/TELEMETRY.md) - Best practices, validation rules, and examples for event tracking
846
+ - [Billing Integration](./docs/BILLING_INTEGRATION.md) - Platform-aware billing with Stripe and In-App Purchases
847
+ - [Billing Migration Guide](./docs/BILLING_MIGRATION_GUIDE.md) - Upgrading from older billing implementations
848
+ - [Ads Integration](./docs/ads.md) - Google H5 Games Ads integration
849
+ - [Native Bridge](./docs/NATIVE_BRIDGE.md) - React Native WebView communication
850
+
844
851
  ## License
845
852
 
846
853
  MIT
package/dist/index.d.mts CHANGED
@@ -33,8 +33,6 @@ interface TelemetryEvent {
33
33
  event_details?: Record<string, any> | string | null;
34
34
  /** Mapping details as JSON string or object (optional) */
35
35
  mapping_details?: Record<string, any> | string | null;
36
- /** Custom data as JSON string or object (optional) */
37
- custom_data?: Record<string, any> | string | null;
38
36
  }
39
37
  /**
40
38
  * Additional telemetry data that can be passed with events
@@ -425,11 +423,10 @@ declare class HyveClient {
425
423
  * @param eventSubCategory Optional sub-category
426
424
  * @param eventSubAction Optional sub-action
427
425
  * @param eventDetails Optional event details (object or JSON string)
428
- * @param customData Optional custom data (object or JSON string)
429
426
  * @param platformId Optional platform identifier
430
427
  * @returns Promise resolving to boolean indicating success
431
428
  */
432
- sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, customData?: Record<string, any> | null, platformId?: string | null): Promise<boolean>;
429
+ sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
433
430
  /**
434
431
  * Makes an authenticated API call using the JWT token
435
432
  * @param endpoint API endpoint path (will be appended to base URL)
package/dist/index.d.ts CHANGED
@@ -33,8 +33,6 @@ interface TelemetryEvent {
33
33
  event_details?: Record<string, any> | string | null;
34
34
  /** Mapping details as JSON string or object (optional) */
35
35
  mapping_details?: Record<string, any> | string | null;
36
- /** Custom data as JSON string or object (optional) */
37
- custom_data?: Record<string, any> | string | null;
38
36
  }
39
37
  /**
40
38
  * Additional telemetry data that can be passed with events
@@ -425,11 +423,10 @@ declare class HyveClient {
425
423
  * @param eventSubCategory Optional sub-category
426
424
  * @param eventSubAction Optional sub-action
427
425
  * @param eventDetails Optional event details (object or JSON string)
428
- * @param customData Optional custom data (object or JSON string)
429
426
  * @param platformId Optional platform identifier
430
427
  * @returns Promise resolving to boolean indicating success
431
428
  */
432
- sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, customData?: Record<string, any> | null, platformId?: string | null): Promise<boolean>;
429
+ sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
433
430
  /**
434
431
  * Makes an authenticated API call using the JWT token
435
432
  * @param endpoint API endpoint path (will be appended to base URL)
package/dist/index.js CHANGED
@@ -1398,10 +1398,17 @@ var HyveClient = class {
1398
1398
  logger.info("HyveClient Initialized");
1399
1399
  logger.info("==========================================");
1400
1400
  logger.info("Session ID:", this.sessionId);
1401
- logger.info("Environment:", this.telemetryConfig.isDev ? "DEVELOPMENT" : "PRODUCTION", `(${envSource})`);
1401
+ logger.info(
1402
+ "Environment:",
1403
+ this.telemetryConfig.isDev ? "DEVELOPMENT" : "PRODUCTION",
1404
+ `(${envSource})`
1405
+ );
1402
1406
  logger.info("API Base URL:", this.apiBaseUrl);
1403
1407
  logger.info("Ads enabled:", this.adsService.isEnabled());
1404
- logger.info("Billing configured:", Object.keys(this.billingConfig).length > 0);
1408
+ logger.info(
1409
+ "Billing configured:",
1410
+ Object.keys(this.billingConfig).length > 0
1411
+ );
1405
1412
  logger.debug("Config:", {
1406
1413
  isDev: this.telemetryConfig.isDev,
1407
1414
  hasCustomApiUrl: !!config?.apiBaseUrl,
@@ -1472,11 +1479,10 @@ var HyveClient = class {
1472
1479
  * @param eventSubCategory Optional sub-category
1473
1480
  * @param eventSubAction Optional sub-action
1474
1481
  * @param eventDetails Optional event details (object or JSON string)
1475
- * @param customData Optional custom data (object or JSON string)
1476
1482
  * @param platformId Optional platform identifier
1477
1483
  * @returns Promise resolving to boolean indicating success
1478
1484
  */
1479
- async sendTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails, customData, platformId) {
1485
+ async sendTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails, platformId) {
1480
1486
  if (!this.jwtToken) {
1481
1487
  logger.error("JWT token required. Call authenticateFromUrl first.");
1482
1488
  return false;
@@ -1486,6 +1492,19 @@ var HyveClient = class {
1486
1492
  return false;
1487
1493
  }
1488
1494
  try {
1495
+ if (eventDetails) {
1496
+ try {
1497
+ if (typeof eventDetails === "string") {
1498
+ JSON.parse(eventDetails);
1499
+ } else if (typeof eventDetails === "object") {
1500
+ JSON.stringify(eventDetails);
1501
+ }
1502
+ } catch (validationError) {
1503
+ logger.error("Invalid JSON in eventDetails:", validationError);
1504
+ logger.error("eventDetails value:", eventDetails);
1505
+ return false;
1506
+ }
1507
+ }
1489
1508
  const toJsonString = (data) => {
1490
1509
  if (!data) return null;
1491
1510
  return typeof data === "string" ? data : JSON.stringify(data);
@@ -1499,11 +1518,10 @@ var HyveClient = class {
1499
1518
  event_action: eventAction,
1500
1519
  event_sub_category: eventSubCategory || null,
1501
1520
  event_sub_action: eventSubAction || null,
1502
- event_details: toJsonString(eventDetails),
1503
- custom_data: toJsonString(customData)
1521
+ event_details: toJsonString(eventDetails)
1504
1522
  };
1505
1523
  logger.debug("Sending telemetry event:", telemetryEvent);
1506
- const telemetryUrl = `${this.apiBaseUrl}/api/v1/telemetry/send`;
1524
+ const telemetryUrl = `${this.apiBaseUrl}/api/v1/analytics/send`;
1507
1525
  const response = await fetch(telemetryUrl, {
1508
1526
  method: "POST",
1509
1527
  headers: {
package/dist/index.mjs CHANGED
@@ -1358,10 +1358,17 @@ var HyveClient = class {
1358
1358
  logger.info("HyveClient Initialized");
1359
1359
  logger.info("==========================================");
1360
1360
  logger.info("Session ID:", this.sessionId);
1361
- logger.info("Environment:", this.telemetryConfig.isDev ? "DEVELOPMENT" : "PRODUCTION", `(${envSource})`);
1361
+ logger.info(
1362
+ "Environment:",
1363
+ this.telemetryConfig.isDev ? "DEVELOPMENT" : "PRODUCTION",
1364
+ `(${envSource})`
1365
+ );
1362
1366
  logger.info("API Base URL:", this.apiBaseUrl);
1363
1367
  logger.info("Ads enabled:", this.adsService.isEnabled());
1364
- logger.info("Billing configured:", Object.keys(this.billingConfig).length > 0);
1368
+ logger.info(
1369
+ "Billing configured:",
1370
+ Object.keys(this.billingConfig).length > 0
1371
+ );
1365
1372
  logger.debug("Config:", {
1366
1373
  isDev: this.telemetryConfig.isDev,
1367
1374
  hasCustomApiUrl: !!config?.apiBaseUrl,
@@ -1432,11 +1439,10 @@ var HyveClient = class {
1432
1439
  * @param eventSubCategory Optional sub-category
1433
1440
  * @param eventSubAction Optional sub-action
1434
1441
  * @param eventDetails Optional event details (object or JSON string)
1435
- * @param customData Optional custom data (object or JSON string)
1436
1442
  * @param platformId Optional platform identifier
1437
1443
  * @returns Promise resolving to boolean indicating success
1438
1444
  */
1439
- async sendTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails, customData, platformId) {
1445
+ async sendTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails, platformId) {
1440
1446
  if (!this.jwtToken) {
1441
1447
  logger.error("JWT token required. Call authenticateFromUrl first.");
1442
1448
  return false;
@@ -1446,6 +1452,19 @@ var HyveClient = class {
1446
1452
  return false;
1447
1453
  }
1448
1454
  try {
1455
+ if (eventDetails) {
1456
+ try {
1457
+ if (typeof eventDetails === "string") {
1458
+ JSON.parse(eventDetails);
1459
+ } else if (typeof eventDetails === "object") {
1460
+ JSON.stringify(eventDetails);
1461
+ }
1462
+ } catch (validationError) {
1463
+ logger.error("Invalid JSON in eventDetails:", validationError);
1464
+ logger.error("eventDetails value:", eventDetails);
1465
+ return false;
1466
+ }
1467
+ }
1449
1468
  const toJsonString = (data) => {
1450
1469
  if (!data) return null;
1451
1470
  return typeof data === "string" ? data : JSON.stringify(data);
@@ -1459,11 +1478,10 @@ var HyveClient = class {
1459
1478
  event_action: eventAction,
1460
1479
  event_sub_category: eventSubCategory || null,
1461
1480
  event_sub_action: eventSubAction || null,
1462
- event_details: toJsonString(eventDetails),
1463
- custom_data: toJsonString(customData)
1481
+ event_details: toJsonString(eventDetails)
1464
1482
  };
1465
1483
  logger.debug("Sending telemetry event:", telemetryEvent);
1466
- const telemetryUrl = `${this.apiBaseUrl}/api/v1/telemetry/send`;
1484
+ const telemetryUrl = `${this.apiBaseUrl}/api/v1/analytics/send`;
1467
1485
  const response = await fetch(telemetryUrl, {
1468
1486
  method: "POST",
1469
1487
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyve-sdk/js",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "Hyve SDK - TypeScript wrapper for Hyve game server integration",
5
5
  "private": false,
6
6
  "publishConfig": {