···11+# Changelog
22+33+## [0.1.0] - 2025-11-28
44+55+Initial release.
66+77+### Added
88+99+- `AnalyticsClient` class for tracking events
1010+- `deriveUidFromDid` helper for anonymous user ID generation
1111+- Support for account, view, and action events
+80
README.md
···11+# Driftline Client
22+33+TypeScript client for
44+[Driftline Analytics](https://github.com/tijs/driftline-analytics) - anonymous
55+analytics for ATProto app views.
66+77+## Installation
88+99+```typescript
1010+// Deno / JSR
1111+import { AnalyticsClient, deriveUidFromDid } from "@tijs/driftline-client";
1212+1313+// Or via URL
1414+import {
1515+ AnalyticsClient,
1616+ deriveUidFromDid,
1717+} from "https://deno.land/x/driftline_client/mod.ts";
1818+```
1919+2020+## Usage
2121+2222+```typescript
2323+import { AnalyticsClient, deriveUidFromDid } from "@tijs/driftline-client";
2424+2525+// Derive anonymous user ID from DID (use your app-specific salt)
2626+const uid = await deriveUidFromDid(user.did, YOUR_APP_SALT);
2727+2828+const analytics = new AnalyticsClient({
2929+ appView: "kipclip.com",
3030+ env: "prod",
3131+ collectorUrl: "https://driftline.val.run",
3232+ apiKey: YOUR_API_KEY,
3333+ uid,
3434+});
3535+3636+// Track account creation (once per user)
3737+await analytics.trackAccountCreated();
3838+3939+// Track screen views
4040+await analytics.trackView("HomeScreen");
4141+4242+// Track actions
4343+await analytics.trackAction("checkin_created", "CheckinScreen", {
4444+ placeType: "cafe",
4545+});
4646+```
4747+4848+## API
4949+5050+### `deriveUidFromDid(did: string, salt: string): Promise<string>`
5151+5252+Derives a pseudonymous 12-character hex user ID from a DID using SHA-256.
5353+5454+- Same DID + salt always produces the same uid
5555+- Different salts produce different uids (for cross-app-view privacy)
5656+- Server never sees the original DID
5757+5858+### `AnalyticsClient`
5959+6060+#### Constructor
6161+6262+```typescript
6363+new AnalyticsClient({
6464+ appView: string; // Your app view identifier
6565+ env: "dev" | "prod"; // Environment
6666+ collectorUrl: string; // Driftline server URL
6767+ apiKey: string; // Your API key
6868+ uid: string; // User ID from deriveUidFromDid
6969+})
7070+```
7171+7272+#### Methods
7373+7474+- `trackAccountCreated(props?)` - Track account creation (once per user)
7575+- `trackView(screen, props?)` - Track screen impressions
7676+- `trackAction(name, screen?, props?)` - Track user actions
7777+7878+## License
7979+8080+MIT