binnacle 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +26 -26
  4. data/lib/binnacle/client.rb +10 -6
  5. data/lib/binnacle/commands/tail.rb +23 -15
  6. data/lib/binnacle/logging/formatter.rb +3 -4
  7. data/lib/binnacle/resources/event.rb +19 -6
  8. data/lib/binnacle/trap/exception_event.rb +4 -6
  9. data/lib/binnacle/version.rb +1 -1
  10. data/spec/client_spec.rb +15 -41
  11. data/spec/commands_spec.rb +22 -12
  12. data/spec/logger_spec.rb +6 -1
  13. data/spec/vcr/binnacle_client/events_invokes_the_events_api.yml +52 -55
  14. data/spec/vcr/binnacle_client/events_returns_a_collection_of_event_objects.yml +52 -55
  15. data/spec/vcr/binnacle_client/recents_invokes_the_events_api_recents.yml +59 -22
  16. data/spec/vcr/binnacle_client/recents_returns_a_collection_of_event_objects.yml +98 -22
  17. data/spec/vcr/binnacle_client/report_exception_invokes_the_events_api_signal.yml +23 -24
  18. data/spec/vcr/binnacle_client/signal_asynch_invokes_the_events_api_signal.yml +26 -19
  19. data/spec/vcr/binnacle_client/signal_invokes_the_events_api_signal.yml +60 -15
  20. data/spec/vcr/binnacle_client_ready_/returns_true_if_a_connection_has_been_successfully_established.yml +45 -6
  21. data/spec/vcr/binnacle_command/requires_a_known_subcommand_argument.yml +42 -0
  22. data/spec/vcr/binnacle_command/tail_command_validates_the_passed_params_before_executing.yml +42 -0
  23. data/spec/vcr/binnacle_command/tail_command_with_n_flag_returns_recent_events.yml +61 -16
  24. data/spec/vcr/binnacle_http_logger/_htt_party_adapter_should_log__ge_t_requests.yml +38 -1
  25. data/spec/vcr/binnacle_http_logger/_http_client_adapter_should_log__ge_t_requests.yml +74 -0
  26. data/spec/vcr/binnacle_http_logger/open_uri_adapter_should_log__ge_t_requests.yml +333 -0
  27. data/spec/vcr/binnacle_http_logger/typhoeus_adapter_should_log__ge_t_requests.yml +38 -1
  28. data/spec/vcr/binnacle_logging/logging_allows_passing_other_parameters_using_a_hash.yml +35 -33
  29. data/spec/vcr/binnacle_logging/logging_invokes_the_events_api_signal.yml +60 -15
  30. data/spec/vcr/binnacle_logging/logging_respects_the_logger_severity.yml +54 -15
  31. data/vendor/assets/javascripts/binnacle/binnacle.js +39 -18
  32. metadata +6 -4
  33. data/spec/exception_event_spec.rb +0 -72
@@ -121,4 +121,41 @@ http_interactions:
121
121
  http://localhost:9292/index.html AS text/html (duration: 9.859e-06ms)\"})"}'
122
122
  http_version:
123
123
  recorded_at: Tue, 02 Feb 2016 02:47:05 GMT
