Module: Framed
- Defined in:
- lib/framed/utils.rb,
lib/framed_rails.rb,
lib/framed/client.rb,
lib/framed/railtie.rb,
lib/framed/version.rb,
lib/framed/emitters.rb,
lib/framed/exceptions.rb
Defined Under Namespace
Modules: Emitters, Utils
Classes: Client, Error, Railtie, RequestError, RequiredConfiguration, Timeout
Constant Summary
collapse
- SEGMENT_API_ENDPOINT =
'https://api.segment.io/v1/track'
- FRAMED_API_ENDPOINT =
'https://intake.framed.io/events'
- COOKIE_NAME =
'framed_id'
- LOG_PREFIX =
'[framed_rails] '
- DEFAULT_EXCLUDED_PARAMS =
[:controller,
:action,
:utf8,
:authenticity_token,
:commit,
:password]
- VERSION =
'0.2.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
26
27
28
|
# File 'lib/framed_rails.rb', line 26
def client
@client
end
|
.emitter ⇒ Object
Returns the value of attribute emitter.
26
27
28
|
# File 'lib/framed_rails.rb', line 26
def emitter
@emitter
end
|
Class Method Details
.anonymous_cookie ⇒ Object
88
89
90
|
# File 'lib/framed_rails.rb', line 88
def anonymous_cookie
configuration[:anonymous_cookie]
end
|
.configuration ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/framed_rails.rb', line 28
def configuration
@configuration ||= {
:emitter => Framed::Emitters::Blocking,
:user_id_controller_method => 'framed_current_user_id',
:endpoint => Framed::FRAMED_API_ENDPOINT,
:logger => Logger.new(STDERR),
:anonymous_cookie => Framed::COOKIE_NAME,
:include_xhr => false,
:excluded_params => []
}
end
|
44
45
46
47
48
49
50
|
# File 'lib/framed_rails.rb', line 44
def configure
yield configuration
self.client = Client.new(configuration)
@emitter.stop(true) if @emitter
@emitter = configuration[:emitter].new(self.client)
end
|
.drain ⇒ Object
80
81
82
|
# File 'lib/framed_rails.rb', line 80
def drain
@emitter.stop(true) if @emitter
end
|
.excluded_params ⇒ Object
40
41
42
|
# File 'lib/framed_rails.rb', line 40
def excluded_params
(configuration[:excluded_params] + DEFAULT_EXCLUDED_PARAMS).uniq
end
|
.log_error(msg) ⇒ Object
76
77
78
|
# File 'lib/framed_rails.rb', line 76
def log_error(msg)
logger.error(LOG_PREFIX + msg)
end
|
.log_info(msg) ⇒ Object
72
73
74
|
# File 'lib/framed_rails.rb', line 72
def log_info(msg)
logger.info(LOG_PREFIX + msg)
end
|
.logger ⇒ Object
68
69
70
|
# File 'lib/framed_rails.rb', line 68
def logger
configuration[:logger]
end
|
.new_anonymous_id ⇒ Object
92
93
94
|
# File 'lib/framed_rails.rb', line 92
def new_anonymous_id
Framed::Utils.uuid
end
|
.report(event) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/framed_rails.rb', line 52
def report(event)
event[:lib] = 'framed_ruby'
event[:lib_version] = Framed::VERSION
event[:type] ||= :track
event[:context] ||= {}
event[:context].merge!({
:channel => 'server'
})
event[:properties] ||= {}
event[:timestamp] ||= Framed::Utils.serialize_date(Time.now)
@emitter.enqueue(event)
end
|
.user_id_controller_method ⇒ Object
84
85
86
|
# File 'lib/framed_rails.rb', line 84
def user_id_controller_method
configuration[:user_id_controller_method]
end
|