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