backend-manager 3.2.22 → 3.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.22",
3
+ "version": "3.2.24",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -1,5 +1,6 @@
1
1
  const _ = require('lodash')
2
2
  const fetch = require('wonderful-fetch');
3
+ const moment = require('moment');
3
4
 
4
5
  const MAX_SIGNUPS = 3;
5
6
  const MAX_AGE = 30;
@@ -64,6 +65,8 @@ Module.prototype.main = function () {
64
65
 
65
66
  // Send welcome email
66
67
  await self.sendWelcomeEmail(user).catch(e => e);
68
+ await self.sendCheckupEmail(user).catch(e => e);
69
+ await self.sendFeedbackEmail(user).catch(e => e);
67
70
 
68
71
  await self.signUp({
69
72
  auth: {
@@ -104,127 +107,6 @@ Module.prototype.main = function () {
104
107
 
105
108
  };
106
109
 
107
- Module.prototype.sendRateEmail = function (user) {
108
- const self = this;
109
-
110
- return new Promise(async function(resolve, reject) {
111
- const Manager = self.Manager;
112
- const assistant = self.assistant;
113
-
114
- // Send email
115
- fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
116
- method: 'post',
117
- response: 'json',
118
- log: true,
119
- body: {
120
- backendManagerKey: Manager.config.backend_manager.key,
121
- app: Manager.config.app.id,
122
- to: {
123
- email: user.auth.email,
124
- },
125
- categories: [`account/too-many-signups`],
126
- subject: `Your ${Manager.config.brand.name} account has been deleted`,
127
- template: 'd-b7f8da3c98ad49a2ad1e187f3a67b546',
128
- group: 25927,
129
- data: {
130
- email: {
131
- preview: `You have signed up for too many accounts at ${Manager.config.brand.name}! Your account has been deleted.`,
132
- },
133
- body: {
134
- title: `Account deleted`,
135
- message: `
136
- Your account at <strong>${Manager.config.brand.name}</strong> has been <strong>deleted</strong> because you have signed up for too many accounts.
137
- <br>
138
- <br>
139
- If you believe this is a mistake, please contact us at ${Manager.config.brand.email}.
140
- <br>
141
- <br>
142
- <strong>User Record</strong>:
143
- <br>
144
- <pre><code>${JSON.stringify(user, null, 2)}</code></pre>
145
- `,
146
- },
147
- },
148
- },
149
- })
150
- .then(async (json) => {
151
- assistant.log('sendEmail(): Success', json)
152
- return resolve(json);
153
- })
154
- .catch(e => {
155
- assistant.error('sendEmail(): Failed', e)
156
- return resolve(e);
157
- });
158
- });
159
- }
160
-
161
- Module.prototype.sendWelcomeEmail = function (user) {
162
- const self = this;
163
-
164
- return new Promise(async function(resolve, reject) {
165
- const Manager = self.Manager;
166
- const assistant = self.assistant;
167
-
168
- // Send email
169
- fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
170
- method: 'post',
171
- response: 'json',
172
- log: true,
173
- body: {
174
- backendManagerKey: Manager.config.backend_manager.key,
175
- app: Manager.config.app.id,
176
- to: {
177
- email: user.auth.email,
178
- },
179
- categories: [`account/welcome-1`],
180
- subject: `Welcome to ${Manager.config.brand.name}!`,
181
- template: 'd-b7f8da3c98ad49a2ad1e187f3a67b546',
182
- group: 25928,
183
- data: {
184
- email: {
185
- preview: `Welcome to ${Manager.config.brand.name}! I'm Ian, the CEO. I'm here to help you get started.`,
186
- },
187
- body: {
188
- title: `Welcome to ${Manager.config.brand.name}!`,
189
- message: `
190
- Hey there,
191
- <br>
192
- <br>
193
- I'm Ian, the CEO of <strong>${Manager.config.brand.name}</strong>. I'm here to help you get started.
194
- <br>
195
- <br>
196
- I'm thrilled to welcome you to <strong>${Manager.config.brand.name}</strong>! Your journey with us starts now, and we're eager to <strong>support you every step of the way</strong>.
197
- <br>
198
- <br>
199
- As the founder and CEO, <strong>I'm personally committed to ensuring your experience with us is nothing short of exceptional</strong>. Should you need any assistance or have any questions, feel free to reply directly to this email. Our team and I are here to help.
200
- <br>
201
- <br>
202
- Thanks for choosing <strong>${Manager.config.brand.name}</strong>. Here's to new beginnings!
203
- <br>
204
- <br>
205
- `
206
- },
207
- signoff: {
208
- type: 'personal',
209
- image: null,
210
- name: 'Ian Wiedenman, CEO',
211
- url: 'https://ianwiedenman.com',
212
- urlText: '@ianwieds',
213
- },
214
- },
215
- },
216
- })
217
- .then(async (json) => {
218
- assistant.log('sendEmail(): Success', json)
219
- return resolve(json);
220
- })
221
- .catch(e => {
222
- assistant.error('sendEmail(): Failed', e)
223
- return resolve(e);
224
- });
225
- });
226
- }
227
-
228
110
  Module.prototype.signUp = function (payload) {
229
111
  const self = this;
230
112
 
@@ -436,34 +318,221 @@ Module.prototype.addToSendGridList = function (user) {
436
318
  });
