-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a526443
commit 92fd170
Showing
8 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const { emailModel } = require('../modules/stores/mongo'); | ||
const logger = require("../modules/logger"); | ||
|
||
router.get('/open-tracking', async (req, res) => { | ||
const { trackingId } = req.query; | ||
|
||
if (!trackingId) { | ||
return res.status(400).send('Tracking ID missing'); | ||
} | ||
|
||
try { | ||
const trackingRecord = await emailModel.findOne({ trackingId }); | ||
if (!trackingRecord) { | ||
return res.status(404).send('Tracking ID not found'); | ||
} | ||
|
||
trackingRecord.isOpened = true; | ||
trackingRecord.openedAt = new Date(); | ||
await trackingRecord.save(); | ||
|
||
res.set('Content-Type', 'image/gif'); | ||
res.send(Buffer.from('R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==', 'base64')); | ||
} catch (err) { | ||
logger.error(err) | ||
res.status(500).send('Internal Server Error') | ||
} | ||
}) | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ const { getS3Url } = require("../modules/stores/aws"); | |
|
||
module.exports = ( | ||
title, | ||
content | ||
content, | ||
trackingId, | ||
origin | ||
) => `<div style="font-family: system-ui; position: relative; background: #ffffff; margin: 0; padding: 72px;"> | ||
<div style="width: max(min(100%, 800px), 320px); margin: 0 auto; padding 0;"> | ||
<div style="height: 102px; background: #6E3678; margin: 0 0 48px; padding: 0;"> | ||
|
@@ -27,5 +29,7 @@ module.exports = ( | |
</a> | ||
<div style="font-family: system-ui; font-size: 12px; font-weight: lighter; color: #999999; margin: 0; padding: 0;">[email protected]</div> | ||
</div> | ||
<!-- Tracking pixel to detect email opens --> | ||
<img src="${new URL(`/email?trackingId=${trackingId}`, origin).href}" width="1" height="1" alt="pixel" /> | ||
</div> | ||
</div>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters