payload-plugin-newsletter 0.16.6 → 0.16.7
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 +24 -0
- package/dist/collections.cjs +68 -19
- package/dist/collections.cjs.map +1 -1
- package/dist/collections.js +68 -19
- package/dist/collections.js.map +1 -1
- package/dist/index.cjs +68 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +68 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [0.16.7] - 2025-07-29
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
- **Comprehensive Diagnostic Logging** - Added extensive logging to diagnose broadcast sync issues
|
|
5
|
+
- Logs the HTML content conversion process
|
|
6
|
+
- Shows exactly what data is being sent to the Broadcast API (with preview)
|
|
7
|
+
- Displays request URL, method, and body structure
|
|
8
|
+
- Shows API response status and headers
|
|
9
|
+
- Captures and logs all error types (Error objects, strings, JSON responses)
|
|
10
|
+
- Logs raw errors to identify unexpected error formats
|
|
11
|
+
|
|
12
|
+
### Improved
|
|
13
|
+
- **Better Error Visibility** - Enhanced error handling to capture more details
|
|
14
|
+
- Raw error logging to see the actual error structure
|
|
15
|
+
- Multiple error format handlers (Error, string, object, unknown)
|
|
16
|
+
- Response body parsing for API errors
|
|
17
|
+
- Document context logging when errors occur
|
|
18
|
+
- API request/response details in provider logs
|
|
19
|
+
|
|
20
|
+
### Technical
|
|
21
|
+
- Added pre-API call logging in afterChange hook
|
|
22
|
+
- Added comprehensive error logging in BroadcastApiProvider
|
|
23
|
+
- Logs help identify if issues are with content, API format, or authentication
|
|
24
|
+
|
|
1
25
|
## [0.16.6] - 2025-07-29
|
|
2
26
|
|
|
3
27
|
### Fixed
|
package/dist/collections.cjs
CHANGED
|
@@ -252,29 +252,46 @@ var init_broadcast2 = __esm({
|
|
|
252
252
|
async create(data) {
|
|
253
253
|
try {
|
|
254
254
|
this.validateRequiredFields(data, ["name", "subject", "content"]);
|
|
255
|
+
const requestBody = {
|
|
256
|
+
broadcast: {
|
|
257
|
+
name: data.name,
|
|
258
|
+
subject: data.subject,
|
|
259
|
+
preheader: data.preheader,
|
|
260
|
+
body: data.content,
|
|
261
|
+
html_body: true,
|
|
262
|
+
track_opens: data.trackOpens ?? true,
|
|
263
|
+
track_clicks: data.trackClicks ?? true,
|
|
264
|
+
reply_to: data.replyTo,
|
|
265
|
+
segment_ids: data.audienceIds
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
console.log("[BroadcastApiProvider] Creating broadcast:", {
|
|
269
|
+
url: `${this.apiUrl}/api/v1/broadcasts`,
|
|
270
|
+
method: "POST",
|
|
271
|
+
hasToken: !!this.token,
|
|
272
|
+
tokenLength: this.token?.length,
|
|
273
|
+
body: JSON.stringify(requestBody, null, 2)
|
|
274
|
+
});
|
|
255
275
|
const response = await fetch(`${this.apiUrl}/api/v1/broadcasts`, {
|
|
256
276
|
method: "POST",
|
|
257
277
|
headers: {
|
|
258
278
|
"Authorization": `Bearer ${this.token}`,
|
|
259
279
|
"Content-Type": "application/json"
|
|
260
280
|
},
|
|
261
|
-
body: JSON.stringify(
|
|
262
|
-
broadcast: {
|
|
263
|
-
name: data.name,
|
|
264
|
-
subject: data.subject,
|
|
265
|
-
preheader: data.preheader,
|
|
266
|
-
body: data.content,
|
|
267
|
-
html_body: true,
|
|
268
|
-
track_opens: data.trackOpens ?? true,
|
|
269
|
-
track_clicks: data.trackClicks ?? true,
|
|
270
|
-
reply_to: data.replyTo,
|
|
271
|
-
segment_ids: data.audienceIds
|
|
272
|
-
}
|
|
273
|
-
})
|
|
281
|
+
body: JSON.stringify(requestBody)
|
|
274
282
|
});
|
|
283
|
+
console.log("[BroadcastApiProvider] Response status:", response.status);
|
|
284
|
+
console.log("[BroadcastApiProvider] Response headers:", Object.fromEntries(response.headers.entries()));
|
|
275
285
|
if (!response.ok) {
|
|
276
|
-
const
|
|
277
|
-
|
|
286
|
+
const errorText = await response.text();
|
|
287
|
+
console.error("[BroadcastApiProvider] Error response body:", errorText);
|
|
288
|
+
let errorDetails;
|
|
289
|
+
try {
|
|
290
|
+
errorDetails = JSON.parse(errorText);
|
|
291
|
+
console.error("[BroadcastApiProvider] Parsed error:", errorDetails);
|
|
292
|
+
} catch {
|
|
293
|
+
}
|
|
294
|
+
throw new Error(`Broadcast API error: ${response.status} - ${errorText}`);
|
|
278
295
|
}
|
|
279
296
|
const result = await response.json();
|
|
280
297
|
return this.get(result.id.toString());
|
|
@@ -1448,8 +1465,9 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
1448
1465
|
}
|
|
1449
1466
|
const { BroadcastApiProvider: BroadcastApiProvider2 } = await Promise.resolve().then(() => (init_broadcast2(), broadcast_exports));
|
|
1450
1467
|
const provider = new BroadcastApiProvider2(providerConfig);
|
|
1468
|
+
req.payload.logger.info("Converting content to HTML...");
|
|
1451
1469
|
const htmlContent = await convertToEmailSafeHtml(doc.contentSection?.content);
|
|
1452
|
-
const
|
|
1470
|
+
const createData = {
|
|
1453
1471
|
name: doc.subject,
|
|
1454
1472
|
// Use subject as name since we removed the name field
|
|
1455
1473
|
subject: doc.subject,
|
|
@@ -1459,7 +1477,21 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
1459
1477
|
trackClicks: doc.settings?.trackClicks,
|
|
1460
1478
|
replyTo: doc.settings?.replyTo || providerConfig.replyTo,
|
|
1461
1479
|
audienceIds: doc.audienceIds?.map((a) => a.audienceId)
|
|
1480
|
+
};
|
|
1481
|
+
req.payload.logger.info("Creating broadcast with data:", {
|
|
1482
|
+
name: createData.name,
|
|
1483
|
+
subject: createData.subject,
|
|
1484
|
+
preheader: createData.preheader || "NONE",
|
|
1485
|
+
contentLength: htmlContent ? htmlContent.length : 0,
|
|
1486
|
+
contentPreview: htmlContent ? htmlContent.substring(0, 100) + "..." : "EMPTY",
|
|
1487
|
+
trackOpens: createData.trackOpens,
|
|
1488
|
+
trackClicks: createData.trackClicks,
|
|
1489
|
+
replyTo: createData.replyTo,
|
|
1490
|
+
audienceIds: createData.audienceIds || [],
|
|
1491
|
+
apiUrl: providerConfig.apiUrl,
|
|
1492
|
+
hasToken: !!providerConfig.token
|
|
1462
1493
|
});
|
|
1494
|
+
const providerBroadcast = await provider.create(createData);
|
|
1463
1495
|
await req.payload.update({
|
|
1464
1496
|
collection: "broadcasts",
|
|
1465
1497
|
id: doc.id,
|
|
@@ -1475,17 +1507,34 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
1475
1507
|
providerData: providerBroadcast.providerData
|
|
1476
1508
|
};
|
|
1477
1509
|
} catch (error) {
|
|
1510
|
+
req.payload.logger.error("Raw error from broadcast provider:");
|
|
1511
|
+
req.payload.logger.error(error);
|
|
1478
1512
|
if (error instanceof Error) {
|
|
1479
|
-
req.payload.logger.error("
|
|
1513
|
+
req.payload.logger.error("Error is instance of Error:", {
|
|
1480
1514
|
message: error.message,
|
|
1481
1515
|
stack: error.stack,
|
|
1482
1516
|
name: error.name,
|
|
1483
1517
|
// If it's a BroadcastProviderError, it might have additional details
|
|
1484
|
-
...error.details
|
|
1518
|
+
...error.details,
|
|
1519
|
+
// Check if it's a fetch response error
|
|
1520
|
+
...error.response,
|
|
1521
|
+
...error.data,
|
|
1522
|
+
...error.status,
|
|
1523
|
+
...error.statusText
|
|
1485
1524
|
});
|
|
1525
|
+
} else if (typeof error === "string") {
|
|
1526
|
+
req.payload.logger.error("Error is a string:", error);
|
|
1527
|
+
} else if (error && typeof error === "object") {
|
|
1528
|
+
req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
|
|
1486
1529
|
} else {
|
|
1487
|
-
req.payload.logger.error("
|
|
1530
|
+
req.payload.logger.error("Unknown error type:", typeof error);
|
|
1488
1531
|
}
|
|
1532
|
+
req.payload.logger.error("Failed broadcast document:", {
|
|
1533
|
+
id: doc.id,
|
|
1534
|
+
subject: doc.subject,
|
|
1535
|
+
hasContent: !!doc.contentSection?.content,
|
|
1536
|
+
contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
|
|
1537
|
+
});
|
|
1489
1538
|
return doc;
|
|
1490
1539
|
}
|
|
1491
1540
|
}
|