Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .claude/rules/features/feature-tips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
paths:
- "backend/app/Services/Domain/FeatureTip/**"
- "backend/app/Services/Application/Handlers/FeatureTip/**"
- "backend/app/Http/Actions/FeatureTips/**"
- "backend/app/DomainObjects/Enums/FeatureTip.php"
- "frontend/src/components/common/FeatureTip/**"
---

# Feature tips

- Hi.Events Cloud only: the handler returns nothing unless `app.saas_mode_enabled`, and the frontend never fetches without `account.is_saas_mode_enabled`. Self-hosted installs never see a tip.
- The server picks the tip: one per event, the first eligible case in `FeatureTip` order (enum order is the priority). Eligibility checks only data, never stores or schedules anything.
- Only live events with an unfinished date, only for members with EDIT (plus the feature's own permission, e.g. ISSUE_REFUNDS for resale), never while impersonating, and never a licensed feature the account can't use (`FeatureFlagService`).
- Dismissing or opening a tip records it per user, across all events, and pauses every tip for `DAYS_BETWEEN_TIPS`. `users.feature_tips_hidden_at` turns them off (profile switch, or "Turn off tips" after a dismissal).
- Check the setting that actually controls the feature, and ignore rows the app creates on its own: the waitlist is switched on per ticket (`products.waitlist_enabled`, never for reserved seating), and every event gets a system default check-in list (`is_system_default`). Link straight to the control when it sits inside a drawer (the products page opens `#waitlist-<product id>`).
- A new tip needs: an enum case, a check in `FeatureTipSelectionService` with a unit test, copy and a link in `featureTipContent.ts` with translations, and an illustration from `public/blank-slate/`. Keep the copy short and in the tips' voice.
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Feature rules live in `.claude/rules/`; Claude Code loads each file automaticall
| Lineup & schedule | `.claude/rules/features/lineup.md` |
| Homepage sections | `.claude/rules/features/homepage-sections.md` |
| Embeddable widget | `.claude/rules/features/widget.md` |
| Feature tips (Cloud) | `.claude/rules/features/feature-tips.md` |
| Registration questions | `.claude/rules/features/questions.md` |
| Ticket transfer, resale, verified self-service | `.claude/rules/features/ticket-transfer-resale.md` |
| Frontend UI patterns | `.claude/rules/frontend/ui.md` |
Expand Down
19 changes: 19 additions & 0 deletions backend/app/DomainObjects/Enums/FeatureTip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace HiEvents\DomainObjects\Enums;

enum FeatureTip: string
{
case WAITLIST = 'WAITLIST';
case CHECK_IN_LIST = 'CHECK_IN_LIST';
case REMINDER_MESSAGE = 'REMINDER_MESSAGE';
case TICKET_RESALE = 'TICKET_RESALE';
case AUDIENCE = 'AUDIENCE';
case EMBED = 'EMBED';
case AFFILIATES = 'AFFILIATES';
case HIDDEN_TICKETS = 'HIDDEN_TICKETS';
case SEQUENTIAL_TIERS = 'SEQUENTIAL_TIERS';
case ADDONS = 'ADDONS';
}
5 changes: 5 additions & 0 deletions backend/app/DomainObjects/FeatureTipDismissalDomainObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace HiEvents\DomainObjects;

class FeatureTipDismissalDomainObject extends Generated\FeatureTipDismissalDomainObjectAbstract {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

namespace HiEvents\DomainObjects\Generated;

use HiEvents\DomainObjects\AbstractDomainObject;

/**
* THIS FILE IS AUTOGENERATED - DO NOT EDIT IT DIRECTLY.
*/
abstract class FeatureTipDismissalDomainObjectAbstract extends AbstractDomainObject
{
final public const SINGULAR_NAME = 'feature_tip_dismissal';

final public const PLURAL_NAME = 'feature_tip_dismissals';

final public const ID = 'id';

final public const USER_ID = 'user_id';

final public const TIP = 'tip';

final public const CREATED_AT = 'created_at';

final public const UPDATED_AT = 'updated_at';

protected int $id;

protected int $user_id;

protected string $tip;

protected ?string $created_at = null;

protected ?string $updated_at = null;

public function toArray(): array
{
return [
'id' => $this->id ?? null,
'user_id' => $this->user_id ?? null,
'tip' => $this->tip ?? null,
'created_at' => $this->created_at ?? null,
'updated_at' => $this->updated_at ?? null,
];
}

public function setId(int $id): self
{
$this->id = $id;

return $this;
}

public function getId(): int
{
return $this->id;
}

public function setUserId(int $user_id): self
{
$this->user_id = $user_id;

return $this;
}

public function getUserId(): int
{
return $this->user_id;
}

public function setTip(string $tip): self
{
$this->tip = $tip;

return $this;
}

public function getTip(): string
{
return $this->tip;
}

public function setCreatedAt(?string $created_at): self
{
$this->created_at = $created_at;

return $this;
}

public function getCreatedAt(): ?string
{
return $this->created_at;
}

public function setUpdatedAt(?string $updated_at): self
{
$this->updated_at = $updated_at;

return $this;
}

public function getUpdatedAt(): ?string
{
return $this->updated_at;
}
}
17 changes: 17 additions & 0 deletions backend/app/DomainObjects/Generated/UserDomainObjectAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ abstract class UserDomainObjectAbstract extends AbstractDomainObject

final public const TOKENS_VALID_AFTER = 'tokens_valid_after';

final public const FEATURE_TIPS_HIDDEN_AT = 'feature_tips_hidden_at';

protected int $id;

protected string $email;
Expand Down Expand Up @@ -93,6 +95,8 @@ abstract class UserDomainObjectAbstract extends AbstractDomainObject

protected ?string $tokens_valid_after = null;

protected ?string $feature_tips_hidden_at = null;

public function toArray(): array
{
return [
Expand All @@ -116,6 +120,7 @@ public function toArray(): array
'two_factor_last_used_timestep' => $this->two_factor_last_used_timestep ?? null,
'lifecycle_emails_unsubscribed_at' => $this->lifecycle_emails_unsubscribed_at ?? null,
'tokens_valid_after' => $this->tokens_valid_after ?? null,
'feature_tips_hidden_at' => $this->feature_tips_hidden_at ?? null,
];
}

Expand Down Expand Up @@ -358,4 +363,16 @@ public function getTokensValidAfter(): ?string
{
return $this->tokens_valid_after;
}

public function setFeatureTipsHiddenAt(?string $feature_tips_hidden_at): self
{
$this->feature_tips_hidden_at = $feature_tips_hidden_at;

return $this;
}

public function getFeatureTipsHiddenAt(): ?string
{
return $this->feature_tips_hidden_at;
}
}
38 changes: 38 additions & 0 deletions backend/app/Http/Actions/FeatureTips/DismissFeatureTipAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace HiEvents\Http\Actions\FeatureTips;

use HiEvents\DomainObjects\Enums\FeatureTip;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Services\Application\Handlers\FeatureTip\DismissFeatureTipHandler;
use HiEvents\Services\Application\Handlers\FeatureTip\DTO\DismissFeatureTipDTO;
use Symfony\Component\HttpFoundation\Response;

class DismissFeatureTipAction extends BaseAction
{
public function __construct(
private readonly DismissFeatureTipHandler $handler,
) {}

public function __invoke(string $tip): Response
{
$featureTip = FeatureTip::tryFrom($tip);

if ($featureTip === null) {
return $this->notFoundResponse();
}

if ($this->isImpersonating()) {
return $this->noContentResponse();
}

$this->handler->handle(new DismissFeatureTipDTO(
userId: $this->getAuthenticatedUser()->getId(),
tip: $featureTip,
));

return $this->noContentResponse();
}
}
36 changes: 36 additions & 0 deletions backend/app/Http/Actions/FeatureTips/GetEventFeatureTipAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace HiEvents\Http\Actions\FeatureTips;

use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Services\Application\Handlers\FeatureTip\DTO\GetEventFeatureTipDTO;
use HiEvents\Services\Application\Handlers\FeatureTip\GetEventFeatureTipHandler;
use Illuminate\Http\JsonResponse;

class GetEventFeatureTipAction extends BaseAction
{
public function __construct(
private readonly GetEventFeatureTipHandler $handler,
) {}

public function __invoke(int $eventId): JsonResponse
{
$this->isActionAuthorized($eventId, EventDomainObject::class);

if ($this->isImpersonating()) {
return $this->jsonResponse(['data' => null]);
}

$tip = $this->handler->handle(new GetEventFeatureTipDTO(
eventId: $eventId,
accountId: $this->getAuthenticatedAccountId(),
userId: $this->getAuthenticatedUser()->getId(),
access: $this->getAuthenticatedAccess(),
));

return $this->jsonResponse(['data' => $tip?->toArray()]);
}
}
1 change: 1 addition & 0 deletions backend/app/Http/Actions/Users/UpdateMeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __invoke(UpdateMeRequest $request): JsonResponse
'locale' => $request->validated('locale'),
'marketing_opt_in' => $request->has('marketing_opt_in') ? (bool) $request->validated('marketing_opt_in') : null,
'notify_new_orders' => $request->has('notify_new_orders') ? (bool) $request->validated('notify_new_orders') : null,
'show_feature_tips' => $request->has('show_feature_tips') ? (bool) $request->validated('show_feature_tips') : null,
'confirmation_password' => $request->validated('confirmation_password'),
'reauth_proof' => $request->validated('reauth_proof'),
'token_id' => $this->getAuthTokenId(),
Expand Down
9 changes: 5 additions & 4 deletions backend/app/Http/Request/User/UpdateMeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function rules(): array
return [
'first_name' => $this->nameRules($this->user()?->first_name),
'last_name' => $this->nameRules($this->user()?->last_name),
'email' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders|email',
'timezone' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders|timezone',
'locale' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders|in:'.implode(',', Locale::getSupportedLocales()),
'email' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders,show_feature_tips|email',
'timezone' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders,show_feature_tips|timezone',
'locale' => 'required_without_all:current_password,password,password_confirmation,notify_new_orders,show_feature_tips|in:'.implode(',', Locale::getSupportedLocales()),

'current_password' => [
'required_with:password,password_confirmation',
Expand All @@ -35,13 +35,14 @@ public function rules(): array
'reauth_proof' => ['nullable', 'string', 'max:128'],
'marketing_opt_in' => 'boolean|nullable',
'notify_new_orders' => 'boolean|nullable',
'show_feature_tips' => 'boolean|nullable',
];
}

private function nameRules(?string $currentValue): array
{
return [
'required_without_all:current_password,password,password_confirmation,notify_new_orders',
'required_without_all:current_password,password,password_confirmation,notify_new_orders,show_feature_tips',
'string',
'min:1',
'max:'.PersonNameRule::maxLengthFor($currentValue),
Expand Down
16 changes: 16 additions & 0 deletions backend/app/Models/FeatureTipDismissal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace HiEvents\Models;

use HiEvents\DomainObjects\Generated\FeatureTipDismissalDomainObjectAbstract;

class FeatureTipDismissal extends BaseModel
{
protected function getFillableFields(): array
{
return [
FeatureTipDismissalDomainObjectAbstract::USER_ID,
FeatureTipDismissalDomainObjectAbstract::TIP,
];
}
}
3 changes: 3 additions & 0 deletions backend/app/Providers/RepositoryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
use HiEvents\Repository\Eloquent\EventSpamCheckRepository;
use HiEvents\Repository\Eloquent\EventStatisticRepository;
use HiEvents\Repository\Eloquent\FeatureFlagRepository;
use HiEvents\Repository\Eloquent\FeatureTipDismissalRepository;
use HiEvents\Repository\Eloquent\ImageRepository;
use HiEvents\Repository\Eloquent\InvoiceRepository;
use HiEvents\Repository\Eloquent\LifecycleEmailTemplateRepository;
Expand Down Expand Up @@ -171,6 +172,7 @@
use HiEvents\Repository\Interfaces\EventSpamCheckRepositoryInterface;
use HiEvents\Repository\Interfaces\EventStatisticRepositoryInterface;
use HiEvents\Repository\Interfaces\FeatureFlagRepositoryInterface;
use HiEvents\Repository\Interfaces\FeatureTipDismissalRepositoryInterface;
use HiEvents\Repository\Interfaces\ImageRepositoryInterface;
use HiEvents\Repository\Interfaces\InvoiceRepositoryInterface;
use HiEvents\Repository\Interfaces\LifecycleEmailTemplateRepositoryInterface;
Expand Down Expand Up @@ -317,6 +319,7 @@ class RepositoryServiceProvider extends ServiceProvider
AccountSubscriptionRepositoryInterface::class => AccountSubscriptionRepository::class,
AnnouncementRepositoryInterface::class => AnnouncementRepository::class,
AnnouncementUserRepositoryInterface::class => AnnouncementUserRepository::class,
FeatureTipDismissalRepositoryInterface::class => FeatureTipDismissalRepository::class,
WaitlistEntryRepositoryInterface::class => WaitlistEntryRepository::class,
WidgetRepositoryInterface::class => WidgetRepository::class,
UserIdentityRepositoryInterface::class => UserIdentityRepository::class,
Expand Down
23 changes: 23 additions & 0 deletions backend/app/Repository/Eloquent/EventOccurrenceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ public function findUpcomingIdsForEvent(int $eventId, ?CarbonInterface $endedAft
->all());
}

public function findNextUnfinishedForEvent(int $eventId): ?EventOccurrenceDomainObject
{
$model = $this->runQuery(fn () => EventOccurrence::query()
->where(EventOccurrenceDomainObjectAbstract::EVENT_ID, $eventId)
->where(EventOccurrenceDomainObjectAbstract::STATUS, '!=', EventOccurrenceStatus::CANCELLED->name)
->whereRaw('COALESCE(end_date, start_date) > ?', [now()])
->orderBy(EventOccurrenceDomainObjectAbstract::START_DATE)
->first());

return $model === null ? null : $this->handleSingleResult($model);
}

public function hasUpcomingAtCapacityRatio(int $eventId, float $ratio): bool
{
return $this->runQuery(fn () => EventOccurrence::query()
->where(EventOccurrenceDomainObjectAbstract::EVENT_ID, $eventId)
->where(EventOccurrenceDomainObjectAbstract::STATUS, '!=', EventOccurrenceStatus::CANCELLED->name)
->where(EventOccurrenceDomainObjectAbstract::START_DATE, '>', now())
->where(EventOccurrenceDomainObjectAbstract::CAPACITY, '>', 0)
->whereRaw('used_capacity >= capacity * CAST(? AS numeric)', [$ratio])
->exists());
}

public function findByEventId(int $eventId, QueryParamsDTO $params): LengthAwarePaginator
{
$this->model = $this->model->newQuery()->orderBy(
Expand Down
Loading
Loading