1.15.2 • Published 3 years ago

fdy2-sales-funnel v1.15.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 years ago

fdy2-sales-funnel

Try it out on sandbox, staging, or production!

Simple web app that allows a user to get a price offering for a Household insurance with FRI:DAY.

NOTE: Requirements here

On this page

  1. Service
  2. Scripts
  3. CI
  4. Feature flags
  5. Release
  6. Monitoring
  7. Troubleshooting

Service

There's an API service running to provide policy data. Check the swagger definition! Check the project repo here.

There's an API service running to provide documents. We host our static legal documents here. Check the project repo here.

Scripts

The provided web app is built with Next.js.

You need to have locally installed node and yarn.

The following scripts are available:

yarn                        # installs all dependencies :)
yarn test                   # run unit & integration tests with jest
yarn dev                    # starts dev server locally, with hot reload
yarn default-translations   # generate updated key/message json files
yarn build                  # generate PRD bundle
yarn export                 # exports a static site to `/out`, ready to be pushed to S3
yarn release                # generate a release with standard-version

Local development

Enviroment variables

The project requires some environment variables to work, in your local environment you should create a .env file providing all of those.

Here is the example:

BACK_SOON_PAGE=false
DISABLED_FEATURE_FLAGS=''
ENABLED_FEATURE_FLAGS=''
ENV=development
GOOGLE_MAPS_API_KEY=AIzaSyCxMd__y-pljsgpPl09MXZgsWIj7IJ7ZCo
IBAN_VALIDATION_SERVICE_URI=/api
NODE_ENV=development
POSTAL_CODE_SERVICE_URL=/api/postalCode
PRICING_SERVICE_URI=https://fdy2-policycenter-sandbox.k8s.blue.fridev.de/rest/friday/hc/
SEGMENT_KEY=SVH5ii842HmW5OUf8SOKiNLlZvTy4FeH
SENTRY_AUTH_TOKEN=
SENTRY_ORG=sentry
SENTRY_PROJECT=fdy2-sales-funnel
SENTRY_URL=https://sentry.forfriday.de
GTM_ID=GTM-NHNBDPL

CI

  • husky enforces linting when committing code (runs locally).
  • Creating a Merge Request will trigger a pipeline (Gitlab CI) that includes running test suites, building a review app, and deploying it to review on a new s3 bucket. Bucket gets destroyed after closing the MR.
  • Merging into master will trigger a new pipeline: builds sandbox app and deploys it to sandbox s3 bucket. It will deploy the app to staging s3 bucket aswell.
  • Pushing a tag to master branch will build production app and deploy to production s3 bucket.
  • SonarQube will check all our MRs and give us a nice list of recomendations in the form of an MR comment.
  • Should you ever be curious on how's the project doing, you can check it out on our hosted sonarqube.

Feature flags

The goal should always be to remove un-used code. In some cases, we can't just remove it because it will be needed again in the future. So we put it on a feature flag.

Try to keep these to a minimum always!
List:

USER_CENTRIC_SNIPET             # used to enable a third-party tracking system
MKT_PROMO_ALERT_AMAZON_VOUCHER  # mkt campaign for seasonal amazon voucher, displayed as an alert
COMBINED_DISCOUNT_OPT_IN        # mkt campaign for motor//home content combined discount, checking if the user already has a motor policy with us

Release

After a successful sprint all the balls are green on master pipeline and e2e pipelines, all tickets went thru stakeholders, feature flags are set to desired states, and there's a general feeling of excitement on the badgers team area.
Now what?
HIT THE RELEASE BUTTON!!!

# Make sure you have latest master on your local
git checkout master && git fetch && git pull
# Cut a release candidate
yarn release
# Send it to the world
git push --follow-tags origin master

Ooooops!

Not working? Stakeholders just realized something is not as expected?
Fret not, for there is always a way to roll-back to a previous tag:

  1. Go to the pipeline runner: https://gitlab.forfriday.de/honey-badger/fdy2-sales-funnel/pipelines/new
  2. Choose any of the available tags.
  3. Hit Run Pipeline

Monitoring

We use sentry.io to collect and report any run-time exceptions that might happen.

All of this services will give an alert on slack channels!

Troubleshooting

Sometimes, things will go sideways. Here you can find a collection of things we once solved. Hopefully, it will prevent a few headaches :)

XXX_XXXX_XX service has CORS and I can not access on my local

We have a dev server to proxy endpoints and make them work on local dev environment. It can be found here, with a few examples already set-up: devServer.js

SonarQube is not working

The easiest way to find the issue is by running Sonarqube server locally via docker, and installing sonar-scanner app.

Set-up server

docker run -d --name sonarqube -p 9000:9000 sonarqube

A local Sonarqube server should be available at http://localhost:9000 More? To the docs!

Set-up scanner

Next, install sonnar-scanner. Remember to add it to PATH.

# $INSTALL_DIR is where you saved sonnar-scanner executable
# sonar-scanner
export PATH="$PATH:/$INSTALL_DIR/sonar-scanner/bin"

Running analysis

Finally we can run the scanner! Navigate to the project root folder.

sonar-scanner -Dsonar.projectKey=fdy2-sales-funnel -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin

Terraform state is locked

Terraform job is failing with Error: Error locking state: Error acquiring the state lock.
This means that another terraform job might still be running. It could also mean that a job failed to release the lock :(
If this is the case, you can always manually unlock the state.
NOTE: make sure to align with the team before doing this, as it might indicate infrastructure issues!!!

# go to the locked env terraform folder, for instance sandbox
cd terraform/envs/sandbox
# need a specific terraform version!
tfenv use 0.11.14
#  --> PROFILE_NAME is what you defined in your local for the ~/.aws/credentials profile
okta_aws_login PROFILE_NAME
# again, PROFILE_NAME that you set on your local
export AWS_PROFILE=PROFILE_NAME
terraform init
# we need to get the locked state first
terraform state pull
# we need a LOCK_ID to find it, it was on the error message from terraform failed job :)
terraform force-unlock -force LOCK_ID