@litemetrics/client 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 (2) hide show
  1. package/README.md +102 -0
  2. package/package.json +11 -3
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @litemetrics/client
2
+
3
+ Client SDK for querying Litemetrics analytics data. Fetch stats, time series, events, users, and manage sites from your frontend or backend.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @litemetrics/client
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```ts
14
+ import { createClient } from '@litemetrics/client';
15
+
16
+ const client = createClient({
17
+ baseUrl: 'https://your-server.com',
18
+ siteId: 'your-site-id',
19
+ secretKey: 'your-secret-key',
20
+ });
21
+ ```
22
+
23
+ ## Querying Stats
24
+
25
+ ```ts
26
+ // Overview metrics
27
+ const overview = await client.getOverview(
28
+ ['pageviews', 'visitors', 'sessions'],
29
+ { period: '7d', compare: true }
30
+ );
31
+
32
+ // Top pages
33
+ const pages = await client.getStats('top_pages', { period: '30d', limit: 10 });
34
+
35
+ // Top referrers
36
+ const referrers = await client.getStats('top_referrers', { period: '7d' });
37
+
38
+ // Country breakdown
39
+ const countries = await client.getTopCountries({ period: '30d', limit: 50 });
40
+ ```
41
+
42
+ ## Time Series
43
+
44
+ ```ts
45
+ const timeseries = await client.getTimeSeries({
46
+ metric: 'pageviews',
47
+ period: '30d',
48
+ granularity: 'day',
49
+ });
50
+
51
+ // Returns: { data: [{ date: '2025-01-01', value: 142 }, ...] }
52
+ ```
53
+
54
+ ## Events & Users
55
+
56
+ ```ts
57
+ // List events
58
+ const events = await client.getEventsList({
59
+ type: 'pageview',
60
+ period: '24h',
61
+ limit: 50,
62
+ });
63
+
64
+ // List users
65
+ const users = await client.getUsersList({ limit: 20 });
66
+
67
+ // User detail
68
+ const user = await client.getUserDetail('visitor-id');
69
+ ```
70
+
71
+ ## Retention
72
+
73
+ ```ts
74
+ const retention = await client.getRetention({ period: '90d', weeks: 8 });
75
+ // Returns weekly cohort retention data
76
+ ```
77
+
78
+ ## Site Management
79
+
80
+ ```ts
81
+ import { createSitesClient } from '@litemetrics/client';
82
+
83
+ const sites = createSitesClient({
84
+ baseUrl: 'https://your-server.com',
85
+ adminSecret: 'your-admin-secret',
86
+ });
87
+
88
+ // CRUD
89
+ const { site } = await sites.createSite({ name: 'My App', domain: 'myapp.com' });
90
+ const { sites: allSites } = await sites.listSites();
91
+ await sites.updateSite(site.siteId, { allowedOrigins: ['myapp.com'] });
92
+ await sites.deleteSite(site.siteId);
93
+ await sites.regenerateSecret(site.siteId);
94
+ ```
95
+
96
+ ## Available Metrics
97
+
98
+ `pageviews` | `visitors` | `sessions` | `events` | `top_pages` | `top_referrers` | `top_countries` | `top_cities` | `top_events` | `top_browsers` | `top_os` | `top_devices`
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litemetrics/client",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Client-side SDK for querying Litemetrics analytics data",
5
5
  "license": "MIT",
6
6
  "author": "Metehan Kurucu",
@@ -9,7 +9,13 @@
9
9
  "url": "https://github.com/metehankurucu/litemetrics",
10
10
  "directory": "packages/client"
11
11
  },
12
- "keywords": ["analytics", "litemetrics", "client", "dashboard", "query"],
12
+ "keywords": [
13
+ "analytics",
14
+ "litemetrics",
15
+ "client",
16
+ "dashboard",
17
+ "query"
18
+ ],
13
19
  "type": "module",
14
20
  "main": "./dist/index.cjs",
15
21
  "module": "./dist/index.js",
@@ -21,7 +27,9 @@
21
27
  "require": "./dist/index.cjs"
22
28
  }
23
29
  },
24
- "files": ["dist"],
30
+ "files": [
31
+ "dist"
32
+ ],
25
33
  "publishConfig": {
26
34
  "access": "public"
27
35
  },