Skip to content

Commit f3277a7

Browse files
committed
int
1 parent a4ee189 commit f3277a7

File tree

27 files changed

+988
-1357
lines changed

27 files changed

+988
-1357
lines changed

apps/api/src/routes/query.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface AuthContext {
2828
user: { id: string; name: string; email: string } | null;
2929
isAuthenticated: boolean;
3030
authMethod: "api_key" | "session" | "none";
31-
};
31+
}
3232

3333
const AUTH_FAILED = new Response(
3434
JSON.stringify({
@@ -67,9 +67,9 @@ function getAccessibleWebsites(authCtx: AuthContext) {
6767
? eq(websites.organizationId, authCtx.apiKey.organizationId)
6868
: authCtx.apiKey.userId
6969
? and(
70-
eq(websites.userId, authCtx.apiKey.userId),
71-
isNull(websites.organizationId)
72-
)
70+
eq(websites.userId, authCtx.apiKey.userId),
71+
isNull(websites.organizationId)
72+
)
7373
: eq(websites.id, "");
7474
return db
7575
.select(select)
@@ -116,12 +116,12 @@ function getTimeUnit(
116116
type ParamInput =
117117
| string
118118
| {
119-
name: string;
120-
start_date?: string;
121-
end_date?: string;
122-
granularity?: string;
123-
id?: string;
124-
};
119+
name: string;
120+
start_date?: string;
121+
end_date?: string;
122+
granularity?: string;
123+
id?: string;
124+
};
125125

126126
function parseParam(p: ParamInput) {
127127
if (typeof p === "string") {
@@ -270,7 +270,7 @@ interface QueryResult {
270270
success: boolean;
271271
data: Record<string, unknown>[];
272272
error?: string;
273-
};
273+
}
274274

275275
async function runDynamicQuery(
276276
req: DynamicQueryRequestType,

apps/basket/src/utils/pixel.ts

Lines changed: 78 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,113 +6,112 @@ const FLOAT_REGEX = /^-?\d*\.\d+$/;
66

77
// 1x1 transparent GIF pixel (base64)
88
const TRANSPARENT_PIXEL = Buffer.from(
9-
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
10-
"base64"
9+
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
10+
"base64"
1111
);
1212

1313
/**
1414
* Returns a 1x1 transparent GIF response
1515
*/
1616
export function createPixelResponse(): Response {
17-
return new Response(TRANSPARENT_PIXEL, {
18-
status: 200,
19-
headers: {
20-
"Content-Type": "image/gif",
21-
"Cache-Control": "no-cache, no-store, must-revalidate",
22-
Pragma: "no-cache",
23-
Expires: "0",
24-
},
25-
});
17+
return new Response(TRANSPARENT_PIXEL, {
18+
status: 200,
19+
headers: {
20+
"Content-Type": "image/gif",
21+
"Cache-Control": "no-cache, no-store, must-revalidate",
22+
Pragma: "no-cache",
23+
Expires: "0",
24+
},
25+
});
2626
}
2727

2828
/**
2929
* Parses string values to appropriate types
3030
*/
3131
function parseValue(value: string): string | number | boolean {
32-
if (INTEGER_REGEX.test(value)) {
33-
return Number.parseInt(value, 10);
34-
}
35-
if (FLOAT_REGEX.test(value)) {
36-
return Number.parseFloat(value);
37-
}
38-
if (value === "true") {
39-
return true;
40-
}
41-
if (value === "false") {
42-
return false;
43-
}
44-
return value;
32+
if (INTEGER_REGEX.test(value)) {
33+
return Number.parseInt(value, 10);
34+
}
35+
if (FLOAT_REGEX.test(value)) {
36+
return Number.parseFloat(value);
37+
}
38+
if (value === "true") {
39+
return true;
40+
}
41+
if (value === "false") {
42+
return false;
43+
}
44+
return value;
4545
}
4646

4747
/**
4848
* Converts pixel query parameters back into event data structure
4949
* Handles nested keys like "key[subkey]" and JSON-stringified properties
5050
*/
5151
export function parsePixelQuery(query: Record<string, string>): {
52-
eventData: Record<string, unknown>;
53-
eventType: string;
52+
eventData: Record<string, unknown>;
53+
eventType: string;
5454
} {
55-
const result: Record<string, unknown> = {};
55+
const result: Record<string, unknown> = {};
5656

57-
for (const [key, value] of Object.entries(query)) {
58-
// Skip SDK metadata
59-
if (key === "sdk_name" || key === "sdk_version" || key === "client_id") {
60-
continue;
61-
}
57+
for (const [key, value] of Object.entries(query)) {
58+
// Skip SDK metadata
59+
if (key === "sdk_name" || key === "sdk_version" || key === "client_id") {
60+
continue;
61+
}
6262

63-
// Handle JSON-stringified properties
64-
if (key === "properties") {
65-
try {
66-
result.properties = JSON.parse(value);
67-
} catch {
68-
result.properties = {};
69-
}
70-
continue;
71-
}
63+
// Handle JSON-stringified properties
64+
if (key === "properties") {
65+
try {
66+
result.properties = JSON.parse(value);
67+
} catch {
68+
result.properties = {};
69+
}
70+
continue;
71+
}
7272

73-
const match = key.match(NESTED_KEY_REGEX);
74-
if (!match) {
75-
result[key] = parseValue(value);
76-
continue;
77-
}
73+
const match = key.match(NESTED_KEY_REGEX);
74+
if (!match) {
75+
result[key] = parseValue(value);
76+
continue;
77+
}
7878

79-
const baseKey = match[1];
80-
const nestedPath = match[2];
79+
const baseKey = match[1];
80+
const nestedPath = match[2];
8181

82-
if (!nestedPath) {
83-
result[baseKey] = parseValue(value);
84-
continue;
85-
}
82+
if (!nestedPath) {
83+
result[baseKey] = parseValue(value);
84+
continue;
85+
}
8686

87-
// Extract nested keys from brackets
88-
const nestedKeys =
89-
nestedPath.match(BRACKET_EXTRACT_REGEX)?.map((k) => k.slice(1, -1)) || [];
87+
// Extract nested keys from brackets
88+
const nestedKeys =
89+
nestedPath.match(BRACKET_EXTRACT_REGEX)?.map((k) => k.slice(1, -1)) || [];
9090

91-
if (nestedKeys.length === 0) {
92-
result[baseKey] = parseValue(value);
93-
continue;
94-
}
91+
if (nestedKeys.length === 0) {
92+
result[baseKey] = parseValue(value);
93+
continue;
94+
}
9595

96-
// Build nested structure
97-
if (!result[baseKey]) {
98-
result[baseKey] = {};
99-
}
96+
// Build nested structure
97+
if (!result[baseKey]) {
98+
result[baseKey] = {};
99+
}
100100

101-
let current = result[baseKey] as Record<string, unknown>;
102-
const lastIndex = nestedKeys.length - 1;
103-
for (let i = 0; i < lastIndex; i++) {
104-
const nestedKey = nestedKeys[i];
105-
if (!current[nestedKey]) {
106-
current[nestedKey] = {};
107-
}
108-
current = current[nestedKey] as Record<string, unknown>;
109-
}
110-
current[nestedKeys[lastIndex]] = parseValue(value);
111-
}
101+
let current = result[baseKey] as Record<string, unknown>;
102+
const lastIndex = nestedKeys.length - 1;
103+
for (let i = 0; i < lastIndex; i++) {
104+
const nestedKey = nestedKeys[i];
105+
if (!current[nestedKey]) {
106+
current[nestedKey] = {};
107+
}
108+
current = current[nestedKey] as Record<string, unknown>;
109+
}
110+
current[nestedKeys[lastIndex]] = parseValue(value);
111+
}
112112

113-
return {
114-
eventData: result,
115-
eventType: (result.type as string) || "track",
116-
};
113+
return {
114+
eventData: result,
115+
eventType: (result.type as string) || "track",
116+
};
117117
}
118-

apps/dashboard/app/(main)/websites/[id]/_components/utils/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export interface DateRange {
66
end_date: string;
77
granularity?: "hourly" | "daily";
88
timezone?: string;
9-
};
9+
}
1010

1111
export interface BaseTabProps {
1212
websiteId: string;
1313
dateRange: DateRange;
14-
};
14+
}
1515

1616
export type WebsiteData = ReturnType<typeof useWebsite>["data"];
1717

@@ -30,7 +30,7 @@ export interface MetricPoint {
3030
sessions?: number;
3131
bounce_rate?: number;
3232
[key: string]: string | number | undefined;
33-
};
33+
}
3434

3535
export interface TrackingOptions {
3636
disabled: boolean;
@@ -54,12 +54,12 @@ export interface TrackingOptions {
5454
enableBatching: boolean;
5555
batchSize: number;
5656
batchTimeout: number;
57-
};
57+
}
5858

5959
export interface TrackingOptionConfig {
6060
key: keyof TrackingOptions;
6161
title: string;
6262
description: string;
6363
data: string[];
6464
inverted?: boolean;
65-
};
65+
}

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-icons.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,31 @@ export const getErrorTypeIcon = (type: string) => {
2020
return <CodeIcon className="size-3.5 text-primary" weight="duotone" />;
2121
}
2222
if (lowerType.includes("network")) {
23-
return (
24-
<NetworkIcon className="size-3.5 text-primary" weight="duotone" />
25-
);
23+
return <NetworkIcon className="size-3.5 text-primary" weight="duotone" />;
2624
}
2725
if (lowerType.includes("script")) {
28-
return (
29-
<FileCodeIcon className="size-3.5 text-primary" weight="duotone" />
30-
);
26+
return <FileCodeIcon className="size-3.5 text-primary" weight="duotone" />;
3127
}
3228
if (lowerType.includes("syntax")) {
33-
return (
34-
<TerminalIcon className="size-3.5 text-primary" weight="duotone" />
35-
);
29+
return <TerminalIcon className="size-3.5 text-primary" weight="duotone" />;
3630
}
3731
return <BugIcon className="size-3.5 text-primary" weight="duotone" />;
3832
};
3933

