Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: stop v1 analytics - cli-569 #5568

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions cliv2/cmd/cliv2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,29 +227,6 @@ func getErrorFromWorkFlowData(engine workflow.Engine, data []workflow.Data) erro
return nil
}

func sendAnalytics(analytics analytics.Analytics, debugLogger *zerolog.Logger) {
debugLogger.Print("Sending Analytics")

res, err := analytics.Send()
if err != nil {
debugLogger.Err(err).Msg("Failed to send Analytics")
return
}
defer res.Body.Close()

successfullySend := 200 <= res.StatusCode && res.StatusCode < 300
if successfullySend {
debugLogger.Print("Analytics successfully send")
} else {
var details string
if res != nil {
details = res.Status
}

debugLogger.Print("Failed to send Analytics:", details)
}
}

func sendInstrumentation(eng workflow.Engine, instrumentor analytics.InstrumentationCollector, logger *zerolog.Logger) {
// Avoid duplicate data to be sent for IDE integrations that use the CLI
if !shallSendInstrumentation(eng.GetConfiguration(), instrumentor) {
Expand Down Expand Up @@ -577,10 +554,6 @@ func MainWithErrorCode() int {
if exitCode == 2 {
cliAnalytics.GetInstrumentation().SetStatus(analytics.Failure)
}

if !globalConfiguration.GetBool(configuration.ANALYTICS_DISABLED) {
sendAnalytics(cliAnalytics, globalLogger)
}
sendInstrumentation(globalEngine, cliAnalytics.GetInstrumentation(), globalLogger)

// cleanup resources in use
Expand Down
7 changes: 1 addition & 6 deletions src/lib/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import stripAnsi = require('strip-ansi');
import { getAuthHeader, someTokenExists } from '../api-token';
import config from '../config';
import { makeRequest } from '../request';
import { config as userConfig } from '../user-config';
import { getStandardData } from './getStandardData';

// Add flags whose values should be redacted in analytics here.
Expand Down Expand Up @@ -56,11 +55,7 @@ export function addDataAndSend(
}

export function allowAnalytics(): boolean {
if (userConfig.get('disable-analytics') || config.DISABLE_ANALYTICS) {
return false;
} else {
return true;
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,38 +112,4 @@ describe('Mail API', function () {
}).catch(done);
});
});

describe.skip('Stub', function () {
it('returns a success', function (done) {
config.set({mail: {transport: 'stub'}});

mailer.init().then(function () {
mailer.transport.transportType.should.eql('STUB');
return MailAPI.send(mailDataNoServer, testUtils.context.internal);
}).then(function (response) {
should.exist(response.mail);
should.exist(response.mail[0].message);
should.exist(response.mail[0].status);
response.mail[0].status.should.eql({message: 'Message Queued'});
response.mail[0].message.subject.should.eql('testemail');
done();
}).catch(done);
});

it('returns a boo boo', function (done) {
config.set({mail: {transport: 'stub', error: 'Stub made a boo boo :('}});

mailer.init().then(function () {
mailer.transport.transportType.should.eql('STUB');
return MailAPI.send(mailDataNoServer, testUtils.context.internal);
}).then(function (response) {
console.log('res', response.mail[0]);
done(new Error('Stub did not error'));
}, function (error) {
error.message.should.startWith('Email Error: Failed sending email: there is no mail server at this address');
error.errorType.should.eql('EmailError');
done();
}).catch(done);
});
});
});
Loading
Loading