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

Replace Slack with Rollbar #107

Merged
merged 1 commit into from
Nov 7, 2023
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
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ EMAIL_ALIASES="
[email protected], [email protected]
[email protected], [email protected]
"
SLACK_API_TOKEN=xoxb-PUT-REST-OF-TOKEN-IN
SLACK_NOTIFICATION_CHANNEL="dxw-breathe-productive-sync"

ROLLBAR_ACCESS_TOKEN=
ROLLBAR_ENVIRONMENT= # production | staging | development
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gem "dotenv"
gem "memo_wise"
gem "productive", "0.6.73"
gem "rake"
gem "slack-ruby-client"
gem "rollbar"

group :development do
gem "standard"
Expand Down
14 changes: 2 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
gli (2.21.1)
hashie (5.0.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
Expand Down Expand Up @@ -79,6 +77,7 @@ GEM
request_store (1.5.1)
rack (>= 1.4)
rexml (3.2.6)
rollbar (3.4.1)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand Down Expand Up @@ -113,12 +112,6 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
slack-ruby-client (1.0.0)
faraday (>= 1.0)
faraday_middleware
gli
hashie
websocket-driver
standard (1.32.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
Expand All @@ -134,9 +127,6 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
arm64-darwin-20
Expand All @@ -153,8 +143,8 @@ DEPENDENCIES
productive (= 0.6.73)
pry
rake
rollbar
rspec
slack-ruby-client
standard

RUBY VERSION
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ synchronising those different systems.
Within dxw this project is deployed and run on Heroku. Due to the sensitive
nature of the data, only a handful of people have access to it.

## Slack Integration

The app will post messages to a slack channel to report if it has encountered
an error. You will need to type `@Breathe Productive Sync` to add them to a new
channel.

You might need to get added to the collaborators list if you need to tweak the
bot's configuration:
https://app.slack.com/app-settings/T025PM7N0/A04U1KEJFKR/collaborators

## Manual usage

Normally you should be running this on a schedule eg on Heroku, but in case you
Expand Down
35 changes: 6 additions & 29 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
require "dotenv"
Dotenv.load

require "slack-ruby-client"

require_relative "lib/event/event"
require_relative "lib/event/event_collection"
require_relative "lib/person/person"
require_relative "lib/breathe_client"
require_relative "lib/productive_client"

Rollbar.configure do |config|
config.access_token = ENV.fetch("ROLLBAR_ACCESS_TOKEN")
config.environment = ENV.fetch("ROLLBAR_ENVIRONMENT")
end

def to_bool(arg)
return true if arg == true || arg =~ (/(true|t|yes|y|1)$/i)
return false if arg == false || arg =~ (/(false|f|no|n|0)$/i)
Expand All @@ -23,26 +26,6 @@ def email_aliases
.map { |line| line.strip.split(/\s*[,;]\s*/) }
end

def configure_slack
Slack.configure do |config|
config.token = ENV.fetch("SLACK_API_TOKEN")
end
Slack::Web::Client.new
end

def notify_slack(client, message)
message_json = message.to_json

client.chat_postMessage(
channel: ENV.fetch("SLACK_NOTIFICATION_CHANNEL"),
text: message,
blocks: %([
{"type": "section", "text": {"type": "mrkdwn", "text": #{message_json}}}
]),
as_user: true
)
end

namespace :productive do
desc "List all event types on Productive"
task :list_event_types do
Expand Down Expand Up @@ -104,13 +87,7 @@ namespace :breathe do

people_to_sync.each { |person| person.sync_breathe_to_productive(after: earliest_date) }
rescue => e
jdudley1123 marked this conversation as resolved.
Show resolved Hide resolved
slack_client = configure_slack
message = "There was a *#{e.class}* error with the Breathe/Productive Sync integration:\n" \
"```#{e.message}```\n" \
"Repository: https://github.com/dxw/scheduling-event-sync/"
notify_slack slack_client, message
backtrace = e.backtrace.reject { |x| x.include? "/bundle/ruby/" }
notify_slack slack_client, "Abbreviated stack trace:\n```" + backtrace.join("\n")[0..2975] + "```"
Rollbar.error(e)
raise
end

Expand Down