openpanel-sdk 0.1.2 → 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: d14ac55d813c9ee97bcee346b856798bd52b1acac190a62945b4914f6588d1ad
4
- data.tar.gz: 9bd22b7c57b950edb91b33c98c4653ad43dcbd18906dddda910fdb402481ec26
3
+ metadata.gz: 9777c4309f179a7458c3db1aa7faa136689ba9952830614c109ff29634950f1a
4
+ data.tar.gz: 827f2e8b345398fc176eb122b2d1eaa0aec28d0179c9ad94a01bd8b613572754
5
5
  SHA512:
6
- metadata.gz: 36be770f2140341f272334848831d667be6dbd44435e2aa6fa5a2ae1752fa76ee7b8c67bf348611c06b6b9817423fe3c11b5eb6835e61bdc0faa7d214ad7701b
7
- data.tar.gz: 41be2ad0aeeb1ceb343e1fce8190591447bba27827bf0c7bbba2349e8ec2edcd0374ffd259bea6c30cffb5ea7f35735ec8fdea2322a087831df852f763df59f0
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,32 +46,21 @@ 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
50
53
  end
51
54
 
52
- ##############################
53
- # Track page view in OpenPanel
54
- # @param user [User] user to track
55
- # @param path [String] page path
56
- ##############################
57
- def track_page_view(user, path)
58
- if user
59
- track 'view', payload: { profileId: user.profile_id, path: path }
60
- else
61
- track 'view', payload: { path: path }
62
- end
63
- end
64
-
65
55
  ##############################
66
56
  # Identify user in OpenPanel
67
57
  # https://openpanel.dev/docs/api/track
68
58
  # @param user [OpenPanel::SDK::IdentifyUser] user to identify
69
59
  ##############################
70
60
  def identify(user)
61
+ properties = user.properties.merge(global_properties) unless global_properties.empty?
71
62
  payload = { profileId: user.profile_id, firstName: user.first_name, lastName: user.last_name,
72
- email: user.email }
63
+ email: user.email, properties: properties }
73
64
  payload = { type: TRACKING_TYPE_IDENTIFY, payload: payload }
74
65
 
75
66
  send_request payload: payload
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OpenPanel
4
4
  module SDK
5
- VERSION = '0.1.2'
5
+ VERSION = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openpanel-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Stätter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-28 00:00:00.000000000 Z
11
+ date: 2025-11-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: OpenPanel SDK for Ruby
14
14
  email: