- move `AnalyticsServiceLayerLive` from CLI runtime setup into `main` server layer - persist telemetry `anonymous-id` under configured `stateDir` instead of home directory - add `FetchHttpClient.layer` to `main.test.ts` test layer wiring
Unified · Split
| @@ -9,12 +9,10 @@ import { Command } from "effect/unstable/cli"; · 8 unmodified lines | ||
| 9 | 9 | import { version } from "../package.json" with { type: "json" }; |
| 10 | 10 | import { ServerLive } from "./wsServer"; |
| 11 | 11 | import { NetService } from "@t3tools/shared/Net"; |
| 12 | −import { AnalyticsServiceLayerLive } from "./telemetry/Layers/AnalyticsService"; | |
| 13 | 12 | import { FetchHttpClient } from "effect/unstable/http"; |
| 14 | 13 | |
| 15 | 14 | const RuntimeLayer = Layer.empty.pipe( |
| 16 | 15 | Layer.provideMerge(CliConfig.layer), |
| 17 | − Layer.provideMerge(AnalyticsServiceLayerLive), | |
| 18 | 16 | Layer.provideMerge(ServerLive), |
| 19 | 17 | Layer.provideMerge(OpenLive), |
| 20 | 18 | Layer.provideMerge(NetService.layer), |
| @@ -5,6 +5,7 @@ import * as ConfigProvider from "effect/ConfigProvider"; · 4 unmodified lines | ||
| 5 | 5 | import * as Effect from "effect/Effect"; |
| 6 | 6 | import * as Layer from "effect/Layer"; |
| 7 | 7 | import * as Command from "effect/unstable/cli/Command"; |
| 8 | +import { FetchHttpClient } from "effect/unstable/http"; | |
| 8 | 9 | import { beforeEach } from "vitest"; |
| 9 | 10 | import { NetService } from "@t3tools/shared/Net"; |
| 10 | 11 | |
| @@ -52,6 +53,7 @@ const testLayer = Layer.mergeAll( · 41 unmodified lines | ||
| 52 | 53 | record: () => Effect.void, |
| 53 | 54 | flush: Effect.void, |
| 54 | 55 | }), |
| 56 | + FetchHttpClient.layer, | |
| 55 | 57 | NodeServices.layer, |
| 56 | 58 | ); |
| 57 | 59 | |
| @@ -23,6 +23,7 @@ import { makeServerProviderLayer, makeServerRuntimeServicesLayer } from "./serve · 22 unmodified lines | ||
| 23 | 23 | import { ProviderHealthLive } from "./provider/Layers/ProviderHealth"; |
| 24 | 24 | import { Server } from "./wsServer"; |
| 25 | 25 | import { ServerLoggerLive } from "./serverLogger"; |
| 26 | +import { AnalyticsServiceLayerLive } from "./telemetry/Layers/AnalyticsService"; | |
| 26 | 27 | |
| 27 | 28 | export class StartupError extends Data.TaggedError("StartupError")<{ |
| 28 | 29 | readonly message: string; |
| @@ -197,6 +198,7 @@ const LayerLive = (input: CliInput) => · 168 unmodified lines | ||
| 197 | 198 | Layer.provideMerge(ProviderHealthLive), |
| 198 | 199 | Layer.provideMerge(SqlitePersistence.layerConfig), |
| 199 | 200 | Layer.provideMerge(ServerLoggerLive), |
| 201 | + Layer.provideMerge(AnalyticsServiceLayerLive), | |
| 200 | 202 | Layer.provideMerge(ServerConfigLive(input)), |
| 201 | 203 | ); |
| 202 | 204 | |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import { Effect, FileSystem, Path, Random, Schema } from "effect"; |
| 2 | 2 | import * as Crypto from "node:crypto"; |
| 3 | 3 | import { homedir } from "node:os"; |
| 4 | +import { ServerConfig } from "../config"; | |
| 4 | 5 | |
| 5 | 6 | const CodexAuthJsonSchema = Schema.Struct({ |
| 6 | 7 | tokens: Schema.Struct({ |
| @@ -39,8 +40,9 @@ const getCodexAccountId = Effect.gen(function* () { · 32 unmodified lines | ||
| 39 | 40 | const upsertAnonymousId = Effect.gen(function* () { |
| 40 | 41 | const fileSystem = yield* FileSystem.FileSystem; |
| 41 | 42 | const path = yield* Path.Path; |
| 43 | + const serverConfig = yield* ServerConfig; | |
| 42 | 44 | |
| 43 | − const anonymousIdPath = path.join(homedir(), ".t3", "telemetry", "anonymous-id"); | |
| 45 | + const anonymousIdPath = path.join(serverConfig.stateDir, "anonymous-id"); | |
| 44 | 46 | const anonymousId = yield* fileSystem.readFileString(anonymousIdPath).pipe( |
| 45 | 47 | Effect.catch(() => |
| 46 | 48 | Effect.gen(function* () { |