4034
// Get device icon
4135
export const getDeviceIcon = (deviceType: string) => {
4236
if (!deviceType) {
43-
return (
44-
<MonitorIcon className="size-3.5 text-chart-2" weight="duotone" />
45-
);
37+
return <MonitorIcon className="size-3.5 text-chart-2" weight="duotone" />;
4638
}
4739

4840
switch (deviceType.toLowerCase()) {
4941
case "mobile":
50-
return (
51-
<PhoneIcon className="size-3.5 text-chart-2" weight="duotone" />
52-
);
42+
return <PhoneIcon className="size-3.5 text-chart-2" weight="duotone" />;
5343
case "tablet":
54-
return (
55-
<TableIcon className="size-3.5 text-chart-2" weight="duotone" />
56-
);
44+
return <TableIcon className="size-3.5 text-chart-2" weight="duotone" />;
5745
case "desktop":
58-
return (
59-
<LaptopIcon className="size-3.5 text-chart-2" weight="duotone" />
60-
);
46+
return <LaptopIcon className="size-3.5 text-chart-2" weight="duotone" />;
6147
default:
62-
return (
63-
<MonitorIcon className="size-3.5 text-chart-2" weight="duotone" />
64-
);
48+
return <MonitorIcon className="size-3.5 text-chart-2" weight="duotone" />;
6549
}
6650
};

