payload-plugin-newsletter 0.13.0 → 0.13.1
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/CHANGELOG.md +11 -0
- package/CLAUDE.md +1 -1
- package/dist/index.cjs +50 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.13.1] - 2025-07-21
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
- Fixed Broadcast API subscriber update method to match API documentation
|
|
5
|
+
- Added comprehensive debug logging for email service initialization and subscriber sync
|
|
6
|
+
- Improved error handling in subscriber hooks to surface sync issues
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Debug logging for troubleshooting subscriber sync with email providers
|
|
10
|
+
- Better error messages when email service configuration fails
|
|
11
|
+
|
|
1
12
|
## [0.13.0] - 2025-07-21
|
|
2
13
|
|
|
3
14
|
### Changed
|
package/CLAUDE.md
CHANGED
|
@@ -72,7 +72,7 @@ Use these resources for understanding patterns and best practices:
|
|
|
72
72
|
|
|
73
73
|
1. **Plugin Documentation**:
|
|
74
74
|
- Check `docs/` directory for comprehensive plugin documentation
|
|
75
|
-
- `docs/references/broadcast-docs
|
|
75
|
+
- `docs/references/broadcast-api-docs.md` - Complete Broadcast API reference (sendbroadcast.net)
|
|
76
76
|
- `docs/guides/email-providers.md` - Email provider setup and comparison
|
|
77
77
|
- `docs/development/context7-setup.md` - How to set up context7 MCP for current docs
|
|
78
78
|
- `docs/architecture/` - Plugin architecture and design decisions
|
package/dist/index.cjs
CHANGED
|
@@ -1046,11 +1046,19 @@ var createSubscribersCollection = (pluginConfig) => {
|
|
|
1046
1046
|
async ({ doc, req, operation, previousDoc }) => {
|
|
1047
1047
|
if (operation === "create") {
|
|
1048
1048
|
const emailService = req.payload.newsletterEmailService;
|
|
1049
|
+
console.log("[Newsletter Plugin] Creating subscriber:", {
|
|
1050
|
+
email: doc.email,
|
|
1051
|
+
hasEmailService: !!emailService
|
|
1052
|
+
});
|
|
1049
1053
|
if (emailService) {
|
|
1050
1054
|
try {
|
|
1051
1055
|
await emailService.addContact(doc);
|
|
1052
|
-
|
|
1056
|
+
console.log("[Newsletter Plugin] Successfully added contact to email service");
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
console.error("[Newsletter Plugin] Failed to add contact to email service:", error);
|
|
1053
1059
|
}
|
|
1060
|
+
} else {
|
|
1061
|
+
console.warn("[Newsletter Plugin] No email service configured for subscriber creation");
|
|
1054
1062
|
}
|
|
1055
1063
|
if (doc.subscriptionStatus === "active" && emailService) {
|
|
1056
1064
|
try {
|
|
@@ -1080,10 +1088,22 @@ var createSubscribersCollection = (pluginConfig) => {
|
|
|
1080
1088
|
}
|
|
1081
1089
|
if (operation === "update" && previousDoc) {
|
|
1082
1090
|
const emailService = req.payload.newsletterEmailService;
|
|
1083
|
-
if (doc.subscriptionStatus !== previousDoc.subscriptionStatus
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1091
|
+
if (doc.subscriptionStatus !== previousDoc.subscriptionStatus) {
|
|
1092
|
+
console.log("[Newsletter Plugin] Subscription status changed:", {
|
|
1093
|
+
email: doc.email,
|
|
1094
|
+
from: previousDoc.subscriptionStatus,
|
|
1095
|
+
to: doc.subscriptionStatus,
|
|
1096
|
+
hasEmailService: !!emailService
|
|
1097
|
+
});
|
|
1098
|
+
if (emailService) {
|
|
1099
|
+
try {
|
|
1100
|
+
await emailService.updateContact(doc);
|
|
1101
|
+
console.log("[Newsletter Plugin] Successfully updated contact in email service");
|
|
1102
|
+
} catch (error) {
|
|
1103
|
+
console.error("[Newsletter Plugin] Failed to update contact in email service:", error);
|
|
1104
|
+
}
|
|
1105
|
+
} else {
|
|
1106
|
+
console.warn("[Newsletter Plugin] No email service configured");
|
|
1087
1107
|
}
|
|
1088
1108
|
}
|
|
1089
1109
|
if (doc.subscriptionStatus === "unsubscribed" && previousDoc.subscriptionStatus !== "unsubscribed") {
|
|
@@ -1654,6 +1674,7 @@ var BroadcastProvider = class {
|
|
|
1654
1674
|
},
|
|
1655
1675
|
body: JSON.stringify({
|
|
1656
1676
|
email: contact.email,
|
|
1677
|
+
// Email at root level to identify the subscriber
|
|
1657
1678
|
subscriber: {
|
|
1658
1679
|
first_name: firstName || void 0,
|
|
1659
1680
|
last_name: lastName || void 0,
|
|
@@ -4489,6 +4510,12 @@ var newsletterPlugin = (pluginConfig) => (incomingConfig) => {
|
|
|
4489
4510
|
const settings = await payload.findGlobal({
|
|
4490
4511
|
slug: config.settingsSlug || "newsletter-settings"
|
|
4491
4512
|
});
|
|
4513
|
+
console.log("[Newsletter Plugin] Initializing with settings:", {
|
|
4514
|
+
hasSettings: !!settings,
|
|
4515
|
+
settingsProvider: settings?.provider,
|
|
4516
|
+
configProvider: config.providers?.default,
|
|
4517
|
+
hasBroadcastConfig: !!config.providers?.broadcast
|
|
4518
|
+
});
|
|
4492
4519
|
let emailServiceConfig;
|
|
4493
4520
|
if (settings) {
|
|
4494
4521
|
emailServiceConfig = {
|
|
@@ -4523,8 +4550,24 @@ var newsletterPlugin = (pluginConfig) => (incomingConfig) => {
|
|
|
4523
4550
|
broadcast: config.providers.broadcast
|
|
4524
4551
|
};
|
|
4525
4552
|
}
|
|
4526
|
-
|
|
4527
|
-
|
|
4553
|
+
console.log("[Newsletter Plugin] Email service config:", {
|
|
4554
|
+
provider: emailServiceConfig.provider,
|
|
4555
|
+
hasBroadcastConfig: !!emailServiceConfig.broadcast,
|
|
4556
|
+
broadcastUrl: emailServiceConfig.broadcast?.apiUrl,
|
|
4557
|
+
hasToken: !!emailServiceConfig.broadcast?.token
|
|
4558
|
+
});
|
|
4559
|
+
try {
|
|
4560
|
+
const emailService = createEmailService(emailServiceConfig);
|
|
4561
|
+
payload.newsletterEmailService = emailService;
|
|
4562
|
+
console.log("[Newsletter Plugin] Email service initialized:", {
|
|
4563
|
+
provider: emailService.getProvider(),
|
|
4564
|
+
hasProvider: !!emailService,
|
|
4565
|
+
payloadHasService: !!payload.newsletterEmailService
|
|
4566
|
+
});
|
|
4567
|
+
} catch (emailServiceError) {
|
|
4568
|
+
console.error("[Newsletter Plugin] Failed to create email service:", emailServiceError);
|
|
4569
|
+
console.error("[Newsletter Plugin] Email service config was:", emailServiceConfig);
|
|
4570
|
+
}
|
|
4528
4571
|
if (config.features?.newsletterManagement?.enabled) {
|
|
4529
4572
|
try {
|
|
4530
4573
|
let broadcastProvider;
|