@eventra_dev/eventra-sdk 0.1.2 → 0.1.3

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,194 +1,248 @@
1
1
  # Eventra SDK
2
2
 
3
- ![npm](https://img.shields.io/npm/v/@eventra/sdk)
4
- ![bundle size](https://img.shields.io/bundlephobia/minzip/@eventra/sdk)
5
- ![license](https://img.shields.io/npm/l/@eventra/sdk)
6
- ![types](https://img.shields.io/npm/types/@eventra/sdk)
3
+ [![npm version](https://img.shields.io/npm/v/@eventra_dev/eventra-sdk.svg)](https://www.npmjs.com/package/@eventra_dev/eventra-sdk)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@eventra_dev/eventra-sdk.svg)](https://www.npmjs.com/package/@eventra_dev/eventra-sdk)
5
+ [![TypeScript](https://img.shields.io/badge/typescript-ready-blue.svg)](https://www.typescriptlang.org/)
7
6
 
8
- Production-grade TypeScript SDK for tracking product events across **browser, server, and edge runtimes**.
7
+ Eventra SDK allows you to send **feature usage and product analytics events** to the Eventra platform.
9
8
 
10
- Eventra is designed for **deterministic ingestion**, batching efficiency, and near-zero runtime overhead.
9
+ It is designed to be:
10
+
11
+ * lightweight
12
+ * runtime-agnostic (Node.js / Browser / Bun / Deno)
13
+ * resilient (batching + retry)
14
+ * production-safe
11
15
 
12
16
  ---
13
17
 
14
- ## Features
18
+ # Installation
15
19
 
16
- - UUID v4 idempotency keys
17
- - Safe retry policy
18
- - Exponential backoff with jitter
19
- - sendBeacon support for browsers
20
- - Multi-runtime support (Browser / Node / Bun / Deno / Edge)
21
- - Optional multi-tab leader mode
22
- - Queue overflow protection
23
- - Zero dependencies
20
+ Install the SDK using your preferred package manager.
24
21
 
25
- ---
22
+ ### npm
23
+
24
+ ```bash
25
+ npm i @eventra_dev/eventra-sdk
26
+ ```
26
27
 
27
- ## Install
28
+ ### pnpm
28
29
 
29
30
  ```bash
30
- pnpm add @eventra/sdk
31
+ pnpm add @eventra_dev/eventra-sdk
31
32
  ```
32
33
 
33
- or
34
+ ### yarn
34
35
 
35
36
  ```bash
36
- npm install @eventra/sdk
37
+ yarn add @eventra_dev/eventra-sdk
37
38
  ```
38
39
 
39
40
  ---
40
41
 
41
- # Quick Start
42
-
43
- ## Browser
42
+ # Quick Start
44
43
 
45
44
  ```ts
46
- import { Eventra } from "@eventra/sdk";
45
+ import { Eventra } from "@eventra_dev/eventra-sdk";
47
46
 
48
- const tracker = new Eventra({
49
- apiKey: "YOUR_API_KEY"
47
+ const eventra = new Eventra({
48
+ apiKey: "your-api-key",
49
+ endpoint: "https://api.eventra.dev/api/v1/events"
50
50
  });
51
51
 
52
- tracker.track("checkout.completed", {
53
- userId: "user_123"
52
+ eventra.track("user_signup", {
53
+ userId: "user_123",
54
+ properties: {
55
+ plan: "pro"
56
+ }
54
57
  });
55
58
  ```
56
59
 
57
60
  ---
58
61
 
59
- ## Node / NestJS
62
+ # Basic Usage
60
63
 
61
64
  ```ts
62
- import { Eventra } from "@eventra/sdk";
65
+ import { Eventra } from "@eventra_dev/eventra-sdk";
63
66
 
64
- const tracker = new Eventra({
65
- apiKey: process.env.EVENTRA_API_KEY!
67
+ const client = new Eventra({
68
+ apiKey: "your-api-key",
69
+ endpoint: "https://api.eventra.dev/api/v1/events"
66
70
  });
67
71
 
68
- tracker.track("invoice.created", {
69
- userId: "user_123"
72
+ client.track("project_created", {
73
+ userId: "user_1",
74
+ properties: {
75
+ projectId: "proj_123"
76
+ }
70
77
  });
71
78
  ```
72
79
 
73
- ---
80
+ Events are automatically:
81
+
82
+ * batched
83
+ * retried
84
+ * flushed periodically
74
85
 
75
- # Configuration
86
+ ---
76
87
 
77
- | Option | Default |
78
- |------|------|
79
- | flushInterval | 2000 ms |
80
- | maxBatchSize | 50 |
81
- | maxRetries | 3 |
82
- | maxQueueSize | 10000 |
83
- | retryBaseDelayMs | 300 |
88
+ # Configuration
84
89
 
85
- Example:
90
+ You can configure the SDK behaviour:
86
91
 
87
92
  ```ts
88
- const tracker = new Eventra({
89
- apiKey: "API_KEY",
93
+ const eventra = new Eventra({
94
+ apiKey: "your-api-key",
95
+
96
+ endpoint: "https://api.eventra.dev/api/v1/events",
97
+
90
98
  flushInterval: 2000,
91
- maxBatchSize: 50
99
+ maxBatchSize: 50,
100
+ maxQueueSize: 10000,
101
+ maxRetries: 3
92
102
  });
93
103
  ```
94
104
 
105
+ ### Options
106
+
107
+ | option | description |
108
+ | ------------- | ---------------------------------- |
109
+ | apiKey | Project API key |
110
+ | endpoint | Event ingestion endpoint |
111
+ | flushInterval | Batch flush interval (ms) |
112
+ | maxBatchSize | Maximum events per batch |
113
+ | maxQueueSize | Maximum buffered events |
114
+ | maxRetries | Retry attempts for failed requests |
115
+
95
116
  ---
96
117
 
97
- # Reliability Model
118
+ # Browser Usage
98
119
 
99
- ### Idempotency
120
+ ```ts
121
+ import { Eventra } from "@eventra_dev/eventra-sdk";
100
122
 
101
- Each event receives a **UUID v4 idempotency key**, ensuring:
123
+ const eventra = new Eventra({
124
+ apiKey: "public-api-key",
125
+ endpoint: "https://api.eventra.dev/api/v1/events"
126
+ });
102
127
 
103
- - safe retries
104
- - duplicate suppression
105
- - multi-tab safety
128
+ eventra.track("page_view", {
129
+ properties: {
130
+ path: window.location.pathname
131
+ }
132
+ });
133
+ ```
106
134
 
107
- ---
135
+ The SDK automatically:
108
136
 
109
- ### Retry Policy
137
+ * batches events
138
+ * retries failed requests
139
+ * flushes on page exit
110
140
 
111
- The SDK retries only when safe:
141
+ ---
112
142
 
113
- network failures
114
- ✔ HTTP 5xx
143
+ # Node.js Usage
115
144
 
116
- It does **not retry**:
145
+ ```ts
146
+ import { Eventra } from "@eventra_dev/eventra-sdk";
147
+
148
+ const eventra = new Eventra({
149
+ apiKey: process.env.EVENTRA_API_KEY!,
150
+ endpoint: "https://api.eventra.dev/api/v1/events"
151
+ });
117
152
 
118
- HTTP 4xx
119
- validation errors
120
- authentication errors
153
+ eventra.track("job_completed", {
154
+ properties: {
155
+ duration: 120
156
+ }
157
+ });
158
+ ```
121
159
 
122
160
  ---
123
161
 
124
- ### Backoff Strategy
162
+ # Multi-tab Mode (Browser)
125
163
 
164
+ To avoid duplicate event sending across multiple tabs you can enable leader mode:
165
+
166
+ ```ts
167
+ const eventra = new Eventra({
168
+ apiKey: "your-api-key",
169
+ multiTabMode: "leader"
170
+ });
126
171
  ```
127
- delay = base * 2^attempt * jitter(0.5–1.5)
128
- ```
172
+
173
+ Only one tab will send events.
129
174
 
130
175
  ---
131
176
 
132
- # Multi-Tab Mode
177
+ # Manual Flush
133
178
 
134
- Default:
179
+ You can flush the queue manually:
135
180
 
136
181
  ```ts
137
- multiTabMode: "independent"
182
+ await eventra.flush();
138
183
  ```
139
184
 
140
- Leader mode:
185
+ ---
186
+
187
+ # Shutdown / Cleanup
141
188
 
142
189
  ```ts
143
- const tracker = new Eventra({
144
- apiKey: "API_KEY",
145
- multiTabMode: "leader"
146
- });
190
+ eventra.destroy();
147
191
  ```
148
192
 
149
- One tab becomes the sender and reduces duplicate traffic.
193
+ Stops timers and prevents further event sending.
150
194
 
151
195
  ---
152
196
 
153
- # Architecture
197
+ # Runtime Support
154
198
 
155
- ```
156
- Application
157
-
158
-
159
- Eventra SDK
160
-
161
- batching + retry
162
-
163
-
164
- Eventra Ingest API
165
-
166
- idempotent pipeline
167
-
168
-
169
- Eventra Event Store
199
+ The SDK works in:
200
+
201
+ * Node.js
202
+ * Browser
203
+ * Bun
204
+ * Deno
205
+ * Edge runtimes
206
+
207
+ ---
208
+
209
+ # Event Format
210
+
211
+ Events are sent in batches:
212
+
213
+ ```json
214
+ {
215
+ "sentAt": "2026-03-12T10:00:00Z",
216
+ "sdk": {
217
+ "name": "@eventra_dev/eventra-sdk",
218
+ "version": "0.1.2",
219
+ "runtime": "node"
220
+ },
221
+ "events": [
222
+ {
223
+ "name": "user_signup",
224
+ "userId": "user_123",
225
+ "timestamp": "2026-03-12T10:00:00Z",
226
+ "properties": {}
227
+ }
228
+ ]
229
+ }
170
230
  ```
171
231
 
172
232
  ---
173
233
 
174
- # Best Practices
234
+ # Error Handling
175
235
 
176
- Use semantic event names.
236
+ Client errors (4xx) are **not retried**.
237
+ Server errors (5xx) are retried with **exponential backoff**.
177
238
 
178
- Good:
239
+ ---
179
240
 
180
- ```
181
- invoice.created
182
- checkout.completed
183
- team.invited
184
- ```
241
+ # Documentation
185
242
 
186
- Bad:
243
+ Full documentation:
187
244
 
188
- ```
189
- button_clicked
190
- modal_opened
191
- ```
245
+ https://eventra.dev/docs
192
246
 
193
247
  ---
194
248
 
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ __export(index_exports, {
25
25
  module.exports = __toCommonJS(index_exports);
26
26
 
27
27
  // src/client.ts
28
- var SDK_VERSION = "0.1.2";
28
+ var SDK_VERSION = "0.1.3";
29
29
  var DEFAULTS = {
30
30
  endpoint: "http://api.eventra.dev/api/v1/ingest/batch",
31
31
  flushInterval: 2e3,
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/client.ts
2
- var SDK_VERSION = "0.1.2";
2
+ var SDK_VERSION = "0.1.3";
3
3
  var DEFAULTS = {
4
4
  endpoint: "http://api.eventra.dev/api/v1/ingest/batch",
5
5
  flushInterval: 2e3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"