124
- recorded_with: VCR 2.9.3
124
+ - request:
125
+ method: post
126
+ uri: http://localhost:8080/api/events/
127
+ body:
128
+ encoding: UTF-8
129
+ string: '{"channelId":null,"sessionId":"","clientEventTime":"2017-06-04T17:53:43-0700","eventName":"GET
130
+ http://104.131.46.61:8080/api/endpoints","clientId":"","logLevel":"log","tags":[],"environment":"production","json":{"direction":"out","url":"http://104.131.46.61:8080/api/endpoints","method":"GET","host":"104.131.46.61","port":8080,"path":"/api/endpoints","query":null,"format":"application/json","time":"2017-06-04
131
+ 17:53:43 -0700","status":200,"duration":4.855867999140173,"headers":{"Date":"Sun,
132
+ 25 Oct 2015 15:43:06 GMT","Content-Type":"application/json","Content-Encoding":"gzip","Vary":"Accept-Encoding","Transfer-Encoding":"chunked"},"body":"[\"104.131.41.123\",\"104.236.110.41\",\"104.131.46.61\",\"104.131.106.113\",\"45.55.141.159\",\"104.131.75.74\"]","data":"","message":"GET
133
+ http://104.131.46.61:8080/api/endpoints AS application/json (duration: 4.855867999140173ms)"}}'
134
+ headers:
135
+ User-Agent:
136
+ - Faraday v0.12.0.1
137
+ Accept:
138
+ - "*/*"
139
+ Accept-Encoding:
140
+ - gzip,deflate
141
+ Date:
142
+ - Mon, 05 Jun 2017 00:53:43 GMT
143
+ Content-Type:
144
+ - application/json
145
+ Authorization:
146
+ - Basic dmNldGg0eGN3cWZvb3dwejJlc2k6MWdydHR5YjhvemJlOWF4dDg4amk=
147
+ response:
148
+ status:
149
+ code: 404
150
+ message: Not Found
151
+ headers:
152
+ Date:
153
+ - Mon, 05 Jun 2017 00:53:43 GMT
154
+ Content-Length:
155
+ - '0'
156
+ body:
157
+ encoding: UTF-8
158
+ string: ''
159
+ http_version:
160
+ recorded_at: Mon, 05 Jun 2017 00:53:43 GMT
161
+ recorded_with: VCR 3.0.3
@@ -8,13 +8,13 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
11
+ - Faraday v0.12.1
12
12
  Accept:
13
13
  - "*/*"
14
14
  Accept-Encoding:
15
15
  - gzip,deflate
16
16
  Date:
17
- - Fri, 23 Oct 2015 19:07:38 GMT
17
+ - Thu, 06 Jul 2017 19:22:45 GMT
18
18
  Content-Type:
19
19
  - application/json
20
20
  Authorization:
@@ -25,7 +25,7 @@ http_interactions:
25
25
  message: OK
26
26
  headers:
27
27
  Date:
28
- - Fri, 23 Oct 2015 19:07:38 GMT
28
+ - Thu, 06 Jul 2017 19:22:45 GMT
29
29
  Content-Type:
30
30
  - application/json
31
31
  Content-Encoding:
@@ -36,25 +36,24 @@ http_interactions:
36
36
  - chunked
37
37
  body:
38
38
  encoding: UTF-8
39
- string: '["68.2.239.31"]'
39
+ string: '["127.0.0.1"]'
40
40
  http_version:
41
- recorded_at: Fri, 23 Oct 2015 19:07:38 GMT
41
+ recorded_at: Thu, 06 Jul 2017 19:22:45 GMT
42
42
  - request:
43
- method: post
44
- uri: http://localhost:8080/api/events/icoc0tnol3obe8pas207
43
+ method: get
44
+ uri: http://localhost:8080/api/endpoints
45
45
  body:
46
46
  encoding: UTF-8
47
- string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"8675309","clientEventTime":"2015-10-23T12:07:38-0700","eventName":"failed_transfer","clientId":"","logLevel":"INFO","tags":[],"json":{"message":"transfer
48
- failed, bad RTN"}}'
47
+ string: ''
49
48
  headers:
50
49
  User-Agent:
51
- - Faraday v0.9.2
50
+ - Faraday v0.12.1
52
51
  Accept:
53
52
  - "*/*"
54
53
  Accept-Encoding:
55
54
  - gzip,deflate
56
55
  Date:
57
- - Fri, 23 Oct 2015 19:07:38 GMT
56
+ - Thu, 06 Jul 2017 19:22:45 GMT
58
57
  Content-Type:
59
58
  - application/json
60
59
  Authorization:
@@ -65,55 +64,58 @@ http_interactions:
65
64
  message: OK
66
65
  headers:
67
66
  Date:
68
- - Fri, 23 Oct 2015 19:07:38 GMT
67
+ - Thu, 06 Jul 2017 19:22:45 GMT
69
68
  Content-Type:
70
69
  - application/json
70
+ Content-Encoding:
71
+ - gzip
72
+ Vary:
73
+ - Accept-Encoding
71
74
  Transfer-Encoding:
72
75
  - chunked
73
76
  body:
74
77
  encoding: UTF-8
75
- string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(5790b9f3-dfb2-4a68-b75d-d972fe938d5a,
76
- bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2015-10-23,
77
- 8675309, Fri Oct 23 12:07:38 MST 2015, failed_transfer, Fri Oct 23 12:07:38
78
- MST 2015, , /0:0:0:0:0:0:0:1, INFO, null, [], null, {\"message\":\"transfer
79
- failed, bad RTN\"})"}'
78
+ string: '["127.0.0.1"]'
80
79
  http_version:
81
- recorded_at: Fri, 23 Oct 2015 19:07:38 GMT
80
+ recorded_at: Thu, 06 Jul 2017 19:22:45 GMT
82
81
  - request:
83
82
  method: post
84
- uri: http://localhost:8080/api/events/
83
+ uri: http://localhost:8080/api/events/icoc0tnol3obe8pas207
85
84
  body:
86
85
  encoding: UTF-8
87
- string: '{"channelId":null,"sessionId":"","clientEventTime":"2017-03-19T13:12:13-0700","eventName":"GET
88
- http://104.131.46.61:8080/api/endpoints","clientId":"","logLevel":"log","tags":[],"json":{"direction":"out","url":"http://104.131.46.61:8080/api/endpoints","method":"GET","host":"104.131.46.61","port":8080,"path":"/api/endpoints","query":null,"format":"application/json","time":"2017-03-19
89
- 13:12:13 -0700","status":200,"duration":3.939591988455504,"headers":{"Date":"Sun,
90
- 25 Oct 2015 15:43:06 GMT","Content-Type":"application/json","Content-Encoding":"gzip","Vary":"Accept-Encoding","Transfer-Encoding":"chunked"},"body":"[\"104.131.41.123\",\"104.236.110.41\",\"104.131.46.61\",\"104.131.106.113\",\"45.55.141.159\",\"104.131.75.74\"]","data":"","message":"GET
91
- http://104.131.46.61:8080/api/endpoints AS application/json (duration: 3.939591988455504ms)"}}'
86
+ string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"8675309","clientEventTime":"2017-07-06T15:22:45-0400","eventName":"failed_transfer","clientId":"","logLevel":"INFO","tags":[],"environment":"production","json":{"message":"transfer
87
+ failed, bad RTN"}}'
92
88
  headers:
93
89
  User-Agent:
94
- - Faraday v0.11.0
90
+ - Faraday v0.12.1
95
91
  Accept:
96
92
  - "*/*"
97
93
  Accept-Encoding:
98
94
  - gzip,deflate
99
95
  Date:
100
- - Sun, 19 Mar 2017 20:12:13 GMT
96
+ - Thu, 06 Jul 2017 19:22:45 GMT
101
97
  Content-Type:
102
98
  - application/json
103
99
  Authorization:
104
100
  - Basic dmNldGg0eGN3cWZvb3dwejJlc2k6MWdydHR5YjhvemJlOWF4dDg4amk=
105
101
  response:
106
102
  status:
107
- code: 404
108
- message: Not Found
103
+ code: 200
104
+ message: OK
109
105
  headers:
110
106
  Date:
111
- - Sun, 19 Mar 2017 20:12:13 GMT
112
- Content-Length:
113
- - '0'
107
+ - Thu, 06 Jul 2017 19:22:45 GMT
108
+ Content-Type:
109
+ - application/json
110
+ Transfer-Encoding:
111
+ - chunked
114
112
  body:
115
113
  encoding: UTF-8
116
- string: ''
114
+ string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(1a0fdd39-2344-4446-b652-bbebc3ef6dd5,
115
+ bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2017-07-06,
116
+ 8675309, Thu Jul 06 15:22:45 EDT 2017, failed_transfer, Thu Jul 06 15:22:45
117
+ EDT 2017, , /0:0:0:0:0:0:0:1, INFO, production, [], null, {\"message\":\"transfer
118
+ failed, bad RTN\"})"}'
117
119
  http_version:
118
- recorded_at: Sun, 19 Mar 2017 20:12:13 GMT
120
+ recorded_at: Thu, 06 Jul 2017 19:22:45 GMT
119
121
  recorded_with: VCR 3.0.3
@@ -8,11 +8,13 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.1
11
+ - Faraday v0.12.1
12
12
  Accept:
13
13
  - "*/*"
14
+ Accept-Encoding:
15
+ - gzip,deflate
14
16
  Date:
15
- - Sat, 17 Oct 2015 20:38:50 GMT
17
+ - Thu, 06 Jul 2017 19:23:21 GMT
16
18
  Content-Type:
17
19
  - application/json
18
20
  Authorization:
@@ -23,32 +25,75 @@ http_interactions:
23
25
  message: OK
24
26
  headers:
25
27
  Date:
26
- - Sat, 17 Oct 2015 20:38:50 GMT
28
+ - Thu, 06 Jul 2017 19:23:21 GMT
27
29
  Content-Type:
28
30
  - application/json
31
+ Content-Encoding:
32
+ - gzip
29
33
  Vary:
30
34
  - Accept-Encoding
31
35
  Transfer-Encoding:
32
36
  - chunked
33
37
  body:
34
38
  encoding: UTF-8
35
- string: '["68.2.239.31"]'
39
+ string: '["127.0.0.1"]'
36
40
  http_version:
37
- recorded_at: Sat, 17 Oct 2015 20:38:50 GMT
41
+ recorded_at: Thu, 06 Jul 2017 19:23:21 GMT
42
+ - request:
43
+ method: get
44
+ uri: http://localhost:8080/api/endpoints
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.12.1
51
+ Accept:
52
+ - "*/*"
53
+ Accept-Encoding:
54
+ - gzip,deflate
55
+ Date:
56
+ - Thu, 06 Jul 2017 19:23:21 GMT
57
+ Content-Type:
58
+ - application/json
59
+ Authorization:
60
+ - Basic dmNldGg0eGN3cWZvb3dwejJlc2k6MWdydHR5YjhvemJlOWF4dDg4amk=
61
+ response:
62
+ status:
63
+ code: 200
64
+ message: OK
65
+ headers:
66
+ Date:
67
+ - Thu, 06 Jul 2017 19:23:21 GMT
68
+ Content-Type:
69
+ - application/json
70
+ Content-Encoding:
71
+ - gzip
72
+ Vary:
73
+ - Accept-Encoding
74
+ Transfer-Encoding:
75
+ - chunked
76
+ body:
77
+ encoding: UTF-8
78
+ string: '["127.0.0.1"]'
79
+ http_version:
80
+ recorded_at: Thu, 06 Jul 2017 19:23:21 GMT
38
81
  - request:
39
82
  method: post
40
83
  uri: http://localhost:8080/api/events/icoc0tnol3obe8pas207
41
84
  body:
42
85
  encoding: UTF-8
43
- string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"","clientEventTime":"2015-10-17T13:38:50-0700","eventName":"log","clientId":"","logLevel":"INFO","tags":[],"json":{"message":"This
86
+ string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"","clientEventTime":"2017-07-06T15:23:21-0400","eventName":"log","clientId":"","logLevel":"INFO","tags":[],"environment":"production","json":{"message":"This
44
87
  is an info message"}}'
45
88
  headers:
46
89
  User-Agent:
47
- - Faraday v0.9.1
90
+ - Faraday v0.12.1
48
91
  Accept:
49
92
  - "*/*"
93
+ Accept-Encoding:
94
+ - gzip,deflate
50
95
  Date:
51
- - Sat, 17 Oct 2015 20:38:50 GMT
96
+ - Thu, 06 Jul 2017 19:23:21 GMT
52
97
  Content-Type:
53
98
  - application/json
54
99
  Authorization:
@@ -59,17 +104,17 @@ http_interactions:
59
104
  message: OK
60
105
  headers:
61
106
  Date:
62
- - Sat, 17 Oct 2015 20:38:50 GMT
107
+ - Thu, 06 Jul 2017 19:23:21 GMT
63
108
  Content-Type:
64
109
  - application/json
65
110
  Transfer-Encoding:
66
111
  - chunked
67
112
  body:
68
113
  encoding: UTF-8
69
- string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(8347bea4-9f3c-425d-9342-3c52e8a49146,
70
- bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2015-10-17,
71
- , Sat Oct 17 13:38:51 MST 2015, log, Sat Oct 17 13:38:50 MST 2015, , /0:0:0:0:0:0:0:1,
72
- INFO, null, [], null, {\"message\":\"This is an info message\"})"}'
114
+ string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(93b1ef01-8524-43fd-9f1f-c91c0a23de86,
115
+ bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2017-07-06,
116
+ , Thu Jul 06 15:23:21 EDT 2017, log, Thu Jul 06 15:23:21 EDT 2017, , /0:0:0:0:0:0:0:1,
117
+ INFO, production, [], null, {\"message\":\"This is an info message\"})"}'
73
118
  http_version:
74
- recorded_at: Sat, 17 Oct 2015 20:38:51 GMT
75
- recorded_with: VCR 2.9.3
119
+ recorded_at: Thu, 06 Jul 2017 19:23:21 GMT
120
+ recorded_with: VCR 3.0.3
@@ -8,13 +8,13 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
11
+ - Faraday v0.12.1
12
12
  Accept:
13
13
  - "*/*"
14
14
  Accept-Encoding:
15
15
  - gzip,deflate
16
16
  Date:
17
- - Fri, 23 Oct 2015 19:04:40 GMT
17
+ - Thu, 06 Jul 2017 19:23:03 GMT
18
18
  Content-Type:
19
19
  - application/json
20
20
  Authorization:
@@ -25,7 +25,7 @@ http_interactions:
25
25
  message: OK
26
26
  headers:
27
27
  Date:
28
- - Fri, 23 Oct 2015 19:04:40 GMT
28
+ - Thu, 06 Jul 2017 19:23:03 GMT
29
29
  Content-Type:
30
30
  - application/json
31
31
  Content-Encoding:
@@ -36,25 +36,64 @@ http_interactions:
36
36
  - chunked
37
37
  body:
38
38
  encoding: UTF-8
39
- string: '["68.2.239.31"]'
39
+ string: '["127.0.0.1"]'
40
40
  http_version:
41
- recorded_at: Fri, 23 Oct 2015 19:04:40 GMT
41
+ recorded_at: Thu, 06 Jul 2017 19:23:03 GMT
42
+ - request:
43
+ method: get
44
+ uri: http://localhost:8080/api/endpoints
45
+ body:
46
+ encoding: UTF-8
47
+ string: ''
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.12.1
51
+ Accept:
52
+ - "*/*"
53
+ Accept-Encoding:
54
+ - gzip,deflate
55
+ Date:
56
+ - Thu, 06 Jul 2017 19:23:03 GMT
57
+ Content-Type:
58
+ - application/json
59
+ Authorization:
60
+ - Basic dmNldGg0eGN3cWZvb3dwejJlc2k6MWdydHR5YjhvemJlOWF4dDg4amk=
61
+ response:
62
+ status:
63
+ code: 200
64
+ message: OK
65
+ headers:
66
+ Date:
67
+ - Thu, 06 Jul 2017 19:23:03 GMT
68
+ Content-Type:
69
+ - application/json
70
+ Content-Encoding:
71
+ - gzip
72
+ Vary:
73
+ - Accept-Encoding
74
+ Transfer-Encoding:
75
+ - chunked
76
+ body:
77
+ encoding: UTF-8
78
+ string: '["127.0.0.1"]'
79
+ http_version:
80
+ recorded_at: Thu, 06 Jul 2017 19:23:03 GMT
42
81
  - request:
43
82
  method: post
44
83
  uri: http://localhost:8080/api/events/icoc0tnol3obe8pas207
45
84
  body:
46
85
  encoding: UTF-8
47
- string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"","clientEventTime":"2015-10-23T12:04:40-0700","eventName":"log","clientId":"","logLevel":"DEBUG","tags":[],"json":{"message":"This
86
+ string: '{"channelId":"icoc0tnol3obe8pas207","sessionId":"","clientEventTime":"2017-07-06T15:23:03-0400","eventName":"log","clientId":"","logLevel":"DEBUG","tags":[],"environment":"production","json":{"message":"This
48
87
  is an debug message"}}'
49
88
  headers:
50
89
  User-Agent:
51
- - Faraday v0.9.2
90
+ - Faraday v0.12.1
52
91
  Accept:
53
92
  - "*/*"
54
93
  Accept-Encoding:
55
94
  - gzip,deflate
56
95
  Date:
57
- - Fri, 23 Oct 2015 19:04:40 GMT
96
+ - Thu, 06 Jul 2017 19:23:03 GMT
58
97
  Content-Type:
59
98
  - application/json
60
99
  Authorization:
@@ -65,17 +104,17 @@ http_interactions:
65
104
  message: OK
66
105
  headers:
67
106
  Date:
68
- - Fri, 23 Oct 2015 19:04:40 GMT
107
+ - Thu, 06 Jul 2017 19:23:03 GMT
69
108
  Content-Type:
70
109
  - application/json
71
110
  Transfer-Encoding:
72
111
  - chunked
73
112
  body:
74
113
  encoding: UTF-8
75
- string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(df4f0000-f65d-4016-bb9b-aa26e4009dde,
76
- bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2015-10-23,
77
- , Fri Oct 23 12:04:40 MST 2015, log, Fri Oct 23 12:04:40 MST 2015, , /0:0:0:0:0:0:0:1,
78
- DEBUG, null, [], null, {\"message\":\"This is an debug message\"})"}'
114
+ string: '{"message":"Signaled: io.binnacle.models.BinnacleEvent(b26af3d4-92e5-44d2-9f0b-45e9d9a51ab3,
115
+ bv4sfcz28up6q6bophx4, n7f05b76tr4xsc6slstl, icoc0tnol3obe8pas207, 2017-07-06,
116
+ , Thu Jul 06 15:23:03 EDT 2017, log, Thu Jul 06 15:23:03 EDT 2017, , /0:0:0:0:0:0:0:1,
117
+ DEBUG, production, [], null, {\"message\":\"This is an debug message\"})"}'
79
118
  http_version:
80
- recorded_at: Fri, 23 Oct 2015 19:04:40 GMT
81
- recorded_with: VCR 2.9.3
119
+ recorded_at: Thu, 06 Jul 2017 19:23:03 GMT
120
+ recorded_with: VCR 3.0.3
@@ -1,5 +1,5 @@
1
1
  /* ===========================================================
2
- # Binnacle JS - v0.2.5
2
+ # Binnacle JS - v0.2.6
3
3
  # ==============================================================
4
4
  # Copyright (c) 2017 Brian Sam-Bodden
5
5
  # Licensed .
@@ -8682,7 +8682,7 @@ Binnacle.Event = (function() {
8682
8682
  options.logLevel = 'EVENT';
8683
8683
  }
8684
8684
  if (options.environment == null) {
8685
- options.environment = {};
8685
+ options.environment = 'production';
8686
8686
  }
8687
8687
  if (options.tags == null) {
8688
8688
  options.tags = [];
@@ -8733,13 +8733,16 @@ Binnacle.Client = (function() {
8733
8733
  var configureMessage;
8734
8734
 
8735
8735
  function Client(options) {
8736
+ if (options.environment == null) {
8737
+ options.environment = 'production';
8738
+ }
8736
8739
  this.options = options;
8737
- this.channelChannelUrl = this.options.endPoint + "/api/subscribe/channel/" + this.options.channelId;
8738
- this.appChannelUrl = this.options.endPoint + "/api/subscribe/app/" + this.options.appId;
8739
- this.subscribersUrl = this.options.endPoint + "/api/subscribers/" + this.options.channelId;
8740
+ this.channelChannelUrl = this.options.endPoint + "/api/subscribe/channel/" + this.options.channelId + "/" + this.options.environment;
8741
+ this.appChannelUrl = this.options.endPoint + "/api/subscribe/app/" + this.options.appId + "/" + this.options.environment;
8742
+ this.subscribersUrl = this.options.endPoint + "/api/subscribers/" + this.options.channelId + "/" + this.options.environment;
8740
8743
  this.notificationsUrl = this.options.endPoint + "/api/subscribe/ntf/" + this.options.accountId;
8741
8744
  this.signalUrl = this.options.endPoint + "/api/events/" + this.options.channelId;
8742
- this.recentsUrl = this.options.endPoint + "/api/events/" + this.options.channelId + "/recents";
8745
+ this.recentsUrl = this.options.endPoint + "/api/events/" + this.options.channelId + "/{environment}/recents";
8743
8746
  this.messagesReceived = 0;
8744
8747
  this.socket = atmosphere;
8745
8748
  }
@@ -8832,12 +8835,22 @@ Binnacle.Client = (function() {
8832
8835
  request.headers = {
8833
8836
  Authorization: 'Basic ' + btoa(this.options.apiKey + ":" + this.options.apiSecret)
8834
8837
  };
8835
- request.onOpen = function(response) {
8836
- return console.log("Binnacle connected using " + response.transport);
8837
- };
8838
- request.onError = function(response) {
8839
- return console.log("Sorry, but there's some problem with your socket or the Binnacle server is down");
8840
- };
8838
+ request.onOpen = (function(_this) {
8839
+ return function(response) {
8840
+ if (_this.options.onOpen != null) {
8841
+ _this.options.onOpen(response);
8842
+ }
8843
+ return console.log("Binnacle connected using " + response.transport);
8844
+ };
8845
+ })(this);
8846
+ request.onError = (function(_this) {
8847
+ return function(response) {
8848
+ if (_this.options.onError != null) {
8849
+ _this.options.onError(response);
8850
+ }
8851
+ return console.log("Sorry, but there's some problem with your socket or the Binnacle server is down");
8852
+ };
8853
+ })(this);
8841
8854
  request.onMessage = (function(_this) {
8842
8855
  return function(response) {
8843
8856
  var e, error, i, json, len, message, messageAsString, messages, payload;
@@ -8976,17 +8989,21 @@ Binnacle.WebPushClient = (function() {
8976
8989
  }
8977
8990
 
8978
8991
  WebPushClient.prototype.subscribe = function() {
8979
- this.initializeFirebase();
8980
- return this.getToken();
8992
+ if (!this.messaging) {
8993
+ this.initialize();
8994
+ }
8995
+ return this.getTokenAndSubscribe();
8981
8996
  };
8982
8997
 
8983
- WebPushClient.prototype.initializeFirebase = function() {
8998
+ WebPushClient.prototype.initialize = function() {
8984
8999
  var config;
8985
9000
  config = {
8986
9001
  apiKey: this.options.firebaseApiKey,
8987
9002
  messagingSenderId: this.options.firebaseMessagingSenderId
8988
9003
  };
8989
- firebase.initializeApp(config);
9004
+ if (!firebase.apps.length) {
9005
+ firebase.initializeApp(config);
9006
+ }
8990
9007
  this.messaging = firebase.messaging();
8991
9008
  this.messaging.onMessage((function(_this) {
8992
9009
  return function(payload) {
@@ -9009,10 +9026,14 @@ Binnacle.WebPushClient = (function() {
9009
9026
  };
9010
9027
 
9011
9028
  WebPushClient.prototype.getToken = function() {
9029
+ return this.messaging.getToken();
9030
+ };
9031
+
9032
+ WebPushClient.prototype.getTokenAndSubscribe = function() {
9012
9033
  return this.messaging.getToken().then((function(_this) {
9013
9034
  return function(currentToken) {
9014
9035
  if (currentToken) {
9015
- _this.sendTokenToServer(currentToken);
9036
+ return _this.sendTokenToServer(currentToken);
9016
9037
  } else {
9017
9038
  _this.options.onBeforePermissionRequest();
9018
9039
  _this.messaging.requestPermission().then(function() {
@@ -9022,7 +9043,7 @@ Binnacle.WebPushClient = (function() {
9022
9043
  console.log('Unable to get permission to notify.', err);
9023
9044
  return _this.options.onPermissionFailed();
9024
9045
  });
9025
- setTokenSentToServer(false);
9046
+ return setTokenSentToServer(false);
9026
9047
  }
9027
9048
  };
9028
9049
  })(this))["catch"](function(err) {