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.
- package/LICENSE +21 -0
- package/README.md +212 -58
- 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
|
-
|
|
3
|
+
A lightweight TypeScript library for comprehensive browser and device information collection with a clean API surface.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/solo-analytics)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://github.com/cesswhite/solo-analytics/blob/main/LICENSE)
|
|
8
|
+
[](https://bundlephobia.com/package/solo-analytics)
|
|
6
9
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
28
|
+
## Basic Usage
|
|
24
29
|
|
|
25
30
|
```typescript
|
|
26
31
|
import { useSoloAnalytics } from "solo-analytics";
|
|
27
32
|
|
|
28
|
-
//
|
|
33
|
+
// Initialize with default options
|
|
29
34
|
const analytics = useSoloAnalytics();
|
|
30
35
|
|
|
31
|
-
//
|
|
32
|
-
console.log("
|
|
33
|
-
console.log("
|
|
34
|
-
console.log("
|
|
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
|
-
//
|
|
37
|
-
console.log("
|
|
41
|
+
// Access the complete data object
|
|
42
|
+
console.log("Full analytics data:", analytics.data);
|
|
38
43
|
```
|
|
39
44
|
|
|
40
|
-
##
|
|
45
|
+
## Configuration Options
|
|
41
46
|
|
|
42
47
|
```typescript
|
|
43
48
|
import { useSoloAnalytics } from "solo-analytics";
|
|
44
49
|
|
|
45
50
|
const analytics = useSoloAnalytics({
|
|
46
|
-
//
|
|
51
|
+
// Automatically refresh dynamic data (network, performance)
|
|
47
52
|
autoRefresh: true,
|
|
48
|
-
//
|
|
53
|
+
// Refresh interval in milliseconds (default: 30000)
|
|
49
54
|
refreshInterval: 10000,
|
|
50
|
-
//
|
|
55
|
+
// Track page visibility changes
|
|
51
56
|
trackVisibility: true,
|
|
52
57
|
});
|
|
53
58
|
```
|
|
54
59
|
|
|
55
|
-
## API
|
|
60
|
+
## API Reference
|
|
56
61
|
|
|
57
|
-
|
|
62
|
+
The `useSoloAnalytics()` function returns an object with the following methods and properties:
|
|
58
63
|
|
|
59
|
-
###
|
|
64
|
+
### Methods
|
|
60
65
|
|
|
61
|
-
- `refresh()`:
|
|
62
|
-
- `destroy()`:
|
|
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
|
-
###
|
|
69
|
+
### Convenience Properties
|
|
65
70
|
|
|
66
|
-
- `isMobile`:
|
|
67
|
-
- `isTablet`:
|
|
68
|
-
- `isDesktop`:
|
|
69
|
-
- `isOnline`:
|
|
70
|
-
- `isVisible`:
|
|
71
|
-
- `browserName`:
|
|
72
|
-
- `osName`:
|
|
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
|
-
###
|
|
79
|
+
### Complete Data
|
|
75
80
|
|
|
76
|
-
- `data`:
|
|
81
|
+
- `data`: An object containing all detailed analytics information
|
|
77
82
|
|
|
78
|
-
##
|
|
83
|
+
## Data Structure
|
|
79
84
|
|
|
80
|
-
|
|
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
|
-
##
|
|
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
|
-
//
|
|
181
|
+
// Initialize on the client side
|
|
177
182
|
const analyticsInstance = useSoloAnalytics();
|
|
178
183
|
setAnalytics(analyticsInstance);
|
|
179
184
|
|
|
180
|
-
//
|
|
185
|
+
// Cleanup on unmount
|
|
181
186
|
return () => {
|
|
182
187
|
analyticsInstance.destroy();
|
|
183
188
|
};
|
|
184
189
|
}, []);
|
|
185
190
|
|
|
186
|
-
if (!analytics) return <div>
|
|
191
|
+
if (!analytics) return <div>Loading...</div>;
|
|
187
192
|
|
|
188
193
|
return (
|
|
189
194
|
<div>
|
|
190
|
-
<h1>
|
|
195
|
+
<h1>Device Information</h1>
|
|
191
196
|
<p>
|
|
192
|
-
|
|
197
|
+
Type:{" "}
|
|
193
198
|
{analytics.isMobile
|
|
194
|
-
? "
|
|
199
|
+
? "Mobile"
|
|
195
200
|
: analytics.isTablet
|
|
196
201
|
? "Tablet"
|
|
197
202
|
: "Desktop"}
|
|
198
203
|
</p>
|
|
199
|
-
<p>
|
|
200
|
-
<p>
|
|
201
|
-
<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
|
-
###
|
|
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
|
-
//
|
|
309
|
+
// Display information on the page
|
|
217
310
|
document.getElementById("deviceType").textContent = analytics.isMobile
|
|
218
|
-
? "
|
|
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}
|
|
318
|
+
).textContent = `${analytics.browserName} on ${analytics.osName}`;
|
|
226
319
|
|
|
227
|
-
//
|
|
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
|
-
##
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A comprehensive browser analytics library with TypeScript support",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"files": [
|
|
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",
|