3.3.15 • Published 18 days ago

@properly/emails v3.3.15

Weekly downloads
2
License
ISC
Repository
-
Last release
18 days ago

Overview

This library is for creating reusable, testable components and email templates using React.

Develop

Setup

  1. Open a terminal
  2. Clone git repository git clone git@github.com:GitProperly/properly-email-engine.git
  3. Go into repository dir cd properly-email-engine
  4. Install root dependencies npm install
  5. Start storybook npm run storybook or npm start

Storybook

Check this page to read more about storybook: https://storybook.js.org/

Folder structure

  • .circleci: CircleCI configuration.
  • .storybook: Storybook configuration.
  • src - _snapshots_: Snapshot files for test. - components: Small components like header, footer, dashboard. - customComponents: Email layout components. - emailComponents: Rendered HTML email files. - emailStrings: String files of rendered HTML emails from emailComponents folder. This is the final result that will be returned. - translations - interpolated: Strings with proper variables. All the %s symbols in the original folder are replaced with the proper variables that are used for localization. - original: Original string files that are downloaded from the Onesky project.

Dependencies

 

Adding a new email

  1. Create a folder and create a new index.js and stories.js file in EmailComponents folder. If there's any components already created in components folder, use them. Or create your own component. Main style guide and variables are in the /styleGuide.js file.
  2. Once you created email, import it from EmailStrings folder.
  3. Create an test file in the same folder.
  4. Add an export function to src/index.js file.
  5. npm test to check if it's all good.

Note: Kindly refrain from using CSS3 in the project, only some of the email client support CSS3.Take a look at email support guide before implementing css.

 

Localization

To check entire localization process, please check this document.

  1. npm run download-strings to download all the language files from the Onesky project.
  2. Use <FormattedMessage> component and pass a string ID, default message, and the values should be dynamic.

Examples

import { reactIntlInitialize } from '../../translations';
import { FormattedMessage } from 'react-intl';

<FormattedMessage
	id="learn.more.about.badges"
	defaultMessage="Learn more about badges"
	values={{ firstName, hostName }}
/>

 

Test

  • Functional test: npm test
  • Rendering test: Currently, we don't have an automatic process to test email rendering by each email client and platform. 1. npm run storybook or npm start to start storybook. 2. Open the browser and go to localhost:9001 or any other localhost that runs storybook. 3. Copy the rendered HTML email string from the story view. For example, if you want to test the Job Finished Notification Email rendering, select Strings > JobRequest > JobFinished > String on the sidebar navigation of Storybook page and copy the code block that printed on the story view. 4. Go to the Intercom Messages tab and login. 5. Select Messages > Manual Messages > New Manual Messages. 6. Select your channel to Email. 7. Select Write your message section, and select import HTML email button. 8. Paste the block of code that you copied on step 3. 9. Select Send a test email button. It will send a test email to the email address that you type. Test email rendering. I recommend you to test email rendering at least on these three platforms: Gmail web, Gmail iOS, Gmail Android.
  • To find email notification history: Connect Properly Mongo DB via Robo 3T. Search db.getCollection('Notification').find({type: [emailTypeName]}).

 

Deploy storybook to environments

  1. run npm run everest | develop | sandbox | beta to deploy the storybook to respective environments and can be accessed by below mentioned links as per env
  2. To deploy to stage , run npm run major | minor | bump (patch), this will upgrade the version as per semvar and auto deploy to stage environment
  3. To deploy to production , run npm run prod ,this will make sure that the storybook is deployed as well as the version gets published to npm registry.
  • Everest- email-engine-everest.getproperly.com
  • Stage- email-engine-staging.getproperly.com
  • Prod- email-engine.getproperly.com

Publish

  1. npm run major | minor | patch to update version and auto deploy storybook to stage environment.
  2. Run npm run prod and then the CircleCI will kindly test, build, and publish the package for you and automatically deploy storybook out to production environment.
  3. If you didn't receive any error message, then hooray! Skull your beer! 🍺

   

Usage

  1. Install npm package via npm: npm install @properly/emails
  2. Import an email rendering function import { stringOfResetPasswordEmail } from @properly/emails
  3. Send appropriate data when you execute a function. Props are mandatory, Options are optional.
  4. If the data/props are appropriate, you'll get a string of rendered email as return. Otherwise, you'll get ruthless errors as return.

