backend-manager 3.2.23 → 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.23",
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,121 +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 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.`,
186
- },
187
- body: {
188
- title: `Welcome to ${Manager.config.brand.name}!`,
189
- message: `
190
- Welcome aboard!
191
- <br><br>
192
- I'm Ian, the founder and CEO of <strong>${Manager.config.brand.name}</strong>, and I'm thrilled to have you with us.
193
- Your journey begins today, and we are committed to supporting you every step of the way.
194
- <br><br>
195
- Feel free to reply directly to this email with any questions you may have.
196
- Our team and I are dedicated to ensuring your experience is exceptional.
197
- <br><br>
198
- Thank you for choosing <strong>${Manager.config.brand.name}</strong>. Here's to new beginnings!
199
- `
200
- },
201
- signoff: {
202
- type: 'personal',
203
- image: null,
204
- name: 'Ian Wiedenman, CEO',
205
- url: `https://ianwiedenman.com?utm_source=welcome-email&utm_medium=email&utm_campaign=${Manager.config.app.id}`,
206
- urlText: '@ianwieds',
207
- },
208
- },
209
- },
210
- })
211
- .then(async (json) => {
212
- assistant.log('sendEmail(): Success', json)
213
- return resolve(json);
214
- })
215
- .catch(e => {
216
- assistant.error('sendEmail(): Failed', e)
217
- return resolve(e);
218
- });
219
- });
220
- }
221
-
222
110
  Module.prototype.signUp = function (payload) {
223
111
  const self = this;
224
112
 
@@ -430,34 +318,221 @@ Module.prototype.addToSendGridList = function (user) {
430
318
  });
431
319
  }
432
320
 
433
- function addToMCList(key, listId, email) {
434
- return new Promise((resolve, reject) => {
435
- let datacenter = key.split('-')[1];
436
- fetch(`https://${datacenter}.api.mailchimp.com/3.0/lists/${listId}/members`, {
437
- method: 'post',
438
- timeout: 30000,
439
- response: 'json',
440
- body: {
441
- email_address: email,
442
- 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,
338
+ },
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
+ },
443
361
  },
444
- headers: {
445
- 'Content-Type': 'application/json',
446
- 'Authorization': `Basic ${key}`,
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,
447
392
  },
448
- })
449
- .then(json => {
450
- if (json.status !== 'subscribed') {
451
- return reject(new Error(json.status));
452
- }
453
- return resolve(json);
454
- })
455
- .catch(e => {
456
- return reject(e);
457
- })
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;
458
440
 
441
+ return new Promise(async function(resolve, reject) {
442
+ const Manager = self.Manager;
443
+ const assistant = self.assistant;
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
+ });
459
498
  });
460
499
  }
461
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
+ }
462
537
 
463
538
  module.exports = Module;