rudder_analytics_sync 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0d385201227d9e778888a6874cf6be75a09b0a74c96243d18061af24996084
4
- data.tar.gz: 56eefbf2bfc77688b912fa4f52795c115645461d2d8c7535f3fca78eb9743984
3
+ metadata.gz: fb211e617c13d145525cadb6d595b2685ac6cb6344cbb24f68770c3b0dc1ad9b
4
+ data.tar.gz: 18f1e329449195fe5547fe385d7a9b029bd412f8c9c7c2eb7c21bd9a15f516ed
5
5
  SHA512:
6
- metadata.gz: 3d29adcc4026b7178b02229f39a0f5f4df21b540bad1aca6bfad723d8e3899e7ed2e229ac21046200a65098e85a87a074b2329a4b7ef6a461a6931538a79f9ad
7
- data.tar.gz: 861bd17aae4ca8147a49628bb6586570c832124b5193939c461fc2796f92416dee60122aeb2acb038ebf6dd7a66df47528c1415450c1b65869f08ad842377c7f
6
+ metadata.gz: 9e4a3abb0d9b46a5808ac8e56ce3af55e275dea61bac56ef029e04fb26fcd0b1dbfd5a4ac1206829e31c724476ec89e277bf67bc179590dd7800dfc3bcc5953c
7
+ data.tar.gz: dc207499b0f313f0ab6442766070875e7855500d03f662e199a25bf65464439021fcef32b8611309ca63a6f315048fb1e418372d3c74c1891e935869ecb37321
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -0,0 +1,3 @@
1
+ # Description
2
+
3
+ < Replace with adequate description for this PR>
@@ -0,0 +1,31 @@
1
+ name: Code Quality Checks
2
+ on:
3
+ pull_request:
4
+ branches: ['master']
5
+ types: ['opened', 'reopened', 'synchronize']
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: '2.7'
17
+ bundler-cache: true
18
+ - name: Install dependencies
19
+ run: bundle install
20
+ - name: Run tests
21
+ run: bundle exec rake
22
+ # - name: Install rubocop
23
+ # run: gem install rubocop
24
+ # - name: Install rubocop-rspec
25
+ # run: gem install rubocop-rspec
26
+ # - name: Install rubocop-performance
27
+ # run: gem install rubocop-performance
28
+ # - name: Install rubocop-rails
29
+ # run: gem install rubocop-rails
30
+ # - name: Execute linting
31
+ # run: bundle exec rubocop
@@ -0,0 +1,16 @@
1
+ name: Check PR title
2
+ on:
3
+ pull_request:
4
+ branches: ['master']
5
+ types: ['opened', 'reopened', 'edited', 'synchronize']
6
+
7
+ jobs:
8
+ check_pr_title:
9
+ name: Check PR title
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout source branch
13
+ uses: actions/checkout@v3
14
+
15
+ - name: Check PR title
16
+ uses: rudderlabs/github-action-check-pr-title@v1.0.7
@@ -0,0 +1,55 @@
1
+ name: Notion PR Sync
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ [
7
+ opened,
8
+ edited,
9
+ deleted,
10
+ transferred,
11
+ pinned,
12
+ unpinned,
13
+ closed,
14
+ reopened,
15
+ assigned,
16
+ unassigned,
17
+ labeled,
18
+ unlabeled,
19
+ locked,
20
+ unlocked,
21
+ milestoned,
22
+ demilestoned,
23
+ ]
24
+ pull_request:
25
+ types:
26
+ [
27
+ assigned,
28
+ unassigned,
29
+ labeled,
30
+ unlabeled,
31
+ opened,
32
+ edited,
33
+ closed,
34
+ reopened,
35
+ synchronize,
36
+ converted_to_draft,
37
+ ready_for_review,
38
+ locked,
39
+ unlocked,
40
+ review_requested,
41
+ review_request_removed,
42
+ auto_merge_enabled,
43
+ auto_merge_disabled,
44
+ ]
45
+
46
+ jobs:
47
+ request:
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - name: Sync Github PRs to Notion
51
+ uses: sivashanmukh/github-notion-pr-sync@1.0.0
52
+ with:
53
+ notionKey: ${{ secrets.NOTION_BOT_KEY }}
54
+ notionDatabaseId: ${{ secrets.NOTION_PR_DB_ID }}
55
+ githubKey: ${{ secrets.PAT }}
@@ -0,0 +1,41 @@
1
+ name: Notify Slack Channel
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ deploy-tag:
9
+ name: Notify Slack
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Send message to Slack channel
13
+ id: slack
14
+ uses: slackapi/slack-github-action@v1.23.0
15
+ env:
16
+ SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
17
+ PROJECT_NAME: 'Ruby(Sync) SDK'
18
+ with:
19
+ channel-id: "${{ secrets.SLACK_RELEASE_CHANNEL_ID }}"
20
+ payload: |
21
+ {
22
+ "blocks": [
23
+ {
24
+ "type": "header",
25
+ "text": {
26
+ "type": "plain_text",
27
+ "text": "New release: ${{ env.PROJECT_NAME }}"
28
+ }
29
+ },
30
+ {
31
+ "type": "divider"
32
+ },
33
+ {
34
+ "type": "section",
35
+ "text": {
36
+ "type": "mrkdwn",
37
+ "text": "*Release: <${{ github.event.release.html_url }}|${{ github.event.release.tag_name }}>*"
38
+ }
39
+ }
40
+ ]
41
+ }
data/.gitignore CHANGED
@@ -6,4 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
- Gemfile.lock
9
+ Gemfile.lock
10
+ *.DS_Store
11
+ local_config.yaml
12
+ .vscode/
data/.hound.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  rubocop:
2
2
  config_file: .rubocop.yml
