@cloudsignal/pwa-sdk 1.0.0 → 1.1.1

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
@@ -1,9 +1,10 @@
1
1
  # CloudSignal PWA SDK
2
2
 
3
- Progressive Web App SDK for CloudSignal platform with push notifications, installation management, and comprehensive device tracking.
3
+ Progressive Web App SDK for CloudSignal platform with push notifications, installation management, comprehensive device tracking, offline resilience, and notification analytics.
4
4
 
5
5
  ## Features
6
6
 
7
+ ### Core Features
7
8
  - **PWA Installation** - Automatic install prompt handling with iOS manual instructions
8
9
  - **Push Notifications** - Web Push Protocol with VAPID authentication
9
10
  - **Device Detection** - 35+ device/browser/OS detection fields
@@ -11,6 +12,14 @@ Progressive Web App SDK for CloudSignal platform with push notifications, instal
11
12
  - **Service Worker** - Badge management, notification history, offline support
12
13
  - **TypeScript** - Full type definitions included
13
14
 
15
+ ### v1.1.0 Features
16
+ - **Screen Wake Lock** - Prevent screen sleep during critical operations
17
+ - **Offline Request Queue** - IndexedDB-backed queue with auto-retry when online
18
+ - **iOS Install Banner** - Beautiful modal guiding iOS Safari users to install
19
+ - **Network-Aware Heartbeat** - Auto-adjusts based on connection quality (4G/3G/2G)
20
+ - **Battery-Aware Heartbeat** - Pauses when battery <15% to save power
21
+ - **Notification Analytics** - Track displayed/clicked/dismissed events
22
+
14
23
  ## Installation
15
24
 
16
25
  ### npm
@@ -170,6 +179,61 @@ pwa.startHeartbeat(): void
170
179
 
171
180
  // Stop heartbeat
172
181
  pwa.stopHeartbeat(): void
182
+
183
+ // Get current interval (may vary with network conditions)
184
+ pwa.getHeartbeatInterval(): number
185
+
186
+ // Get network connection info
187
+ pwa.getNetworkInfo(): NetworkConnectionInfo
188
+
189
+ // Get battery info (if available)
190
+ await pwa.getBatteryInfo(): Promise<BatteryInfo | null>
191
+ ```
192
+
193
+ ### Screen Wake Lock (v1.1.0)
194
+
195
+ ```typescript
196
+ // Request screen wake lock (prevents screen from sleeping)
197
+ await pwa.requestWakeLock(): Promise<boolean>
198
+
199
+ // Release wake lock
200
+ pwa.releaseWakeLock(): void
201
+
202
+ // Get current state
203
+ pwa.getWakeLockState(): WakeLockState
204
+ // Returns: { isSupported: boolean, isActive: boolean }
205
+ ```
206
+
207
+ ### Offline Request Queue (v1.1.0)
208
+
209
+ ```typescript
210
+ // Queue a request for later (when offline)
211
+ await pwa.queueOfflineRequest(url, method, body?, headers?): Promise<string | null>
212
+
213
+ // Process queued requests
214
+ await pwa.processOfflineQueue(): Promise<QueueProcessResult>
215
+
216
+ // Get queue statistics
217
+ await pwa.getOfflineQueueStats(): Promise<OfflineQueueStats>
218
+
219
+ // Clear all queued requests
220
+ await pwa.clearOfflineQueue(): Promise<void>
221
+ ```
222
+
223
+ ### iOS Install Banner (v1.1.0)
224
+
225
+ ```typescript
226
+ // Show iOS install guidance banner
227
+ pwa.showIOSInstallBanner(): void
228
+
229
+ // Hide banner
230
+ pwa.hideIOSInstallBanner(): void
231
+
232
+ // Check if previously dismissed
233
+ pwa.wasIOSBannerDismissed(): boolean
234
+
235
+ // Reset dismissal state
236
+ pwa.resetIOSBannerDismissal(): void
173
237
  ```
174
238
 
175
239
  ### Badge Management
@@ -208,6 +272,18 @@ pwa.off(event: PWAEvent, handler: (data) => void): void
208
272
  | `config:error` | Config download failed |
209
273
  | `heartbeat:sent` | Heartbeat sent successfully |
210
274
  | `heartbeat:error` | Heartbeat failed |
275
+ | `heartbeat:intervalChanged` | Heartbeat interval adjusted (v1.1.0) |
276
+ | `heartbeat:pausedForBattery` | Heartbeat paused due to low battery (v1.1.0) |
277
+ | `heartbeat:resumedFromBattery` | Heartbeat resumed (v1.1.0) |
278
+ | `wakeLock:acquired` | Screen wake lock acquired (v1.1.0) |
279
+ | `wakeLock:released` | Screen wake lock released (v1.1.0) |
280
+ | `wakeLock:error` | Wake lock operation failed (v1.1.0) |
281
+ | `offlineQueue:queued` | Request added to offline queue (v1.1.0) |
282
+ | `offlineQueue:processed` | Queued request processed (v1.1.0) |
283
+ | `offlineQueue:flushed` | All queued requests processed (v1.1.0) |
284
+ | `iosBanner:shown` | iOS install banner shown (v1.1.0) |
285
+ | `iosBanner:dismissed` | iOS install banner dismissed (v1.1.0) |
286
+ | `iosBanner:installClicked` | User clicked install on iOS banner (v1.1.0) |
211
287
  | `network:online` | Network came online |
212
288
  | `network:offline` | Network went offline |
213
289
  | `sw:registered` | Service worker registered |
@@ -374,10 +450,59 @@ import {
374
450
  DeviceInfo,
375
451
  InstallationState,
376
452
  Registration,
377
- PWAEvent
453
+ PWAEvent,
454
+ // v1.1.0 types
455
+ WakeLockState,
456
+ WakeLockConfig,
457
+ OfflineQueueConfig,
458
+ IOSInstallBannerConfig,
459
+ NetworkConnectionInfo,
460
+ BatteryInfo,
461
+ QueueProcessResult,
462
+ OfflineQueueStats,
378
463
  } from '@cloudsignal/pwa-sdk'
379
464
  ```
380
465
 
466
+ ## v1.1.0 Configuration
467
+
468
+ ```javascript
469
+ const pwa = new CloudSignalPWA({
470
+ organizationId: 'your-org-uuid',
471
+ organizationSecret: 'your-secret-key',
472
+ serviceId: 'your-service-uuid',
473
+
474
+ // Wake Lock (prevents screen sleep)
475
+ wakeLock: {
476
+ enabled: true,
477
+ autoRequest: false, // Request manually when needed
478
+ reacquireOnVisibility: true,
479
+ },
480
+
481
+ // Offline Queue (stores failed requests)
482
+ offlineQueue: {
483
+ enabled: true,
484
+ maxQueueSize: 100,
485
+ maxAgeTTLHours: 24,
486
+ autoProcessOnOnline: true,
487
+ },
488
+
489
+ // iOS Install Banner
490
+ iosInstallBanner: {
491
+ enabled: true,
492
+ appName: 'My PWA',
493
+ showOnFirstVisit: true,
494
+ showDelay: 3000,
495
+ dismissRememberDays: 7,
496
+ },
497
+
498
+ // Notification Analytics
499
+ notificationAnalytics: {
500
+ enabled: true,
501
+ endpoint: 'https://api.example.com/analytics', // Optional custom endpoint
502
+ },
503
+ })
504
+ ```
505
+
381
506
  ## License
382
507
 
383
- MIT License - Copyright (c) 2024 CloudSignal
508
+ MIT License - Copyright (c) 2024-2025 CloudSignal