Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions src/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.constant('GOOGLE_APPID')
.constant('INTERCOM_APPID')
.constant('LIVE_APPID')
.constant('SLACK_APPID')
.constant('STRIPE_PUBLISHABLE_KEY')
.constant('SYSTEM_NOTIFICATION_MESSAGE')
.constant('USE_HTML5_MODE', false)
Expand Down
3 changes: 2 additions & 1 deletion src/app/app-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

angular.module('app')
.controller('App', function ($rootScope, $scope, $state, $stateParams, $window, authService, billingService, $ExceptionlessClient, filterService, hotkeys, INTERCOM_APPID, $intercom, locker, notificationService, organizationService, signalRService, stateService, STRIPE_PUBLISHABLE_KEY, urlService, userService) {
.controller('App', function ($rootScope, $scope, $state, $stateParams, $window, authService, billingService, $ExceptionlessClient, filterService, hotkeys, INTERCOM_APPID, $intercom, locker, notificationService, organizationService, signalRService, stateService, SLACK_APPID, STRIPE_PUBLISHABLE_KEY, urlService, userService) {
var vm = this;
function addHotkeys() {
function logFeatureUsage(name) {
Expand Down Expand Up @@ -265,6 +265,7 @@
vm.getUser = getUser;
vm.isMenuActive = {};
vm.isIntercomEnabled = isIntercomEnabled;
vm.isSlackEnabled = !!SLACK_APPID;
vm.isSideNavCollapsed = vm._store.get('sideNavCollapsed') === true;
vm.organizations = [];
vm.showIntercom = showIntercom;
Expand Down
65 changes: 64 additions & 1 deletion src/app/project/manage/manage-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@
return dialogs.create('app/project/manage/add-configuration-dialog.tpl.html', 'AddConfigurationDialog as vm', vm.config).result.then(saveClientConfiguration).catch(function(e){});
}

function addSlack() {
if (!vm.hasPremiumFeatures) {
return billingService.confirmUpgradePlan("Please upgrade your plan to enable slack integration.", vm.project.organization_id).then(function () {
return addSlackIntegration();
}).catch(function(e){});
}

return addSlackIntegration();
}

function addSlackIntegration() {
function onFailure() {
notificationService.error('An error occurred while adding Slack to your project.');
}

return projectService.addSlack(vm._projectId).catch(onFailure);
}

function addToken() {
function onFailure() {
notificationService.error('An error occurred while creating a new API key for your project.');
Expand Down Expand Up @@ -58,7 +76,7 @@
return;
}

return getProject().then(getOrganization).then(getConfiguration).then(getTokens).then(getWebHooks);
return getProject().then(getOrganization).then(getConfiguration).then(getTokens).then(getSlackNotificationSettings).then(getWebHooks);
}

function getOrganization() {
Expand Down Expand Up @@ -182,6 +200,20 @@
return projectService.getConfig(vm._projectId).then(onSuccess, onFailure);
}

function getSlackNotificationSettings() {
function onSuccess(response) {
vm.slackNotificationSettings = response.data.plain();
return vm.slackNotificationSettings;
}

function onFailure() {
notificationService.error('An error occurred while loading the slack notification settings.');
}

vm.slackNotificationSettings = null;
return projectService.getIntegrationNotificationSettings(vm._projectId, 'slack').then(onSuccess, onFailure);
}

function getWebHooks() {
function onSuccess(response) {
vm.webHooks = response.data.plain();
Expand Down Expand Up @@ -222,6 +254,16 @@
}).catch(function(e){});
}

function removeSlack() {
return dialogService.confirmDanger('Are you sure you want to remove slack support?', 'REMOVE SLACK').then(function () {
function onFailure() {
notificationService.error('An error occurred while trying to remove slack.');
}

return projectService.removeSlack(vm._projectId).catch(onFailure);
}).catch(function(e){});
}

function removeToken(token) {
return dialogService.confirmDanger('Are you sure you want to delete this API key?', 'DELETE API KEY').then(function () {
function onFailure() {
Expand Down Expand Up @@ -336,6 +378,22 @@
}
}

function saveSlackNotificationSettings() {
function onFailure(response) {
if (response.status === 426) {
return billingService.confirmUpgradePlan(response.data.message, vm.project.organization_id).then(function () {
return saveSlackNotificationSettings();
}).catch(function(e){
return getSlackNotificationSettings();
});
}

notificationService.error('An error occurred while saving your slack notification settings.');
}

return projectService.setIntegrationNotificationSettings(vm._projectId, 'slack', vm.slackNotificationSettings).catch(onFailure);
}

function showChangePlanDialog() {
return billingService.changePlan(vm.project.organization_id).catch(function(e){});
}
Expand All @@ -359,6 +417,7 @@
this.$onInit = function $onInit() {
vm._ignoreRefresh = false;
vm._projectId = $stateParams.id;
vm.addSlack = addSlack;
vm.addToken = addToken;
vm.addConfiguration = addConfiguration;
vm.addWebHook = addWebHook;
Expand Down Expand Up @@ -462,6 +521,7 @@
vm.getOrganization = getOrganization;
vm.getTokens = getTokens;
vm.getWebHooks = getWebHooks;
vm.getSlackNotificationSettings = getSlackNotificationSettings;
vm.hasMonthlyUsage = true;
vm.hasPremiumFeatures = false;
vm.next_billing_date = moment().startOf('month').add(1, 'months').toDate();
Expand All @@ -471,6 +531,7 @@
vm.remainingEventLimit = 3000;
vm.removeConfig = removeConfig;
vm.removeProject = removeProject;
vm.removeSlack = removeSlack;
vm.removeToken = removeToken;
vm.removeWebHook = removeWebHook;
vm.resetData = resetData;
Expand All @@ -480,9 +541,11 @@
vm.saveCommonMethods = saveCommonMethods;
vm.saveDataExclusion = saveDataExclusion;
vm.saveDeleteBotDataEnabled = saveDeleteBotDataEnabled;
vm.saveSlackNotificationSettings = saveSlackNotificationSettings;
vm.saveUserAgents = saveUserAgents;
vm.saveUserNamespaces = saveUserNamespaces;
vm.showChangePlanDialog = showChangePlanDialog;
vm.slackNotificationSettings = null;
vm.tokens = [];
vm.user_agents = null;
vm.user_namespaces = null;
Expand Down
86 changes: 85 additions & 1 deletion src/app/project/manage/tabs/integrations.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,94 @@
<a ng-click="vm.showChangePlanDialog()">Upgrade now</a> to enable integrations!
</div>

<div ng-if="appVm.isSlackEnabled">
<h4>Slack</h4>

<div ng-if="vm.project.has_slack_integration">
<p>Choose how often you want to receive slack notifications for event occurrences in this project.</p>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.send_daily_summary"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Send daily project summary <strong>(Coming soon!)</strong>
</label>
</div>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.report_new_errors"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Notify me on new errors
</label>
</div>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.report_critical_errors"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Notify me on critical errors
</label>
</div>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.report_event_regressions"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Notify me on error regressions
</label>
</div>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.report_new_events"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Notify me on new events
</label>
</div>

<div class="checkbox">
<label class="checks">
<input type="checkbox"
ng-model="vm.slackNotificationSettings.report_critical_events"
ng-model-options="{ debounce: 500 }"
ng-change="vm.saveSlackNotificationSettings()">
<i></i>
Notify me on critical events
</label>
</div>
</div>

<p>
<a ng-if="!vm.project.has_slack_integration" ng-click="vm.addSlack()" class="btn btn-primary" role="button" title="Add to Slack">
<i class="fa fa-fw fa-slack"></i> Add Slack Notifications
</a>
<a ng-if="vm.project.has_slack_integration" ng-click="vm.removeSlack()" class="btn btn-danger" role="button" title="Remove Slack">
<i class="fa fa-fw fa-slack"></i> Remove Slack
</a>
</p>
</div>

<h4>Web hooks</h4>
<p>
The following web hooks will be called for this project. We also support
<a href="http://zapier.com/" target="_blank">Zapier</a> which allows
you to easily integrate Exceptionless with many different services (200+)
you to easily integrate Exceptionless with many different services (750+)
like JIRA, HipChat, Twilio, Basecamp and more.
</p>

Expand Down
2 changes: 2 additions & 0 deletions src/app_data/jobs/triggered/config/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function updateAppConfig() {
var googleAppId = process.env.Exceptionless_GoogleAppId ? process.env.Exceptionless_GoogleAppId : '';
var intercomId = process.env.Exceptionless_IntercomAppId ? process.env.Exceptionless_IntercomAppId : '';
var liveAppId = process.env.Exceptionless_MicrosoftAppId ? process.env.Exceptionless_MicrosoftAppId : '';
var slackAppId = process.env.Exceptionless_SlackAppId ? process.env.Exceptionless_SlackAppId : '';
var stripePubKey = process.env.Exceptionless_StripePublishableApiKey ? process.env.Exceptionless_StripePublishableApiKey : '';
var notificationMessage = process.env.Exceptionless_Message ? process.env.Exceptionless_Message : '';
var useHTML5Mode = process.env.Exceptionless_HTML5Mode ? process.env.Exceptionless_HTML5Mode === 'true' : false;
Expand All @@ -29,6 +30,7 @@ function updateAppConfig() {
' .constant("GOOGLE_APPID", "' + googleAppId + '")',
' .constant("INTERCOM_APPID", "' + intercomId + '")',
' .constant("LIVE_APPID", "' + liveAppId + '")',
' .constant("SLACK_APPID", "' + slackAppId + '")',
' .constant("STRIPE_PUBLISHABLE_KEY", "' + stripePubKey + '")',
' .constant("SYSTEM_NOTIFICATION_MESSAGE", "' + notificationMessage + '")',
' .constant("USE_HTML5_MODE", ' + useHTML5Mode + ')',
Expand Down
28 changes: 26 additions & 2 deletions src/components/project/project-service.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function () {
'use strict';

angular.module('exceptionless.project', ['restangular'])
.factory('projectService', function ($cacheFactory, $rootScope, Restangular) {
angular.module('exceptionless.project')
.factory('projectService', function ($auth, $cacheFactory, $rootScope, Restangular) {
var _cache = $cacheFactory('http:project');
$rootScope.$on('cache:clear', _cache.removeAll);
$rootScope.$on('cache:clear-project', _cache.removeAll);
Expand All @@ -20,6 +20,14 @@
RestangularConfigurer.setDefaultHttpFields({ cache: _cache });
});

function addSlack(id) {
function onSuccess(response) {
return Restangular.one('projects', id).post('slack', null, { code: response.code });
}

return $auth.link('slack').then(onSuccess);
}

function create(organizationId, name) {
return Restangular.all('projects').post({'organization_id': organizationId, 'name': name, delete_bot_data_enabled: true });
}
Expand Down Expand Up @@ -60,6 +68,10 @@
return _cachedRestangular.one('users', userId).one('projects', id).one('notifications').get();
}

function getIntegrationNotificationSettings(id, integration) {
return _cachedRestangular.one('projects', id).one(integration, 'notifications').get();
}

function isNameAvailable(organizationId, name) {
return Restangular.one('organizations', organizationId).one('projects', 'check-name').get({ name: encodeURIComponent(name) });
}
Expand All @@ -80,6 +92,10 @@
return Restangular.one('projects', id).one('data').remove({ key: key });
}

function removeSlack(id) {
return Restangular.one('projects', id).one('slack').remove();
}

function removeNotificationSettings(id, userId) {
return Restangular.one('users', userId).one('projects', id).one('notifications').remove();
}
Expand All @@ -104,24 +120,32 @@
return Restangular.one('users', userId).one('projects', id).post('notifications', settings);
}

function setIntegrationNotificationSettings(id, integration, settings) {
return Restangular.one('projects', id).one(integration).post('notifications', settings);
}

var service = {
addSlack: addSlack,
create: create,
demoteTab: demoteTab,
getAll: getAll,
getById: getById,
getByOrganizationId: getByOrganizationId,
getConfig: getConfig,
getNotificationSettings: getNotificationSettings,
getIntegrationNotificationSettings: getIntegrationNotificationSettings,
isNameAvailable: isNameAvailable,
promoteTab: promoteTab,
remove: remove,
removeConfig: removeConfig,
removeData: removeData,
removeNotificationSettings: removeNotificationSettings,
removeSlack: removeSlack,
resetData: resetData,
setConfig: setConfig,
setData: setData,
setNotificationSettings: setNotificationSettings,
setIntegrationNotificationSettings: setIntegrationNotificationSettings,
update: update
};
return service;
Expand Down
27 changes: 27 additions & 0 deletions src/components/project/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(function () {
'use strict';

angular.module('exceptionless.project', [
'restangular',
'satellizer',

'app.config'
])
.config(function ($authProvider, SLACK_APPID) {
if (SLACK_APPID) {
$authProvider.oauth2({
name: 'slack',
authorizationEndpoint: 'https://slack.com/oauth/authorize',
clientId: SLACK_APPID,
redirectUri: window.location.origin,
requiredUrlParams: ['client_id', 'scope'],
optionalUrlParams: ['redirect_uri', 'state', 'team'],
scope: ['incoming-webhook'],
scopeDelimiter: ' ',
display: 'popup',
popupOptions: { width: 580, height: 630 },
state: function () { return encodeURIComponent(Math.random().toString(36).substr(2)); }
});
}
});
}());
21 changes: 21 additions & 0 deletions src/components/satellizer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Sahat Yalkabov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading