@churndown/sdk 0.0.3 → 0.0.4
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 +19 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +4 -0
- package/dist/index.mjs +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,6 +81,25 @@ await churndown.track("user_123", "send-message", {
|
|
|
81
81
|
})
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### `churndown.importEvents(events)`
|
|
85
|
+
|
|
86
|
+
Import historical events to backfill data. Each event must include a `timestamp`.
|
|
87
|
+
|
|
88
|
+
| Parameter | Type | Required | Description |
|
|
89
|
+
|-----------|------|----------|-------------|
|
|
90
|
+
| `events[].userId` | `string` | Yes | The user's ID |
|
|
91
|
+
| `events[].event` | `string` | Yes | Event name |
|
|
92
|
+
| `events[].timestamp` | `string` | Yes | ISO 8601 timestamp |
|
|
93
|
+
| `events[].properties` | `Record<string, unknown>` | No | Any additional event data |
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
await churndown.importEvents([
|
|
97
|
+
{ userId: "user_123", event: "send-message", timestamp: "2026-01-15T10:30:00Z" },
|
|
98
|
+
{ userId: "user_123", event: "send-message", timestamp: "2026-02-01T14:22:00Z" },
|
|
99
|
+
{ userId: "user_456", event: "send-message", timestamp: "2026-02-10T09:15:00Z" },
|
|
100
|
+
])
|
|
101
|
+
```
|
|
102
|
+
|
|
84
103
|
## Frameworks
|
|
85
104
|
|
|
86
105
|
Works everywhere — server-side, client-side, edge functions, serverless. The SDK is just a thin `fetch` wrapper with no dependencies.
|
package/dist/index.d.mts
CHANGED
|
@@ -14,13 +14,22 @@ interface TrackParams {
|
|
|
14
14
|
event: string;
|
|
15
15
|
properties?: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
|
+
interface ImportEvent {
|
|
18
|
+
userId: string;
|
|
19
|
+
event: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
properties?: Record<string, unknown>;
|
|
22
|
+
}
|
|
17
23
|
declare class Churndown {
|
|
18
24
|
private apiKey;
|
|
19
25
|
private baseUrl;
|
|
20
26
|
constructor(apiKey: string, config?: Omit<ChurndownConfig, "apiKey">);
|
|
21
27
|
identify(params: IdentifyParams): Promise<void>;
|
|
22
28
|
track(userId: string, event: string, properties?: Record<string, unknown>): Promise<void>;
|
|
29
|
+
importEvents(events: ImportEvent[]): Promise<{
|
|
30
|
+
imported: number;
|
|
31
|
+
}>;
|
|
23
32
|
private post;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
export { Churndown, type ChurndownConfig, type IdentifyParams, type TrackParams, Churndown as default };
|
|
35
|
+
export { Churndown, type ChurndownConfig, type IdentifyParams, type ImportEvent, type TrackParams, Churndown as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,13 +14,22 @@ interface TrackParams {
|
|
|
14
14
|
event: string;
|
|
15
15
|
properties?: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
|
+
interface ImportEvent {
|
|
18
|
+
userId: string;
|
|
19
|
+
event: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
properties?: Record<string, unknown>;
|
|
22
|
+
}
|
|
17
23
|
declare class Churndown {
|
|
18
24
|
private apiKey;
|
|
19
25
|
private baseUrl;
|
|
20
26
|
constructor(apiKey: string, config?: Omit<ChurndownConfig, "apiKey">);
|
|
21
27
|
identify(params: IdentifyParams): Promise<void>;
|
|
22
28
|
track(userId: string, event: string, properties?: Record<string, unknown>): Promise<void>;
|
|
29
|
+
importEvents(events: ImportEvent[]): Promise<{
|
|
30
|
+
imported: number;
|
|
31
|
+
}>;
|
|
23
32
|
private post;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
export { Churndown, type ChurndownConfig, type IdentifyParams, type TrackParams, Churndown as default };
|
|
35
|
+
export { Churndown, type ChurndownConfig, type IdentifyParams, type ImportEvent, type TrackParams, Churndown as default };
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,10 @@ var Churndown = class {
|
|
|
39
39
|
async track(userId, event, properties) {
|
|
40
40
|
await this.post("/v1/track", { userId, event, properties });
|
|
41
41
|
}
|
|
42
|
+
async importEvents(events) {
|
|
43
|
+
const res = await this.post("/v1/import", { events });
|
|
44
|
+
return res;
|
|
45
|
+
}
|
|
42
46
|
async post(path, body) {
|
|
43
47
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
44
48
|
method: "POST",
|
package/dist/index.mjs
CHANGED
|
@@ -14,6 +14,10 @@ var Churndown = class {
|
|
|
14
14
|
async track(userId, event, properties) {
|
|
15
15
|
await this.post("/v1/track", { userId, event, properties });
|
|
16
16
|
}
|
|
17
|
+
async importEvents(events) {
|
|
18
|
+
const res = await this.post("/v1/import", { events });
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
17
21
|
async post(path, body) {
|
|
18
22
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
19
23
|
method: "POST",
|