gitlab-sdk 0.1.0 → 0.2.1

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: d02a90e3d161d2e2edc18fb76a08dc011bc567d56ef7d29d62c3df22c40c3ebc
4
- data.tar.gz: 15e64bfc91b0e4f23dddc7fc07d32e0906232bca06d9f4f4c36dbaa17b6c19c5
3
+ metadata.gz: f7b6fd23071b9f55fa712ae849d2091563108bc5fcff52e17699ca6e2247ab2b
4
+ data.tar.gz: 07a37a862af1807ee7b25a2fd25eef3d991d2b54c1cf288440b55416723f7e17
5
5
  SHA512:
6
- metadata.gz: d9c5ed95c3d1bcdef50e777a04a42e64ccc6d0f4bb77fc6385e8050248d81f51c3f16f898793468512dfd90a5fd85e63f343bb4afc76b73fee0f8a73a45a8a9d
7
- data.tar.gz: cf474d2e60515b417caa2230c81d24d620f464761ed835b1fa71f37968fecf327bcee8ea7a69a59ddf746e9cef149f236824baee967e03ea8c0ef89edbd8058c
6
+ metadata.gz: 59c75ccb7af6e55324536e752f934f37fc894b68bddcb7216061b28ae5736cc8e9af5db092d082e550db1a45430ecd9edd99382fa8ccc1fe1054e8310286144c
7
+ data.tar.gz: 250d4d34a8ab534da48e318bcd3149746735f8cb090bad8deabcac65445f3cace997cbc44abed17ffff7dfa2ac745d2da5986cc99661f20de9ef3617ca11211a
data/.rubocop.yml CHANGED
@@ -18,3 +18,7 @@ RSpec/MultipleMemoizedHelpers:
18
18
  Naming/FileName:
19
19
  Exclude:
20
20
  - lib/gitlab-sdk.rb
21
+
22
+ RSpec/MultipleMemoizedHelpers:
23
+ Max: 25
24
+ AllowSubject: true
data/Gemfile CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in gitlab-sdk.gemspec
5
+ # Specify your gem's dependencies in gl-application-sdk-rb.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-sdk (0.1.0)
5
- activesupport (~> 7.0)
4
+ gitlab-sdk (0.2.1)
5
+ activesupport (>= 5.2.0)
6
6
  rake (~> 13.0)
7
7
  snowplow-tracker (~> 0.8.0)
8
8
 
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', '~> 0.1.0', git: 'git@gitlab.com:gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb.git'
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).
@@ -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 = SnowplowTracker::Emitter.new(endpoint: host)
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
- set_user_data(track_arguments)
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 set_user_data(track_arguments)
48
- set_user_id
49
- set_user_context(track_arguments)
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 set_user_id
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabSDK
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
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.0
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-05-17 00:00:00.000000000 Z
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.2.22
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: []