Class: Osso::Analytics

Inherits:
Object
  • Object
show all
Defined in:
lib/osso/lib/analytics.rb

Overview

Osso::Analytics provides an interface to track product analytics for any provider. Osso recommends PostHog as an open source solution for your product analytics needs. If you want to use another product analytics provider, you can patch the Osso::Analytics class yourself in your parent application. Be sure to implement the public .identify and .capture class methods with the required method signatures and require your class after requiring Osso.

Class Method Summary collapse

Class Method Details

.capture(email:, event:, properties: {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/osso/lib/analytics.rb', line 23

def capture(email:, event:, properties: {})
  return unless configured?

  client.capture(
    distinct_id: email,
    event: event,
    properties: properties.merge(instance_properties),
  )
end

.identify(email:, properties: {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/osso/lib/analytics.rb', line 14

def identify(email:, properties: {})
  return unless configured?

  client.identify({
    distinct_id: email,
    properties: properties.merge(instance_properties),
  })
end