solo-analytics 0.1.1 → 0.2.0

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
@@ -54,6 +54,10 @@ const analytics = useSoloAnalytics({
54
54
  refreshInterval: 10000,
55
55
  // Track page visibility changes
56
56
  trackVisibility: true,
57
+ // Skip expensive async probes (incognito, battery, media, permissions)
58
+ detectFeatures: true,
59
+ // Defer async probes to idle time (default: true, recommended)
60
+ lazyFeatures: true,
57
61
  });
58
62
  ```
59
63
 
@@ -345,13 +349,36 @@ Some advanced features may not be available in older browsers but the library in
345
349
  # Install dependencies
346
350
  npm install
347
351
 
348
- # Run development server
352
+ # Run development server (demo playground)
349
353
  npm run dev
350
354
 
351
- # Build for production
355
+ # Type-check and build for production
352
356
  npm run build
357
+
358
+ # Run tests
359
+ npm test
360
+
361
+ # Watch tests during development
362
+ npm run test:watch
353
363
  ```
354
364
 
365
+ ## Performance
366
+
367
+ Solo Analytics is designed to stay off the critical path:
368
+
369
+ | Metric | Value |
370
+ |--------|-------|
371
+ | ESM bundle (gzip) | ~3.5 KB |
372
+ | UMD bundle (gzip) | ~3.1 KB |
373
+ | `sideEffects` | `false` (tree-shakeable) |
374
+
375
+ **Recommendations:**
376
+
377
+ - Use `lazyFeatures: true` (default) so async probes run during idle time
378
+ - Set `detectFeatures: false` if you only need UA, screen, and network data
379
+ - Call `destroy()` when unmounting in SPAs to clear timers and listeners
380
+ - Initialize client-side only (`onMounted` in Vue/Nuxt, `useEffect` in React)
381
+
355
382
  ## Contributing
356
383
 
357
384
  Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,46 @@
1
+ import { SoloAnalyticsInfo } from '../types/analytics';
2
+ /**
3
+ * Type definition for analytics options
4
+ */
5
+ export interface SoloAnalyticsOptions {
6
+ /** Automatically refresh dynamic data (network, performance) */
7
+ autoRefresh?: boolean;
8
+ /** Refresh interval in milliseconds (default: 30000) */
9
+ refreshInterval?: number;
10
+ /** Track page visibility changes */
11
+ trackVisibility?: boolean;
12
+ /**
13
+ * Run expensive async probes (incognito, battery, media, permissions).
14
+ * Set to `false` to skip entirely and reduce main-thread work.
15
+ * @default true
16
+ */
17
+ detectFeatures?: boolean;
18
+ /**
19
+ * Defer async feature probes to idle time via requestIdleCallback.
20
+ * Sync data (UA, screen, network) is collected immediately.
21
+ * @default true
22
+ */
23
+ lazyFeatures?: boolean;
24
+ }
25
+ /**
26
+ * Type definition for the return value of useSoloAnalytics
27
+ */
28
+ export interface SoloAnalyticsReturn {
29
+ data: SoloAnalyticsInfo;
30
+ refresh: () => Promise<void>;
31
+ isMobile: boolean;
32
+ isTablet: boolean;
33
+ isDesktop: boolean;
34
+ isOnline: boolean;
35
+ isVisible: boolean;
36
+ browserName: string;
37
+ osName: string;
38
+ destroy: () => void;
39
+ }
40
+ /**
41
+ * A function that provides comprehensive browser, device, and performance analytics.
42
+ * @param options Configuration options
43
+ * @returns Object with analytics data and helper methods
44
+ */
45
+ export declare function useSoloAnalytics(options?: SoloAnalyticsOptions): SoloAnalyticsReturn;
46
+ //# sourceMappingURL=useSoloAnalytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSoloAnalytics.d.ts","sourceRoot":"","sources":["../../src/composables/useSoloAnalytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAevD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AA8ED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CA6JxF"}
@@ -0,0 +1,4 @@
1
+ export { useSoloAnalytics } from './composables/useSoloAnalytics';
2
+ export type { SoloAnalyticsOptions, SoloAnalyticsReturn } from './composables/useSoloAnalytics';
3
+ export type { SoloAnalyticsInfo, BrowserInfo, OSInfo, DeviceInfo, NetworkInfo, ScreenInfo, PerformanceInfo, LocationInfo } from './types/analytics';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGhG,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,MAAM,EACN,UAAU,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACb,MAAM,mBAAmB,CAAC"}