Skip to content

Commit

Permalink
Merge pull request #112 from MindscapeHQ/add-utc-offset-to-payload
Browse files Browse the repository at this point in the history
Add utc offset to payload
  • Loading branch information
UberMouse authored Mar 15, 2017
2 parents 61c7a75 + 7c71205 commit b446304
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 1.4.0
## 1.5.0 (16/03/2017)

Features
- Send utcOffset with Raygun payload to calculate local server time in Raygun dashboard

## 1.4.0 (14/03/2017)

Features:
- Raygun API url is now configurable via `Configuration.api_url`
Expand Down
6 changes: 4 additions & 2 deletions lib/raygun/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ def build_payload_hash(exception_instance, env = {}, user = nil)
error: error_details(exception_instance),
userCustomData: exception_custom_data.merge(custom_data).merge(configured_custom_data),
tags: Raygun.configuration.tags.concat(tags).compact.uniq,
request: request_information(env)
request: request_information(env),
environment: {
utcOffset: Time.now.utc_offset / 3600
}
}

error_details.merge!(groupingKey: grouping_key) if grouping_key
Expand Down Expand Up @@ -250,6 +253,5 @@ def ip_address_from(env_hash)
def print_api_key_warning
$stderr.puts(NO_API_KEY_MESSAGE)
end

end
end
2 changes: 1 addition & 1 deletion lib/raygun/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Raygun
VERSION = "1.4.0"
VERSION = "1.5.0"
end
14 changes: 13 additions & 1 deletion test/unit/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def setup
super
@client = Raygun::Client.new
fake_successful_entry

# Force NZ time zone for utcOffset tests
ENV['TZ'] = 'UTC-13'
end

def test_api_key_required_message
Expand Down Expand Up @@ -57,6 +60,12 @@ def test_error_details_with_nil_message
assert_equal expected_message, @client.send(:error_details, e)[:message]
end

def test_utc_offset
expected = 13

assert_equal expected, @client.send(:build_payload_hash, test_exception, sample_env_hash)[:details][:environment][:utcOffset]
end

def test_inner_error_details
oe = TestException.new("A test message")
oe.set_backtrace(["/some/folder/some_file.rb:123:in `some_method_name'"])
Expand Down Expand Up @@ -178,7 +187,10 @@ def test_full_payload_hash
userCustomData: {},
tags: ["test"],
request: {},
groupingKey: grouping_key
groupingKey: grouping_key,
environment: {
utcOffset: 13
}
}
}

Expand Down

0 comments on commit b446304

Please sign in to comment.