apps/dashboard/app/(main)/websites/[id]/errors/_components/recent-errors-table.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ export const RecentErrorsTable = ({ recentErrors }: Props) => {
221221
}
222222

223223
return (
224-
<div className="flex items-center gap-1.5">
225-
<CountryFlag
226-
country={countryCode || countryName || ""}
227-
size={16}
228-
/>
229-
<span className="max-w-[80px] truncate text-sm">
230-
{countryName}
231-
</span>
232-
</div>
224+
<div className="flex items-center gap-1.5">
225+
<CountryFlag
226+
country={countryCode || countryName || ""}
227+
size={16}
228+
/>
229+
<span className="max-w-[80px] truncate text-sm">
230+
{countryName}
231+
</span>
232+
</div>
233233
);
234234
},
235235
},
@@ -246,10 +246,7 @@ export const RecentErrorsTable = ({ recentErrors }: Props) => {
246246
<Tooltip skipProvider>
247247
<TooltipTrigger asChild>
248248
<div className="flex items-center gap-1.5 text-muted-foreground">
249-
<ClockIcon
250-
className="size-3.5 shrink-0"
251-
weight="duotone"
252-
/>
249+
<ClockIcon className="size-3.5 shrink-0" weight="duotone" />
253250
<span className="whitespace-nowrap text-sm">{relative}</span>
254251
</div>
255252
</TooltipTrigger>

0 commit comments

Comments
 (0)