diff --git a/CHANGELOG.md b/CHANGELOG.md index 718c547d..1f0cc432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changed -- Stats page now loads significantly faster due to caching +- Stats page now loads significantly faster due to caching. - Data on the Stats page is being updated daily, except for total distance and number of geopoints tracked, which are being updated on the fly. Also, charts with yearly and monthly stats are being updated every hour. - Minor versions are now being built only for amd64 architecture to speed up the build process. - If user is not authorized to see a page, they will be redirected to the home page with appropriate message instead of seeing an error. diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 113e6ec7..5b453fbc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,58 +21,6 @@ module ApplicationHelper %w[info success warning error accent secondary primary] end - def countries_and_cities_stat_for_year(year, stats) - data = { countries: [], cities: [] } - - stats.select { _1.year == year }.each do - data[:countries] << _1.toponyms.flatten.map { |t| t['country'] }.uniq.compact - data[:cities] << _1.toponyms.flatten.flat_map { |t| t['cities'].map { |c| c['city'] } }.compact.uniq - end - - data[:cities].flatten!.uniq! - data[:countries].flatten!.uniq! - - grouped_by_country = {} - stats.select { _1.year == year }.each do |stat| - stat.toponyms.flatten.each do |toponym| - country = toponym['country'] - next if country.blank? - - grouped_by_country[country] ||= [] - - next if toponym['cities'].blank? - - toponym['cities'].each do |city_data| - city = city_data['city'] - grouped_by_country[country] << city if city.present? - end - end - end - - grouped_by_country.transform_values!(&:uniq) - - { - countries_count: data[:countries].count, - cities_count: data[:cities].count, - grouped_by_country: grouped_by_country.transform_values(&:sort).sort.to_h, - year: year, - modal_id: "countries_cities_modal_#{year}" - } - end - - def countries_and_cities_stat_for_month(stat) - countries = stat.toponyms.count { _1['country'] } - cities = stat.toponyms.sum { _1['cities'].count } - - "#{countries} countries, #{cities} cities" - end - - def year_distance_stat(year, user) - # Distance is now stored in meters, convert to user's preferred unit for display - total_distance_meters = Stat.year_distance(year, user).sum { _1[1] } - Stat.convert_distance(total_distance_meters, user.safe_settings.distance_unit) - end - def new_version_available? CheckAppVersion.new.call end diff --git a/app/jobs/users/mailer_sending_job.rb b/app/jobs/users/mailer_sending_job.rb index fef4fcea..ae8b80dc 100644 --- a/app/jobs/users/mailer_sending_job.rb +++ b/app/jobs/users/mailer_sending_job.rb @@ -26,10 +26,6 @@ class Users::MailerSendingJob < ApplicationJob user.active? when 'post_trial_reminder_early', 'post_trial_reminder_late' user.active? || !user.trial? - when 'subscription_expires_soon_early', 'subscription_expires_soon_late' - !user.active? || !user.active_until&.future? - when 'subscription_expired_early', 'subscription_expired_late' - user.active? || user.active_until&.future? || user.trial? else false end @@ -41,10 +37,6 @@ class Users::MailerSendingJob < ApplicationJob 'user is already subscribed' when 'post_trial_reminder_early', 'post_trial_reminder_late' user.active? ? 'user is subscribed' : 'user is not in trial state' - when 'subscription_expires_soon_early', 'subscription_expires_soon_late' - 'user is not active or subscription already expired' - when 'subscription_expired_early', 'subscription_expired_late' - 'user is active, subscription not expired, or user is in trial' else 'unknown reason' end diff --git a/app/mailers/users_mailer.rb b/app/mailers/users_mailer.rb index a06d3dc9..95afd3ea 100644 --- a/app/mailers/users_mailer.rb +++ b/app/mailers/users_mailer.rb @@ -2,62 +2,44 @@ class UsersMailer < ApplicationMailer def welcome + # Sent after user signs up @user = params[:user] mail(to: @user.email, subject: 'Welcome to Dawarich!') end def explore_features + # Sent 2 days after user signs up @user = params[:user] mail(to: @user.email, subject: 'Explore Dawarich features!') end def trial_expires_soon + # Sent 2 days before trial expires @user = params[:user] mail(to: @user.email, subject: '⚠️ Your Dawarich trial expires in 2 days') end def trial_expired + # Sent when trial expires @user = params[:user] mail(to: @user.email, subject: 'πŸ’” Your Dawarich trial expired') end def post_trial_reminder_early + # Sent 2 days after trial expires @user = params[:user] mail(to: @user.email, subject: 'πŸš€ Still interested in Dawarich? Subscribe now!') end def post_trial_reminder_late + # Sent 7 days after trial expires @user = params[:user] mail(to: @user.email, subject: 'πŸ“ Your location data is waiting - Subscribe to Dawarich') end - - def subscription_expires_soon_early - @user = params[:user] - - mail(to: @user.email, subject: '⚠️ Your Dawarich subscription expires in 14 days') - end - - def subscription_expires_soon_late - @user = params[:user] - - mail(to: @user.email, subject: '🚨 Your Dawarich subscription expires in 2 days') - end - - def subscription_expired_early - @user = params[:user] - - mail(to: @user.email, subject: 'πŸ’” Your Dawarich subscription expired - Reactivate now') - end - - def subscription_expired_late - @user = params[:user] - - mail(to: @user.email, subject: 'πŸ“ Missing your location insights? Renew Dawarich subscription') - end end diff --git a/app/models/user.rb b/app/models/user.rb index 4ff89d3b..19da0fd3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,6 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength after_create :create_api_key after_commit :activate, on: :create, if: -> { DawarichSettings.self_hosted? } after_commit :start_trial, on: :create, if: -> { !DawarichSettings.self_hosted? } - after_commit :schedule_subscription_emails_on_activation, if: :should_schedule_subscription_emails? before_save :sanitize_input @@ -170,45 +169,6 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength Users::MailerSendingJob.set(wait: 14.days).perform_later(id, 'post_trial_reminder_late') end - def schedule_subscription_expiry_emails - return unless active? && active_until&.future? - - days_until_expiry = (active_until.to_date - Time.current.to_date).to_i - - if days_until_expiry >= 14 - Users::MailerSendingJob.set(wait: (days_until_expiry - 14).days).perform_later(id, - 'subscription_expires_soon_early') - end - - if days_until_expiry >= 2 - Users::MailerSendingJob.set(wait: (days_until_expiry - 2).days).perform_later(id, - 'subscription_expires_soon_late') - end - - schedule_subscription_expired_emails - end - - def schedule_subscription_expired_emails - return unless active? && active_until&.future? - - days_until_expiry = (active_until.to_date - Time.current.to_date).to_i - - Users::MailerSendingJob.set(wait: (days_until_expiry + 7).days).perform_later(id, 'subscription_expired_early') - Users::MailerSendingJob.set(wait: (days_until_expiry + 14).days).perform_later(id, 'subscription_expired_late') - end - - def should_schedule_subscription_emails? - return false unless persisted? - - # Schedule if status changed to active or active_until was updated for an active user - (saved_change_to_status? && status == 'active') || - (saved_change_to_active_until? && active? && active_until&.future?) - end - - def schedule_subscription_emails_on_activation - schedule_subscription_expiry_emails - end - def countries_visited_uncached points .without_raw_data diff --git a/app/views/stats/index.html.erb b/app/views/stats/index.html.erb index 706e30b3..926b5b5e 100644 --- a/app/views/stats/index.html.erb +++ b/app/views/stats/index.html.erb @@ -25,7 +25,6 @@ All stats data above except for total distance and number of geopoints tracked is being updated daily - <% if current_user.active? %> <%= link_to 'Update stats', update_all_stats_path, data: { turbo_method: :put }, class: 'btn btn-primary mt-5' %> <% end %> diff --git a/app/views/users_mailer/explore_features.html.erb b/app/views/users_mailer/explore_features.html.erb index 9d8c64c0..9e70e509 100644 --- a/app/views/users_mailer/explore_features.html.erb +++ b/app/views/users_mailer/explore_features.html.erb @@ -17,12 +17,17 @@

