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 66} from "../core/usageV2.js" ;
77import { KafkaProducer } from "./kafka.js" ;
88
9+ const TEAM_ID_PREFIX = "team_" ;
10+ const PROJECT_ID_PREFIX = "prj_" ;
11+
912/**
1013 * Creates a UsageV2Producer which opens a persistent TCP connection.
1114 * This class is thread-safe so your service should re-use one instance.
@@ -65,9 +68,13 @@ export class UsageV2Producer {
6568 // Default to now.
6669 created_at : event . created_at ?? new Date ( ) ,
6770 // 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 )
7073 : 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 ,
7178 } ) ) ;
7279 await this . kafkaProducer . send ( this . topic , parsedEvents ) ;
7380 }
You can’t perform that action at this time.
0 commit comments