Mauricio Araujo 2 лет назад
Родитель
Сommit
44d1655a6f
1 измененных файлов с 6 добавлено и 5 удалено
  1. 6 5
      internal/billing/usage.go

+ 6 - 5
internal/billing/usage.go

@@ -380,13 +380,14 @@ func (m LagoClient) IngestEvents(ctx context.Context, subscriptionID string, eve
 		batch := events[i:end]
 		var batchInput []lago.EventInput
 		for i := range batch {
+			projectID, err := strconv.ParseUint(batch[i].CustomerID, 10, 64)
+			if err != nil {
+				return telemetry.Error(ctx, span, err, "failed to parse project id")
+			}
+
 			if enableSandbox {
 				// For Porter Cloud, we can't infer the project ID from the request, so we
-				// instead extract it from the billing events
-				projectID, err := strconv.ParseUint(batch[i].CustomerID, 10, 64)
-				if err != nil {
-					return telemetry.Error(ctx, span, err, "failed to parse project id")
-				}
+				// instead use the one in the billing event
 				subscriptionID = m.generateLagoID(SubscriptionIDPrefix, uint(projectID), enableSandbox)
 			}