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 +4 -4
- data/lib/openpanel/sdk/tracker.rb +7 -16
- data/lib/openpanel/sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9777c4309f179a7458c3db1aa7faa136689ba9952830614c109ff29634950f1a
|
|
4
|
+
data.tar.gz: 827f2e8b345398fc176eb122b2d1eaa0aec28d0179c9ad94a01bd8b613572754
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
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.
|
|
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-
|
|
11
|
+
date: 2025-11-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: OpenPanel SDK for Ruby
|
|
14
14
|
email:
|