Skip to content

Commit

Permalink
Chore: Do not log integrations using name key (#26163)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego authored Jul 11, 2022
1 parent 8d2397a commit 786fd15
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions apps/meteor/app/integrations/server/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getIntegrationScript(integration) {
const script = integration.scriptCompiled;
const { sandbox, store } = buildSandbox();
try {
incomingLogger.info({ msg: 'Will evaluate script of Trigger', name: integration.name });
incomingLogger.info({ msg: 'Will evaluate script of Trigger', integration: integration.name });
incomingLogger.debug(script);

const vmScript = new VMScript(`${script}; Script;`, 'script.js');
Expand All @@ -89,20 +89,20 @@ function getIntegrationScript(integration) {
} catch (err) {
incomingLogger.error({
msg: 'Error evaluating Script in Trigger',
name: integration.name,
integration: integration.name,
script,
err,
});
throw API.v1.failure('error-evaluating-script');
}

incomingLogger.error({ msg: 'Class "Script" not in Trigger', name: integration.name });
incomingLogger.error({ msg: 'Class "Script" not in Trigger', integration: integration.name });
throw API.v1.failure('class-script-not-found');
}

function createIntegration(options, user) {
incomingLogger.info({ msg: 'Add integration', name: options.name });
incomingLogger.debug(options);
incomingLogger.info({ msg: 'Add integration', integration: options.name });
incomingLogger.debug({ options });

Meteor.runAsUser(user._id, function () {
switch (options.event) {
Expand Down Expand Up @@ -139,7 +139,7 @@ function createIntegration(options, user) {

function removeIntegration(options, user) {
incomingLogger.info('Remove integration');
incomingLogger.debug(options);
incomingLogger.debug({ options });

const integrationToRemove = Promise.await(Integrations.findOneByUrl(options.target_url));
if (!integrationToRemove) {
Expand All @@ -152,7 +152,7 @@ function removeIntegration(options, user) {
}

function executeIntegrationRest() {
incomingLogger.info({ msg: 'Post integration:', name: this.integration.name });
incomingLogger.info({ msg: 'Post integration:', integration: this.integration.name });
incomingLogger.debug({ urlParams: this.urlParams, bodyParams: this.bodyParams });

if (this.integration.enabled !== true) {
Expand Down Expand Up @@ -230,7 +230,7 @@ function executeIntegrationRest() {
if (!result) {
incomingLogger.debug({
msg: 'Process Incoming Request result of Trigger has no data',
name: this.integration.name,
integration: this.integration.name,
});
return API.v1.success();
}
Expand All @@ -246,13 +246,13 @@ function executeIntegrationRest() {

incomingLogger.debug({
msg: 'Process Incoming Request result of Trigger',
name: this.integration.name,
integration: this.integration.name,
result: this.bodyParams,
});
} catch (err) {
incomingLogger.error({
msg: 'Error running Script in Trigger',
name: this.integration.name,
integration: this.integration.name,
script: this.integration.scriptCompiled,
err,
});
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/app/integrations/server/lib/triggerHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class RocketChatIntegrationHandler {
const { store, sandbox } = this.buildSandbox();

try {
outgoingLogger.info({ msg: 'Will evaluate script of Trigger', name: integration.name });
outgoingLogger.info({ msg: 'Will evaluate script of Trigger', integration: integration.name });
outgoingLogger.debug(script);

const vmScript = new VMScript(`${script}; Script;`, 'script.js');
Expand All @@ -296,7 +296,7 @@ export class RocketChatIntegrationHandler {
} catch (err) {
outgoingLogger.error({
msg: 'Error evaluating Script in Trigger',
name: integration.name,
integration: integration.name,
script,
err,
});
Expand Down Expand Up @@ -385,12 +385,12 @@ export class RocketChatIntegrationHandler {
});
outgoingLogger.error({
msg: 'Error running Script in the Integration',
name: integration.name,
integration: integration.name,
err,
});
outgoingLogger.debug({
msg: 'Error running Script in the Integration',
name: integration.name,
integration: integration.name,
script: integration.scriptCompiled,
}); // Only output the compiled script if debugging is enabled, so the logs don't get spammed.
}
Expand Down Expand Up @@ -708,7 +708,7 @@ export class RocketChatIntegrationHandler {
this.updateHistory({ historyId, step: 'mapped-args-to-data', data, triggerWord: word });

outgoingLogger.info(`Will be executing the Integration "${trigger.name}" to the url: ${url}`);
outgoingLogger.debug(data);
outgoingLogger.debug({ data });

let opts = {
params: {},
Expand Down

0 comments on commit 786fd15

Please sign in to comment.