Explore Dawarich Features

-

Hi <%= @user.email %>,

+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

-

You're now 2 days into your Dawarich trial! We hope you're enjoying tracking your location data.

+

You're now 2 days into your Dawarich trial! I hope you're enjoying tracking your location data.

Here are some powerful features you might want to explore:

+
+

✈️ Reliving your travels

+

Revisit your past journeys with detailed maps and insights.

+
+

πŸ“Š Statistics & Analytics

View detailed insights about distances traveled and time spent in different locations.

diff --git a/app/views/users_mailer/explore_features.text.erb b/app/views/users_mailer/explore_features.text.erb index 0ffa8e99..e6b92042 100644 --- a/app/views/users_mailer/explore_features.text.erb +++ b/app/views/users_mailer/explore_features.text.erb @@ -1,11 +1,14 @@ Explore Dawarich Features -Hi <%= @user.email %>, +Hi <%= @user.email %>, this is Evgenii from Dawarich. -You're now 2 days into your Dawarich trial! We hope you're enjoying tracking your location data. +You're now 2 days into your Dawarich trial! I hope you're enjoying tracking your location data. Here are some powerful features you might want to explore: +✈️ Reliving your travels +Revisit your past journeys with detailed maps and insights. + πŸ“Š Statistics & Analytics View detailed insights about distances traveled and time spent in different locations. diff --git a/app/views/users_mailer/post_trial_reminder_early.html.erb b/app/views/users_mailer/post_trial_reminder_early.html.erb new file mode 100644 index 00000000..c2459943 --- /dev/null +++ b/app/views/users_mailer/post_trial_reminder_early.html.erb @@ -0,0 +1,49 @@ + + + + + + + +
+
+