Available functions

  • Password Behaviours - stringOfResetPasswordEmail(): - props = { firstName(string), passwordToken(string) } - stringOfSetupPasswordEmail(): - props = { firstName(string), passwordToken(string) }
  • Job Requests - Hosts side - stringOfJobAcceptedEmail() - stringOfJobDeclinedEmail() - stringOfCleanerJobCanceledEmail() - stringOfJobStartedEmail() - stringOfJobFinishedEmail() - stringOfJobSummaryEmail() - stringOfReportedProblemsEmail() - Service Providers side - stringOfNewJobRequestEmail() - stringOfJobNotAvailableEmail() - stringOfHostJobCanceledEmail()
  • Bookings - Airbnb - stringOfAirbnbNewBookingEmail() - MyVR - stringOfMyVRNewBookingEmail() - stringOfMyVRBookingChangedEmail() - stringOfMyVRBookingCanceledEmail()

  • Invitations - Service Providers - stringOfNewInvitationEmail() - stringOfNewInvitationWithRequestEmail() - Partner - stringOfNewPartnerInvitationEmail() - stringOfExistingPartnerInvitationEmail() - Company - stringOfVerifyCompanyDomainEmail() - stringOfNewEmployeeInvitationEmail()

  • Badges - Loved - stringOfLovedBadgeCompleteEmail() - Experienced - stringOfExperiencedBadgeFirstEmail() - stringOfExperiencedBadgeCompleteEmail() - Checklist Champion - stringOfChecklistChampionBadgeCompleteEmail() - Punctuality - stringOfPunctualityBadgeCompleteEmail() - Fast Responder - stringOfFastResponderBadgeCompleteEmail()

  • Found Service Provider On Location - stringOfServiceProviderFoundOnLocationEmail()

    • stringOfServiceProviderFoundOnLocationWithSubscriptionEmail()  

Examples

import { stringOfResetPasswordEmail } from @properly/emails;
const props = {
	firstName:  'Caroline',
	passwordToken: 'https://app.getproperly.com/#/password/new?token=tokenId8&email=test@getproperly.com&behavior=changePassword'
};
const options = {
	language: 'en',
	currency: 'USD',
	timeZone: 'America/Los_Angeles',
}
stringOfResetPasswordEmail(props, options);
3.3.15

18 days ago

3.3.14

19 days ago

3.3.13

19 days ago

3.3.12

24 days ago

3.3.10

2 months ago

3.3.9

3 months ago

3.3.8

3 months ago

3.3.7

5 months ago

3.3.6

5 months ago

3.3.0

8 months ago

3.3.5

8 months ago

3.3.4

8 months ago

3.3.3

8 months ago

3.3.2

8 months ago

3.2.5

2 years ago

3.2.4

2 years ago

3.1.8

2 years ago

3.2.1

2 years ago

3.1.7

3 years ago

3.1.5

3 years ago

3.1.4

3 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.0.9

3 years ago

3.1.0

3 years ago

3.0.7

3 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.12.0

4 years ago

2.11.4

4 years ago

2.11.3

4 years ago

2.11.1

4 years ago

2.11.2

4 years ago

2.11.0

4 years ago

2.10.6

4 years ago

2.10.5

4 years ago

2.10.4

4 years ago

2.10.3

4 years ago

2.10.2

4 years ago

2.10.1

4 years ago

2.10.0

4 years ago

2.8.7

4 years ago

2.8.6

5 years ago

2.8.5

5 years ago

2.8.4

5 years ago

2.8.3

5 years ago

2.8.2

5 years ago

2.8.1

5 years ago

2.8.0

5 years ago

2.7.7

5 years ago

2.7.5

5 years ago

2.7.4

5 years ago

2.6.3

5 years ago

2.6.0

5 years ago

2.5.10

5 years ago

2.5.8

5 years ago

2.5.7

5 years ago

2.5.4

5 years ago

2.5.3

5 years ago

2.5.1

6 years ago

2.4.6

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.4.0

6 years ago

2.3.6

6 years ago

2.3.5

6 years ago

2.3.4

6 years ago

2.3.3

6 years ago

2.3.2

6 years ago

2.3.0

6 years ago

2.2.10

6 years ago

2.2.9

6 years ago

2.2.7

6 years ago

2.2.6

6 years ago

2.2.5

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.1

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.1

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.3.10

6 years ago

1.3.2

6 years ago