File tree Expand file tree Collapse file tree 5 files changed +49
-41
lines changed Expand file tree Collapse file tree 5 files changed +49
-41
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @thirdweb-dev/service-utils " : patch
3+ ---
4+
5+ [ service-utils] fix: Add missing CompressionCodecs import
Original file line number Diff line number Diff line change 2626 },
2727 "typesVersions" : {
2828 "*" : {
29- "node" : [
30- " ./dist/types/node/index.d.ts"
31- ],
32- "cf-worker" : [
33- " ./dist/types/cf-worker/index.d.ts"
34- ]
29+ "node" : [" ./dist/types/node/index.d.ts" ],
30+ "cf-worker" : [" ./dist/types/cf-worker/index.d.ts" ]
3531 }
3632 },
3733 "repository" : " https://github.com/thirdweb-dev/js/tree/main/packages/pay" ,
4036 "url" : " https://github.com/thirdweb-dev/js/issues"
4137 },
4238 "author" :
" thirdweb eng <[email protected] >" ,
43- "files" : [
44- " dist/"
45- ],
39+ "files" : [" dist/" ],
4640 "sideEffects" : false ,
4741 "dependencies" : {
4842 "aws4fetch" : " 1.0.20" ,
4943 "kafkajs" : " 2.2.4" ,
50- "lz4js" : " ^ 0.2.0" ,
44+ "lz4js" : " 0.2.0" ,
5145 "zod" : " 3.24.1"
5246 },
5347 "devDependencies" : {
5448 "@cloudflare/workers-types" : " 4.20250129.0" ,
55- "@types/lz4js" : " ^ 0.2.1" ,
49+ "@types/lz4js" : " 0.2.1" ,
5650 "@types/node" : " 22.13.0" ,
5751 "typescript" : " 5.7.3" ,
5852 "vitest" : " 3.0.4"
Original file line number Diff line number Diff line change 1- import type { ServiceName } from "../node/index.js" ;
1+ import type { ServiceName } from "./services.js" ;
2+
3+ export type UsageV2Source = ServiceName | "sdk" ;
24
35export interface UsageV2Event {
46 /**
@@ -53,6 +55,6 @@ export interface UsageV2Event {
5355 [ key : string ] : boolean | number | string | Date | null | undefined ;
5456}
5557
56- export function getTopicName ( productName : ServiceName ) {
57- return `usage_v2.raw_${ productName } ` ;
58+ export function getTopicName ( source : UsageV2Source ) {
59+ return `usage_v2.raw_${ source } ` ;
5860}
Original file line number Diff line number Diff line change 11import { randomUUID } from "node:crypto" ;
22import { checkServerIdentity } from "node:tls" ;
33import {
4- CompressionCodecs ,
54 CompressionTypes ,
65 Kafka ,
76 type Producer ,
87 type ProducerConfig ,
98} from "kafkajs" ;
109import { compress , decompress } from "lz4js" ;
11- import type { ServiceName } from "../core/services.js" ;
12- import { type UsageV2Event , getTopicName } from "../core/usageV2.js" ;
10+ import {
11+ type UsageV2Event ,
12+ type UsageV2Source ,
13+ getTopicName ,
14+ } from "../core/usageV2.js" ;
15+
16+ // CompressionCodecs is not exported properly in kafkajs. Source: https://github.com/tulios/kafkajs/issues/1391
17+ import KafkaJS from "kafkajs" ;
18+ const { CompressionCodecs } = KafkaJS ;
1319
1420/**
1521 * Creates a UsageV2Producer which opens a persistent TCP connection.
@@ -40,9 +46,9 @@ export class UsageV2Producer {
4046 */
4147 environment : "development" | "production" ;
4248 /**
43- * The product "source" where usage is coming from.
49+ * The product where usage is coming from.
4450 */
45- productName : ServiceName ;
51+ source : UsageV2Source ;
4652 /**
4753 * Whether to compress the events.
4854 */
@@ -54,7 +60,7 @@ export class UsageV2Producer {
5460 const {
5561 producerName,
5662 environment,
57- productName ,
63+ source ,
5864 shouldCompress = true ,
5965 username,
6066 password,
@@ -78,7 +84,7 @@ export class UsageV2Producer {
7884 } ,
7985 } ) ;
8086
81- this . topic = getTopicName ( productName ) ;
87+ this . topic = getTopicName ( source ) ;
8288 this . compression = shouldCompress
8389 ? CompressionTypes . LZ4
8490 : CompressionTypes . None ;
You can’t perform that action at this time.
0 commit comments