| ... | ... | @@ -70,34 +70,35 @@ const makeAnalyticsService = Effect.gen(function* () { |
| 70 | 70 | }), |
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | | const sendBatch = (events: ReadonlyArray<BufferedAnalyticsEvent>) => |
| 74 | | Effect.gen(function* () { |
| 75 | | if (!telemetryConfig.enabled || !identifier) return; |
| 76 | | |
| 77 | | const payload = { |
| 78 | | api_key: telemetryConfig.posthogKey, |
| 79 | | batch: events.map((event) => ({ |
| 80 | | event: event.event, |
| 81 | | distinct_id: identifier, |
| 82 | | properties: { |
| 83 | | ...event.properties, |
| 84 | | $process_person_profile: false, |
| 85 | | platform: process.platform, |
| 86 | | wsl: process.env.WSL_DISTRO_NAME, |
| 87 | | arch: process.arch, |
| 88 | | t3CodeVersion: version, |
| 89 | | clientType, |
| 90 | | }, |
| 91 | | timestamp: event.capturedAt, |
| 92 | | })), |
| 93 | | }; |
| 94 | | |
| 95 | | yield* HttpClientRequest.post(`${telemetryConfig.posthogHost}/batch/`).pipe( |
| 96 | | HttpClientRequest.bodyJson(payload), |
| 97 | | Effect.flatMap(httpClient.execute), |
| 98 | | Effect.flatMap(HttpClientResponse.filterStatusOk), |
| 99 | | ); |
| 100 | | }); |
| 73 | const sendBatch = Effect.fn("sendBatch")(function* ( |
| 74 | events: ReadonlyArray<BufferedAnalyticsEvent>, |
| 75 | ) { |
| 76 | if (!telemetryConfig.enabled || !identifier) return; |
| 77 | |
| 78 | const payload = { |
| 79 | api_key: telemetryConfig.posthogKey, |
| 80 | batch: events.map((event) => ({ |
| 81 | event: event.event, |
| 82 | distinct_id: identifier, |
| 83 | properties: { |
| 84 | ...event.properties, |
| 85 | $process_person_profile: false, |
| 86 | platform: process.platform, |
| 87 | wsl: process.env.WSL_DISTRO_NAME, |
| 88 | arch: process.arch, |
| 89 | t3CodeVersion: version, |
| 90 | clientType, |
| 91 | }, |
| 92 | timestamp: event.capturedAt, |
| 93 | })), |
| 94 | }; |
| 95 | |
| 96 | yield* HttpClientRequest.post(`${telemetryConfig.posthogHost}/batch/`).pipe( |
| 97 | HttpClientRequest.bodyJson(payload), |
| 98 | Effect.flatMap(httpClient.execute), |
| 99 | Effect.flatMap(HttpClientResponse.filterStatusOk), |
| 100 | ); |
| 101 | }); |
| 101 | 102 | |
| 102 | 103 | const flush: AnalyticsServiceShape["flush"] = Effect.gen(function* () { |
| 103 | 104 | while (true) { |