(organizationId: string)
| 149 | ); |
| 150 | |
| 151 | const trackExecution = (organizationId: string) => |
| 152 | Effect.gen(function* () { |
| 153 | yield* Effect.annotateCurrentSpan({ "autumn.customer.id": organizationId }); |
| 154 | yield* withProvisionedCustomer( |
| 155 | organizationId, |
| 156 | use((c) => c.track({ customerId: organizationId, featureId: "executions", value: 1 })), |
| 157 | ).pipe( |
| 158 | Effect.catch((error) => |
| 159 | Effect.gen(function* () { |
| 160 | // Silent billing data loss is worth paging on: autumn.trackExecution |
| 161 | // is fire-and-forget so the caller doesn't handle it themselves. |
| 162 | yield* Effect.sync(() => { |
| 163 | console.error("[billing] track failed:", error); |
| 164 | }); |
| 165 | yield* captureCauseEffect(error); |
| 166 | yield* Effect.annotateCurrentSpan({ "autumn.track.failed": true }); |
| 167 | }), |
| 168 | ), |
| 169 | ); |
| 170 | }).pipe(Effect.withSpan("autumn.trackExecution")); |
| 171 | |
| 172 | const checkExecutionBalance = (organizationId: string) => |
| 173 | Effect.gen(function* () { |
nothing calls this directly
no test coverage detected