diff --git a/.env.template b/.env.template index 587cf197..ca35a41f 100644 --- a/.env.template +++ b/.env.template @@ -2,6 +2,9 @@ GCP_PROJECT_ID="op://env/$ENV/gcp/GCP_PROJECT_ID" STRIPE_API_KEY="op://env/$ENV/stripe/STRIPE_API_KEY" STRIPE_WEBHOOK_ENDPOINT_SECRET="op://env/$ENV/stripe/STRIPE_WEBHOOK_ENDPOINT_SECRET" +STRIPE_PRODUCT_ID_RESEARCH_TWIC="op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_TWIC" +STRIPE_PRODUCT_ID_RESEARCH_NN="op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_NN" +STRIPE_PRODUCT_ID_RESEARCH_AOC="op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_AOC" STRIPE_PRODUCT_ID_RESEARCH_PRO="op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_PRO" STRIPE_COUPON_CORPORATE_PLAN="op://env/$ENV/stripe/STRIPE_COUPON_CORPORATE_PLAN" # for AT @@ -44,8 +47,28 @@ SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_TEM SENDGRID_UNSUBSCRIBE_GROUP_ID_K33="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33" SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH" # stripe webhook +## TWIC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL" +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC" +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC="op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC" +# SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH" +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC" +## NN +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL" +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN" +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN="op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN" +# SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH" +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN" +## AOC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL" +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC" +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC="op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC" +# SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH" +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC" +## PRO +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL" SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO" -SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO" +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO" # SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH" SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO="op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO" diff --git a/.github/workflows/canary-deploy.yaml b/.github/workflows/canary-deploy.yaml index 8be8e300..75a9d541 100644 --- a/.github/workflows/canary-deploy.yaml +++ b/.github/workflows/canary-deploy.yaml @@ -31,8 +31,13 @@ jobs: env: OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} GCP_PROJECT_ID: op://env/prod/gcp/GCP_PROJECT_ID + # stripe + STRIPE_PRODUCT_ID_RESEARCH_TWIC: op://env/prod/stripe/STRIPE_PRODUCT_ID_RESEARCH_TWIC + STRIPE_PRODUCT_ID_RESEARCH_NN: op://env/prod/stripe/STRIPE_PRODUCT_ID_RESEARCH_NN + STRIPE_PRODUCT_ID_RESEARCH_AOC: op://env/prod/stripe/STRIPE_PRODUCT_ID_RESEARCH_AOC STRIPE_PRODUCT_ID_RESEARCH_PRO: op://env/prod/stripe/STRIPE_PRODUCT_ID_RESEARCH_PRO STRIPE_COUPON_CORPORATE_PLAN: op://env/prod/stripe/STRIPE_COUPON_CORPORATE_PLAN + # slack SLACK_ALERTS_CHANNEL_ID: op://env/prod/slack/SLACK_ALERTS_CHANNEL_ID SLACK_GENERAL_CHANNEL_ID: op://env/prod/slack/SLACK_GENERAL_CHANNEL_ID SLACK_INVEST_CHANNEL_ID: op://env/prod/slack/SLACK_INVEST_CHANNEL_ID @@ -40,20 +45,41 @@ jobs: SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID: op://env/prod/slack/SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID SLACK_RESEARCH_CHANNEL_ID: op://env/prod/slack/SLACK_RESEARCH_CHANNEL_ID SLACK_RESEARCH_EVENTS_CHANNEL_ID: op://env/prod/slack/SLACK_RESEARCH_EVENTS_CHANNEL_ID + # sendgrid SENDGRID_TEMPLATE_ID_WELCOME_TO_K33: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33 SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH - SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO - SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO: op://env/prod/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO SENDGRID_UNSUBSCRIBE_GROUP_ID_K33: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33 SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH + ## TWIC + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC: op://env/prod/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC + ## NN + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN: op://env/prod/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN + ## AOC + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC: op://env/prod/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC + ## PRO + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO: op://env/prod/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO: op://env/prod/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO: op://env/prod/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO + # ga GOOGLE_ANALYTICS_FIREBASE_APP_ID: op://env/prod/analytics/GOOGLE_ANALYTICS_FIREBASE_APP_ID GOOGLE_ANALYTICS_MEASUREMENT_ID: op://env/prod/analytics/GOOGLE_ANALYTICS_MEASUREMENT_ID + # invest INVEST_DENIED_COUNTRY_CODE_LIST: op://env/prod/invest/INVEST_DENIED_COUNTRY_CODE_LIST INVEST_EMAIL_FROM: op://env/prod/invest/INVEST_EMAIL_FROM INVEST_EMAIL_TO_LIST: op://env/prod/invest/INVEST_EMAIL_TO_LIST INVEST_EMAIL_CC_LIST: op://env/prod/invest/INVEST_EMAIL_CC_LIST INVEST_EMAIL_BCC_LIST: op://env/prod/invest/INVEST_EMAIL_BCC_LIST + # gcp GCP_WORKLOAD_IDENTITY_PROVIDER: op://env/github/gcp/GCP_WORKLOAD_IDENTITY_PROVIDER GCP_SERVICE_ACCOUNT: op://env/github/gcp/GCP_SERVICE_ACCOUNT - name: Google auth @@ -85,6 +111,9 @@ jobs: --concurrency=1000 \ --set-env-vars=GCP_PROJECT_ID="${GCP_PROJECT_ID}" \ --set-env-vars=GOOGLE_CLOUD_PROJECT="${GCP_PROJECT_ID}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_TWIC="${STRIPE_PRODUCT_ID_RESEARCH_TWIC}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_NN="${STRIPE_PRODUCT_ID_RESEARCH_NN}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_AOC="${STRIPE_PRODUCT_ID_RESEARCH_AOC}" \ --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_PRO="${STRIPE_PRODUCT_ID_RESEARCH_PRO}" \ --set-env-vars=STRIPE_COUPON_CORPORATE_PLAN="${STRIPE_COUPON_CORPORATE_PLAN}" \ --set-env-vars=SLACK_ALERTS_CHANNEL_ID="${SLACK_ALERTS_CHANNEL_ID}" \ @@ -96,10 +125,23 @@ jobs: --set-env-vars=SLACK_RESEARCH_EVENTS_CHANNEL_ID="${SLACK_RESEARCH_EVENTS_CHANNEL_ID}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH}" \ - --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ - --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}" \ --set-env-vars=GOOGLE_ANALYTICS_FIREBASE_APP_ID="${GOOGLE_ANALYTICS_FIREBASE_APP_ID}" \ --set-env-vars=GOOGLE_ANALYTICS_MEASUREMENT_ID="${GOOGLE_ANALYTICS_MEASUREMENT_ID}" \ diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 392846c8..067b7f6a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,6 +36,9 @@ jobs: # stripe STRIPE_API_KEY: op://env/dev/stripe/STRIPE_API_KEY STRIPE_WEBHOOK_ENDPOINT_SECRET: op://env/dev/stripe/STRIPE_WEBHOOK_ENDPOINT_SECRET + STRIPE_PRODUCT_ID_RESEARCH_TWIC: op://env/dev/stripe/STRIPE_PRODUCT_ID_RESEARCH_TWIC + STRIPE_PRODUCT_ID_RESEARCH_NN: op://env/dev/stripe/STRIPE_PRODUCT_ID_RESEARCH_NN + STRIPE_PRODUCT_ID_RESEARCH_AOC: op://env/dev/stripe/STRIPE_PRODUCT_ID_RESEARCH_AOC STRIPE_PRODUCT_ID_RESEARCH_PRO: op://env/dev/stripe/STRIPE_PRODUCT_ID_RESEARCH_PRO STRIPE_COUPON_CORPORATE_PLAN: op://env/dev/stripe/STRIPE_COUPON_CORPORATE_PLAN # for AT @@ -77,9 +80,25 @@ jobs: SENDGRID_UNSUBSCRIBE_GROUP_ID_K33: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33 SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH # stripe webhook + ## TWIC + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC: op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC + ## NN + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN: op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN + ## AOC + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC + SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC: op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC + SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC + ## PRO + SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO: op://env/dev/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO: op://env/dev/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO - # SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO: op://env/dev/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO # analytics GOOGLE_ANALYTICS_API_SECRET: op://env/dev/analytics/GOOGLE_ANALYTICS_API_SECRET diff --git a/infra/gcp/canary-deploy.sh b/infra/gcp/canary-deploy.sh index 2981ca9b..bde94bbe 100755 --- a/infra/gcp/canary-deploy.sh +++ b/infra/gcp/canary-deploy.sh @@ -23,8 +23,10 @@ fi ENV=prod GCP_PROJECT_ID=$(op read op://env/$ENV/gcp/GCP_PROJECT_ID) +# stripe STRIPE_PRODUCT_ID_RESEARCH_PRO=$(op read op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_PRO) STRIPE_COUPON_CORPORATE_PLAN=$(op read op://env/$ENV/stripe/STRIPE_COUPON_CORPORATE_PLAN) +# slack SLACK_ALERTS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_ALERTS_CHANNEL_ID) SLACK_GENERAL_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_GENERAL_CHANNEL_ID) SLACK_INVEST_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_INVEST_CHANNEL_ID) @@ -32,15 +34,35 @@ SLACK_PRODUCT_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_PRODUCT_CHANNEL_ID) SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID) SLACK_RESEARCH_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_RESEARCH_CHANNEL_ID) SLACK_RESEARCH_EVENTS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_RESEARCH_EVENTS_CHANNEL_ID) +# sendgrid SENDGRID_TEMPLATE_ID_WELCOME_TO_K33=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33) SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH) -SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO) -SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH) +## TWIC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC) +## NN +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN) +## AOC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC) +## PRO +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO) +# ga GOOGLE_ANALYTICS_FIREBASE_APP_ID=$(op read op://env/$ENV/analytics/GOOGLE_ANALYTICS_FIREBASE_APP_ID) GOOGLE_ANALYTICS_MEASUREMENT_ID=$(op read op://env/$ENV/analytics/GOOGLE_ANALYTICS_MEASUREMENT_ID) +# invest INVEST_DENIED_COUNTRY_CODE_LIST=$(op read op://env/$ENV/invest/INVEST_DENIED_COUNTRY_CODE_LIST) INVEST_EMAIL_FROM=$(op read op://env/$ENV/invest/INVEST_EMAIL_FROM) INVEST_EMAIL_TO_LIST=$(op read op://env/$ENV/invest/INVEST_EMAIL_TO_LIST) @@ -71,6 +93,9 @@ gcloud run deploy "${backendCloudRun["service"]}" \ --concurrency=1000 \ --set-env-vars=GCP_PROJECT_ID="${GCP_PROJECT_ID}" \ --set-env-vars=GOOGLE_CLOUD_PROJECT="${GCP_PROJECT_ID}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_TWIC="${STRIPE_PRODUCT_ID_RESEARCH_TWIC}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_NN="${STRIPE_PRODUCT_ID_RESEARCH_NN}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_AOC="${STRIPE_PRODUCT_ID_RESEARCH_AOC}" \ --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_PRO="${STRIPE_PRODUCT_ID_RESEARCH_PRO}" \ --set-env-vars=STRIPE_COUPON_CORPORATE_PLAN="${STRIPE_COUPON_CORPORATE_PLAN}" \ --set-env-vars=SLACK_ALERTS_CHANNEL_ID="${SLACK_ALERTS_CHANNEL_ID}" \ @@ -82,10 +107,23 @@ gcloud run deploy "${backendCloudRun["service"]}" \ --set-env-vars=SLACK_RESEARCH_EVENTS_CHANNEL_ID="${SLACK_RESEARCH_EVENTS_CHANNEL_ID}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH}" \ - --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ - --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}" \ --set-env-vars=GOOGLE_ANALYTICS_FIREBASE_APP_ID="${GOOGLE_ANALYTICS_FIREBASE_APP_ID}" \ --set-env-vars=GOOGLE_ANALYTICS_MEASUREMENT_ID="${GOOGLE_ANALYTICS_MEASUREMENT_ID}" \ diff --git a/infra/gcp/deploy.sh b/infra/gcp/deploy.sh index 6f76ed53..ecb69dbd 100755 --- a/infra/gcp/deploy.sh +++ b/infra/gcp/deploy.sh @@ -28,8 +28,10 @@ fi ENV=$1 GCP_PROJECT_ID=$(op read op://env/$ENV/gcp/GCP_PROJECT_ID) +# stripe STRIPE_PRODUCT_ID_RESEARCH_PRO=$(op read op://env/$ENV/stripe/STRIPE_PRODUCT_ID_RESEARCH_PRO) STRIPE_COUPON_CORPORATE_PLAN=$(op read op://env/$ENV/stripe/STRIPE_COUPON_CORPORATE_PLAN) +# slack SLACK_ALERTS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_ALERTS_CHANNEL_ID) SLACK_GENERAL_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_GENERAL_CHANNEL_ID) SLACK_INVEST_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_INVEST_CHANNEL_ID) @@ -37,15 +39,35 @@ SLACK_PRODUCT_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_PRODUCT_CHANNEL_ID) SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_PROFESSIONAL_INVESTORS_CHANNEL_ID) SLACK_RESEARCH_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_RESEARCH_CHANNEL_ID) SLACK_RESEARCH_EVENTS_CHANNEL_ID=$(op read op://env/$ENV/slack/SLACK_RESEARCH_EVENTS_CHANNEL_ID) +# sendgrid SENDGRID_TEMPLATE_ID_WELCOME_TO_K33=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33) SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH) -SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO) -SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH) +## TWIC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC) +## NN +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN) +## AOC +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC) +SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC) +## PRO +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL) +SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO) +SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO) SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO=$(op read op://env/$ENV/sendgrid/SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO) +# ga GOOGLE_ANALYTICS_FIREBASE_APP_ID=$(op read op://env/$ENV/analytics/GOOGLE_ANALYTICS_FIREBASE_APP_ID) GOOGLE_ANALYTICS_MEASUREMENT_ID=$(op read op://env/$ENV/analytics/GOOGLE_ANALYTICS_MEASUREMENT_ID) +# invest INVEST_DENIED_COUNTRY_CODE_LIST=$(op read op://env/$ENV/invest/INVEST_DENIED_COUNTRY_CODE_LIST) INVEST_EMAIL_FROM=$(op read op://env/$ENV/invest/INVEST_EMAIL_FROM) INVEST_EMAIL_TO_LIST=$(op read op://env/$ENV/invest/INVEST_EMAIL_TO_LIST) @@ -76,6 +98,9 @@ gcloud run deploy "${backendCloudRun["service"]}" \ --concurrency=1000 \ --set-env-vars=GCP_PROJECT_ID="${GCP_PROJECT_ID}" \ --set-env-vars=GOOGLE_CLOUD_PROJECT="${GCP_PROJECT_ID}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_TWIC="${STRIPE_PRODUCT_ID_RESEARCH_TWIC}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_NN="${STRIPE_PRODUCT_ID_RESEARCH_NN}" \ + --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_AOC="${STRIPE_PRODUCT_ID_RESEARCH_AOC}" \ --set-env-vars=STRIPE_PRODUCT_ID_RESEARCH_PRO="${STRIPE_PRODUCT_ID_RESEARCH_PRO}" \ --set-env-vars=STRIPE_COUPON_CORPORATE_PLAN="${STRIPE_COUPON_CORPORATE_PLAN}" \ --set-env-vars=SLACK_ALERTS_CHANNEL_ID="${SLACK_ALERTS_CHANNEL_ID}" \ @@ -87,10 +112,23 @@ gcloud run deploy "${backendCloudRun["service"]}" \ --set-env-vars=SLACK_RESEARCH_EVENTS_CHANNEL_ID="${SLACK_RESEARCH_EVENTS_CHANNEL_ID}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33}" \ --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH}" \ - --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ - --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL}" \ + --set-env-vars=SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO="${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO}" \ + --set-env-vars=SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO="${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO}" \ --set-env-vars=SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO="${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}" \ --set-env-vars=GOOGLE_ANALYTICS_FIREBASE_APP_ID="${GOOGLE_ANALYTICS_FIREBASE_APP_ID}" \ --set-env-vars=GOOGLE_ANALYTICS_MEASUREMENT_ID="${GOOGLE_ANALYTICS_MEASUREMENT_ID}" \ diff --git a/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/Config.kt b/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/Config.kt index 697847c0..7c920994 100644 --- a/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/Config.kt +++ b/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/Config.kt @@ -1,3 +1,13 @@ package com.k33.platform.payment.stripe -const val TRIAL_PERIOD_DAYS = 30 \ No newline at end of file +import com.k33.platform.email.EmailTemplateConfig + +const val TRIAL_PERIOD_DAYS = 30 + +data class ProductConfig( + val name: String, + val stripeProductId: String, + val sendgridContactListId: String, + val welcomeEmailForTrial: EmailTemplateConfig, + val welcomeEmail: EmailTemplateConfig, +) diff --git a/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/StripeWebhook.kt b/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/StripeWebhook.kt index 6e8bbde7..122948dd 100644 --- a/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/StripeWebhook.kt +++ b/libs/services/payment/stripe/src/main/kotlin/com/k33/platform/payment/stripe/StripeWebhook.kt @@ -2,7 +2,6 @@ package com.k33.platform.payment.stripe import com.google.gson.JsonSyntaxException import com.k33.platform.email.Email -import com.k33.platform.email.EmailTemplateConfig import com.k33.platform.email.MailTemplate import com.k33.platform.email.getEmailService import com.k33.platform.identity.auth.gcp.FirebaseAuthService @@ -31,12 +30,11 @@ import kotlinx.coroutines.launch fun Application.module() { - val product by lazy { System.getenv("STRIPE_PRODUCT_ID_RESEARCH_PRO") } val endpointSecret by lazy { System.getenv("STRIPE_WEBHOOK_ENDPOINT_SECRET") } - val contactListId by lazy { System.getenv("SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO") } - val researchProWelcomeEmail by loadConfig( + + val productMap by loadConfig>( "researchApp", - "apps.research.researchProWelcomeEmail" + "apps.research.products", ) val authService by lazy { FirebaseAuthService } @@ -77,220 +75,228 @@ fun Application.module() { null }?.let(::UserId) val userAnalyticsId = userId?.fetchUser()?.analyticsId - val products = subscription.items.data.map { subscriptionItem -> + val productIds = subscription.items.data.map { subscriptionItem -> subscriptionItem.plan.product - }.toSet() - if (products.contains(product)) { - suspend fun proSubscriptionEvent() { - launch { - emailService.upsertToMarketingContactLists( - contactEmails = listOf(customerEmail), - contactListIds = listOf(contactListId), - ) - } - launch { - emailService.sendEmail( - from = Email( - address = researchProWelcomeEmail.from.email, - label = researchProWelcomeEmail.from.label, - ), - toList = listOf(Email(customerEmail)), - mail = MailTemplate(researchProWelcomeEmail.sendgridTemplateId), - unsubscribeSettings = researchProWelcomeEmail.unsubscribeSettings, - ) + } + for (productId in productIds) { + val product = productMap[productId] + if (product != null) { + suspend fun proSubscriptionEvent(trail: Boolean = false) { + launch { + emailService.upsertToMarketingContactLists( + contactEmails = listOf(customerEmail), + contactListIds = listOf(product.sendgridContactListId), + ) + } + launch { + val welcomeEmail = if (trail) { + product.welcomeEmailForTrial + } else { + product.welcomeEmail + } + emailService.sendEmail( + from = Email( + address = welcomeEmail.from.email, + label = welcomeEmail.from.label, + ), + toList = listOf(Email(customerEmail)), + mail = MailTemplate(welcomeEmail.sendgridTemplateId), + unsubscribeSettings = welcomeEmail.unsubscribeSettings, + ) + } } - } - suspend fun disableProSubscriptionEvent() { - launch { - emailService.removeFromMarketingContactLists( - contactEmails = listOf(customerEmail), - contactListId = contactListId, - ) + suspend fun disableProSubscriptionEvent() { + launch { + emailService.removeFromMarketingContactLists( + contactEmails = listOf(customerEmail), + contactListId = product.sendgridContactListId, + ) + } } - } - fun notifySlack(message: String) { - call.application.log.info(NotifySlack.RESEARCH_EVENTS, message) - } + fun notifySlack(message: String) { + call.application.log.info(NotifySlack.RESEARCH_EVENTS, message) + } - val status = Status.valueOf(subscription.status) - val previousStatus = event.data.previousAttributes?.get("status") - ?.let { string -> Status.valueOf(string as String) } - call.application.log.info("event.type: ${event.type}, status: $status, previousStatus: $previousStatus") + val status = Status.valueOf(subscription.status) + val previousStatus = event.data.previousAttributes?.get("status") + ?.let { string -> Status.valueOf(string as String) } + call.application.log.info("event.type: ${event.type}, status: $status, previousStatus: $previousStatus") - when (event.type) { - "customer.subscription.created" -> { - when (status) { - Status.trialing -> { - // started a trial subscription - notifySlack("$customerEmail has become a trial subscriber of K33 Research Pro") - proSubscriptionEvent() - Log.beginSubscriptionTrial( - webClientId = subscription.metadata["web-client-id"], - userAnalyticsId = userAnalyticsId, - productId = product, - ) - } + when (event.type) { + "customer.subscription.created" -> { + when (status) { + Status.trialing -> { + // started a trial subscription + notifySlack("$customerEmail has become a trial subscriber of ${product.name}") + proSubscriptionEvent(trail = true) + Log.beginSubscriptionTrial( + webClientId = subscription.metadata["web-client-id"], + userAnalyticsId = userAnalyticsId, + productId = productId, + ) + } - Status.incomplete -> { - // failed to subscribe - call.application.log.warn( - NotifySlack.RESEARCH_EVENTS, - "$customerEmail failed to subscribe to K33 Research Pro", - ) - disableProSubscriptionEvent() - } + Status.incomplete -> { + // failed to subscribe + call.application.log.warn( + NotifySlack.RESEARCH_EVENTS, + "$customerEmail failed to subscribe to ${product.name}", + ) + disableProSubscriptionEvent() + } - Status.active -> { - // started an active (paid) subscription - notifySlack("$customerEmail has become an active subscriber of K33 Research Pro") - proSubscriptionEvent() - Log.beginSubscription( - webClientId = subscription.metadata["web-client-id"], - userAnalyticsId = userAnalyticsId, - productId = product, - ) - } + Status.active -> { + // started an active (paid) subscription + notifySlack("$customerEmail has become an active subscriber of ${product.name}") + proSubscriptionEvent() + Log.beginSubscription( + webClientId = subscription.metadata["web-client-id"], + userAnalyticsId = userAnalyticsId, + productId = productId, + ) + } - else -> { - call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.created") + else -> { + call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.created") + } } } - } - "customer.subscription.updated" -> { + "customer.subscription.updated" -> { - val subscriptionTrialToActive = - previousStatus == Status.trialing - && status == Status.active - val subscriptionIncompleteToExpired = previousStatus == - Status.incomplete - && status == Status.incomplete_expired - val subscriptionNonProToPro = - previousStatus != null - && previousStatus.productSubscriptionStatus != StripeClient.ProductSubscriptionStatus.active - && status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active - val subscriptionProToBlocked = - previousStatus?.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active - && status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.blocked + val subscriptionTrialToActive = + previousStatus == Status.trialing + && status == Status.active + val subscriptionIncompleteToExpired = previousStatus == + Status.incomplete + && status == Status.incomplete_expired + val subscriptionNonProToPro = + previousStatus != null + && previousStatus.productSubscriptionStatus != StripeClient.ProductSubscriptionStatus.active + && status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active + val subscriptionProToBlocked = + previousStatus?.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active + && status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.blocked - val subscriptionToBeCanceled = - event.data.previousAttributes?.get("cancel_at_period_end") == false - && subscription.cancelAtPeriodEnd == true - val subscriptionUncanceled = - status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active - && event.data.previousAttributes?.get("cancel_at_period_end") == true - && subscription.cancelAtPeriodEnd == false - val updatedCancellationDetails = setOf("cancellation_details") == event.data.previousAttributes?.keys?.toSet() - val updatedDefaultPaymentMethod = setOf("default_payment_method") == event.data.previousAttributes?.keys?.toSet() - val extendedActivePeriod = - previousStatus == null - && status == Status.active - && setOf("latest_invoice", "current_period_end", "current_period_start") == event.data.previousAttributes?.keys?.toSet() - val usedDiscount = - previousStatus == null - && status == Status.active - && event.data.previousAttributes?.keys?.contains("discount") == true + val subscriptionToBeCanceled = + event.data.previousAttributes?.get("cancel_at_period_end") == false + && subscription.cancelAtPeriodEnd == true + val subscriptionUncanceled = + status.productSubscriptionStatus == StripeClient.ProductSubscriptionStatus.active + && event.data.previousAttributes?.get("cancel_at_period_end") == true + && subscription.cancelAtPeriodEnd == false + val updatedCancellationDetails = setOf("cancellation_details") == event.data.previousAttributes?.keys?.toSet() + val updatedDefaultPaymentMethod = setOf("default_payment_method") == event.data.previousAttributes?.keys?.toSet() + val extendedActivePeriod = + previousStatus == null + && status == Status.active + && setOf("latest_invoice", "current_period_end", "current_period_start") == event.data.previousAttributes?.keys?.toSet() + val usedDiscount = + previousStatus == null + && status == Status.active + && event.data.previousAttributes?.keys?.contains("discount") == true - when { - extendedActivePeriod -> { - notifySlack("$customerEmail has done recurring payment and continued as Pro (active) subscriber of K33 Research Pro") - } + when { + extendedActivePeriod -> { + notifySlack("$customerEmail has done recurring payment and continued as Pro (active) subscriber of ${product.name}") + } - subscriptionToBeCanceled -> { - // subscription is set to be cancelled at the end of billing period - notifySlack("$customerEmail has scheduled to unsubscribe from K33 Research Pro at the end of billing period") - } + subscriptionToBeCanceled -> { + // subscription is set to be cancelled at the end of billing period + notifySlack("$customerEmail has scheduled to unsubscribe from ${product.name} at the end of billing period") + } - subscriptionTrialToActive -> { - // changed trial subscription to active (paid) subscription - notifySlack("$customerEmail upgraded from trial to active subscriber of K33 Research Pro") - Log.beginSubscription( - webClientId = subscription.metadata["web-client-id"], - userAnalyticsId = userAnalyticsId, - productId = product, - ) - } + subscriptionTrialToActive -> { + // changed trial subscription to active (paid) subscription + notifySlack("$customerEmail upgraded from trial to active subscriber of ${product.name}") + Log.beginSubscription( + webClientId = subscription.metadata["web-client-id"], + userAnalyticsId = userAnalyticsId, + productId = productId, + ) + } - subscriptionIncompleteToExpired -> { - // changed incomplete subscription to incomplete_expired - notifySlack("$customerEmail is from Blocked (incomplete) to ex-Pro (incomplete_expired) subscriber of K33 Research Pro because first payment was not done within 23hr past of due date.") - } + subscriptionIncompleteToExpired -> { + // changed incomplete subscription to incomplete_expired + notifySlack("$customerEmail is from Blocked (incomplete) to ex-Pro (incomplete_expired) subscriber of ${product.name} because first payment was not done within 23hr past of due date.") + } - subscriptionProToBlocked -> { - notifySlack("$customerEmail changed from Pro ($previousStatus) to Blocked ($status) subscriber of K33 Research Pro") - disableProSubscriptionEvent() - } + subscriptionProToBlocked -> { + notifySlack("$customerEmail changed from Pro ($previousStatus) to Blocked ($status) subscriber of ${product.name}") + disableProSubscriptionEvent() + } - // has to be after subscriptionTrialToActive - subscriptionNonProToPro -> { - // updated from non-pro to an active (paid) subscription - notifySlack("$customerEmail changed from non-Pro ($previousStatus) to Pro ($status) subscriber of K33 Research Pro") - proSubscriptionEvent() - Log.beginSubscription( - webClientId = subscription.metadata["web-client-id"], - userAnalyticsId = userAnalyticsId, - productId = product, - ) - } + // has to be after subscriptionTrialToActive + subscriptionNonProToPro -> { + // updated from non-pro to an active (paid) subscription + notifySlack("$customerEmail changed from non-Pro ($previousStatus) to Pro ($status) subscriber of ${product.name}") + proSubscriptionEvent() + Log.beginSubscription( + webClientId = subscription.metadata["web-client-id"], + userAnalyticsId = userAnalyticsId, + productId = productId, + ) + } - // has to be after subscriptionToBeCanceled - updatedCancellationDetails -> { - logWithMDC( - *listOfNotNull( - subscription.cancellationDetails?.reason?.let { "cancellation_reason" to it }, - subscription.cancellationDetails?.feedback?.let { "cancellation_feedback" to it }, - subscription.cancellationDetails?.comment?.let { "cancellation_comment" to it }, - ).toTypedArray() - ) { - notifySlack("$customerEmail entered cancellation details") + // has to be after subscriptionToBeCanceled + updatedCancellationDetails -> { + logWithMDC( + *listOfNotNull( + subscription.cancellationDetails?.reason?.let { "cancellation_reason" to it }, + subscription.cancellationDetails?.feedback?.let { "cancellation_feedback" to it }, + subscription.cancellationDetails?.comment?.let { "cancellation_comment" to it }, + ).toTypedArray() + ) { + notifySlack("$customerEmail entered cancellation details") + } } - } - updatedDefaultPaymentMethod -> { - call.application.log.info("Updated default payment method") - } + updatedDefaultPaymentMethod -> { + call.application.log.info("Updated default payment method") + } - subscriptionUncanceled -> { - notifySlack("$customerEmail has uncancelled subscription") - } + subscriptionUncanceled -> { + notifySlack("$customerEmail has uncancelled subscription") + } - usedDiscount -> { - call.application.log.info("$customerEmail has updated discount coupon") - } + usedDiscount -> { + call.application.log.info("$customerEmail has updated discount coupon") + } - else -> { - call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.updated") + else -> { + call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.updated") + } } } - } - "customer.subscription.deleted" -> { - when (status) { - Status.canceled -> { - // subscription is cancelled - logWithMDC( - *listOfNotNull( - subscription.cancellationDetails?.reason?.let { "cancellation_reason" to it }, - subscription.cancellationDetails?.feedback?.let { "cancellation_feedback" to it }, - ).toTypedArray() - ) { - notifySlack("$customerEmail has unsubscribed from K33 Research Pro") + "customer.subscription.deleted" -> { + when (status) { + Status.canceled -> { + // subscription is cancelled + logWithMDC( + *listOfNotNull( + subscription.cancellationDetails?.reason?.let { "cancellation_reason" to it }, + subscription.cancellationDetails?.feedback?.let { "cancellation_feedback" to it }, + ).toTypedArray() + ) { + notifySlack("$customerEmail has unsubscribed from ${product.name}") + } + disableProSubscriptionEvent() + Log.endSubscription( + webClientId = subscription.metadata["web-client-id"], + userAnalyticsId = userAnalyticsId, + productId = productId, + ) } - disableProSubscriptionEvent() - Log.endSubscription( - webClientId = subscription.metadata["web-client-id"], - userAnalyticsId = userAnalyticsId, - productId = product, - ) + else -> call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.deleted") } - else -> call.application.log.error("Unexpected status: ${status.name} for Stripe event: customer.subscription.deleted") } - } - else -> { - call.application.log.error("Received unexpected event of type: ${event.type}") + else -> { + call.application.log.error("Received unexpected event of type: ${event.type}") + } } } } diff --git a/libs/services/payment/stripe/src/main/resources/researchApp.conf b/libs/services/payment/stripe/src/main/resources/researchApp.conf index b5d22d48..7c5652c2 100644 --- a/libs/services/payment/stripe/src/main/resources/researchApp.conf +++ b/libs/services/payment/stripe/src/main/resources/researchApp.conf @@ -1,14 +1,113 @@ apps { research { - researchProWelcomeEmail { - from: { - email: "research@k33.com" - label: "K33 Research" - } - sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO} - unsubscribeSettings: { - groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}, - preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + products { + twic = { + name: "K33 Research >> This week in crypto" + stripeProductId: ${STRIPE_PRODUCT_ID_RESEARCH_TWIC} + sendgridContactListId: ${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_TWIC} + welcomeEmailForTrial { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC_TRIAL} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + welcomeEmail { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_TWIC} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_TWIC},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + } + nn = { + name: "K33 Research >> Navigating Narratives" + stripeProductId: ${STRIPE_PRODUCT_ID_RESEARCH_NN} + sendgridContactListId: ${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_NN} + welcomeEmailForTrial { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN_TRIAL} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + welcomeEmail { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_NN} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_NN},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + } + aoc = { + name: "K33 Research >> Ahead of Curve" + stripeProductId: ${STRIPE_PRODUCT_ID_RESEARCH_AOC} + sendgridContactListId: ${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_AOC} + welcomeEmailForTrial { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC_TRIAL} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + welcomeEmail { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_AOC} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_AOC},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + } + pro = { + name: "K33 Research Pro" + stripeProductId: ${STRIPE_PRODUCT_ID_RESEARCH_PRO} + sendgridContactListId: ${SENDGRID_CONTACT_LIST_ID_K33_RESEARCH_PRO} + welcomeEmailForTrial { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO_TRIAL} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } + welcomeEmail { + from { + email: "research@k33.com" + label: "K33 Research" + } + sendgridTemplateId: ${SENDGRID_TEMPLATE_ID_WELCOME_TO_K33_RESEARCH_PRO} + unsubscribeSettings { + groupId: ${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO}, + preferencesGroupIds: [${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH_PRO},${SENDGRID_UNSUBSCRIBE_GROUP_ID_K33_RESEARCH}] + } + } } } } diff --git a/libs/utils/config/src/main/kotlin/com/k33/platform/utils/config/Config.kt b/libs/utils/config/src/main/kotlin/com/k33/platform/utils/config/Config.kt index c113b7f1..03d1c129 100644 --- a/libs/utils/config/src/main/kotlin/com/k33/platform/utils/config/Config.kt +++ b/libs/utils/config/src/main/kotlin/com/k33/platform/utils/config/Config.kt @@ -12,7 +12,12 @@ fun getConfig( name: String, path: String? = null, ): Lazy = lazy { - getConfigEager(name, path) + val config = getConfigEager(name) + if (!path.isNullOrBlank()) { + config.getConfig(path) + } else { + config + } } inline fun loadConfig( @@ -25,20 +30,22 @@ inline fun loadConfig( inline fun loadConfigEager( name: String, path: String? = null, -): CONFIG = getConfigEager(name, path).extract() +): CONFIG { + val config = getConfigEager(name) + return if (!path.isNullOrBlank()) { + config.extract(path) + } else { + config.extract() + } +} fun getConfigEager( name: String, - path: String? = null, ): Config { val configFile = ConfigAsResourceFile("/$name.conf") if (configFile.exists()) { logger.info("Loading config: $configFile") - var config = ConfigFactory.parseString(configFile.readText()) - if (!path.isNullOrBlank()) { - config = config.resolve().getConfig(path) - } - return config + return ConfigFactory.parseString(configFile.readText()).resolve() } throw FileNotFoundException("Config file not found - $configFile") } @@ -49,4 +56,4 @@ data class ConfigAsResourceFile( fun exists(): Boolean = object {}.javaClass.getResource(name) != null override fun toString(): String = "resource:$name @ ${object {}.javaClass.getResource(name)?.file}" fun readText(): String? = object {}.javaClass.getResource(name)?.readText() -} \ No newline at end of file +}