3
- version: 0.75.0
3
+ version: 1.42
data/.rubocop.yml CHANGED
@@ -1,12 +1,38 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - 'example/**/*'
8
+
1
9
  Metrics/BlockLength:
2
10
  Exclude:
3
- - '**/*_spec.rb'
11
+ - 'spec/**/*'
12
+ - 'example/**/*'
4
13
 
5
- Metrics/LineLength:
6
- Max: 100
14
+ Style/OptionalBooleanParameter:
15
+ Exclude:
16
+ - 'spec/**/*'
17
+ - 'example/**/*'
18
+
19
+ Style/FormatStringToken:
20
+ Enabled: false
21
+
22
+ Layout/LineLength:
23
+ Max: 200
7
24
  IgnoreCopDirectives: true
8
25
  Exclude:
9
- - 'simple_segment.gemspec'
26
+ - 'rudder_analytics_sync.gemspec'
10
27
 
11
28
  Style/Documentation:
12
29
  Enabled: false
30
+
31
+ Gemspec/RequiredRubyVersion:
32
+ Enabled: false
33
+
34
+ Metrics/MethodLength:
35
+ Max: 200
36
+
37
+ Style/IfUnlessModifier:
38
+ Enabled: false
data/CODEOWNERS ADDED
@@ -0,0 +1 @@
1
+ * @pallabmaiti @bardisg
data/Gemfile CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in simple_segment.gemspec
5
+ # Specify your gem's dependencies in rudder_analytics_sync.gemspec
6
+ # gem 'debug'
6
7
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 RudderStack
3
+ Copyright (c) 2016 Mikhail Topolskiy
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,56 +1,108 @@
1
- # What is RudderStack?
1
+ <p align="center">
2
+ <a href="https://rudderstack.com/">
3
+ <img src="https://user-images.githubusercontent.com/59817155/121357083-1c571300-c94f-11eb-8cc7-ce6df13855c9.png">
4
+ </a>
5
+ </p>
2
6
 
3
- **Short answer:**
4
- Rudder is an open-source Segment alternative written in Go, built for the enterprise. .
7
+ <p align="center"><b>The Customer Data Platform for Developers</b></p>
5
8
 