πŸš€ Still Interested in Dawarich?

+
+
+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

+ +
+

Your Dawarich trial ended 2 days ago.

+
+ +

I noticed you haven't subscribed yet, but I don't want you to miss out on the amazing features Dawarich has to offer!

+ +

Your location data is still safely stored and waiting for you for 365 days. With a subscription, you can pick up exactly where you left off.

+ +

🌟 What you're missing:

+
    +
  • Real-time location tracking and analysis
  • +
  • Beautiful, interactive maps with your travel history
  • +
  • Detailed statistics and insights about your journeys
  • +
  • Data export capabilities for your peace of mind
  • +
+ + Subscribe Now + +

Ready to unlock your location story? Subscribe today and continue your journey with Dawarich!

+ +

Questions? Just reply to this email – I'm here to help.

+ +

Best regards,
+ Evgenii from Dawarich

+
+
+ + diff --git a/app/views/users_mailer/post_trial_reminder_early.text.erb b/app/views/users_mailer/post_trial_reminder_early.text.erb new file mode 100644 index 00000000..be2edcc8 --- /dev/null +++ b/app/views/users_mailer/post_trial_reminder_early.text.erb @@ -0,0 +1,24 @@ +πŸš€ Still Interested in Dawarich? + +Hi <%= @user.email %>, + +Your Dawarich trial ended 2 days ago. + +I noticed you haven't subscribed yet, but I don't want you to miss out on the amazing features Dawarich has to offer! + +Your location data is still safely stored and waiting for you for 365 days. With a subscription, you can pick up exactly where you left off. + +🌟 What you're missing: +- Real-time location tracking and analysis +- Beautiful, interactive maps with your travel history +- Detailed statistics and insights about your journeys +- Data export capabilities for your peace of mind + +Subscribe now: https://my.dawarich.app + +Ready to unlock your location story? Subscribe today and continue your journey with Dawarich! + +Questions? Just reply to this email – I'm here to help. + +Best regards, +Evgenii from Dawarich diff --git a/app/views/users_mailer/post_trial_reminder_late.html.erb b/app/views/users_mailer/post_trial_reminder_late.html.erb new file mode 100644 index 00000000..f347ecb0 --- /dev/null +++ b/app/views/users_mailer/post_trial_reminder_late.html.erb @@ -0,0 +1,51 @@ + + + + + + + +
+
+

