File tree Expand file tree Collapse file tree 4 files changed +23
-11
lines changed Expand file tree Collapse file tree 4 files changed +23
-11
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 5252 },
5353 "devDependencies" : {
5454 "@cloudflare/workers-types" : " 4.20250129.0" ,
55- "@types/lz4js" : " ^0.2.1" ,
5655 "@types/node" : " 22.13.0" ,
5756 "typescript" : " 5.7.3" ,
5857 "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