Skip to content

Commit

Permalink
Modify payload directly and add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
theodoretan committed Mar 29, 2024
1 parent c3200bd commit fd7f92a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/cli-kit/src/public/node/monorail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ describe('monorail', () => {
const res = await publishMonorailEvent('fake_schema/0.0', {api_key: 'some-api-key'}, {baz: 'abc'})
expect(res.type).toEqual('ok')
expect(outputMock.debug()).toContain('"api_key": "****"')
expect(outputMock.debug()).not.toContain('some-api-key')
})
})
7 changes: 3 additions & 4 deletions packages/cli-kit/src/public/node/monorail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ export async function publishMonorailEvent<TSchemaId extends keyof Schemas, TPay
* @returns The payload with the api_key sanitized.
*/
function sanitizePayload<T extends object>(payload: T): T {
const result = {...payload}
if ('api_key' in result) {
result.api_key = '****'
if ('api_key' in payload) {
payload.api_key = '****'
}

return result
return payload
}

const buildHeaders = (currentTime: number) => {
Expand Down

0 comments on commit fd7f92a

Please sign in to comment.