@entrolytics/api-client 2.1.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/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/index.cjs +1575 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1917 -0
- package/dist/index.d.ts +1917 -0
- package/dist/index.js +1520 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Entrolytics
|
|
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
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @entrolytics/api-client
|
|
2
|
+
|
|
3
|
+
TypeScript API client for Entrolytics - First-party growth analytics for the edge.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
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
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { EntrolyticsClient } from '@entrolytics/api-client';
|
|
19
|
+
|
|
20
|
+
const client = new EntrolyticsClient({
|
|
21
|
+
apiKey: 'your-api-key',
|
|
22
|
+
apiUrl: 'https://api.entrolytics.click', // optional
|
|
23
|
+
});
|
|
24
|
+
|
|
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
|
+
});
|
|
34
|
+
|
|
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
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
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
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
### Constructor Options
|
|
55
|
+
|
|
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)
|
|
60
|
+
|
|
61
|
+
### Methods
|
|
62
|
+
|
|
63
|
+
#### `track(data: TrackEventData): Promise<void>`
|
|
64
|
+
|
|
65
|
+
Track a single event.
|
|
66
|
+
|
|
67
|
+
#### `trackBatch(events: TrackEventData[]): Promise<void>`
|
|
68
|
+
|
|
69
|
+
Track multiple events in a single request.
|
|
70
|
+
|
|
71
|
+
#### `analytics.getOverview(params): Promise<AnalyticsOverview>`
|
|
72
|
+
|
|
73
|
+
Get overview analytics for a website.
|
|
74
|
+
|
|
75
|
+
#### `analytics.getTopPages(params): Promise<TopPage[]>`
|
|
76
|
+
|
|
77
|
+
Get top pages by pageviews.
|
|
78
|
+
|
|
79
|
+
#### `analytics.getTopReferrers(params): Promise<TopReferrer[]>`
|
|
80
|
+
|
|
81
|
+
Get top referrers.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT © Entrolytics
|