Skip to content

Commit c2f0482

Browse files
committed
feat: #137, #161 ask mid and end -trial feedback
1 parent a461ecc commit c2f0482

File tree

6 files changed

+141
-75
lines changed

6 files changed

+141
-75
lines changed

Diff for: app/Listeners/ScheduleTrialEndNotifications.php renamed to app/Listeners/StartTrialFeedbackFlow.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace App\Listeners;
44

5-
use App\Notifications\TrialEndsSoonNotification;
5+
use App\Notifications\AskFinalTrialFeedback;
6+
use App\Notifications\AskMidTrialFeedback;
67
use Carbon\CarbonInterval;
78
use Illuminate\Auth\Events\Verified;
89
use Illuminate\Events\Dispatcher;
910

10-
class ScheduleTrialEndNotifications
11+
class StartTrialFeedbackFlow
1112
{
1213
/**
1314
* Create the event listener.
@@ -39,10 +40,10 @@ public function scheduleNotifications(Verified $event): void
3940
return;
4041
}
4142

42-
$days3 = $team->trialEndsAt()->sub(CarbonInterval::days(3))->diffAsDateInterval(now(), absolute: true);
43-
$team->notify((new TrialEndsSoonNotification($team))->delay($days3));
43+
$days7 = $team->trialEndsAt()->sub(CarbonInterval::days(7))->diffAsDateInterval(now(), absolute: true);
44+
$team->notify((new AskMidTrialFeedback($team))->delay($days7));
4445

4546
$days1 = $team->trialEndsAt()->sub(CarbonInterval::day())->diffAsDateInterval(now(), absolute: true);
46-
$team->notify((new TrialEndsSoonNotification($team))->delay($days1));
47+
$team->notify((new AskFinalTrialFeedback($team))->delay($days1));
4748
}
4849
}

Diff for: app/Models/Deployment.php

-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ public function asNodeTasks(): array
259259
'payload' => [
260260
'caddy' => $caddy,
261261
],
262-
263262
];
264263
}
265264

Diff for: app/Notifications/AskFinalTrialFeedback.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace App\Notifications;
4+
5+
use App\Models\Team;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Notifications\Messages\MailMessage;
9+
use Illuminate\Notifications\Notification;
10+
11+
class AskFinalTrialFeedback extends Notification implements ShouldQueue
12+
{
13+
use Queueable;
14+
15+
public function __construct(
16+
protected Team $team
17+
) {
18+
$this->afterCommit();
19+
}
20+
21+
public function shouldSend(object $notifiable, string $channel): bool
22+
{
23+
return $this->team->onTrial();
24+
}
25+
26+
public function via(object $notifiable): array
27+
{
28+
return ['mail'];
29+
}
30+
31+
public function toMail(object $notifiable): MailMessage
32+
{
33+
$trialEndsAt = $this->team->trialEndsAt();
34+
$dateDiff = $trialEndsAt->longRelativeToNowDiffForHumans();
35+
36+
return (new MailMessage)
37+
->subject("Your Ptah.sh trial ends soon - We'd love your final feedback")
38+
->greeting("Hello {$this->team->owner->name}!")
39+
->line("Your Ptah.sh trial for team {$this->team->name} is ending soon.")
40+
->line("You will not be able to use Ptah.sh after {$trialEndsAt->toDateTimeString()} ({$dateDiff}).")
41+
->line('Before your trial ends, we\'d greatly appreciate your final thoughts.')
42+
->line('Your feedback is crucial in helping us improve Ptah.sh for you and future users.')
43+
->line('Please reply to this email with your experience and any suggestions you might have.')
44+
->line('Thank you for trying Ptah.sh. We hope you\'ve found it valuable!')
45+
->line('If you\'re interested in continuing with Ptah.sh, please visit our pricing page to choose a plan that suits your needs.')
46+
->action('Choose a Plan', route('teams.billing.show', $this->team))
47+
->line('If you have any questions or need assistance, don\'t hesitate to reach out at '.config('app.email').'.');
48+
}
49+
50+
public function toArray(object $notifiable): array
51+
{
52+
return [
53+
//
54+
];
55+
}
56+
}

Diff for: app/Notifications/AskMidTrialFeedback.php

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
namespace App\Notifications;
4+
5+
use App\Models\Team;
6+
use Illuminate\Bus\Queueable;
7+
use Illuminate\Contracts\Queue\ShouldQueue;
8+
use Illuminate\Notifications\Messages\MailMessage;
9+
use Illuminate\Notifications\Notification;
10+
11+
class AskMidTrialFeedback extends Notification implements ShouldQueue
12+
{
13+
use Queueable;
14+
15+
/**
16+
* Create a new notification instance.
17+
*/
18+
public function __construct(
19+
protected Team $team
20+
) {
21+
$this->afterCommit();
22+
}
23+
24+
/**
25+
* Get the notification's delivery channels.
26+
*
27+
* @return array<int, string>
28+
*/
29+
public function via(object $notifiable): array
30+
{
31+
return ['mail'];
32+
}
33+
34+
/**
35+
* Get the mail representation of the notification.
36+
*/
37+
public function toMail(object $notifiable): MailMessage
38+
{
39+
$nodeCount = $this->team->nodes()->count();
40+
$serviceCount = $this->team->services()->count();
41+
42+
$message = (new MailMessage)
43+
->subject('We\'d love your feedback on Ptah.sh')
44+
->greeting("Hello {$this->team->owner->name}!")
45+
->line('We hope you\'re enjoying your experience with Ptah.sh so far.')
46+
->line('We\'d love to hear your thoughts and improve our service based on your feedback.')
47+
->line('Simply reply to this email with your feedback - we\'re eager to hear from you!');
48+
49+
if ($nodeCount === 0) {
50+
$message->line('We noticed you don\'t have any active nodes at the moment. We\'d love to know if there\'s anything holding you back or if you need any assistance getting started or restarting with nodes.');
51+
} elseif ($serviceCount === 1) {
52+
$message->line('We see you haven\'t created any custom services yet. How has your experience been so far? Is there anything we can do to make it easier for you to create and manage services?');
53+
} elseif ($serviceCount === 2) {
54+
$message->line('We see you\'ve created your first custom service. How was your experience? Is there anything we can do to make it easier for you to manage or create more services?');
55+
} else {
56+
$message->line('It looks like you\'re actively using Ptah.sh with multiple custom services. We\'d love to hear about your experience and any suggestions you might have for improvements.');
57+
}
58+
59+
return $message
60+
->line('Your feedback is invaluable to us and will help shape the future of Ptah.sh.')
61+
->line('Also, we invite you to join our Discord community to connect with other users and our team.')
62+
->action('Join Our Discord', 'https://r.ptah.sh/chat')
63+
->line('Thank you for being a part of Ptah.sh!');
64+
}
65+
66+
/**
67+
* Get the array representation of the notification.
68+
*
69+
* @return array<string, mixed>
70+
*/
71+
public function toArray(object $notifiable): array
72+
{
73+
return [
74+
//
75+
];
76+
}
77+
}

Diff for: app/Notifications/TrialEndsSoonNotification.php

-67
This file was deleted.

Diff for: app/Providers/AppServiceProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Providers;
44

5-
use App\Listeners\ScheduleTrialEndNotifications;
5+
use App\Listeners\StartTrialFeedbackFlow;
66
use Illuminate\Support\Facades\Event;
77
use Illuminate\Support\ServiceProvider;
88
use Lorisleiva\Actions\Facades\Actions;
@@ -22,6 +22,6 @@ public function register(): void
2222
*/
2323
public function boot(): void
2424
{
25-
Event::subscribe(ScheduleTrialEndNotifications::class);
25+
Event::subscribe(StartTrialFeedbackFlow::class);
2626
}
2727
}

0 commit comments

Comments
 (0)