framed_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +11 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG +1 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +1 -0
  6. data/README.md +107 -0
  7. data/framed_rails.gemspec +37 -0
  8. data/lib/framed/client.rb +34 -0
  9. data/lib/framed/emitters.rb +113 -0
  10. data/lib/framed/example.rb +17 -0
  11. data/lib/framed/exceptions.rb +13 -0
  12. data/lib/framed/okjson.rb +602 -0
  13. data/lib/framed/rails.rb +43 -0
  14. data/lib/framed/railtie.rb +9 -0
  15. data/lib/framed/utils.rb +54 -0
  16. data/lib/framed/version.rb +4 -0
  17. data/lib/framed_rails.rb +71 -0
  18. data/vendor/gems/excon-0.45.3/data/cacert.pem +3860 -0
  19. data/vendor/gems/excon-0.45.3/lib/excon/connection.rb +469 -0
  20. data/vendor/gems/excon-0.45.3/lib/excon/constants.rb +142 -0
  21. data/vendor/gems/excon-0.45.3/lib/excon/errors.rb +155 -0
  22. data/vendor/gems/excon-0.45.3/lib/excon/extensions/uri.rb +33 -0
  23. data/vendor/gems/excon-0.45.3/lib/excon/headers.rb +83 -0
  24. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/base.rb +24 -0
  25. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/decompress.rb +35 -0
  26. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/escape_path.rb +11 -0
  27. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/expects.rb +18 -0
  28. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/idempotent.rb +33 -0
  29. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/instrumentor.rb +34 -0
  30. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/mock.rb +51 -0
  31. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/redirect_follower.rb +56 -0
  32. data/vendor/gems/excon-0.45.3/lib/excon/middlewares/response_parser.rb +12 -0
  33. data/vendor/gems/excon-0.45.3/lib/excon/pretty_printer.rb +45 -0
  34. data/vendor/gems/excon-0.45.3/lib/excon/response.rb +212 -0
  35. data/vendor/gems/excon-0.45.3/lib/excon/socket.rb +310 -0
  36. data/vendor/gems/excon-0.45.3/lib/excon/ssl_socket.rb +151 -0
  37. data/vendor/gems/excon-0.45.3/lib/excon/standard_instrumentor.rb +27 -0
  38. data/vendor/gems/excon-0.45.3/lib/excon/unix_socket.rb +40 -0
  39. data/vendor/gems/excon-0.45.3/lib/excon/utils.rb +87 -0
  40. data/vendor/gems/excon-0.45.3/lib/excon.rb +234 -0
  41. metadata +91 -0
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+ require 'logger'
3
+
4
+ require 'framed/version'
5
+ require 'framed/rails' if defined?(::Rails)
6
+ require 'framed/railtie' if defined?(::Rails::Railtie)
7
+ require 'framed/client'
8
+ require 'framed/emitters'
9
+ require 'framed/utils'
10
+
11
+ module Framed
12
+ SEGMENT_API_ENDPOINT = 'https://api.segment.io/v1/track'
13
+ FRAMED_API_ENDPOINT = 'https://intake.framed.io/events'
14
+ COOKIE_NAME = 'framed_id'
15
+
16
+ class << self
17
+ attr_accessor :client, :consumer
18
+
19
+ def configuration
20
+ @configuration ||= {
21
+ :consumer => Framed::Emitters::Blocking,
22
+ :user_id_controller_method => 'framed_devise_user_id',
23
+ :endpoint => Framed::FRAMED_API_ENDPOINT,
24
+ :logger => Logger.new(STDERR),
25
+ :anonymous_cookie => Framed::COOKIE_NAME
26
+ }
27
+ end
28
+
29
+ def configure(silent = false)
30
+ yield configuration
31
+ self.client = Client.new(configuration)
32
+
33
+ @consumer.stop if @consumer
34
+ @consumer = configuration[:consumer].new(self.client)
35
+ end
36
+
37
+ def report(event)
38
+ event[:lib] = "framed_ruby"
39
+ event[:lib_version] = Framed::VERSION
40
+ event[:context] ||= {}
41
+ event[:context].merge!({
42
+ :channel => 'server',
43
+ })
44
+
45
+ # fill in if needed, in case it sits in queue for a while.
46
+ event[:timestamp] ||= Framed::Utils.serialize_date(Time.now)
47
+
48
+ @consumer.enqueue(event)
49
+ end
50
+
51
+ def logger
52
+ configuration[:logger]
53
+ end
54
+
55
+ def drain
56
+ @consumer.stop(true)
57
+ end
58
+
59
+ def user_id_controller_method
60
+ configuration[:user_id_controller_method]
61
+ end
62
+
63
+ def anonymous_cookie
64
+ configuration[:anonymous_cookie]
65
+ end
66
+
67
+ def new_anonymous_id
68
+ Framed::Utils.uuid
69
+ end
70
+ end
71
+ end