openpanel-sdk 0.1.3 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71d49e2703660c679a0fa144f8b12f121f0014cca877ea1e9858d3dfd3e80af1
4
- data.tar.gz: b5d6a0b7a266fbe4f6efeaacccb509c77a9950371ad2b5ed0bb98e4883ef5e7f
3
+ metadata.gz: 9777c4309f179a7458c3db1aa7faa136689ba9952830614c109ff29634950f1a
4
+ data.tar.gz: 827f2e8b345398fc176eb122b2d1eaa0aec28d0179c9ad94a01bd8b613572754
5
5
  SHA512:
6
- metadata.gz: 38f322c5ab571c40cf5a145514e4b648421d4531097bb90af3bef33088a3464d4fc306eae886e071c40942157f1b720c9f68574f833a5bfa1d00181196074284
7
- data.tar.gz: 2b12b3273ba1c973a41eff1fa1abc03ac8274334fd7c17679e760ad5cc4c0a011d2ee4f7d059622ccd9a963674734376ee7e4306346c3d7e2884d4f9f563a15c
6
+ metadata.gz: 79e882b70b392f8e475057be327696ccc79b4fca5bfbe48d78baffb3deaf9a5781cedb52cb6bc8d55ffeaa8a4e4ef3a3b9624943cd4d2322c151cc32d9a97b5c
7
+ data.tar.gz: 9b0814453c46b72f92c37a077804ccaaf413cd1e0e15bf23c4de31a51e0bb99f8a45f9ef7e3a7c00f577c7a3fded802fea3372f6cdb6ca1baab3e00e2fd1f77f
@@ -12,19 +12,21 @@ module OpenPanel
12
12
  TRACKING_TYPE_INCREMENT = 'increment'
13
13
  TRACKING_TYPE_DECREMENT = 'decrement'
14
14
 
15
- attr_reader :headers
15
+ attr_reader :headers, :global_properties
16
16
 
17
17
  ##############################
18
18
  # Initialize OpenPanel tracker
19
+ # @param global_props [Hash] global properties to send with every `track` and `identify` event
19
20
  # @param disabled [Boolean] disable sending tracking events, defaults to false
20
21
  ##############################
21
- def initialize(disabled: false)
22
+ def initialize(global_props: {}, disabled: false)
22
23
  @headers = {
23
24
  'Content-Type' => 'application/json',
24
25
  'openpanel-client-id' => ENV['OPENPANEL_CLIENT_ID'],
25
26
  'openpanel-client-secret' => ENV['OPENPANEL_CLIENT_SECRET']
26
27
  }
27
28
  @disabled = disabled
29
+ @global_properties = global_props
28
30
  end
29
31
 
30
32
  ##############################
@@ -44,6 +46,7 @@ module OpenPanel
44
46
  # @param payload [Hash] event payload
45
47
  ##############################
46
48
  def track(event, tracking_type: TRACKING_TYPE_TRACK, payload: {})
49
+ payload = global_properties.merge(payload) unless global_properties.empty?
47
50
  payload = { type: tracking_type, payload: { name: event, properties: payload } }
48
51
 
49
52
  send_request payload: payload
@@ -55,8 +58,9 @@ module OpenPanel
55
58
  # @param user [OpenPanel::SDK::IdentifyUser] user to identify
56
59
  ##############################
57
60
  def identify(user)
61
+ properties = user.properties.merge(global_properties) unless global_properties.empty?
58
62
  payload = { profileId: user.profile_id, firstName: user.first_name, lastName: user.last_name,
59
- email: user.email }
63
+ email: user.email, properties: properties }
60
64
  payload = { type: TRACKING_TYPE_IDENTIFY, payload: payload }
61
65
 
62
66
  send_request payload: payload
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenPanel
4
4
  module SDK
5
- VERSION = '0.1.3'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openpanel-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Stätter