ahoy_panel 0.0.5 β 0.0.7
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/README.md +77 -9
- data/app/controllers/ahoy_panel/application_controller.rb +25 -0
- data/app/controllers/ahoy_panel/views_data_controller.rb +12 -0
- data/app/controllers/ahoy_panel/visits_controller.rb +7 -3
- data/config/routes.rb +3 -1
- data/lib/ahoy_panel/version.rb +1 -1
- data/lib/ahoy_panel.rb +2 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30ad1497fbf5bf2457d257333673b84c928df34e620669bdd54139f6e08139ef
|
4
|
+
data.tar.gz: 0edb2465e6c4780691b4ccdac95e26eaafe9d2e2b083396664fb8e05f2c7dc96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66637704dab635875a85244c19f2937c3ca54d85e5df9fbe079516def52dc27d991c94db4714f41796cfe4290967719002fb37e49e7e3321a0e9bcc5e8565d3
|
7
|
+
data.tar.gz: b1e106a8825fd6f90db2eb52dd37dbd1f51c37bdb9e94a8ceb98d37f0030584a550cb75c0afa28e7c9ab2f0cd9de6d53c98e2ece401b7e0bf188c4a01a8b2580
|
data/README.md
CHANGED
@@ -1,28 +1,96 @@
|
|
1
|
-
#
|
2
|
-
Short description and motivation.
|
1
|
+
# Ahoy Panel
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
[](https://badge.fury.io/rb/ahoy_panel)
|
4
|
+
|
5
|
+
**Ahoy Panel** is a companion gem for the [Ahoy Panel](https://www.ahoypanel.com) web app β a modern, hosted dashboard for your [Ahoy](https://github.com/ankane/ahoy) analytics data.
|
6
|
+
|
7
|
+
It enables your Rails app to stream Ahoy events to the Ahoy Panel API for real-time analytics and beautiful insights.
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## Features
|
12
|
+
|
13
|
+
- π Simple integration with your existing Ahoy setup
|
14
|
+
- π Centralized dashboard at [ahoypanel.com](https://www.ahoypanel.com)
|
15
|
+
- π Lightweight and configurable
|
16
|
+
- π Secure API key-based authentication
|
17
|
+
|
18
|
+
---
|
6
19
|
|
7
20
|
## Installation
|
8
|
-
|
21
|
+
|
22
|
+
Add this line to your Rails application's Gemfile:
|
9
23
|
|
10
24
|
```ruby
|
11
25
|
gem "ahoy_panel"
|
12
26
|
```
|
13
27
|
|
14
28
|
And then execute:
|
29
|
+
|
15
30
|
```bash
|
16
|
-
|
31
|
+
bundle install
|
17
32
|
```
|
18
33
|
|
19
|
-
|
34
|
+
---
|
35
|
+
|
36
|
+
## Configuration
|
37
|
+
|
38
|
+
After installing the gem, you'll need to configure it to connect to your Ahoy Panel account. This gem assumes that you already have `ahoy_matey` gem installed, configured, and in usage.
|
39
|
+
|
40
|
+
Create an initializer file:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# config/initializers/ahoy_panel.rb
|
44
|
+
AhoyPanel.configure do |config|
|
45
|
+
# Your projectβs API key from https://www.ahoypanel.com/settings
|
46
|
+
config.api_key = ENV.fetch("AHOY_PANEL_API_KEY")
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
Add your API key to your environment variables:
|
51
|
+
|
20
52
|
```bash
|
21
|
-
|
53
|
+
# .env
|
54
|
+
AHOY_PANEL_API_KEY=your-api-key-here
|
22
55
|
```
|
23
56
|
|
57
|
+
---
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
Once configured, anytime you load your dashboard in [Ahoy Panel](https://www.ahoypanel.com), your `ahoy_panel` will send the data that's needed `Ahoy::Visit` and `Ahoy::Event` to [Ahoy Panel](https://www.ahoypanel.com) to build the dashboard.
|
62
|
+
|
63
|
+
No extra setup required β just install, configure, and you're done! π
|
64
|
+
|
65
|
+
---
|
66
|
+
|
67
|
+
## Requirements
|
68
|
+
|
69
|
+
- Rails 6+
|
70
|
+
- [Ahoy](https://github.com/ankane/ahoy) gem installed and configured
|
71
|
+
|
72
|
+
---
|
73
|
+
|
74
|
+
## Privacy & Performance
|
75
|
+
|
76
|
+
- Events are batched and sent asynchronously to minimize request overhead
|
77
|
+
- Only relevant event data (like `name`, `properties`, `user_id`, and timestamps) is sent
|
78
|
+
- You retain full control over what data is tracked
|
79
|
+
|
80
|
+
---
|
81
|
+
|
82
|
+
## Troubleshooting
|
83
|
+
|
84
|
+
- Ensure your API key is correct and the base_url configured in your [Ahoy Panel](https://www.ahoypanel.com) account is correct. Any issues, reach out.
|
85
|
+
|
86
|
+
---
|
87
|
+
|
24
88
|
## Contributing
|
25
|
-
|
89
|
+
|
90
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/typefastco/ahoy_panel](https://github.com/typefastco/ahoy_panel).
|
91
|
+
|
92
|
+
---
|
26
93
|
|
27
94
|
## License
|
95
|
+
|
28
96
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -1,4 +1,29 @@
|
|
1
1
|
module AhoyPanel
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
before_action :authenticate_api_key!
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def authenticate_api_key!
|
8
|
+
api_key = request.headers["Ahoy-Panel-Api-Key"]
|
9
|
+
|
10
|
+
return true if Rails.env.development?
|
11
|
+
|
12
|
+
ahoy_panel_root_url = "https://www.ahoypanel.com"
|
13
|
+
|
14
|
+
client = Faraday.new(url: ahoy_panel_root_url) do |conn|
|
15
|
+
conn.headers["Ahoy-Panel-Api-Key"] = "#{api_key}"
|
16
|
+
conn.request :json
|
17
|
+
conn.response :json
|
18
|
+
end
|
19
|
+
|
20
|
+
response = client.get("/api_key_verify")
|
21
|
+
|
22
|
+
client = Faraday.new(url: ahoy_panel_root_url)
|
23
|
+
|
24
|
+
if !response.body["verified"]
|
25
|
+
client.get("/invalid_api_key")
|
26
|
+
end
|
27
|
+
end
|
3
28
|
end
|
4
29
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module AhoyPanel
|
2
|
+
class ViewsDataController < ApplicationController
|
3
|
+
def index
|
4
|
+
@start_date = params[:start_date].to_date
|
5
|
+
@end_date = params[:end_date].to_date
|
6
|
+
|
7
|
+
@visits = ::Ahoy::Visit.where(started_at: @start_date..@end_date)
|
8
|
+
|
9
|
+
render json: @visits
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module AhoyPanel
|
2
2
|
class VisitsController < ApplicationController
|
3
|
-
def
|
4
|
-
|
3
|
+
def all_time_dates
|
4
|
+
start_date = ::Ahoy::Visit.order(started_at: :asc).first.started_at.to_date
|
5
|
+
end_date = ::Ahoy::Visit.order(started_at: :desc).first.started_at.to_date
|
5
6
|
|
6
|
-
render json:
|
7
|
+
render json: {
|
8
|
+
start_date: start_date,
|
9
|
+
end_date: end_date
|
10
|
+
}
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
data/config/routes.rb
CHANGED
data/lib/ahoy_panel/version.rb
CHANGED
data/lib/ahoy_panel.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahoy_panel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Jeon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-28 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '6'
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '
|
25
|
+
version: '6'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: ahoy_matey
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,6 +51,20 @@ dependencies:
|
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.3'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: faraday
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.12'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.12'
|
54
68
|
description: Ahoy is a great analytics tracking gem. AhoyPanel is a great dashboard
|
55
69
|
for the data collected by Ahoy.
|
56
70
|
email:
|
@@ -64,6 +78,7 @@ files:
|
|
64
78
|
- Rakefile
|
65
79
|
- app/assets/stylesheets/ahoy_panel/application.css
|
66
80
|
- app/controllers/ahoy_panel/application_controller.rb
|
81
|
+
- app/controllers/ahoy_panel/views_data_controller.rb
|
67
82
|
- app/controllers/ahoy_panel/visits_controller.rb
|
68
83
|
- app/helpers/ahoy_panel/application_helper.rb
|
69
84
|
- app/jobs/ahoy_panel/application_job.rb
|