File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
packages/service-utils/src/node Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @thirdweb-dev/service-utils " : patch
3
+ ---
4
+
5
+ [ service-utils] trim project ID prefix
Original file line number Diff line number Diff line change 6
6
} from "../core/usageV2.js" ;
7
7
import { KafkaProducer } from "./kafka.js" ;
8
8
9
+ const TEAM_ID_PREFIX = "team_" ;
10
+ const PROJECT_ID_PREFIX = "prj_" ;
11
+
9
12
/**
10
13
* Creates a UsageV2Producer which opens a persistent TCP connection.
11
14
* This class is thread-safe so your service should re-use one instance.
@@ -65,9 +68,13 @@ export class UsageV2Producer {
65
68
// Default to now.
66
69
created_at : event . created_at ?? new Date ( ) ,
67
70
// Remove the "team_" prefix, if any.
68
- team_id : event . team_id . startsWith ( "team_" )
69
- ? event . team_id . slice ( 5 )
71
+ team_id : event . team_id . startsWith ( TEAM_ID_PREFIX )
72
+ ? event . team_id . slice ( TEAM_ID_PREFIX . length )
70
73
: event . team_id ,
74
+ // Remove the "prj_" prefix, if any.
75
+ project_id : event . project_id ?. startsWith ( PROJECT_ID_PREFIX )
76
+ ? event . project_id . slice ( PROJECT_ID_PREFIX . length )
77
+ : event . project_id ,
71
78
} ) ) ;
72
79
await this . kafkaProducer . send ( this . topic , parsedEvents ) ;
73
80
}
You can’t perform that action at this time.
0 commit comments