Skip to content

Commit 1328016

Browse files
committed
linting, etc
1 parent a2c10e7 commit 1328016

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/core/src/ourlogs.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function addLog(log: Log): void {
2929
return;
3030
}
3131

32-
// if (!client.getOptions()._experiments?.logSupport) {
33-
// return;
34-
// }
32+
if (!client.getOptions()._experiments?.logSupport) {
33+
return;
34+
}
3535

3636
const globalScope = getGlobalScope();
3737
const dsn = client.getDsn();
@@ -99,16 +99,24 @@ function valueToAttribute(key: string, value: unknown): LogAttribute {
9999
* A utility function to be able to create methods like Sentry.info`...`
100100
*
101101
* The first parameter is bound with, e.g., const info = captureLog.bind(null, 'info')
102-
* The other parameters are in the format to be passed a template, Sentry.info`hello ${world}`
102+
* The other parameters are in the format to be passed a tagged template, Sentry.info`hello ${world}`
103103
*/
104104
export function captureLog(level: LogSeverityLevel, messages: string[] | string, ...values: unknown[]): void {
105105
const message = Array.isArray(messages) ? messages.reduce((acc, str, i) => acc + str + (values[i] ?? ''), '') : messages;
106-
106+
const attributes = values.map<LogAttribute>((value, index) => valueToAttribute(`param${index}`, value));
107+
if (Array.isArray(messages)) {
108+
attributes.push({
109+
key: 'sentry.template',
110+
value: {
111+
stringValue: messages.map((s, i) => s + (i < messages.length - 1 ? `$param${i}` : '')).join('')
112+
}
113+
})
114+
}
107115
addLog({
108116
severityText: level,
109117
body: {
110118
stringValue: message,
111119
},
112-
attributes: values.map<LogAttribute>((value, index) => valueToAttribute(`param${index}`, value)),
120+
attributes: attributes,
113121
})
114122
}

packages/core/src/types-hoist/envelope.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { ReplayEvent, ReplayRecordingData } from './replay';
1010
import type { SdkInfo } from './sdkinfo';
1111
import type { SerializedSession, SessionAggregates } from './session';
1212
import type { SpanJSON } from './span';
13-
import { Log } from './ourlogs';
13+
import type { Log } from './ourlogs';
1414

1515
// Based on: https://develop.sentry.dev/sdk/envelopes/
1616

0 commit comments

Comments
 (0)