πŸ“ Your Location Data is Waiting

+
+
+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

+ +
+

It's been a week since your Dawarich trial ended.

+
+ +

Your location data is still safely stored and patiently waiting for you to return. I understand that choosing the right tool for your location tracking needs is important, and I wanted to reach out one more time.

+ +

πŸ—ΊοΈ Here's what's waiting for you:

+
    +
  • All your location data, preserved and ready
  • +
  • Reliving your travels through detailed maps and insights
  • +
  • Privacy-first approach – your data stays yours
  • +
  • Beautiful visualizations of your travel patterns
  • +
  • Regular updates and new features
  • +
+ + Return to Dawarich + +

This is my final reminder about your trial. If Dawarich isn't the right fit for you right now, I completely understand. Your data will remain secure for the next year, and you're always welcome back.

+ +

Thank you for giving Dawarich a try. I hope to see you again soon!

+ +

Safe travels,
+ Evgenii from Dawarich

+ +

P.S. If you have any questions or need assistance, just hit reply – I'm here to help!

+
+
+ + diff --git a/app/views/users_mailer/post_trial_reminder_late.text.erb b/app/views/users_mailer/post_trial_reminder_late.text.erb new file mode 100644 index 00000000..d43db950 --- /dev/null +++ b/app/views/users_mailer/post_trial_reminder_late.text.erb @@ -0,0 +1,26 @@ +πŸ“ Your Location Data is Waiting + +Hi <%= @user.email %>, this is Evgenii from Dawarich. + +It's been a week since your Dawarich trial ended. + +Your location data is still safely stored and patiently waiting for you to return. I understand that choosing the right tool for your location tracking needs is important, and I wanted to reach out one more time. + +πŸ—ΊοΈ Here's what's waiting for you: +- All your location data, preserved and ready +- Reliving your travels through detailed maps and insights +- Privacy-first approach – your data stays yours +- Beautiful visualizations of your travel patterns +- Integration with popular location apps and services +- Regular updates and new features + +Return to Dawarich: https://my.dawarich.app + +This is my final reminder about your trial. If Dawarich isn't the right fit for you right now, I completely understand. Your data will remain secure for the next year, and you're always welcome back. + +Thank you for giving Dawarich a try. I hope to see you again soon! + +Safe travels, +Evgenii from Dawarich + +P.S. If you have any questions or need assistance, just hit reply – I'm here to help! diff --git a/app/views/users_mailer/trial_expired.html.erb b/app/views/users_mailer/trial_expired.html.erb index 3294b88b..6407fdbf 100644 --- a/app/views/users_mailer/trial_expired.html.erb +++ b/app/views/users_mailer/trial_expired.html.erb @@ -17,13 +17,13 @@

πŸ”’ Your Trial Has Expired

-

Hi <%= @user.email %>,

+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

Your 7-day Dawarich trial has ended.

-

Thank you for trying Dawarich! We hope you enjoyed exploring your location data over the past week.

+

Thank you for trying Dawarich! I hope you enjoyed exploring your location data over the past week.

Your trial account is now limited, but your data is safe and secure. To regain full access to all features, please subscribe to continue your journey with Dawarich.

@@ -40,7 +40,7 @@

Ready to unlock the full power of location insights? Subscribe now and pick up right where you left off!

-

We'd love to have you back as a subscriber.

+

I'd love to have you back as a subscriber.

Best regards,
Evgenii from Dawarich

