Skip to content

Commit 1db2c8a

Browse files
committed
fix: logging for track calls
1 parent ffad746 commit 1db2c8a

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

apps/api/src/hooks/request-logging.hook.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const getTrpcInput = (
1010
const input = path<any>(['query', 'input'], request);
1111
try {
1212
return typeof input === 'string' ? JSON.parse(input).json : input;
13-
} catch (e) {
13+
} catch {
1414
return undefined;
1515
}
1616
};
@@ -33,14 +33,26 @@ export async function requestLoggingHook(
3333
elapsed: reply.elapsedTime,
3434
});
3535
} else {
36-
request.log.info('request done', {
36+
const payload: {
37+
url: string;
38+
method: string;
39+
elapsed: number;
40+
headers: Record<string, string | string[] | undefined>;
41+
body?: unknown;
42+
} = {
3743
url: request.url,
3844
method: request.method,
3945
elapsed: reply.elapsedTime,
4046
headers: pick(
4147
['openpanel-client-id', 'openpanel-sdk-name', 'openpanel-sdk-version'],
4248
request.headers
4349
),
44-
});
50+
};
51+
52+
if (payload.url.startsWith('/track')) {
53+
payload.body = request.body;
54+
}
55+
56+
request.log.info('request done', payload);
4557
}
4658
}

biome.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
},
7373
"suspicious": {
7474
"noExplicitAny": "off",
75-
"noShadowRestrictedNames": "off"
75+
"noShadowRestrictedNames": "off",
76+
"useAwait": "off"
7677
},
7778
"security": {
7879
"noDangerouslySetInnerHtml": "off"

packages/sdks/sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export class OpenPanel {
175175
this.flush();
176176
}
177177

178-
if (Object.keys(payload).length > 1) {
178+
if (payload.profileId && Object.keys(payload).length > 1) {
179179
return this.send({
180180
type: 'identify',
181181
payload: {

0 commit comments

Comments
 (0)