0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-18 23:01:11 +02:00

Merge pull request #274 from paviliondev/add_discourse_plugin_statistics

Add discourse_plugin_statistics plugin definition
Dieser Commit ist enthalten in:
Angus McLeod 2023-11-15 09:28:22 +01:00 committet von GitHub
Commit 112a0eeee3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 187 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -25,3 +25,7 @@ If you're not sure how to install a plugin in Discourse, please follow the [plug
## Support
- [Report an issue](https://pavilion.tech/products/discourse-custom-wizard-plugin/support/bug-report)
## Statistics
For improved service and development, this plugin collects some generalised quantitative data related to version and usage. No personal or sensitive information is gathered. Please email contact@pavilion.tech if you have any questions or concerns about our data collection.

Datei anzeigen

@ -0,0 +1,98 @@
# frozen_string_literal: true
module DiscoursePluginStatistics
class Plugin
def self.discourse_custom_wizard
subscription_features = {
wizard: {
save_submissions: 0,
after_signup: 0,
prompt_completion: 0,
required: 0,
permitted: 0,
},
step: {
required_data: 0,
permitted_params: 0,
force_final: 0
},
field: {
condition: 0,
type: {
text: 0,
textarea: 0,
text_only: 0,
date: 0,
time: 0,
date_time: 0,
number: 0,
checkbox: 0,
dropdown: 0,
composer: 0,
composer_preview: 0,
url: 0,
upload: 0,
tag: 0,
category: 0,
group: 0,
user_selector: 0,
},
realtime_validations: 0
},
action: {
type: {
create_topic: 0,
send_message: 0,
update_profile: 0,
open_composer: 0,
route_to: 0,
send_to_api: 0,
watch_categories: 0,
watch_tags: 0,
add_to_group: 0,
create_group: 0,
create_category: 0,
}
}
}
increment_feature_count = lambda do |type, key, value|
if key == 'type'
if !subscription_features[type.to_sym][:type][value.to_sym].nil?
subscription_features[type.to_sym][:type][value.to_sym] += 1
end
else
if !subscription_features[type.to_sym][key.to_sym].nil?
subscription_features[type.to_sym][key.to_sym] += 1
end
end
end
CustomWizard::Template.list.each do |template|
template.each do |key, value|
increment_feature_count.call(:wizard, key, value)
end
template['steps'].each do |step|
step.each do |key, value|
increment_feature_count.call(:step, key, value)
end
step['fields'].each do |field|
field.each do |key, value|
increment_feature_count.call(:field, key, value)
end
end
end
template['actions'].each do |action|
action.each do |key, value|
increment_feature_count.call(:action, key, value)
end
end
end
{
total_wizards: CustomWizard::Template.list.size,
subscription_type: CustomWizard::Subscription.type.to_s,
subscription_features: subscription_features
}
end
end
end

Datei anzeigen

@ -1,13 +1,14 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.4.30
# version: 2.5.0
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech
# subscription_url: https://coop.pavilion.tech
gem 'liquid', '5.0.1', require: true
gem 'discourse_plugin_statistics', '0.1.0.pre7', require: true
register_asset 'stylesheets/common/admin.scss'
register_asset 'stylesheets/common/wizard.scss'
@ -73,6 +74,7 @@ after_initialize do
../lib/custom_wizard/api/log_entry.rb
../lib/custom_wizard/liquid_extensions/first_non_empty.rb
../lib/custom_wizard/exceptions/exceptions.rb
../lib/discourse_plugin_statistics/plugin.rb
../app/serializers/custom_wizard/api/authorization_serializer.rb
../app/serializers/custom_wizard/api/basic_endpoint_serializer.rb
../app/serializers/custom_wizard/api/endpoint_serializer.rb

Datei anzeigen

@ -0,0 +1,82 @@
# frozen_string_literal: true
describe DiscoursePluginStatistics::Plugin do
let(:template_json) { get_wizard_fixture("wizard") }
describe "#discourse_custom_wizard" do
before do
enable_subscription('standard')
CustomWizard::Template.save(template_json, skip_jobs: true)
template_json_2 = template_json.dup
template_json_2["id"] = 'super_mega_fun_wizard_2'
CustomWizard::Template.save(template_json_2, skip_jobs: true)
@data = DiscoursePluginStatistics::Plugin.discourse_custom_wizard
end
it "includes a total wizard count" do
expect(@data[:total_wizards]).to eq(2)
end
it "includes the subscription type" do
expect(@data[:subscription_type]).to eq('standard')
end
it "includes a count of features being used across all wizards" do
expect(@data[:subscription_features]).to eq(
wizard: {
save_submissions: 2,
after_signup: 2,
prompt_completion: 2,
required: 0,
permitted: 0,
},
step: {
required_data: 0,
permitted_params: 0,
force_final: 0
},
field: {
condition: 0,
type: {
text: 2,
textarea: 2,
text_only: 2,
date: 2,
time: 2,
date_time: 2,
number: 2,
checkbox: 2,
dropdown: 2,
composer: 0,
composer_preview: 0,
url: 0,
upload: 0,
tag: 0,
category: 0,
group: 0,
user_selector: 0,
},
realtime_validations: 0
},
action: {
type: {
create_topic: 2,
send_message: 0,
update_profile: 2,
open_composer: 2,
route_to: 2,
send_to_api: 0,
watch_categories: 0,
watch_tags: 0,
add_to_group: 0,
create_group: 0,
create_category: 0,
}
}
)
end
end
end