Skip to content

Conversation

@idoshamun
Copy link
Member

Summary

Implements automatic Super Agent trial upgrade for organizations when they submit their first opportunity for review.

  • Organizations get 30-day Super Agent trial on first opportunity submission
  • Trial features: batchSize=150, reminders, showSlack, showFeedback
  • After trial expires, downgrades to original plan or Agent plan
  • Feature controlled via GrowthBook superAgentTrial config
  • Frontend notification via showSuperAgentTrialUpgrade alert

Key Changes

  • src/common/opportunity/trial.ts - Trial activation and helper functions
  • src/schema/opportunity.ts - Modified updateOpportunityState for trial logic
  • src/cron/expireSuperAgentTrial.ts - Cron job for auto-downgrade
  • src/entity/Alerts.ts - Added showSuperAgentTrialUpgrade field
  • src/entity/Organization.ts - Added trial index decorator

Pending

Migrations need to be created manually for:

  • showSuperAgentTrialUpgrade column in alerts table
  • IDX_organization_trial_expires_at index on organization table

Test plan

  • Unit tests for trial helper functions
  • Cron job tests for expiration logic
  • Integration tests (some skipped pending migrations)
  • E2E testing after GrowthBook config deployed

🤖 Generated with Claude Code

When an organization submits their first opportunity for review,
automatically upgrade them to the Super Agent plan for 30 days as a trial.
After 30 days, auto-downgrade to their original plan or Agent plan.

Changes:
- Add superAgentTrial config to RemoteConfig for GrowthBook control
- Add trial fields (trialExpiresAt, trialPlan, isTrialActive) to
  recruiterSubscriptionFlags schema
- Add showSuperAgentTrialUpgrade field to Alerts for frontend notification
- Create trial helper functions in src/common/opportunity/trial.ts
- Modify updateOpportunityState mutation to activate trial on first IN_REVIEW
- Create expireSuperAgentTrial cron job to handle auto-downgrade
- Add comprehensive tests for trial logic and cron

NOTE: Migrations for showSuperAgentTrialUpgrade column and trial index
need to be created and applied separately.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@pulumi
Copy link

pulumi bot commented Jan 21, 2026

🍹 The Update (preview) for dailydotdev/api/prod (at d47e13a) was successful.

Resource Changes

    Name                                                   Type                           Operation
~   vpc-native-sync-subscription-with-cio-cron             kubernetes:batch/v1:CronJob    update
-   vpc-native-api-db-migration-b599631c                   kubernetes:batch/v1:Job        delete
~   vpc-native-clean-zombie-images-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-update-trending-cron                        kubernetes:batch/v1:CronJob    update
+   vpc-native-api-db-migration-166ffff3                   kubernetes:batch/v1:Job        create
~   vpc-native-deployment                                  kubernetes:apps/v1:Deployment  update
~   vpc-native-user-profile-updated-sync-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-private-deployment                          kubernetes:apps/v1:Deployment  update
~   vpc-native-calculate-top-readers-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-daily-digest-cron                           kubernetes:batch/v1:CronJob    update
~   vpc-native-update-source-tag-view-cron                 kubernetes:batch/v1:CronJob    update
+   vpc-native-expire-super-agent-trial-cron               kubernetes:batch/v1:CronJob    create
~   vpc-native-hourly-notification-cron                    kubernetes:batch/v1:CronJob    update
~   vpc-native-bg-deployment                               kubernetes:apps/v1:Deployment  update
~   vpc-native-ws-deployment                               kubernetes:apps/v1:Deployment  update
~   vpc-native-clean-zombie-opportunities-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-stale-user-transactions-cron          kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-gifted-plus-cron                      kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tag-recommendations-cron             kubernetes:batch/v1:CronJob    update
~   vpc-native-update-tags-str-cron                        kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-cron                    kubernetes:batch/v1:CronJob    update
-   vpc-native-api-clickhouse-migration-b599631c           kubernetes:batch/v1:Job        delete
~   vpc-native-post-analytics-clickhouse-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-users-cron                     kubernetes:batch/v1:CronJob    update
+   vpc-native-api-clickhouse-migration-166ffff3           kubernetes:batch/v1:Job        create
~   vpc-native-update-current-streak-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-personalized-digest-deployment              kubernetes:apps/v1:Deployment  update
~   vpc-native-update-source-public-threshold-cron         kubernetes:batch/v1:CronJob    update
~   vpc-native-clean-zombie-user-companies-cron            kubernetes:batch/v1:CronJob    update
~   vpc-native-validate-active-users-cron                  kubernetes:batch/v1:CronJob    update
~   vpc-native-update-views-cron                           kubernetes:batch/v1:CronJob    update
~   vpc-native-generic-referral-reminder-cron              kubernetes:batch/v1:CronJob    update
~   vpc-native-generate-search-invites-cron                kubernetes:batch/v1:CronJob    update
~   vpc-native-post-analytics-history-day-clickhouse-cron  kubernetes:batch/v1:CronJob    update
~   vpc-native-temporal-deployment                         kubernetes:apps/v1:Deployment  update
~   vpc-native-check-analytics-report-cron                 kubernetes:batch/v1:CronJob    update
~   vpc-native-update-highlighted-views-cron               kubernetes:batch/v1:CronJob    update

idoshamun and others added 4 commits January 21, 2026 13:26
The Alerts entity had a new showSuperAgentTrialUpgrade column but was
missing the database migration, causing test failures.

- Add migration for alerts.showSuperAgentTrialUpgrade column
- Consolidate skipped activateSuperAgentTrial tests into one test
- Enable previously skipped tests now that migration exists

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add the new showSuperAgentTrialUpgrade field to:
- REST API route query in src/routes/alerts.ts
- Test GraphQL query in __tests__/alerts.ts

This field was added to the entity and schema but was missing from
the queries that return alerts data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nizations

- Introduce flexible `DataSourceOrManager` type to streamline database interactions.
- Remove `isSuperAgentTrialEnabled`, fold checks into `getSuperAgentTrialConfig`.
- Simplify `DEFAULT_TRIAL_CONFIG` structure, delegate to remote config.
- Improve subscription and trial flag handling with `updateRecruiterSubscriptionFlags`.
- Update tests to align with refactor, reducing redundancy and enhancing clarity.
Extract repeated test setup patterns into shared helpers:
- Add createMockLogger() for consistent logger mocking
- Add defaultSuperAgentTrialConfig constant for trial setup

This reduces code duplication across trial-related tests
and ensures consistency in test configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants