Keep your email safe from hackers and trackers. Make an email alias with 1 click, and keep your address to yourself.
Перейти к файлу
groovecoder d7cfa68774
wip: tinker with react-ga4
2024-06-17 11:22:53 -05:00
.circleci Enable isort, fix import order 2024-04-22 12:10:32 -05:00
.github Merge pull request #4707 from mozilla/gha-regen-glean-parser 2024-05-13 22:24:37 +00:00
.husky Switch from husky v8 to v9 2024-03-01 09:30:29 -06:00
api for MPP-3817: do not forward sms or calls for deactivated users 2024-05-20 11:27:47 -05:00
docs Fix spelling 2024-04-18 08:06:04 -05:00
e2e-tests Allow page to load after signup in E2E email forwarding test 2024-05-08 19:25:09 -04:00
emails Update tests for STATSD_DEBUG=True 2024-06-04 16:45:07 -05:00
frontend wip: tinker with react-ga4 2024-06-17 11:22:53 -05:00
mypy_stubs Remove local stubs for waffle 2024-05-03 13:58:24 -05:00
phones Update tests for STATSD_DEBUG=True 2024-06-04 16:45:07 -05:00
privaterelay Merge in latest l10n strings 2024-06-11 00:06:15 +00:00
telemetry/glean Remove mask_id from email event data 2024-04-16 13:58:26 -05:00
tmp Make healthcheck a required parameter 2022-05-05 15:12:21 -05:00
.buildpacks everything(?) heroku needs for django-gulp 2021-06-11 12:48:43 -05:00
.dockerignore Co-locate images with their place of use 2022-06-28 14:56:32 +02:00
.env-dist create Google app creds file from env var as needed 2024-02-07 13:13:23 -06:00
.git-blame-ignore-revs Ignore prettier 3.0.0 update 2023-07-18 10:12:37 -05:00
.gitignore for MPP-3467: add googlecloudprofiler to PrivateRelayConfig.ready 2024-01-26 14:34:34 -06:00
.gitmodules Mark `main` as the default branch of the submodule 2022-03-03 08:48:22 -08:00
.lintstagedrc.js Added e2e-tests path for prettier linting, updated e2e readme 2024-04-24 16:16:55 -04:00
CODEOWNERS add @bcolsson to landing page owners 2023-08-08 12:27:13 -05:00
Dockerfile Update Python from 3.10.14 to 3.11.8 2024-03-26 13:29:16 -05:00
LICENSE Note licence exception for stock images 2023-02-20 12:13:21 +01:00
METRICS.md Add missing events to metrics docs 2022-03-24 17:26:35 +01:00
Procfile Run "./manage.py migrate" on Heroku release 2022-08-22 17:22:05 -05:00
README.md Recommend venv over virtualenv 2024-03-26 13:30:22 -05:00
gunicorn.conf use PORT env var for gunicorn binding 2020-03-05 12:10:53 -06:00
manage.py Reformat with black 22.3.0 2022-05-09 08:16:01 -05:00
package-lock.json wip: tinker with react-ga4 2024-06-17 11:22:53 -05:00
package.json Bump @playwright/test from 1.43.0 to 1.43.1 2024-04-15 01:42:47 +00:00
playwright.config.ts Linter and more test fixes 2024-04-22 15:25:45 -04:00
pyproject.toml Skip google-cloud-sqlcommenter, middleware in 3.12 2024-05-23 16:10:22 -05:00
requirements.txt Merge pull request #4781 from mozilla/dependabot/pip/boto-e515dbe13d 2024-06-17 15:28:05 +00:00
runtime.txt Update Python from 3.10.14 to 3.11.8 2024-03-26 13:29:16 -05:00

README.md

Private Relay

License: MPL 2.0 Repo Size Coverage Status What's Deployed CircleCI Relay e2e Tests

Private Relay provides generated email addresses to use in place of personal email addresses.

Recipients will still receive emails, but Private Relay keeps their personal email address from being harvested, and then bought, sold, traded, or combined with other data to personally identify, track, and/or target them.

Development

Please refer to our coding standards for code styles, naming conventions and other methodologies.

Requirements

  • python 3.11 (we recommend venv)
  • PostgreSQL - even if you are using sqlite for development, requirements.txt installs psycopg2 which requires libpq and Python header files. The following should work:
    • On Windows
    • On Ubuntu: sudo apt install postgresql libpq-dev python3-dev
    • On OSX: brew install postgresql libpq
    • On Fedora: sudo dnf install libpq-devel python3-devel
  • SES if you want to send real emails
  • Volta – Sets up the right versions of Node and npm, needed to compile the front-end

Install and Run the Site Locally

  1. Clone and change to the directory:

    git clone --recurse-submodules https://github.com/mozilla/fx-private-relay.git
    cd fx-private-relay
    
  2. Create and activate a virtual environment:

    Unix based systems:

    virtualenv env
    source env/bin/activate
    

    Windows:

    python -m venv env
    source env/Scripts/activate
    

    If you are not using Git Bash on Windows, instead of typing source env/Scripts/activate, type .\env\Scripts\activate.

    Note: If you're running on Windows and get an error message stating that executing scripts are disabled on your computer, go into the Windows powershell and type Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted, then try again.

  3. Install Python and Node requirements:

    pip install -r requirements.txt
    
    cd frontend
    npm install
    cd ../
    

    Note: If you're running on Windows, you may run into an issue with usage of environment variables in npm scripts. You can force npm to use git-bash: npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe". This the default location, your install may be different.

  4. Copy .env file for decouple config:

    cp .env-dist .env
    
  5. Add a SECRET_KEY value to .env:

    SECRET_KEY=secret-key-should-be-different-for-every-install
    
  6. Migrate DB:

    python manage.py migrate
    
  7. Create superuser:

    python manage.py createsuperuser
    
  8. Run the backend:

    python manage.py runserver
    

    and in a different terminal, build the frontend:

    cd frontend
    npm run watch
    

Working with translations

The following docs will get you started with development, include creating new strings to translate. See Translation and Localization for general information on Relay localization.

Getting the latest translations

We use a git submodule for translated message files. The --recurse-submodules step of installation should bring the message files into your working directory already, but you may want also want to update the translations after install. The easiest way to do that is:

  • git submodule update --remote

To update the submodule automatically when running git pull or other commands:

  • git config --global submodule.recurse true

Add/update messages for translation

The privaterelay/locales directory is a git repository like any other, so to make changes to the messages:

  1. Make whatever changes you need in privaterelay/locales/en as you work.

  2. cd privaterelay/locales/en

  3. git branch message-updates-yyyymmdd

  4. git push -u origin message-updates-yyyymmdd

You can then open a pull request from the message-updates-yyyymmdd branch to the l10n repo main branch.

If you're not yet ready to submit some strings for translation, you can tentatively add them to frontend/pendingTranslations.ftl. Strings in that file will show up until strings with the same ID are added to the l10n repository.

Similarly, there is a pending_locales/pending.ftl where temporary backend locales strings can be stored. Once the strings from the pull request in the l10n repo has been merged into the Relay repo, these respective strings need to be removed from pending_locales/pending.ftl to avoid failing CircleCI tests.

Commit translations for release

To commit updates to the app's translations (e.g., before a release), we need to commit this submodule update. So, if the updated translations are ready to be committed into the app, you can git add the submodule just like any other file:

  • git add privaterelay/locales

You can then commit and push to set the app repository to the updated version of the translations submodule:

  • git push

An automated process updates the submodule daily, bringing in any new changes and translations from the Localization Team.

To enable Mozilla Accounts authentication on your local server, you can use the "Firefox Private Relay local dev" OAuth app on accounts.stage.mozaws.net.

To do so:

  1. Set ADMIN_ENABLED=True in your .env file

  2. Shutdown the server if running, and add the admin tables with:

    python manage.py migrate
    
  3. Run the server, now with /admin endpoints:

    python manage.py runserver
    
  4. Go to the django admin page to change the default site.

  5. Change example.com to 127.0.0.1:8000 and click Save.

  6. Go to the django-allauth social app admin page, sign in with the superuser account you created above, and add a social app for Firefox Accounts:

Field Value
Provider Mozilla Accounts
Name accounts.stage.mozaws.net
Client id 9ebfe2c2f9ea3c58
Secret key Request this from #fx-private-relay-eng Slack channel
Sites 127.0.0.1:8000 -> Chosen sites

Now you can sign into http://127.0.0.1:8000/ with an FxA.

⚠️ Remember that you'll need to use an account on https://accounts.stage.mozaws.net/, not the production site, accounts.firefox.com.

Optional: Install and run the add-on locally

Note: The add-on is located in a separate repo. See it for additional information on getting started.

The add-on adds Firefox UI to generate and auto-fill email addresses across the web. Running the add-on locally allows it to communicate with your local server (127.0.0.1:8000) instead of the production server (relay.firefox.com).