diff --git a/app/views/users_mailer/trial_expired.text.erb b/app/views/users_mailer/trial_expired.text.erb index d43178f3..338f0899 100644 --- a/app/views/users_mailer/trial_expired.text.erb +++ b/app/views/users_mailer/trial_expired.text.erb @@ -1,10 +1,10 @@ πŸ”’ Your Trial Has Expired -Hi <%= @user.email %>, +Hi <%= @user.email %>, this is Evgenii from Dawarich. Your 7-day Dawarich trial has ended. -Thank you for trying Dawarich! We hope you enjoyed exploring your location data over the past week. +Thank you for trying Dawarich! I hope you enjoyed exploring your location data over the past week. Your trial account is now limited, but your data is safe and secure. To regain full access to all features, please subscribe to continue your journey with Dawarich. @@ -19,7 +19,7 @@ Subscribe to continue: https://my.dawarich.app Ready to unlock the full power of location insights? Subscribe now and pick up right where you left off! -We'd love to have you back as a subscriber. +I'd love to have you back as a subscriber. Best regards, Evgenii from Dawarich diff --git a/app/views/users_mailer/trial_expires_soon.html.erb b/app/views/users_mailer/trial_expires_soon.html.erb index c1e5ff6e..a0ac2f3f 100644 --- a/app/views/users_mailer/trial_expires_soon.html.erb +++ b/app/views/users_mailer/trial_expires_soon.html.erb @@ -17,13 +17,13 @@

⏰ Your Trial Expires Soon

-

Hi <%= @user.email %>,

+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

⚠️ Important: Your Dawarich trial expires in just 2 days!

-

We hope you've enjoyed exploring your location data with Dawarich over the past 5 days.

+

I hope you've enjoyed exploring your location data with Dawarich over the past 5 days.

To continue using all of Dawarich's powerful features after your trial ends, you'll need to subscribe to a plan.

@@ -40,7 +40,7 @@

Don't lose access to your location insights. Subscribe today and continue your journey with Dawarich!

-

Questions? Drop us a message at hi@dawarich.app or just reply to this email.

+

Questions? Drop me a message at hi@dawarich.app or just reply to this email.

Best regards,
Evgenii from Dawarich

diff --git a/app/views/users_mailer/trial_expires_soon.text.erb b/app/views/users_mailer/trial_expires_soon.text.erb index c5f7352e..6b15ef3a 100644 --- a/app/views/users_mailer/trial_expires_soon.text.erb +++ b/app/views/users_mailer/trial_expires_soon.text.erb @@ -1,10 +1,10 @@ ⏰ Your Trial Expires Soon -Hi <%= @user.email %>, +Hi <%= @user.email %>, this is Evgenii from Dawarich. ⚠️ Important: Your Dawarich trial expires in just 2 days! -We hope you've enjoyed exploring your location data with Dawarich over the past 5 days. +I hope you've enjoyed exploring your location data with Dawarich over the past 5 days. To continue using all of Dawarich's powerful features after your trial ends, you'll need to subscribe to a plan. @@ -19,7 +19,7 @@ Subscribe now: https://my.dawarich.app Don't lose access to your location insights. Subscribe today and continue your journey with Dawarich! -Questions? Drop us a message at hi@dawarich.app +Questions? Drop me a message at hi@dawarich.app or just reply to this email. Best regards, Evgenii from Dawarich diff --git a/app/views/users_mailer/welcome.html.erb b/app/views/users_mailer/welcome.html.erb index 07f80721..c3c34c82 100644 --- a/app/views/users_mailer/welcome.html.erb +++ b/app/views/users_mailer/welcome.html.erb @@ -16,9 +16,9 @@

Welcome to Dawarich!

-

Hi <%= @user.email %>,

+

Hi <%= @user.email %>, this is Evgenii from Dawarich.

-

Welcome to Dawarich! We're excited to have you on board.

+

Welcome to Dawarich! I'm excited to have you on board.

Your 7-day free trial has started. During this time, you can: