gitlab-sdk 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +8 -1
- data/lib/gitlab-sdk/client.rb +22 -8
- data/lib/gitlab-sdk/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7b6fd23071b9f55fa712ae849d2091563108bc5fcff52e17699ca6e2247ab2b
|
4
|
+
data.tar.gz: 07a37a862af1807ee7b25a2fd25eef3d991d2b54c1cf288440b55416723f7e17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59c75ccb7af6e55324536e752f934f37fc894b68bddcb7216061b28ae5736cc8e9af5db092d082e550db1a45430ecd9edd99382fa8ccc1fe1054e8310286144c
|
7
|
+
data.tar.gz: 250d4d34a8ab534da48e318bcd3149746735f8cb090bad8deabcac65445f3cace997cbc44abed17ffff7dfa2ac745d2da5986cc99661f20de9ef3617ca11211a
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ This SDK is for using GitLab Application Services with Ruby.
|
|
9
9
|
Add the gem to your Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'gitlab-sdk'
|
12
|
+
gem 'gitlab-sdk'
|
13
13
|
```
|
14
14
|
|
15
15
|
### Using the client
|
@@ -60,3 +60,10 @@ client.track(event_name, event_attributes)
|
|
60
60
|
To develop with a local Snowplow pipeline, use Analytics devkit's [Snowplow setup](https://gitlab.com/gitlab-org/analytics-section/product-analytics/devkit/-/tree/main#setup).
|
61
61
|
|
62
62
|
To test the gem's functionality, run `bin/console`.
|
63
|
+
|
64
|
+
## Releasing the gem
|
65
|
+
|
66
|
+
To release a new version of the gem:
|
67
|
+
|
68
|
+
1. Update the version in [lib/gitlab-sdk/version.rb](lib/gitlab-sdk/version.rb).
|
69
|
+
2. After merging the MR including the changes, new version of the gem will be uploaded to [RubyGems](https://rubygems.org/gems/gitlab-sdk).
|
data/lib/gitlab-sdk/client.rb
CHANGED
@@ -11,9 +11,12 @@ module GitlabSDK
|
|
11
11
|
user_context: 'iglu:com.gitlab/user_context/jsonschema/1-0-0'
|
12
12
|
}.freeze
|
13
13
|
DEFAULT_TRACKER_NAMESPACE = 'gitlab'
|
14
|
+
USERAGENT = "GitLab Analytics Ruby SDK/#{GitlabSDK::VERSION}"
|
15
|
+
|
16
|
+
HostHasNoSchemeError = Class.new(StandardError)
|
14
17
|
|
15
18
|
def initialize(app_id:, host:)
|
16
|
-
emitter =
|
19
|
+
emitter = build_emitter(host)
|
17
20
|
|
18
21
|
@tracker = SnowplowTracker::Tracker.new(
|
19
22
|
emitters: emitter,
|
@@ -30,7 +33,9 @@ module GitlabSDK
|
|
30
33
|
)
|
31
34
|
|
32
35
|
track_arguments = { event_json: self_desc_json }
|
33
|
-
|
36
|
+
|
37
|
+
set_subject_data
|
38
|
+
set_user_context(track_arguments)
|
34
39
|
|
35
40
|
tracker.track_self_describing_event(**track_arguments)
|
36
41
|
end
|
@@ -44,17 +49,26 @@ module GitlabSDK
|
|
44
49
|
|
45
50
|
attr_reader :tracker
|
46
51
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
52
|
+
def build_emitter(host)
|
53
|
+
uri = URI(host)
|
54
|
+
raise HostHasNoSchemeError unless uri.scheme
|
55
|
+
|
56
|
+
SnowplowTracker::Emitter.new(endpoint: uri.hostname + uri.path, options: { protocol: uri.scheme })
|
50
57
|
end
|
51
58
|
|
52
|
-
def
|
59
|
+
def set_subject_data
|
60
|
+
subject = SnowplowTracker::Subject.new
|
61
|
+
|
62
|
+
set_user_id_on_subject(subject)
|
63
|
+
subject.set_useragent(USERAGENT)
|
64
|
+
|
65
|
+
tracker.set_subject(subject)
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_user_id_on_subject(subject)
|
53
69
|
user_id = GitlabSDK::CurrentUser.user_id
|
54
70
|
|
55
|
-
subject = SnowplowTracker::Subject.new
|
56
71
|
subject.set_user_id(user_id) if user_id
|
57
|
-
tracker.set_subject(subject)
|
58
72
|
end
|
59
73
|
|
60
74
|
def set_user_context(track_arguments)
|
data/lib/gitlab-sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -119,7 +119,7 @@ metadata:
|
|
119
119
|
homepage_uri: https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb
|
120
120
|
source_code_uri: https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb
|
121
121
|
changelog_uri: https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb/-/releases
|
122
|
-
post_install_message:
|
122
|
+
post_install_message:
|
123
123
|
rdoc_options: []
|
124
124
|
require_paths:
|
125
125
|
- lib
|
@@ -134,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
137
|
+
rubygems_version: 3.1.6
|
138
|
+
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Client side Ruby SDK for GitLab Application services
|
141
141
|
test_files: []
|