6
- **Long answer:**
7
- Rudder is a platform for collecting, storing and routing customer event data to dozens of tools. Rudder is open-source, can run in your cloud environment (AWS, GCP, Azure or even your data-centre) and provides a powerful transformation framework to process your event data on the fly.
9
+ <p align="center">
10
+ <b>
11
+ <a href="https://rudderstack.com">Website</a>
12
+ ·
13
+ <a href="https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-ruby-sdk/">Documentation</a>
14
+ ·
15
+ <a href="https://rudderstack.com/join-rudderstack-slack-community">Community Slack</a>
16
+ </b>
17
+ </p>
18
+
19
+ <p align="center"><a href="https://rubygems.org/gems/rudder_analytics_sync/"><img src="https://img.shields.io/gem/v/rudder_analytics_sync?style=flat"/></a></p>
20
+
21
+ ----
22
+
23
+ # RudderStack Ruby SDK
24
+
25
+ The RudderStack Ruby SDK lets you send customer event data from your Ruby applications to your specified destinations.
26
+
27
+ ## SDK setup requirements
28
+
29
+ - Set up a [RudderStack open source](https://app.rudderstack.com/signup?type=opensource) account.
30
+ - Set up a Ruby source in the dashboard.
31
+ - Copy the write key and the data plane URL. For more information, refer to the [Ruby SDK documentation](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-ruby-sdk/#sdk-setup-requirements).
8
32
 
9
33
  ## Installation
10
34
 
11
- Add this line to your application's Gemfile:
35
+ To install the RudderStack Ruby SDK, add this line to your application's Gem file:
12
36
 
13
37
  ```ruby
14
38
  gem 'rudder_analytics_sync'
15
39
  ```
16
40
 
17
- Or install it yourself as:
41
+ You can also install it yourself by running the following command:
18
42
 
19
- ```sh
20
- $ gem install rudder_analytics_sync
43
+ ```bash
44
+ gem install rudder_analytics_sync
21
45
  ```
22
46
 
23
- ## Usage
47
+ ## Using the SDK
24
48
 
25
- Create a client instance:
49
+ To use the Ruby SDK, create a client instance as shown:
26
50
 
27
51
  ```ruby
28
52
  analytics = RudderAnalyticsSync::Client.new(
29
- write_key: <YOUR_WRITE_KEY>, # required
30
- data_plane_url: <DATA_PLANE_URL>
53
+ write_key: 'WRITE_KEY', # Required
54
+ data_plane_url: 'DATA_PLANE_URL',
55
+ stub: false,
56
+ gzip: true, # Set to false to disable Gzip compression
31
57
  on_error: proc { |error_code, error_body, exception, response|
32
58
  # defaults to an empty proc
33
59
  }
34
60
  )
35
61
  ```
36
62
 
37
- Use it as you would use `analytics-ruby`:
63
+ You can then use this client to send the events. A sample `track` call sent using the client is shown below:
38
64
 
39
65
  ```ruby
40
66
  analytics.track(
41
- user_id: user.id,
42
- event: 'Created Account'
67
+ user_id: 12345,
68
+ event: 'Test Event'
43
69
  )
44
70
  ```
45
71
 
46
- ### Batching
72
+ ## Gzip support
47
73
 
48
- You can manually batch events with `analytics.batch`:
74
+ From version 2.0.0, the Ruby SDK supports Gzip compression and it is enabled (set to `true`) by default. However, you can disable this feature by setting the `Gzip` parameter to `false` while initializing the SDK, as shown:
75
+
76
+ ```ruby
77
+ analytics = RudderAnalyticsSync::Client.new(
78
+ write_key: 'WRITE_KEY', # required
79
+ data_plane_url: 'DATA_PLANE_URL',
80
+ stub: false,
81
+ gzip: false, // Set to true to enable Gzip compression
82
+ on_error: proc { |error_code, error_body, exception, response|
83
+ # defaults to an empty proc
84
+ }
85
+ )
86
+ ```
87
+
88
+ | Note: Gzip requires `rudder-server` version 1.4 or later. |
89
+ | :-----|
90
+
91
+ ## Sending events
92
+
93
+ Refer to the [RudderStack Ruby SDK documentation](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-ruby-sdk/) for more information on the supported event types.
94
+
95
+ | From version 2.0.0, the Ruby SDK supports [`screen`](https://www.rudderstack.com/docs/event-spec/standard-events/screen/) events. |
96
+ | :-----|
97
+
98
+ ### Manually batching events
99
+
100
+ You can manually batch your events using `analytics.batch`, as shown:
49
101
 
50
102
  ```ruby
51
103
  analytics.batch do |batch|
52
- batch.context = {...} # shared context for all events
53
- batch.integrations = {...} # shared integrations hash for all events
104
+ batch.context = {...} # Shared context for all the events
105
+ batch.integrations = {...} # Shared integrations hash for all the events
54
106
  batch.identify(...)
55
107
  batch.track(...)
56
108
  batch.track(...)
@@ -58,5 +110,6 @@ analytics.batch do |batch|
58
110
  end
59
111
  ```
60
112
 
61
- ## Contact Us
62
- If you come across any issues while configuring or using RudderStack, please feel free to [contact us](https://rudderstack.com/contact/) or start a conversation on our [Discord](https://discordapp.com/invite/xNEdEGw) channel. We will be happy to help you.
113
+ ## License
114
+
115
+ The RudderStack Ruby SDK is released under the [MIT license](https://github.com/rudderlabs/rudder-sdk-ruby-sync/blob/feat/latest-pull/LICENSE.txt).
data/SECURITY.md ADDED
@@ -0,0 +1,19 @@
1
+ # Security Reporting
2
+
3
+ Thank you in advance for helping us keep RudderStack secure!
4
+
5
+ Please report any security issues or vulnerabilities to [security@rudderstack.com](mailto:security@rudderstack.com), before proceeding to post them publicly as issues on GitHub or any other public channel like the RudderStack community Slack. These issues might also affect other users, and security vulnerabilities need to be handled quickly and sometimes privately.
6
+
7
+ We will triage the issue, contact you for further instructions and make sure to take any necessary measures as needed.
8
+
9
+ ## Supported versions
10
+
11
+ We will fix any security bugs for the latest major.minor version published in the [Docker Hub](https://hub.docker.com/r/rudderlabs/rudder-server).
12
+
13
+ | Version | Supported |
14
+ | :-------| :---------|
15
+ | Latest 1.x | ✅ |
16
+ | Older 1.x | ❌ |
17
+ | < 1.0 | ❌ |
18
+
19
+ We may fix the vulnerabilities in the older versions depending on the severity of the issue and the age of the release, but we are only committing to the latest version released.
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'simple_segment'
5
+ require 'rudder_analytics_sync'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
data/example/example.rb CHANGED
@@ -1,53 +1,163 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rudder_analytics_sync'
4
+ require 'yaml'
5
+ require 'date'
6
+
7
+ def uid
8
+ arr = SecureRandom.random_bytes(16).unpack('NnnnnN')
9
+ arr[2] = (arr[2] & 0x0fff) | 0x4000
10
+ arr[3] = (arr[3] & 0x3fff) | 0x8000
11
+ '%08x-%04x-%04x-%04x-%04x%08x' % arr
12
+ end
2
13
 
3
- include RudderAnalyticsSync
14
+ local_config = YAML.safe_load(File.read('example/local_config.yaml'))
15
+
16
+ ENV['WRITE_KEY'] = local_config['WRITE_KEY']
17
+ ENV['DATA_PLANE_URL'] = local_config['DATA_PLANE_URL']
18
+ ENV['LOCAL_DATA_PLANE_URL'] = local_config['LOCAL_DATA_PLANE_URL']
4
19
 
5
20
  analytics = RudderAnalyticsSync::Client.new(
6
- write_key: '1aJDXU7xlQpUp6qW1ppTJTvkgSi', # required
7
- data_plane_url: 'https://86143ed0.ngrok.io',
8
- stub: true,
21
+ write_key: ENV['WRITE_KEY'], # required
22
+ data_plane_url: ENV['LOCAL_DATA_PLANE_URL'],
23
+ # logger: Logger::DEBUG,
24
+ gzip: false,
9
25
  on_error: proc { |error_code, error_body, exception, response|
10
26
  # defaults to an empty proc
11
27
  }
12
28
  )
13
29
 
14
- # analytics.track(
15
- # user_id: 'test_user_id',
16
- # event: 'Created Account'
17
- # )
30
+ properties = {
31
+ library: {
32
+ application: 'Rudder Desktop',
33
+ version: '1.1.0',
34
+ platform: 'osx'
35
+ }
36
+ }
37
+
38
+ traits = {
39
+ firstname: 'First',
40
+ lastname: 'Last',
41
+ Role: 'Jedi',
42
+ age: 25
43
+ }
44
+
45
+ user_id = '123456'
46
+ anonymous_id = uid
47
+
48
+ context = {
49
+ screen: {
50
+ width: 852,
51
+ height: 393,
52
+ density: 3
53
+ },
54
+ os: {
55
+ name: 'macOS',
56
+ version: '2.0.0'
57
+ },
58
+ locale: 'en-US'
59
+ }
60
+
61
+ context_with_library = {
62
+ screen: {
63
+ width: 852,
64
+ height: 393,
65
+ density: 3
66
+ },
67
+ os: {
68
+ name: 'macOS',
69
+ version: '2.0.0'
70
+ },
71
+ locale: 'en-US',
72
+ library: {
73
+ name: 'analytics-random-sdk',
74
+ version: '1.0.0.beta.1'
75
+ }
76
+ }
77
+
78
+ analytics.track(
79
+ user_id: user_id,
80
+ event: 'Test Track',
81
+ anonymous_id: anonymous_id,
82
+ properties: properties,
83
+ context: context
84
+ )
85
+
86
+ analytics.screen(
87
+ user_id: user_id,
88
+ name: 'Test Screen',
89
+ anonymous_id: anonymous_id,
90
+ properties: properties,
91
+ context: context
92
+ )
93
+
94
+ analytics.identify(
95
+ user_id: '654321',
96
+ traits: traits,
97
+ context: context
98
+ )
99
+
100
+ analytics.group(
101
+ user_id: user_id,
102
+ group_id: uid,
103
+ anonymous_id: anonymous_id,
104
+ traits: traits,
105
+ context: context
106
+ )
107
+
108
+ analytics.alias(
109
+ user_id: user_id,
110
+ previous_id: '654321',
111
+ context: context
112
+ )
113
+
114
+ analytics.page(
115
+ user_id: user_id,
116
+ name: 'Test Page',
117
+ anonymous_id: anonymous_id,
118
+ properties: properties,
119
+ context: context
120
+ )
18
121
 
19
122
  analytics.batch do |batch|
20
- batch.context = { source: "test"}
123
+ batch.context = context_with_library
21
124
  batch.integrations = { All: false, S3: true }
22
- batch.track({ event: "test" })
23
- batch.identify({ user_id: "test" })
24
- batch.screen({ user_id: "test", name: 'test'})
25
- batch.page({ user_id: "test", name: 'test'})
26
- batch.alias({ user_id: "test", previous_id: 'test'})
27
- batch.group({ group_id: "test" })
28
- # batch.track(
29
- # user_id: 'test_user_id',
30
- # event: 'Created Account'
31
- # )
32
- # batch.page(
33
- # user_id: 'test_user_id',
34
- # name: 'Created Account',
35
- # properties: {
36
- # k1: 'v1'
37
- # }
38
- # )
39
- # batch.track(
40
- # user_id: 'test_user_id',
41
- # event: 'Closed Account'
42
- # )
43
- # batch.identify(
44
- # user_id: 'test_user_id_1',
45
- # traits: {
46
- # name: 'test'
47
- # }
48
- # )
49
- # batch.group(
50
- # user_id: 'test_user_id',
51
- # group_id: 'group_id'
52
- # )
53
- end
125
+
126
+ batch.track(
127
+ user_id: user_id,
128
+ event: 'Test Track',
129
+ anonymous_id: anonymous_id,
130
+ properties: properties
131
+ )
132
+
133
+ batch.screen(
134
+ user_id: user_id,
135
+ name: 'Test Screen',
136
+ anonymous_id: anonymous_id,
137
+ properties: properties
138
+ )
139
+
140
+ batch.identify(
141
+ user_id: '654321',
142
+ traits: traits
143
+ )
144
+
145
+ batch.group(
146
+ user_id: user_id,
147
+ group_id: uid,
148
+ anonymous_id: anonymous_id,
149
+ traits: traits
150
+ )
151
+
152
+ batch.alias(
153
+ user_id: user_id,
154
+ previous_id: '654321'
155
+ )
156
+
157
+ batch.page(
158
+ user_id: user_id,
159
+ name: 'Test Page',
160
+ anonymous_id: anonymous_id,
161
+ properties: properties
162
+ )
163
+ end