@entrolytics/api-client 2.2.0 → 2.2.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,85 +1,79 @@
1
- # @entrolytics/api-client
1
+ # ⚠️ DEPRECATED
2
2
 
3
- TypeScript API client for Entrolytics - First-party growth analytics for the edge.
3
+ **This package is deprecated in favor of [`@entrolytics/trpc-client`](../trpc/).**
4
4
 
5
- ## Installation
5
+ The new tRPC client provides:
6
6
 
7
- ```bash
8
- npm install @entrolytics/api-client
9
- # or
10
- pnpm add @entrolytics/api-client
11
- # or
12
- yarn add @entrolytics/api-client
13
- ```
7
+ - ✅ Full end-to-end type safety
8
+ - ✅ Auto-completion for all API methods
9
+ - ✅ Automatic request batching
10
+ - ✅ Better error handling
11
+ - ✅ Same functionality, better DX
14
12
 
15
- ## Usage
13
+ ## Migration Guide
16
14
 
17
- ```typescript
18
- import { EntrolyticsClient } from '@entrolytics/api-client';
15
+ ### Installation
19
16
 
20
- const client = new EntrolyticsClient({
21
- apiKey: 'your-api-key',
22
- apiUrl: 'https://api.entrolytics.click', // optional
23
- });
17
+ ```bash
24
18
 
25
- // Track an event
26
- await client.track({
27
- websiteId: 'your-website-id',
28
- event: 'pageview',
29
- url: 'https://example.com/page',
30
- properties: {
31
- customProperty: 'value',
32
- },
33
- });
19
+ # Remove old client
34
20
 
35
- // Get analytics data
36
- const analytics = await client.analytics.getOverview({
37
- websiteId: 'your-website-id',
38
- startDate: '2025-01-01',
39
- endDate: '2025-01-31',
40
- });
21
+ npm uninstall @entrolytics/api-client
22
+
23
+ # Install new client
24
+
25
+ npm install @entrolytics/trpc-client
41
26
  ```
42
27
 
43
- ## Features
28
+ ### Usage Changes
44
29
 
45
- - 🔒 Type-safe API client
46
- - 📊 Full analytics API coverage
47
- - 🚀 Promise-based async/await
48
- - ⚡ Automatic retry logic
49
- - 🔄 Request/response interceptors
50
- - 📝 TypeScript definitions included
30
+ **Before (REST Client)**:
51
31
 
52
- ## API Reference
32
+ ```typescript
33
+ import { EntrolyticsClient } from "@entrolytics/api-client";
53
34
 
54
- ### Constructor Options
35
+ const client = new EntrolyticsClient({
36
+ apiUrl: "https://api.entrolytics.click",
37
+ apiKey: "your-key",
38
+ });
55
39
 
56
- - `apiKey` (string, required): Your Entrolytics API key
57
- - `apiUrl` (string, optional): Custom API URL (defaults to production)
58
- - `timeout` (number, optional): Request timeout in ms (default: 5000)
59
- - `retries` (number, optional): Number of retries on failure (default: 3)
40
+ const websites = await client.websites.list();
41
+ ```
60
42
 
61
- ### Methods
43
+ **After (tRPC Client)**:
62
44
 
63
- #### `track(data: TrackEventData): Promise<void>`
45
+ ```typescript
46
+ import { createClient } from "@entrolytics/trpc-client";
64
47
 
65
- Track a single event.
48
+ const client = createClient({
49
+ apiUrl: "https://api.entrolytics.click",
50
+ apiKey: "your-key",
51
+ });
66
52
 
67
- #### `trackBatch(events: TrackEventData[]): Promise<void>`
53
+ const websites = await client.websites.list.query();
54
+ ```
68
55
 
69
- Track multiple events in a single request.
56
+ ### Key Differences
70
57
 
71
- #### `analytics.getOverview(params): Promise<AnalyticsOverview>`
58
+ 1. **Query/Mutation Pattern**: tRPC uses `.query()` for reads and `.mutate()` for writes
59
+ 2. **Type Safety**: All types are automatically inferred from the backend
60
+ 3. **Error Handling**: Errors are typed and more predictable
72
61
 
73
- Get overview analytics for a website.
62
+ ### API Mapping
74
63
 
75
- #### `analytics.getTopPages(params): Promise<TopPage[]>`
64
+ | Old Method | New Method |
65
+ | ----------------------------------- | ----------------------------------------- |
66
+ | `client.websites.list()` | `client.websites.list.query()` |
67
+ | `client.websites.create(data)` | `client.websites.create.mutate(data)` |
68
+ | `client.analytics.overview(params)` | `client.analytics.overview.query(params)` |
69
+ | `client.events.list(params)` | `client.events.list.query(params)` |
76
70
 
77
- Get top pages by pageviews.
71
+ See the [full tRPC client documentation](../trpc/README.md) for complete migration details.
78
72
 
79
- #### `analytics.getTopReferrers(params): Promise<TopReferrer[]>`
73
+ ---
80
74
 
81
- Get top referrers.
75
+ # @entrolytics/api-client (Legacy)
82
76
 
83
- ## License
77
+ REST API client for Entrolytics (no longer maintained).
84
78
 
85
- MIT © Entrolytics
79
+ For new projects, use [`@entrolytics/trpc-client`](../trpc/) instead.
package/package.json CHANGED
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "name": "@entrolytics/api-client",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "TypeScript API client for Entrolytics - First-party growth analytics for the edge",
5
+ "keywords": [
6
+ "analytics",
7
+ "api",
8
+ "client",
9
+ "entrolytics",
10
+ "typescript"
11
+ ],
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/entrolytics/api-client.git",
16
+ "directory": "packages/api"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
5
22
  "type": "module",
6
23
  "main": "./dist/index.cjs",
7
24
  "module": "./dist/index.js",
@@ -18,37 +35,23 @@
18
35
  }
19
36
  }
20
37
  },
21
- "files": [
22
- "dist",
23
- "README.md"
24
- ],
25
- "devDependencies": {
26
- "@biomejs/biome": "^2.3.11",
27
- "@types/node": "^25.0.3",
28
- "tsup": "^8.5.1",
29
- "typescript": "^5.9.3"
30
- },
31
- "keywords": [
32
- "entrolytics",
33
- "analytics",
34
- "api",
35
- "client",
36
- "typescript"
37
- ],
38
- "repository": {
39
- "type": "git",
40
- "url": "https://github.com/entrolytics/api-client.git",
41
- "directory": "packages/api"
42
- },
43
- "license": "MIT",
44
38
  "dependencies": {
45
- "@entrolytics/shared": "^2.2.0"
39
+ "@entrolytics/shared": "^2.4.0"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^25.5.0",
43
+ "typescript": "^6.0.2",
44
+ "vite-plus": "latest"
46
45
  },
47
46
  "scripts": {
48
- "build": "tsup",
49
- "dev": "tsup --watch",
50
- "lint": "biome lint .",
51
- "format": "biome format --write .",
52
- "typecheck": "tsc --noEmit"
47
+ "build": "vp pack",
48
+ "check": "vp check",
49
+ "dev": "vp pack --watch",
50
+ "lint": "vp lint --fix . && vp fmt --write .",
51
+ "lint:check": "vp lint . && vp fmt --check .",
52
+ "lint:fix-unsafe": "vp lint -f stylish --import-plugin --type-aware --type-check --vitest-plugin --fix --fix-suggestions --fix-dangerously .",
53
+ "format": "vp fmt --write .",
54
+ "test": "vp test run",
55
+ "typecheck": "tsgo --noEmit"
53
56
  }
54
57
  }