evntaly 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f33c5ed1efa2540d8f4180cc2918d57e3e3d0e54ee2508b5306ff096c8f34784
4
+ data.tar.gz: e981103ffa7558e04c875127664a78dafb22ecc81cc0686b1088488f44306c90
5
+ SHA512:
6
+ metadata.gz: 47762429b717e8d0d33544dcc81d7aee6637bc58156c6af5212ec4095ec2cee6225344dd1d39461fdca23e4c6088a5bc9cd9b1bad1dbb4c922018b8919b48e43
7
+ data.tar.gz: f0f85d9fce0bdfaedb815bdb2d1f11e9fe76d60b54461f16fe1b2fd1e7ed197b1fb0f90c4c15e0fb82491dd7ffa4b29194c3c13cec99b3db169a49789b35262f
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .rspec_status
2
+ .byebug_history
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in evntaly.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ evntaly (1.0.0)
5
+ json (~> 2.5)
6
+ net-http (~> 0.1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ byebug (12.0.0)
12
+ diff-lcs (1.6.1)
13
+ json (2.10.2)
14
+ net-http (0.1.1)
15
+ net-protocol
16
+ uri
17
+ net-protocol (0.2.2)
18
+ timeout
19
+ rake (13.2.1)
20
+ rspec (3.13.0)
21
+ rspec-core (~> 3.13.0)
22
+ rspec-expectations (~> 3.13.0)
23
+ rspec-mocks (~> 3.13.0)
24
+ rspec-core (3.13.3)
25
+ rspec-support (~> 3.13.0)
26
+ rspec-expectations (3.13.3)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.13.0)
29
+ rspec-mocks (3.13.2)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-support (3.13.2)
33
+ timeout (0.4.3)
34
+ uri (1.0.3)
35
+
36
+ PLATFORMS
37
+ arm64-darwin-24
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ byebug
42
+ evntaly!
43
+ rake (~> 13.0)
44
+ rspec (~> 3.10)
45
+
46
+ BUNDLED WITH
47
+ 2.5.22
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Evntaly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,116 @@
1
+ <p align="center">
2
+ <img src="https://cdn.evntaly.com/Resources/og.png" alt="Evntaly Cover" width="100%">
3
+ </p>
4
+
5
+ <h3 align="center">Evntaly</h3>
6
+
7
+ <p align="center">
8
+ An advanced event tracking and analytics platform designed to help developers capture, analyze, and react to user interactions efficiently.
9
+ </p>
10
+ <p align="center">
11
+ <a href="https://github.com/Evntaly/evntaly-ruby"><img src="https://img.shields.io/github/license/Evntaly/evntaly-ruby" alt="license"></a>
12
+ </p>
13
+
14
+ # evntaly-ruby
15
+ **EvntalySDK** is a ruby gem for interacting with the Evntaly event tracking platform. It provides methods to initialize tracking, log events, identify users, and check API usage limits.
16
+
17
+ ## Features
18
+
19
+ - **Initialize** the SDK with a developer secret and project token.
20
+ - **Track events** with metadata and tags.
21
+ - **Identify users** for personalization and analytics.
22
+ - **Enable or disable** tracking globally.
23
+
24
+ ## Installation
25
+
26
+ To install the SDK using `bundler`:
27
+
28
+ ```sh
29
+ gem 'evntaly', github: 'github.com/Evntaly/evntaly-ruby'
30
+ ```
31
+ and then run:
32
+ ```
33
+ bundle install
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ ### Initialization
39
+
40
+ Initialize the SDK with your developer secret and project token:
41
+
42
+ ```ruby
43
+ sdk = Evntaly::SDK.new(
44
+ developer_secret: 'YOUR_DEVELOPER_SECRET',
45
+ project_token: 'YOUR_PROJECT_TOKEN'
46
+ )
47
+ ```
48
+
49
+ ### Tracking Events
50
+
51
+ To track an event:
52
+
53
+ ```ruby
54
+ event = Evntaly::Event.new(
55
+ title: 'User Signed Up',
56
+ description: 'A new user signed up to the platform.',
57
+ message: 'Welcome email sent to the user.',
58
+ data: { plan: 'pro', referrer: 'campaign_xyz' },
59
+ tags: ['signup', 'email', 'marketing'],
60
+ notify: true,
61
+ icon: "💰",
62
+ apply_rule_only: false,
63
+ user: { id: '12345' },
64
+ type: 'user_event',
65
+ session_id: 'session_abc',
66
+ feature: 'onboarding',
67
+ topic: 'user_activity'
68
+ )
69
+
70
+ begin
71
+ sdk.track(event)
72
+ rescue => e
73
+ # error handling logic
74
+ end
75
+ ```
76
+
77
+ ### Identifying Users
78
+
79
+ To identify a user:
80
+
81
+ ```ruby
82
+ user = Evntaly::User.new(
83
+ id: 'u123',
84
+ email: 'user@example.com',
85
+ full_name: 'John Doe',
86
+ organization: 'Example Org',
87
+ data: { role: 'admin' }
88
+ )
89
+
90
+ begin
91
+ sdk.identify_user(user)
92
+ rescue => e
93
+ # error handling logic
94
+ end
95
+ ```
96
+
97
+ ### Enabling/Disabling Tracking
98
+
99
+ Control event tracking globally:
100
+
101
+ ```ruby
102
+ Evntaly::SDK.disable_tracking # Disables tracking
103
+ Evntaly::SDK.enable_tracking # Enables tracking
104
+ ```
105
+ And to check if tracking is enabled, do:
106
+ ```ruby
107
+ Evntaly::SDK.tracking_enabled?
108
+ ```
109
+
110
+ ## License
111
+
112
+ This project is licensed under the MIT License.
113
+
114
+ ---
115
+
116
+ *Note: Replace **`"YOUR_DEVELOPER_SECRET"`** and **`"YOUR_PROJECT_TOKEN"`** with actual credentials.*
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ module Tools
9
+ class Releaser < Bundler::GemHelper
10
+ def release(remote='origin')
11
+ tag_version do
12
+ git_push(remote)
13
+ end unless already_tagged?
14
+ end
15
+ end
16
+ end
17
+
18
+ desc 'Creates a tag using version.rb and pushes it to GitHub'
19
+ task 'gh-release', [:remote] do
20
+ Tools::Releaser.new.release
21
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "evntaly"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
data/evntaly.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ require_relative 'lib/evntaly/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "evntaly"
5
+ spec.version = Evntaly::VERSION
6
+ spec.authors = ["Sayed Alesawy"]
7
+
8
+ spec.summary = "Evntaly official library for your ruby projects"
9
+ spec.homepage = "https://github.com/Evntaly/evntaly-ruby"
10
+ spec.metadata["homepage_uri"] = spec.homepage
11
+ spec.license = "MIT"
12
+
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
+
15
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ end
18
+ spec.bindir = "bin"
19
+ spec.require_paths = ["lib"]
20
+
21
+ # Add dependencies here
22
+ spec.add_runtime_dependency "net-http", "~> 0.1.0"
23
+ spec.add_runtime_dependency "json", "~> 2.5"
24
+
25
+ # Development dependencies
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
+ spec.add_development_dependency "rspec", "~> 3.10"
28
+ spec.add_development_dependency 'byebug'
29
+
30
+ # post-install message
31
+ spec.post_install_message = "Thank you for using the Evntaly SDK. For more details, visit https://evntaly.com"
32
+ end
@@ -0,0 +1,40 @@
1
+ module Evntaly
2
+ class Event
3
+ attr_accessor :title, :description, :message, :data, :tags, :notify, :icon,
4
+ :apply_rule_only, :user, :type, :session_id, :feature, :topic
5
+
6
+ def initialize(title:, description:, message:, data:, tags:, notify:, icon:, apply_rule_only:, user:, type:, session_id:, feature:, topic:)
7
+ @title = title
8
+ @description = description
9
+ @message = message
10
+ @data = data
11
+ @tags = tags
12
+ @notify = notify
13
+ @icon = icon
14
+ @apply_rule_only = apply_rule_only
15
+ @user = user
16
+ @type = type
17
+ @session_id = session_id
18
+ @feature = feature
19
+ @topic = topic
20
+ end
21
+
22
+ def to_json(*_args)
23
+ {
24
+ title: @title,
25
+ description: @description,
26
+ message: @message,
27
+ data: @data,
28
+ tags: @tags,
29
+ notify: @notify,
30
+ icon: @icon,
31
+ apply_rule_only: @apply_rule_only,
32
+ user: @user,
33
+ type: @type,
34
+ session_id: @session_id,
35
+ feature: @feature,
36
+ topic: @topic
37
+ }.to_json
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,110 @@
1
+ require "net/http"
2
+ require "json"
3
+ require "uri"
4
+
5
+ module Evntaly
6
+ class SDK
7
+ attr_accessor :base_url, :developer_secret, :project_token, :timeout
8
+
9
+ @@tracking_enabled = true
10
+
11
+ def initialize(developer_secret:, project_token:)
12
+ @base_url = "https://app.evntaly.com/prod"
13
+ @developer_secret = developer_secret
14
+ @project_token = project_token
15
+ end
16
+
17
+ def set_timeout(seconds)
18
+ @timeout = seconds
19
+ end
20
+
21
+ def check_limit
22
+ uri = URI("#{base_url}/api/v1/account/check-limits/#{developer_secret}")
23
+ request = Net::HTTP::Get.new(uri, "Content-Type" => "application/json")
24
+
25
+ response = send_request(uri, request)
26
+
27
+ result = JSON.parse(response.body)
28
+ raise "Unexpected API response format" unless result.key?("limitReached")
29
+
30
+ !result["limitReached"]
31
+ rescue => e
32
+ puts "Error checking limit: #{e.message}"
33
+ false
34
+ end
35
+
36
+ def track(event)
37
+ unless self.class.tracking_enabled?
38
+ puts "Tracking is disabled. Event not sent."
39
+ return
40
+ end
41
+
42
+ unless check_limit
43
+ puts "checkLimit returned false. Event not sent."
44
+ return
45
+ end
46
+
47
+ uri = URI("#{base_url}/api/v1/register/event")
48
+ request = Net::HTTP::Post.new(uri)
49
+ request["Content-Type"] = "application/json"
50
+ request["secret"] = developer_secret
51
+ request["pat"] = project_token
52
+ request.body = event.to_json
53
+
54
+ response = send_request(uri, request)
55
+
56
+ unless response.code.to_i.between?(200, 299)
57
+ raise "Failed to track event: status code #{response.code}"
58
+ end
59
+
60
+ puts "✅ Event tracked successfully"
61
+ end
62
+
63
+ def identify_user(user)
64
+ uri = URI("#{base_url}/api/v1/register/user")
65
+ request = Net::HTTP::Post.new(uri)
66
+ request["Content-Type"] = "application/json"
67
+ request["secret"] = developer_secret
68
+ request["pat"] = project_token
69
+ request.body = user.to_json
70
+
71
+ response = send_request(uri, request)
72
+
73
+ unless response.code.to_i.between?(200, 299)
74
+ raise "Failed to identify user: status code #{response.code}"
75
+ end
76
+
77
+ puts "✅ User identified successfully"
78
+
79
+ true
80
+ end
81
+
82
+ def self.tracking_enabled?
83
+ @@tracking_enabled
84
+ end
85
+
86
+ def self.disable_tracking
87
+ @@tracking_enabled = false
88
+ puts "🚫 Tracking disabled."
89
+ end
90
+
91
+ def self.enable_tracking
92
+ @@tracking_enabled = true
93
+ puts "🟢 Tracking enabled."
94
+ end
95
+
96
+ private
97
+
98
+ def send_request(uri, request)
99
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, open_timeout: @timeout, read_timeout: @timeout) do |http|
100
+ http.request(request)
101
+ end
102
+ rescue Net::OpenTimeout
103
+ raise "Request timed out (open timeout)"
104
+ rescue Net::ReadTimeout
105
+ raise "Request timed out (read timeout)"
106
+ rescue StandardError => e
107
+ raise "Network error: #{e.message}"
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,23 @@
1
+ module Evntaly
2
+ class User
3
+ attr_accessor :id, :email, :full_name, :organization, :data
4
+
5
+ def initialize(id:, email:, full_name:, organization:, data:)
6
+ @id = id
7
+ @email = email
8
+ @full_name = full_name
9
+ @organization = organization
10
+ @data = data
11
+ end
12
+
13
+ def to_json(*_args)
14
+ {
15
+ id: @id,
16
+ email: @email,
17
+ full_name: @full_name,
18
+ organization: @organization,
19
+ data: @data
20
+ }.to_json
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Evntaly
2
+ VERSION = "1.0.0"
3
+ end
data/lib/evntaly.rb ADDED
@@ -0,0 +1,7 @@
1
+ require_relative 'evntaly/version'
2
+
3
+ module Evntaly
4
+ autoload :Event, 'evntaly/event'
5
+ autoload :User, 'evntaly/user'
6
+ autoload :SDK, 'evntaly/sdk'
7
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: evntaly
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sayed Alesawy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".gitignore"
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - evntaly.gemspec
98
+ - lib/evntaly.rb
99
+ - lib/evntaly/event.rb
100
+ - lib/evntaly/sdk.rb
101
+ - lib/evntaly/user.rb
102
+ - lib/evntaly/version.rb
103
+ homepage: https://github.com/Evntaly/evntaly-ruby
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ homepage_uri: https://github.com/Evntaly/evntaly-ruby
108
+ post_install_message: Thank you for using the Evntaly SDK. For more details, visit
109
+ https://evntaly.com
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.6.0
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.5.18
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Evntaly official library for your ruby projects
128
+ test_files: []