Optional: Run a development server to compile the frontend

npm run watch watches the frontend/src directory and builds the frontend when it detects changes. However, creating a production build is just time-consuming enough to interrupt your development flow. It is therefore also possible to run the front-end on a separate server that only recompiles changed modules, and does not apply production optimizations. To do so, instead of npm run watch, run npm run dev.

The frontend is now available at http://localhost:3000. Keep in mind that this does make your local development environment less similar to production; in particular, authentication is normally bound to the backend server, and thus needs to be simulated when running the frontend on a separate server. If you make any changes related to authentication, make sure to test them using npm run watch as well.

Optional: Enable Premium Features

Note: Premium features are automatically enabled for any user with an email address ending in mozilla.com, getpocket.com, or mozillafoundation.org (see PREMIUM_DOMAINS in emails/models.py). To mimic the customer's experience, it is recommended to follow the below procedure.

To enable the premium Relay features, we integrate with the FXA Subscription Platform. At a high level, to set up Relay premium subscription, we:

  1. Enable Mozilla Accounts Authentication as described above.

  2. Create a product & price in our Stripe dashboard. (Ask in #subscription-platform Slack channel to get access to our Stripe dashboard.)

  3. Link free users of Relay to the appropriate SubPlat purchase flow.

  4. Check users' FXA profile json for a subscriptions field to see if they can access a premium, subscription-only feature.

In detail:

  1. Enable Mozilla Accounts Authentication as described above.

  2. Go to our Stripe dashboard. (Ask in #subscription-platform Slack channel to get access to our Stripe dashboard.)

  3. Create a new product in Stripe.

  4. Add all required product: metadata.

    • Note: each piece of this metadata must have a product: prefix. So, for example, webIconURL must be entered as product:webIconURL.
  5. Add capabilities: metadata.

    • Note: Each piece of this metadata must have a format like capabilities:<fxa oauth client ID>, and the value is a free-form string to describe the "capability" that purchasing the subscription gives to the user. E.g., capabilities:9ebfe2c2f9ea3c58 with value of premium-relay.
  6. Set some env vars with values from the above steps:

Var Value
FXA_SUBSCRIPTIONS_URL https://accounts.stage.mozaws.net/subscriptions
PERIODICAL_PREMIUM_PROD_ID prod_KEq0LXqs7vysQT (from Stripe)
PREMIUM_PLAN_ID_US_MONTHLY price_1LiMjeKb9q6OnNsLzwixHuRz (from Stripe)
PREMIUM_PLAN_ID_US_YEARLY price_1LiMlBKb9q6OnNsL7tvrtI7y (from Stripe)
PHONE_PROD_ID prod_LviM2I0paxH1DZ (from Stripe)
PHONE_PLAN_ID_US_MONTHLY price_1LDqw3Kb9q6OnNsL6XIDst28 (from Stripe)
PHONE_PLAN_ID_US_YEARLY price_1Lhd35Kb9q6OnNsL9bAxjUGq (from Stripe)
BUNDLE_PROD_ID prod_MQ9Zf1cyI81XS2 (from Stripe)
BUNDLE_PLAN_ID_US price_1Lwp7uKb9q6OnNsLQYzpzUs5 (from Stripe)
SUBSCRIPTIONS_WITH_UNLIMITED "premium-relay" (match the capabilities value you used in Stripe)
SUBSCRIPTIONS_WITH_PHONE "relay-phones" (match the capabilities value you used in Stripe)

Optional: Debugging JavaScript bundle sizes

In frontend/, set ANALYZE=true when running npm run build to generate a report detailing which modules are taking up most of the bundle size. A report will be generated for both the client and server part of the frontend, but since we only use the client, we're really only interested in that. The reports will automatically open in your browser, and can also be found in /frontend/.next/analyze/.

ANALYZE=true npm run build

Test Premium

There is a comprehensive doc of test cases for purchasing premium Relay.

You can use Stripe's test credit card details for payment.

The phone features are further protected by a waffle flag phones. In stage, you'll need an SRE to add the flag to your test user. On the development server, a developer can add the flag.

Production Environments

Requirements

In addition to the requirements for dev, production environments should use:

Environment Variables

Production environments should also set some additional environment variables:

DATABASE_URL=postgresql://<username>:<password>@<host>:<port>/<database>
DJANGO_SECURE_HSTS_SECONDS=15768000
DJANGO_SECURE_SSL_REDIRECT=True