Skip to content

Commit 000ef1a

Browse files
committed
fix: flag disabled percentage rollout
1 parent 1f32e96 commit 000ef1a

File tree

3 files changed

+8
-89
lines changed

3 files changed

+8
-89
lines changed

apps/api/src/routes/public/flags.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,17 @@ export function evaluateRule(rule: FlagRule, context: UserContext): boolean {
150150
return evaluateStringRule(context.email, rule);
151151
case 'property': {
152152
if (!rule.field) {
153+
if (typeof rule.value === 'number') {
154+
const userId = context.userId || context.email || 'anonymous';
155+
const hash = hashString(`percentage:${userId}`);
156+
const percentage = hash % 100;
157+
return percentage < rule.value;
158+
}
153159
return false;
154160
}
155161
const propertyValue = context.properties?.[rule.field];
156162
return evaluateValueRule(propertyValue, rule);
157163
}
158-
// case 'percentage': {
159-
// if (typeof rule.value !== 'number') {
160-
// return false;
161-
// }
162-
// const userId = context.userId || context.email || 'anonymous';
163-
// const hash = hashString(`percentage:${userId}`);
164-
// const percentage = hash % 100;
165-
// return percentage < rule.value;
166-
// }
167164
default:
168165
return false;
169166
}

apps/basket/src/routes/basket.ts

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,6 @@ async function insertCustomEvent(
351351
typeof customData.timestamp === 'number' ? customData.timestamp : now,
352352
};
353353

354-
console.log('🔍 INSERTING CUSTOM EVENT TO DATABASE:');
355-
console.log('📥 Raw input properties:', JSON.stringify(customData.properties, null, 2));
356-
console.log('📤 Final stored properties:', customEvent.properties);
357-
console.log('📊 Full event object:', JSON.stringify(customEvent, null, 2));
358-
console.log('---');
359-
360354
try {
361355
await clickHouse.insert({
362356
table: 'analytics.custom_events',
@@ -698,12 +692,6 @@ const app = new Elysia()
698692

699693
const parseResult = analyticsEventSchema.safeParse(body);
700694
if (!parseResult.success) {
701-
console.error(
702-
'Blocked event schema errors:',
703-
parseResult.error.issues,
704-
'Payload:',
705-
body
706-
);
707695
await logBlockedTraffic(
708696
request,
709697
body,
@@ -741,12 +729,6 @@ const app = new Elysia()
741729

742730
const parseResult = errorEventSchema.safeParse(body);
743731
if (!parseResult.success) {
744-
console.error(
745-
'Blocked event schema errors:',
746-
parseResult.error.issues,
747-
'Payload:',
748-
body
749-
);
750732
await logBlockedTraffic(
751733
request,
752734
body,
@@ -781,12 +763,6 @@ const app = new Elysia()
781763

782764
const parseResult = webVitalsEventSchema.safeParse(body);
783765
if (!parseResult.success) {
784-
console.error(
785-
'Blocked event schema errors:',
786-
parseResult.error.issues,
787-
'Payload:',
788-
body
789-
);
790766
await logBlockedTraffic(
791767
request,
792768
body,
@@ -807,20 +783,8 @@ const app = new Elysia()
807783
}
808784

809785
if (eventType === 'custom') {
810-
console.log('📨 RECEIVED SINGLE CUSTOM EVENT:');
811-
console.log('🎯 Event name:', body.name);
812-
console.log('📋 Properties:', JSON.stringify(body.properties, null, 2));
813-
console.log('📏 Properties count:', Object.keys(body.properties || {}).length);
814-
console.log('---');
815-
816786
const parseResult = customEventSchema.safeParse(body);
817787
if (!parseResult.success) {
818-
console.error(
819-
'Blocked event schema errors:',
820-
parseResult.error.issues,
821-
'Payload:',
822-
body
823-
);
824788
await logBlockedTraffic(
825789
request,
826790
body,
@@ -858,12 +822,6 @@ const app = new Elysia()
858822

859823
const parseResult = outgoingLinkSchema.safeParse(body);
860824
if (!parseResult.success) {
861-
console.error(
862-
'Blocked event schema errors:',
863-
parseResult.error.issues,
864-
'Payload:',
865-
body
866-
);
867825
await logBlockedTraffic(
868826
request,
869827
body,
@@ -946,12 +904,6 @@ const app = new Elysia()
946904

947905
const parseResult = analyticsEventSchema.safeParse(event);
948906
if (!parseResult.success) {
949-
console.error(
950-
'Blocked event schema errors:',
951-
parseResult.error.issues,
952-
'Payload:',
953-
event
954-
);
955907
await logBlockedTraffic(
956908
request,
957909
event,
@@ -1014,12 +966,6 @@ const app = new Elysia()
1014966

1015967
const parseResult = errorEventSchema.safeParse(event);
1016968
if (!parseResult.success) {
1017-
console.error(
1018-
'Blocked event schema errors:',
1019-
parseResult.error.issues,
1020-
'Payload:',
1021-
event
1022-
);
1023969
await logBlockedTraffic(
1024970
request,
1025971
event,
@@ -1073,12 +1019,6 @@ const app = new Elysia()
10731019

10741020
const parseResult = webVitalsEventSchema.safeParse(event);
10751021
if (!parseResult.success) {
1076-
console.error(
1077-
'Blocked event schema errors:',
1078-
parseResult.error.issues,
1079-
'Payload:',
1080-
event
1081-
);
10821022
await logBlockedTraffic(
10831023
request,
10841024
event,
@@ -1112,21 +1052,9 @@ const app = new Elysia()
11121052
};
11131053
}
11141054
}
1115-
if (eventType === 'custom') {
1116-
console.log('📦 RECEIVED BATCH CUSTOM EVENT:');
1117-
console.log('🎯 Event name:', event.name);
1118-
console.log('📋 Properties:', JSON.stringify(event.properties, null, 2));
1119-
console.log('📏 Properties count:', Object.keys(event.properties || {}).length);
1120-
console.log('---');
1121-
1055+
if (eventType === 'custom') {
11221056
const parseResult = customEventSchema.safeParse(event);
11231057
if (!parseResult.success) {
1124-
console.error(
1125-
'Blocked event schema errors:',
1126-
parseResult.error.issues,
1127-
'Payload:',
1128-
event
1129-
);
11301058
await logBlockedTraffic(
11311059
request,
11321060
event,
@@ -1184,12 +1112,6 @@ const app = new Elysia()
11841112

11851113
const parseResult = outgoingLinkSchema.safeParse(event);
11861114
if (!parseResult.success) {
1187-
console.error(
1188-
'Blocked event schema errors:',
1189-
parseResult.error.issues,
1190-
'Payload:',
1191-
event
1192-
);
11931115
await logBlockedTraffic(
11941116
request,
11951117
event,

infra/clickhouse/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
clickhouse:
33
image: clickhouse/clickhouse-server:25.6
44
container_name: clickhouse
5-
restart: unless-stopped
5+
restart: unless-bstopped
66
ports:
77
- "8123:8123" # HTTP interface
88
- "9000:9000" # TCP native protocol

0 commit comments

Comments
 (0)