437
319
  }
438
320
 
439
- function addToMCList(key, listId, email) {
440
- return new Promise((resolve, reject) => {
441
- let datacenter = key.split('-')[1];
442
- fetch(`https://${datacenter}.api.mailchimp.com/3.0/lists/${listId}/members`, {
443
- method: 'post',
444
- timeout: 30000,
445
- response: 'json',
446
- body: {
447
- email_address: email,
448
- status: 'subscribed',
321
+ Module.prototype.sendRateEmail = function (user) {
322
+ const self = this;
323
+
324
+ return new Promise(async function(resolve, reject) {
325
+ const Manager = self.Manager;
326
+ const assistant = self.assistant;
327
+
328
+ // Send email
329
+ fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
330
+ method: 'post',
331
+ response: 'json',
332
+ log: true,
333
+ body: {
334
+ backendManagerKey: Manager.config.backend_manager.key,
335
+ app: Manager.config.app.id,
336
+ to: {
337
+ email: user.auth.email,
449
338
  },
450
- headers: {
451
- 'Content-Type': 'application/json',
452
- 'Authorization': `Basic ${key}`,
339
+ categories: [`account/too-many-signups`],
340
+ subject: `Your ${Manager.config.brand.name} account has been deleted`,
341
+ template: 'd-b7f8da3c98ad49a2ad1e187f3a67b546',
342
+ group: 25927,
343
+ data: {
344
+ email: {
345
+ preview: `You have signed up for too many accounts at ${Manager.config.brand.name}! Your account has been deleted.`,
346
+ },
347
+ body: {
348
+ title: `Account deleted`,
349
+ message: `
350
+ Your account at <strong>${Manager.config.brand.name}</strong> has been <strong>deleted</strong> because you have signed up for too many accounts.
351
+ <br>
352
+ <br>
353
+ If you believe this is a mistake, please contact us at ${Manager.config.brand.email}.
354
+ <br>
355
+ <br>
356
+ <strong>User Record</strong>:
357
+ <br>
358
+ <pre><code>${JSON.stringify(user, null, 2)}</code></pre>
359
+ `,
360
+ },
453
361
  },
454
- })
455
- .then(json => {
456
- if (json.status !== 'subscribed') {
457
- return reject(new Error(json.status));
458
- }
459
- return resolve(json);
460
- })
461
- .catch(e => {
462
- return reject(e);
463
- })
362
+ },
363
+ })
364
+ .then(async (json) => {
365
+ assistant.log('sendEmail(): Success', json)
366
+ return resolve(json);
367
+ })
368
+ .catch(e => {
369
+ assistant.error('sendEmail(): Failed', e)
370
+ return resolve(e);
371
+ });
372
+ });
373
+ }
374
+
375
+ Module.prototype.sendWelcomeEmail = function (user) {
376
+ const self = this;
377
+
378
+ return new Promise(async function(resolve, reject) {
379
+ const Manager = self.Manager;
380
+ const assistant = self.assistant;
381
+
382
+ // Send email
383
+ fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
384
+ method: 'post',
385
+ response: 'json',
386
+ log: true,
387
+ body: {
388
+ backendManagerKey: Manager.config.backend_manager.key,
389
+ app: Manager.config.app.id,
390
+ to: {
391
+ email: user.auth.email,
392
+ },
393
+ categories: [`account/welcome`],
394
+ subject: `Welcome to ${Manager.config.brand.name}!`,
395
+ template: 'd-b7f8da3c98ad49a2ad1e187f3a67b546',
396
+ group: 25928,
397
+ copy: false,
398
+ sendAt: moment().add(1, 'day').unix(),
399
+ data: {
400
+ email: {
401
+ preview: `Welcome aboard! I'm Ian, the CEO and founder of ${Manager.config.brand.name}. I'm here to ensure your journey with us gets off to a great start.`,
402
+ },
403
+ body: {
404
+ title: `Welcome to ${Manager.config.brand.name}!`,
405
+ message: `
406
+ Welcome aboard!
407
+ <br><br>
408
+ I'm Ian, the founder and CEO of <strong>${Manager.config.brand.name}</strong>, and I'm thrilled to have you with us.
409
+ Your journey begins today, and we are committed to supporting you every step of the way.
410
+ <br><br>
411
+ Feel free to reply directly to this email with any questions you may have.
412
+ Our team and I are dedicated to ensuring your experience is exceptional.
413
+ <br><br>
414
+ Thank you for choosing <strong>${Manager.config.brand.name}</strong>. Here's to new beginnings!
415
+ `
416
+ },
417
+ signoff: {
418
+ type: 'personal',
419
+ image: undefined,
420
+ name: 'Ian Wiedenman, CEO',
421
+ url: `https://ianwiedenman.com?utm_source=welcome-email&utm_medium=email&utm_campaign=${Manager.config.app.id}`,
422
+ urlText: '@ianwieds',
423
+ },
424
+ },
425
+ },
426
+ })
427
+ .then(async (json) => {
428
+ assistant.log('sendEmail(): Success', json)
429
+ return resolve(json);
430
+ })
431
+ .catch(e => {
432
+ assistant.error('sendEmail(): Failed', e)
433
+ return resolve(e);
434
+ });
435
+ });
436
+ }
437
+
438
+ Module.prototype.sendCheckupEmail = function (user) {
439
+ const self = this;
440
+
441
+ return new Promise(async function(resolve, reject) {
442
+ const Manager = self.Manager;
443
+ const assistant = self.assistant;
464
444
 
445
+ // Send email
446
+ fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
447
+ method: 'post',
448
+ response: 'json',
449
+ log: true,
450
+ body: {
451
+ backendManagerKey: Manager.config.backend_manager.key,
452
+ app: Manager.config.app.id,
453
+ to: {
454
+ email: user.auth.email,
455
+ },
456
+ categories: [`account/checkup`],
457
+ subject: `How's your experience with ${Manager.config.brand.name}?`,
458
+ template: 'd-b7f8da3c98ad49a2ad1e187f3a67b546',
459
+ group: 25928,
460
+ copy: false,
461
+ sendAt: moment().add(7, 'days').unix(),
462
+ data: {
463
+ email: {
464
+ preview: `Checking in from ${Manager.config.brand.name} to see how things are going. Let us know if you have any questions or feedback!`,
465
+ },
466
+ body: {
467
+ title: `How's everything going?`,
468
+ message: `
469
+ Hi there,
470
+ <br><br>
471
+ It's Ian again from <strong>${Manager.config.brand.name}</strong>. Just checking in to see how things are going for you.
472
+ <br><br>
473
+ Have you had a chance to explore all our features? Any questions or feedback for us?
474
+ <br><br>
475
+ We're always here to help, so don't hesitate to reach out. Just reply to this email and we'll get back to you as soon as possible.
476
+ <br><br>
477
+ Thank you for choosing <strong>${Manager.config.brand.name}</strong>. Here's to new beginnings!
478
+ `
479
+ },
480
+ signoff: {
481
+ type: 'personal',
482
+ image: undefined,
483
+ name: 'Ian Wiedenman, CEO',
484
+ url: `https://ianwiedenman.com?utm_source=checkup-email&utm_medium=email&utm_campaign=${Manager.config.app.id}`,
485
+ urlText: '@ianwieds',
486
+ },
487
+ },
488
+ },
489
+ })
490
+ .then(async (json) => {
491
+ assistant.log('sendEmail(): Success', json)
492
+ return resolve(json);
493
+ })
494
+ .catch(e => {
495
+ assistant.error('sendEmail(): Failed', e)
496
+ return resolve(e);
497
+ });
465
498
  });
