Skip to content

Commit

Permalink
Merge pull request #675 from DataDog/marcosaia/RUM-4495/validate-context
Browse files Browse the repository at this point in the history
[RUM-4495] Validate context argument in SDK functions
  • Loading branch information
marco-saia-datadog authored Jun 13, 2024
2 parents 99914f0 + 988a827 commit 44c9272
Show file tree
Hide file tree
Showing 8 changed files with 1,454 additions and 104 deletions.
17 changes: 9 additions & 8 deletions packages/core/src/logs/DdLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
import { SdkVerbosity } from '../SdkVerbosity';
import type { DdNativeLogsType } from '../nativeModulesTypes';
import { validateContext } from '../utils/argsUtils';

import { generateEventMapper } from './eventMapper';
import type {
Expand Down Expand Up @@ -49,11 +50,11 @@ class DdLogsWrapper implements DdLogsType {
args[1],
args[2],
args[3],
args[4] || {},
validateContext(args[4]),
'debug'
);
}
return this.log(args[0], args[1] || {}, 'debug');
return this.log(args[0], validateContext(args[1]), 'debug');
};

info = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
Expand All @@ -63,11 +64,11 @@ class DdLogsWrapper implements DdLogsType {
args[1],
args[2],
args[3],
args[4] || {},
validateContext(args[4]),
'info'
);
}
return this.log(args[0], args[1] || {}, 'info');
return this.log(args[0], validateContext(args[1]), 'info');
};

warn = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
Expand All @@ -77,11 +78,11 @@ class DdLogsWrapper implements DdLogsType {
args[1],
args[2],
args[3],
args[4] || {},
validateContext(args[4]),
'warn'
);
}
return this.log(args[0], args[1] || {}, 'warn');
return this.log(args[0], validateContext(args[1]), 'warn');
};

error = (...args: LogArguments | LogWithErrorArguments): Promise<void> => {
Expand All @@ -91,11 +92,11 @@ class DdLogsWrapper implements DdLogsType {
args[1],
args[2],
args[3],
args[4] || {},
validateContext(args[4]),
'error'
);
}
return this.log(args[0], args[1] || {}, 'error');
return this.log(args[0], validateContext(args[1]), 'error');
};

/**
Expand Down
Loading

0 comments on commit 44c9272

Please sign in to comment.