solo-analytics 0.1.0 → 0.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +212 -58
  3. package/package.json +4 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Céss White
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,83 +1,88 @@
1
1
  # 📊 Solo Analytics
2
2
 
3
- Una biblioteca TypeScript ligera y completa para recopilar información del navegador y del dispositivo de una manera simple.
3
+ A lightweight TypeScript library for comprehensive browser and device information collection with a clean API surface.
4
4
 
5
- ## Características
5
+ [![npm version](https://img.shields.io/npm/v/solo-analytics.svg?style=flat-square)](https://www.npmjs.com/package/solo-analytics)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?style=flat-square)](https://www.typescriptlang.org/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square)](https://github.com/cesswhite/solo-analytics/blob/main/LICENSE)
8
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/solo-analytics?style=flat-square)](https://bundlephobia.com/package/solo-analytics)
6
9
 
7
- - 🔍 Detección completa del navegador, sistema operativo y dispositivo
8
- - 📱 Identificación de dispositivos móviles, tablets y escritorio
9
- - 🌐 Información de red y conectividad
10
- - 📏 Detalles de pantalla y orientación
11
- - ⚡ Métricas de rendimiento
12
- - 🌍 Información de ubicación y entorno
13
- - ⚙️ Detección de funcionalidades avanzadas (cámara, micrófono, batería, etc.)
14
- - 🔒 Detección de modo incógnito
15
- - 🔄 Actualización automática opcional de datos
10
+ ## Features
16
11
 
17
- ## Instalación
12
+ - 🔍 Extensive browser, OS, and device detection with full TypeScript support
13
+ - 📱 Precise mobile, tablet, and desktop device classification
14
+ - 🌐 Network connectivity and performance data
15
+ - 📏 Screen and viewport dimensions with orientation detection
16
+ - ⚡ Comprehensive performance metrics (navigation, timing, memory)
17
+ - 🌍 Locale, timezone, and environment information
18
+ - ⚙️ Advanced feature detection (camera, microphone, battery, etc.)
19
+ - 🔒 Incognito/private mode detection
20
+ - 🔄 Auto-refresh capability for dynamic metrics
21
+
22
+ ## Installation
18
23
 
19
24
  ```bash
20
25
  npm install solo-analytics
21
26
  ```
22
27
 
23
- ## Uso básico
28
+ ## Basic Usage
24
29
 
25
30
  ```typescript
26
31
  import { useSoloAnalytics } from "solo-analytics";
27
32
 
28
- // Inicializar con opciones por defecto
33
+ // Initialize with default options
29
34
  const analytics = useSoloAnalytics();
30
35
 
31
- // Obtener información básica
32
- console.log("¿Es móvil?", analytics.isMobile);
33
- console.log("Navegador:", analytics.browserName);
34
- console.log("Sistema operativo:", analytics.osName);
36
+ // Access common properties
37
+ console.log("Mobile device:", analytics.isMobile);
38
+ console.log("Browser:", analytics.browserName);
39
+ console.log("OS:", analytics.osName);
35
40
 
36
- // Obtener todos los datos completos
37
- console.log("Datos completos:", analytics.data);
41
+ // Access the complete data object
42
+ console.log("Full analytics data:", analytics.data);
38
43
  ```
39
44
 
40
- ## Opciones de configuración
45
+ ## Configuration Options
41
46
 
42
47
  ```typescript
43
48
  import { useSoloAnalytics } from "solo-analytics";
44
49
 
45
50
  const analytics = useSoloAnalytics({
46
- // Actualizar automáticamente los datos dinámicos (red, performance)
51
+ // Automatically refresh dynamic data (network, performance)
47
52
  autoRefresh: true,
48
- // Intervalo de actualización en milisegundos (por defecto: 30000)
53
+ // Refresh interval in milliseconds (default: 30000)
49
54
  refreshInterval: 10000,
50
- // Detectar cambios de visibilidad de la página
55
+ // Track page visibility changes
51
56
  trackVisibility: true,
52
57
  });
53
58
  ```
54
59
 
55
- ## API de retorno
60
+ ## API Reference
56
61
 
57
- La función `useSoloAnalytics` retorna un objeto con las siguientes propiedades y métodos:
62
+ The `useSoloAnalytics()` function returns an object with the following methods and properties:
58
63
 
59
- ### Métodos
64
+ ### Methods
60
65
 
61
- - `refresh()`: Actualiza manualmente todos los datos de análisis
62
- - `destroy()`: Limpia todos los listeners y timers para evitar fugas de memoria
66
+ - `refresh()`: Manually triggers a refresh of all analytics data
67
+ - `destroy()`: Cleans up all event listeners and timers to prevent memory leaks
63
68
 
64
- ### Propiedades de conveniencia
69
+ ### Convenience Properties
65
70
 
66
- - `isMobile`: Indica si es un dispositivo móvil
67
- - `isTablet`: Indica si es una tablet
68
- - `isDesktop`: Indica si es un dispositivo de escritorio
69
- - `isOnline`: Estado de conexión a internet
70
- - `isVisible`: Si la página está visible actualmente
71
- - `browserName`: Nombre del navegador
72
- - `osName`: Nombre del sistema operativo
71
+ - `isMobile`: Whether the device is a mobile phone
72
+ - `isTablet`: Whether the device is a tablet
73
+ - `isDesktop`: Whether the device is a desktop computer
74
+ - `isOnline`: Current network connection state
75
+ - `isVisible`: Whether the page is currently visible
76
+ - `browserName`: The name of the browser
77
+ - `osName`: The name of the operating system
73
78
 
74
- ### Datos completos
79
+ ### Complete Data
75
80
 
76
- - `data`: Un objeto que contiene toda la información detallada
81
+ - `data`: An object containing all detailed analytics information
77
82
 
78
- ## Estructura de datos
83
+ ## Data Structure
79
84
 
80
- El objeto `data` contiene la siguiente estructura:
85
+ The `data` object contains the following structure:
81
86
 
82
87
  ```typescript
83
88
  interface SoloAnalyticsInfo {
@@ -161,7 +166,7 @@ interface SoloAnalyticsInfo {
161
166
  }
162
167
  ```
163
168
 
164
- ## Uso en proyectos
169
+ ## Framework Integration Examples
165
170
 
166
171
  ### React
167
172
 
@@ -173,38 +178,126 @@ function DeviceInfo() {
173
178
  const [analytics, setAnalytics] = useState<SoloAnalyticsReturn | null>(null);
174
179
 
175
180
  useEffect(() => {
176
- // Inicializar en el lado del cliente
181
+ // Initialize on the client side
177
182
  const analyticsInstance = useSoloAnalytics();
178
183
  setAnalytics(analyticsInstance);
179
184
 
180
- // Limpiar al desmontar
185
+ // Cleanup on unmount
181
186
  return () => {
182
187
  analyticsInstance.destroy();
183
188
  };
184
189
  }, []);
185
190
 
186
- if (!analytics) return <div>Cargando...</div>;
191
+ if (!analytics) return <div>Loading...</div>;
187
192
 
188
193
  return (
189
194
  <div>
190
- <h1>Información del dispositivo</h1>
195
+ <h1>Device Information</h1>
191
196
  <p>
192
- Tipo:{" "}
197
+ Type:{" "}
193
198
  {analytics.isMobile
194
- ? "Móvil"
199
+ ? "Mobile"
195
200
  : analytics.isTablet
196
201
  ? "Tablet"
197
202
  : "Desktop"}
198
203
  </p>
199
- <p>Navegador: {analytics.browserName}</p>
200
- <p>Sistema operativo: {analytics.osName}</p>
201
- <p>En línea: {analytics.isOnline ? "" : "No"}</p>
204
+ <p>Browser: {analytics.browserName}</p>
205
+ <p>Operating System: {analytics.osName}</p>
206
+ <p>Network Status: {analytics.isOnline ? "Online" : "Offline"}</p>
202
207
  </div>
203
208
  );
204
209
  }
205
210
  ```
206
211
 
207
- ### JavaScript Vanilla
212
+ ### Vue 3
213
+
214
+ ```vue
215
+ <template>
216
+ <div>
217
+ <h1>Device Information</h1>
218
+ <p>Type: {{ deviceType }}</p>
219
+ <p>Browser: {{ analytics.browserName }}</p>
220
+ <p>Operating System: {{ analytics.osName }}</p>
221
+ <p>Network Status: {{ analytics.isOnline ? "Online" : "Offline" }}</p>
222
+ </div>
223
+ </template>
224
+
225
+ <script setup lang="ts">
226
+ import { onMounted, onUnmounted, ref, computed } from "vue";
227
+ import { useSoloAnalytics, SoloAnalyticsReturn } from "solo-analytics";
228
+
229
+ const analytics = ref<SoloAnalyticsReturn | null>(null);
230
+
231
+ onMounted(() => {
232
+ analytics.value = useSoloAnalytics({
233
+ trackVisibility: true,
234
+ });
235
+ });
236
+
237
+ onUnmounted(() => {
238
+ analytics.value?.destroy();
239
+ });
240
+
241
+ const deviceType = computed(() => {
242
+ if (!analytics.value) return "Unknown";
243
+
244
+ if (analytics.value.isMobile) return "Mobile";
245
+ if (analytics.value.isTablet) return "Tablet";
246
+ return "Desktop";
247
+ });
248
+ </script>
249
+ ```
250
+
251
+ ### Nuxt 3
252
+
253
+ ```vue
254
+ <template>
255
+ <div>
256
+ <h1>Device Information</h1>
257
+ <div v-if="analytics">
258
+ <p>Type: {{ deviceType }}</p>
259
+ <p>Browser: {{ analytics.browserName }}</p>
260
+ <p>Operating System: {{ analytics.osName }}</p>
261
+ <p>Network Status: {{ analytics.isOnline ? "Online" : "Offline" }}</p>
262
+ </div>
263
+ <div v-else>
264
+ <p>Loading device information...</p>
265
+ </div>
266
+ </div>
267
+ </template>
268
+
269
+ <script setup lang="ts">
270
+ import { ref, computed } from "vue";
271
+ import { useSoloAnalytics, SoloAnalyticsReturn } from "solo-analytics";
272
+
273
+ const analytics = ref<SoloAnalyticsReturn | null>(null);
274
+
275
+ // Important: Only initialize on client-side to avoid SSR issues
276
+ onMounted(() => {
277
+ analytics.value = useSoloAnalytics({
278
+ trackVisibility: true,
279
+ autoRefresh: true,
280
+ refreshInterval: 15000,
281
+ });
282
+ });
283
+
284
+ onBeforeUnmount(() => {
285
+ if (analytics.value) {
286
+ analytics.value.destroy();
287
+ }
288
+ });
289
+
290
+ const deviceType = computed(() => {
291
+ if (!analytics.value) return "Unknown";
292
+
293
+ if (analytics.value.isMobile) return "Mobile";
294
+ if (analytics.value.isTablet) return "Tablet";
295
+ return "Desktop";
296
+ });
297
+ </script>
298
+ ```
299
+
300
+ ### Vanilla JavaScript
208
301
 
209
302
  ```html
210
303
  <script type="module">
@@ -213,18 +306,18 @@ function DeviceInfo() {
213
306
  document.addEventListener("DOMContentLoaded", () => {
214
307
  const analytics = useSoloAnalytics();
215
308
 
216
- // Mostrar información en la página
309
+ // Display information on the page
217
310
  document.getElementById("deviceType").textContent = analytics.isMobile
218
- ? "Móvil"
311
+ ? "Mobile"
219
312
  : analytics.isTablet
220
313
  ? "Tablet"
221
314
  : "Desktop";
222
315
 
223
316
  document.getElementById(
224
317
  "browserInfo"
225
- ).textContent = `${analytics.browserName} en ${analytics.osName}`;
318
+ ).textContent = `${analytics.browserName} on ${analytics.osName}`;
226
319
 
227
- // Limpiar al cerrar
320
+ // Cleanup on window close
228
321
  window.addEventListener("beforeunload", () => {
229
322
  analytics.destroy();
230
323
  });
@@ -232,6 +325,67 @@ function DeviceInfo() {
232
325
  </script>
233
326
  ```
234
327
 
235
- ## Licencia
328
+ ## Browser Compatibility
329
+
330
+ Solo Analytics is compatible with all modern browsers, including:
331
+
332
+ - Chrome 60+
333
+ - Firefox 55+
334
+ - Safari 11+
335
+ - Edge 16+
336
+ - Opera 47+
337
+ - iOS Safari 11+
338
+ - Android Browser 67+
339
+
340
+ Some advanced features may not be available in older browsers but the library includes graceful fallbacks.
341
+
342
+ ## Development
343
+
344
+ ```bash
345
+ # Install dependencies
346
+ npm install
347
+
348
+ # Run development server
349
+ npm run dev
350
+
351
+ # Build for production
352
+ npm run build
353
+ ```
354
+
355
+ ## Contributing
356
+
357
+ Contributions are welcome! Please feel free to submit a Pull Request.
358
+
359
+ 1. Fork the repository
360
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
361
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
362
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
363
+ 5. Open a Pull Request
364
+
365
+ ## Repository
366
+
367
+ GitHub: [https://github.com/cesswhite/solo-analytics](https://github.com/cesswhite/solo-analytics)
368
+
369
+ ## License
370
+
371
+ MIT License
372
+
373
+ Copyright (c) 2025 Céss White
374
+
375
+ Permission is hereby granted, free of charge, to any person obtaining a copy
376
+ of this software and associated documentation files (the "Software"), to deal
377
+ in the Software without restriction, including without limitation the rights
378
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
379
+ copies of the Software, and to permit persons to whom the Software is
380
+ furnished to do so, subject to the following conditions:
381
+
382
+ The above copyright notice and this permission notice shall be included in all
383
+ copies or substantial portions of the Software.
236
384
 
237
- MIT
385
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
386
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
387
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
388
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
389
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
390
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
391
+ SOFTWARE.
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "solo-analytics",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A comprehensive browser analytics library with TypeScript support",
5
5
  "type": "module",
6
- "files": ["dist"],
6
+ "files": [
7
+ "dist"
8
+ ],
7
9
  "main": "./dist/solo-analytics.umd.js",
8
10
  "module": "./dist/solo-analytics.js",
9
11
  "types": "./dist/index.d.ts",