466
499
  }
467
500
 
501
+ Module.prototype.sendFeedbackEmail = function (user) {
502
+ const self = this;
503
+
504
+ return new Promise(async function(resolve, reject) {
505
+ const Manager = self.Manager;
506
+ const assistant = self.assistant;
507
+
508
+ // Send email
509
+ fetch(`https://us-central1-itw-creative-works.cloudfunctions.net/sendEmail`, {
510
+ method: 'post',
511
+ response: 'json',
512
+ log: true,
513
+ body: {
514
+ backendManagerKey: Manager.config.backend_manager.key,
515
+ app: Manager.config.app.id,
516
+ to: {
517
+ email: user.auth.email,
518
+ },
519
+ categories: [`engagement/feedback`],
520
+ subject: `Want to share your feedback about ${Manager.config.brand.name}?`,
521
+ template: 'd-c1522214c67b47058669acc5a81ed663',
522
+ group: 25928,
523
+ copy: false,
524
+ sendAt: moment().add(14, 'days').unix(),
525
+ },
526
+ })
527
+ .then(async (json) => {
528
+ assistant.log('sendEmail(): Success', json)
529
+ return resolve(json);
530
+ })
531
+ .catch(e => {
532
+ assistant.error('sendEmail(): Failed', e)
533
+ return resolve(e);
534
+ });
535
+ });
536
+ }
468
537
 
469
538
  module.exports = Module;