Skip to content

Commit 44c9272

Browse files
Merge pull request #675 from DataDog/marcosaia/RUM-4495/validate-context
[RUM-4495] Validate context argument in SDK functions
2 parents 99914f0 + 988a827 commit 44c9272

File tree

8 files changed

+1454
-104
lines changed

8 files changed

+1454
-104
lines changed

packages/core/src/logs/DdLogs.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
88
import { SdkVerbosity } from '../SdkVerbosity';
99
import type { DdNativeLogsType } from '../nativeModulesTypes';
10+
import { validateContext } from '../utils/argsUtils';
1011

1112
import { generateEventMapper } from './eventMapper';
1213
import type {
@@ -49,11 +50,11 @@ class DdLogsWrapper implements DdLogsType {
4950
args[1],
5051
args[2],
5152
args[3],
52-
args[4] || {},
53+
validateContext(args[4]),
5354
'debug'
5455
);
5556
}
56-
return this.log(args[0], args[1] || {}, 'debug');
57+
return this.log(args[0], validateContext(args[1]), 'debug');
5758
};
5859

5960
info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
@@ -63,11 +64,11 @@ class DdLogsWrapper implements DdLogsType {
6364
args[1],
6465
args[2],
6566
args[3],
66-
args[4] || {},
67+
validateContext(args[4]),
6768
'info'
6869
);
6970
}
70-
return this.log(args[0], args[1] || {}, 'info');
71+
return this.log(args[0], validateContext(args[1]), 'info');
7172
};
7273

7374
warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
@@ -77,11 +78,11 @@ class DdLogsWrapper implements DdLogsType {
7778
args[1],
7879
args[2],
7980
args[3],
80-
args[4] || {},
81+
validateContext(args[4]),
8182
'warn'
8283
);
8384
}
84-
return this.log(args[0], args[1] || {}, 'warn');
85+
return this.log(args[0], validateContext(args[1]), 'warn');
8586
};
8687

8788
error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
@@ -91,11 +92,11 @@ class DdLogsWrapper implements DdLogsType {
9192
args[1],
9293
args[2],
9394
args[3],
94-
args[4] || {},
95+
validateContext(args[4]),
9596
'error'
9697
);
9798
}
98-
return this.log(args[0], args[1] || {}, 'error');
99+
return this.log(args[0], validateContext(args[1]), 'error');
99100
};
100101

101102
/**

0 commit comments

Comments
 (0)