@cakemail-org/cakemail-cli 1.5.0 → 2.0.0

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.
Files changed (234) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.env.example +40 -0
  3. package/.env.test.example +45 -0
  4. package/CHANGELOG.md +1031 -0
  5. package/README.md +319 -15
  6. package/audit-formats.js +128 -0
  7. package/cakemail.rb +20 -0
  8. package/dist/cli.js +27 -10
  9. package/dist/cli.js.map +1 -1
  10. package/dist/client.d.ts +2 -0
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +16 -6
  13. package/dist/client.js.map +1 -1
  14. package/dist/commands/account.js +1 -1
  15. package/dist/commands/account.js.map +1 -1
  16. package/dist/commands/attributes.js +1 -1
  17. package/dist/commands/attributes.js.map +1 -1
  18. package/dist/commands/campaigns.d.ts.map +1 -1
  19. package/dist/commands/campaigns.js +103 -8
  20. package/dist/commands/campaigns.js.map +1 -1
  21. package/dist/commands/config.d.ts.map +1 -1
  22. package/dist/commands/config.js +63 -4
  23. package/dist/commands/config.js.map +1 -1
  24. package/dist/commands/contacts.d.ts.map +1 -1
  25. package/dist/commands/contacts.js +91 -12
  26. package/dist/commands/contacts.js.map +1 -1
  27. package/dist/commands/emails.js +1 -1
  28. package/dist/commands/emails.js.map +1 -1
  29. package/dist/commands/interests.d.ts +5 -0
  30. package/dist/commands/interests.d.ts.map +1 -0
  31. package/dist/commands/interests.js +172 -0
  32. package/dist/commands/interests.js.map +1 -0
  33. package/dist/commands/lists.d.ts.map +1 -1
  34. package/dist/commands/lists.js +6 -8
  35. package/dist/commands/lists.js.map +1 -1
  36. package/dist/commands/logs.d.ts +5 -0
  37. package/dist/commands/logs.d.ts.map +1 -0
  38. package/dist/commands/logs.js +237 -0
  39. package/dist/commands/logs.js.map +1 -0
  40. package/dist/commands/reports.js +1 -1
  41. package/dist/commands/reports.js.map +1 -1
  42. package/dist/commands/segments.js +1 -1
  43. package/dist/commands/segments.js.map +1 -1
  44. package/dist/commands/senders.d.ts.map +1 -1
  45. package/dist/commands/senders.js +11 -8
  46. package/dist/commands/senders.js.map +1 -1
  47. package/dist/commands/suppressed.js +1 -1
  48. package/dist/commands/suppressed.js.map +1 -1
  49. package/dist/commands/tags.d.ts +5 -0
  50. package/dist/commands/tags.d.ts.map +1 -0
  51. package/dist/commands/tags.js +124 -0
  52. package/dist/commands/tags.js.map +1 -0
  53. package/dist/commands/templates.js +1 -1
  54. package/dist/commands/templates.js.map +1 -1
  55. package/dist/commands/transactional-templates.d.ts +5 -0
  56. package/dist/commands/transactional-templates.d.ts.map +1 -0
  57. package/dist/commands/transactional-templates.js +354 -0
  58. package/dist/commands/transactional-templates.js.map +1 -0
  59. package/dist/commands/webhooks.js +1 -1
  60. package/dist/commands/webhooks.js.map +1 -1
  61. package/dist/utils/auth.d.ts +8 -1
  62. package/dist/utils/auth.d.ts.map +1 -1
  63. package/dist/utils/auth.js +39 -11
  64. package/dist/utils/auth.js.map +1 -1
  65. package/dist/utils/config-file.d.ts +7 -0
  66. package/dist/utils/config-file.d.ts.map +1 -1
  67. package/dist/utils/config-file.js +15 -0
  68. package/dist/utils/config-file.js.map +1 -1
  69. package/dist/utils/config.d.ts +2 -0
  70. package/dist/utils/config.d.ts.map +1 -1
  71. package/dist/utils/config.js +12 -4
  72. package/dist/utils/config.js.map +1 -1
  73. package/dist/utils/errors.js +1 -1
  74. package/dist/utils/errors.js.map +1 -1
  75. package/dist/utils/list-defaults.d.ts +33 -0
  76. package/dist/utils/list-defaults.d.ts.map +1 -0
  77. package/dist/utils/list-defaults.js +52 -0
  78. package/dist/utils/list-defaults.js.map +1 -0
  79. package/dist/utils/output.d.ts.map +1 -1
  80. package/dist/utils/output.js +36 -13
  81. package/dist/utils/output.js.map +1 -1
  82. package/dist/utils/progress.d.ts.map +1 -1
  83. package/dist/utils/progress.js +32 -4
  84. package/dist/utils/progress.js.map +1 -1
  85. package/dist/utils/spinner.d.ts +17 -0
  86. package/dist/utils/spinner.d.ts.map +1 -0
  87. package/dist/utils/spinner.js +43 -0
  88. package/dist/utils/spinner.js.map +1 -0
  89. package/docs/DOCUMENTATION-STANDARD.md +1068 -0
  90. package/docs/README.md +161 -0
  91. package/docs/developer/ARCHITECTURE.md +516 -0
  92. package/docs/developer/AUTH.md +204 -0
  93. package/docs/developer/CONTRIBUTING.md +227 -0
  94. package/docs/developer/DOCUMENTATION_SUMMARY.md +346 -0
  95. package/docs/developer/PROJECT_INDEX.md +365 -0
  96. package/docs/planning/API_COVERAGE.md +1045 -0
  97. package/docs/planning/BACKLOG.md +1159 -0
  98. package/docs/planning/PROFILE_SYSTEM_TASKS.md +287 -0
  99. package/docs/planning/UX_IMPLEMENTATION_PLAN.md +691 -0
  100. package/docs/planning/archive/RELEASE_CHECKLIST_v1.3.0.md +332 -0
  101. package/docs/planning/archive/RELEASE_v1.3.0.md +428 -0
  102. package/docs/planning/archive/cakemail-cli-ux-improvements.md +438 -0
  103. package/docs/planning/cakemail-profile-system-plan.md +1121 -0
  104. package/docs/testing/AI_USER_SIMULATION_DESIGN.md +1342 -0
  105. package/docs/testing/KENOGAMI_BIDIRECTIONAL_FLOW.md +1517 -0
  106. package/docs/testing/KENOGAMI_TRUTH_RECONCILIATION_SYSTEM.md +1369 -0
  107. package/docs/user-manual/.obsidian/app.json +1 -0
  108. package/docs/user-manual/.obsidian/appearance.json +1 -0
  109. package/docs/user-manual/.obsidian/core-plugins.json +33 -0
  110. package/docs/user-manual/.obsidian/workspace.json +167 -0
  111. package/docs/user-manual/01-getting-started/01-installation.md +214 -0
  112. package/docs/user-manual/01-getting-started/02-quick-start.md +432 -0
  113. package/docs/user-manual/01-getting-started/03-authentication.md +448 -0
  114. package/docs/user-manual/01-getting-started/04-configuration.md +430 -0
  115. package/docs/user-manual/01-getting-started/05-output-formats.md +447 -0
  116. package/docs/user-manual/02-core-concepts/01-accounts.md +514 -0
  117. package/docs/user-manual/02-core-concepts/02-profile-system.md +771 -0
  118. package/docs/user-manual/02-core-concepts/03-smart-defaults.md +485 -0
  119. package/docs/user-manual/02-core-concepts/04-authentication-methods.md +435 -0
  120. package/docs/user-manual/02-core-concepts/05-pagination-filtering.md +600 -0
  121. package/docs/user-manual/02-core-concepts/06-error-handling.md +718 -0
  122. package/docs/user-manual/02-core-concepts/07-api-coverage.md +483 -0
  123. package/docs/user-manual/03-email-operations/01-senders.md +490 -0
  124. package/docs/user-manual/03-email-operations/02-templates.md +444 -0
  125. package/docs/user-manual/03-email-operations/03-transactional-emails.md +706 -0
  126. package/docs/user-manual/03-email-operations/04-email-tracking.md +407 -0
  127. package/docs/user-manual/04-campaign-management/01-campaigns-basics.md +394 -0
  128. package/docs/user-manual/04-campaign-management/02-campaign-scheduling.md +630 -0
  129. package/docs/user-manual/04-campaign-management/03-campaign-testing.md +997 -0
  130. package/docs/user-manual/04-campaign-management/04-campaign-lifecycle.md +709 -0
  131. package/docs/user-manual/04-campaign-management/05-campaign-links.md +934 -0
  132. package/docs/user-manual/05-contact-management/01-lists.md +836 -0
  133. package/docs/user-manual/05-contact-management/02-contacts.md +1035 -0
  134. package/docs/user-manual/05-contact-management/03-custom-attributes.md +788 -0
  135. package/docs/user-manual/05-contact-management/04-segments.md +1028 -0
  136. package/docs/user-manual/05-contact-management/05-contact-import-export.md +1031 -0
  137. package/docs/user-manual/06-analytics-reporting/01-campaign-analytics.md +867 -0
  138. package/docs/user-manual/06-analytics-reporting/02-account-reports.md +227 -0
  139. package/docs/user-manual/07-integrations/01-webhooks-integration.md +259 -0
  140. package/docs/user-manual/07-integrations/02-automation.md +326 -0
  141. package/docs/user-manual/08-advanced-usage/01-scripting-patterns.md +672 -0
  142. package/docs/user-manual/08-advanced-usage/02-bulk-operations.md +932 -0
  143. package/docs/user-manual/08-advanced-usage/03-ci-cd-integration.md +892 -0
  144. package/docs/user-manual/08-advanced-usage/04-performance-optimization.md +766 -0
  145. package/docs/user-manual/09-command-reference/01-config.md +776 -0
  146. package/docs/user-manual/09-command-reference/02-account.md +652 -0
  147. package/docs/user-manual/09-command-reference/03-lists.md +958 -0
  148. package/docs/user-manual/09-command-reference/04-contacts.md +1408 -0
  149. package/docs/user-manual/09-command-reference/05-attributes.md +617 -0
  150. package/docs/user-manual/09-command-reference/06-segments.md +894 -0
  151. package/docs/user-manual/09-command-reference/07-senders.md +803 -0
  152. package/docs/user-manual/09-command-reference/08-templates.md +818 -0
  153. package/docs/user-manual/09-command-reference/09-campaigns.md +1250 -0
  154. package/docs/user-manual/09-command-reference/10-emails.md +807 -0
  155. package/docs/user-manual/09-command-reference/11-reports.md +1135 -0
  156. package/docs/user-manual/09-command-reference/12-webhooks.md +773 -0
  157. package/docs/user-manual/09-command-reference/13-suppressed.md +797 -0
  158. package/docs/user-manual/09-command-reference/14-interests.md +630 -0
  159. package/docs/user-manual/09-command-reference/15-tags.md +584 -0
  160. package/docs/user-manual/09-command-reference/16-logs.md +656 -0
  161. package/docs/user-manual/09-command-reference/17-transactional-templates.md +850 -0
  162. package/docs/user-manual/10-troubleshooting/01-common-errors.md +457 -0
  163. package/docs/user-manual/10-troubleshooting/02-authentication-issues.md +558 -0
  164. package/docs/user-manual/10-troubleshooting/03-connection-problems.md +634 -0
  165. package/docs/user-manual/10-troubleshooting/04-debugging.md +725 -0
  166. package/docs/user-manual/11-appendix/04-faq.md +484 -0
  167. package/docs/user-manual/11-appendix/05-glossary.md +250 -0
  168. package/docs/user-manual/README.md +0 -0
  169. package/package.json +13 -47
  170. package/src/cli.ts +125 -0
  171. package/src/client.ts +16 -0
  172. package/src/commands/account.ts +267 -0
  173. package/src/commands/accounts.ts +78 -0
  174. package/src/commands/actions.ts +249 -0
  175. package/src/commands/attributes.ts +139 -0
  176. package/src/commands/campaign-blueprints.ts +106 -0
  177. package/src/commands/campaigns.ts +469 -0
  178. package/src/commands/config.ts +77 -0
  179. package/src/commands/contacts.ts +612 -0
  180. package/src/commands/custom-attributes.ts +127 -0
  181. package/src/commands/dkims.ts +117 -0
  182. package/src/commands/domains.ts +82 -0
  183. package/src/commands/email-apis.ts +569 -0
  184. package/src/commands/emails.ts +197 -0
  185. package/src/commands/forms.ts +283 -0
  186. package/src/commands/interests.ts +155 -0
  187. package/src/commands/links.ts +38 -0
  188. package/src/commands/lists.ts +406 -0
  189. package/src/commands/logos.ts +71 -0
  190. package/src/commands/logs.ts +386 -0
  191. package/src/commands/reports.ts +306 -0
  192. package/src/commands/segments.ts +158 -0
  193. package/src/commands/senders.ts +204 -0
  194. package/src/commands/sub-accounts.ts +271 -0
  195. package/src/commands/suppressed-emails.ts +234 -0
  196. package/src/commands/suppressed.ts +198 -0
  197. package/src/commands/system-emails.ts +85 -0
  198. package/src/commands/tags.ts +146 -0
  199. package/src/commands/tasks.ts +116 -0
  200. package/src/commands/templates.ts +189 -0
  201. package/src/commands/tokens.ts +83 -0
  202. package/src/commands/transactional-emails.ts +374 -0
  203. package/src/commands/transactional-templates.ts +385 -0
  204. package/src/commands/users.ts +506 -0
  205. package/src/commands/webhooks.ts +172 -0
  206. package/src/commands/workflow-blueprints.ts +123 -0
  207. package/src/commands/workflows.ts +265 -0
  208. package/src/types/profile.ts +93 -0
  209. package/src/utils/auth.ts +272 -0
  210. package/src/utils/config-file.ts +96 -0
  211. package/src/utils/config.ts +134 -0
  212. package/src/utils/confirm.ts +32 -0
  213. package/src/utils/defaults.ts +99 -0
  214. package/src/utils/errors.ts +116 -0
  215. package/src/utils/interactive.ts +91 -0
  216. package/src/utils/list-defaults.ts +74 -0
  217. package/src/utils/output.ts +190 -0
  218. package/src/utils/progress.ts +320 -0
  219. package/src/utils/spinner.ts +22 -0
  220. package/tests/IMPLEMENTATION_STATUS.md +258 -0
  221. package/tests/PTY_SETUP.md +118 -0
  222. package/tests/PTY_TESTING_GUIDE.md +507 -0
  223. package/tests/README.md +244 -0
  224. package/tests/fixtures/api-responses/campaigns.json +34 -0
  225. package/tests/fixtures/test-config.json +13 -0
  226. package/tests/helpers/cli-runner.ts +128 -0
  227. package/tests/helpers/mock-server.ts +301 -0
  228. package/tests/helpers/pty-runner.ts +181 -0
  229. package/tests/integration/campaigns-real-api.test.ts +196 -0
  230. package/tests/integration/setup-integration.ts +50 -0
  231. package/tests/pty/campaigns.test.ts +241 -0
  232. package/tests/setup.ts +34 -0
  233. package/tsconfig.json +15 -0
  234. package/vitest.config.ts +28 -0
@@ -0,0 +1,656 @@
1
+ # Logs Commands
2
+
3
+ View and export activity logs for campaigns and lists.
4
+
5
+ ## Overview
6
+
7
+ Activity logs track all events related to your campaigns and lists, including opens, clicks, bounces, unsubscribes, and more. Use these commands to analyze engagement, troubleshoot issues, and export data for external analysis.
8
+
9
+ **Available Commands:**
10
+ - [`logs campaign`](#logs-campaign) - View campaign activity logs
11
+ - [`logs list`](#logs-list) - View list activity logs
12
+ - [`logs campaign-export`](#logs-campaign-export) - Create campaign log export
13
+ - [`logs campaign-export-download`](#logs-campaign-export-download) - Download campaign log export
14
+ - [`logs list-export`](#logs-list-export) - Create list log export
15
+ - [`logs list-export-download`](#logs-list-export-download) - Download list log export
16
+
17
+ **Key Features:**
18
+ - Real-time activity tracking
19
+ - Filtering by event type, time, contact
20
+ - Sorting and pagination
21
+ - CSV export for external analysis
22
+ - Auto-detection for list logs
23
+
24
+ **Log Event Types:**
25
+ - **Campaign**: open, click, bounce, complaint, delivered, failed
26
+ - **List**: subscribe, unsubscribe, update, import
27
+
28
+ ---
29
+
30
+ ## logs campaign
31
+
32
+ View activity logs for a specific campaign.
33
+
34
+ ### Usage
35
+
36
+ ```bash
37
+ cakemail logs campaign <campaign-id> [options]
38
+ ```
39
+
40
+ ### Arguments
41
+
42
+ - `<campaign-id>` - Campaign ID (required)
43
+
44
+ ### Options
45
+
46
+ - `--filter <filter>` - Filter logs (e.g., `type==open`, `contact_id==123`)
47
+ - `--sort <sort>` - Sort order (e.g., `+time`, `-contact_id`)
48
+ - `-p, --page <number>` - Page number
49
+ - `--per-page <number>` - Results per page
50
+ - `--start-time <timestamp>` - Start time (Unix timestamp)
51
+ - `--end-time <timestamp>` - End time (Unix timestamp)
52
+
53
+ ### Examples
54
+
55
+ **View all campaign logs:**
56
+ ```bash
57
+ $ cakemail logs campaign 789
58
+ ```
59
+
60
+ **Output:**
61
+ ```
62
+ Campaign: Weekly Newsletter (789)
63
+
64
+ ┌──────────────────────┬────────────┬────────────┬─────────────────────┐
65
+ │ Contact Email │ Event Type │ Details │ Time │
66
+ ├──────────────────────┼────────────┼────────────┼─────────────────────┤
67
+ │ john@example.com │ delivered │ - │ 2025-10-11 08:00:12 │
68
+ │ john@example.com │ open │ - │ 2025-10-11 08:15:33 │
69
+ │ john@example.com │ click │ Link #1 │ 2025-10-11 08:16:45 │
70
+ │ jane@example.com │ delivered │ - │ 2025-10-11 08:00:15 │
71
+ │ jane@example.com │ open │ - │ 2025-10-11 09:22:18 │
72
+ │ bob@example.com │ bounce │ Hard │ 2025-10-11 08:01:05 │
73
+ └──────────────────────┴────────────┴────────────┴─────────────────────┘
74
+
75
+ Showing 1-6 of 1,234 logs
76
+ ```
77
+
78
+ **Filter by event type:**
79
+ ```bash
80
+ $ cakemail logs campaign 789 --filter "type==open"
81
+ ```
82
+
83
+ **Filter by contact:**
84
+ ```bash
85
+ $ cakemail logs campaign 789 --filter "contact_id==456"
86
+ ```
87
+
88
+ **Multiple filters:**
89
+ ```bash
90
+ $ cakemail logs campaign 789 --filter "type==click;contact_id==456"
91
+ ```
92
+
93
+ **Sort by time (newest first):**
94
+ ```bash
95
+ $ cakemail logs campaign 789 --sort "-time"
96
+ ```
97
+
98
+ **Time range (Unix timestamps):**
99
+ ```bash
100
+ $ cakemail logs campaign 789 --start-time 1696118400 --end-time 1696204800
101
+ ```
102
+
103
+ **JSON output (Developer profile):**
104
+ ```bash
105
+ $ cakemail --profile developer logs campaign 789 --filter "type==open"
106
+ ```
107
+
108
+ **Output:**
109
+ ```json
110
+ {
111
+ "data": [
112
+ {
113
+ "contact_id": 456,
114
+ "contact_email": "john@example.com",
115
+ "event_type": "open",
116
+ "timestamp": 1697025333,
117
+ "user_agent": "Mozilla/5.0...",
118
+ "ip_address": "192.168.1.1"
119
+ }
120
+ ],
121
+ "pagination": {
122
+ "page": 1,
123
+ "per_page": 25,
124
+ "total": 342
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Event Types
130
+
131
+ **Delivery Events:**
132
+ - `delivered` - Email successfully delivered
133
+ - `bounce` - Email bounced (hard or soft)
134
+ - `failed` - Delivery failed
135
+
136
+ **Engagement Events:**
137
+ - `open` - Email opened
138
+ - `click` - Link clicked
139
+ - `complaint` - Spam complaint
140
+
141
+ **Unsubscribe Events:**
142
+ - `unsubscribe` - Contact unsubscribed
143
+
144
+ ---
145
+
146
+ ## logs list
147
+
148
+ View activity logs for a specific list.
149
+
150
+ ### Usage
151
+
152
+ ```bash
153
+ cakemail logs list [list-id] [options]
154
+ ```
155
+
156
+ ### Arguments
157
+
158
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
159
+
160
+ ### Options
161
+
162
+ - `--filter <filter>` - Filter logs (e.g., `type==subscribe`, `contact_id==123`)
163
+ - `--sort <sort>` - Sort order (e.g., `+time`, `-contact_id`)
164
+ - `-p, --page <number>` - Page number
165
+ - `--per-page <number>` - Results per page
166
+ - `--start-time <timestamp>` - Start time (Unix timestamp)
167
+ - `--end-time <timestamp>` - End time (Unix timestamp)
168
+
169
+ ### Examples
170
+
171
+ **View list logs (auto-detect):**
172
+ ```bash
173
+ $ cakemail logs list
174
+ ```
175
+
176
+ **Output:**
177
+ ```
178
+ ✓ Auto-detected list: 123 (Newsletter Subscribers)
179
+
180
+ ┌──────────────────────┬──────────────┬─────────────────────┐
181
+ │ Contact Email │ Event Type │ Time │
182
+ ├──────────────────────┼──────────────┼─────────────────────┤
183
+ │ new@example.com │ subscribe │ 2025-10-11 14:23:11 │
184
+ │ old@example.com │ unsubscribe │ 2025-10-11 13:05:42 │
185
+ │ user@example.com │ update │ 2025-10-11 12:15:33 │
186
+ └──────────────────────┴──────────────┴─────────────────────┘
187
+ ```
188
+
189
+ **Filter by subscribe events:**
190
+ ```bash
191
+ $ cakemail logs list --filter "type==subscribe" --sort "-time"
192
+ ```
193
+
194
+ **View specific list:**
195
+ ```bash
196
+ $ cakemail logs list 123 --filter "type==unsubscribe"
197
+ ```
198
+
199
+ **Time range:**
200
+ ```bash
201
+ $ cakemail logs list --start-time 1696118400
202
+ ```
203
+
204
+ ### Event Types
205
+
206
+ **List Events:**
207
+ - `subscribe` - Contact subscribed
208
+ - `unsubscribe` - Contact unsubscribed
209
+ - `update` - Contact information updated
210
+ - `import` - Contact imported from file
211
+ - `delete` - Contact deleted
212
+ - `bounce` - Contact bounced
213
+
214
+ ---
215
+
216
+ ## logs campaign-export
217
+
218
+ Create a CSV export of campaign activity logs.
219
+
220
+ ### Usage
221
+
222
+ ```bash
223
+ cakemail logs campaign-export <campaign-id> [options]
224
+ ```
225
+
226
+ ### Arguments
227
+
228
+ - `<campaign-id>` - Campaign ID (required)
229
+
230
+ ### Options
231
+
232
+ - `--description <text>` - Export description (optional)
233
+ - `--filter <filter>` - Filter logs to export
234
+ - `--start-time <timestamp>` - Start time
235
+ - `--end-time <timestamp>` - End time
236
+
237
+ ### Examples
238
+
239
+ **Create export:**
240
+ ```bash
241
+ $ cakemail logs campaign-export 789 --description "Q4 Analytics"
242
+ ```
243
+
244
+ **Output:**
245
+ ```
246
+ ✓ Export created successfully
247
+
248
+ Export ID: abc-123-def
249
+ Status: processing
250
+ Description: Q4 Analytics
251
+
252
+ To download:
253
+ cakemail logs campaign-export-download 789 abc-123-def
254
+ ```
255
+
256
+ **Export with filters:**
257
+ ```bash
258
+ $ cakemail logs campaign-export 789 \
259
+ --filter "type==open" \
260
+ --description "Opens Only"
261
+ ```
262
+
263
+ **Export time range:**
264
+ ```bash
265
+ $ cakemail logs campaign-export 789 \
266
+ --start-time 1696118400 \
267
+ --end-time 1696204800 \
268
+ --description "Week of Oct 1"
269
+ ```
270
+
271
+ **JSON output:**
272
+ ```bash
273
+ $ cakemail -f json logs campaign-export 789
274
+ ```
275
+
276
+ **Output:**
277
+ ```json
278
+ {
279
+ "export_id": "abc-123-def",
280
+ "campaign_id": 789,
281
+ "status": "processing",
282
+ "description": "Q4 Analytics",
283
+ "created_on": "2025-10-11T15:30:00Z"
284
+ }
285
+ ```
286
+
287
+ ### Export Status
288
+
289
+ Exports are processed asynchronously:
290
+ - `processing` - Export is being generated
291
+ - `completed` - Export ready for download
292
+ - `failed` - Export failed (check error message)
293
+
294
+ Check status with `logs campaign-export-download` command.
295
+
296
+ ---
297
+
298
+ ## logs campaign-export-download
299
+
300
+ Get download URL for a campaign log export.
301
+
302
+ ### Usage
303
+
304
+ ```bash
305
+ cakemail logs campaign-export-download <campaign-id> <export-id>
306
+ ```
307
+
308
+ ### Arguments
309
+
310
+ - `<campaign-id>` - Campaign ID (required)
311
+ - `<export-id>` - Export ID from campaign-export command (required)
312
+
313
+ ### Examples
314
+
315
+ **Get download URL:**
316
+ ```bash
317
+ $ cakemail logs campaign-export-download 789 abc-123-def
318
+ ```
319
+
320
+ **Output (if completed):**
321
+ ```
322
+ ✓ Export ready for download
323
+
324
+ Export: Q4 Analytics
325
+ Status: completed
326
+ Created: 2025-10-11 15:30:00
327
+ Size: 2.4 MB
328
+ Rows: 12,345
329
+
330
+ Download URL:
331
+ https://exports.cakemail.com/logs/789/abc-123-def.csv?expires=1697040000
332
+
333
+ 💡 URL expires in 24 hours
334
+ ```
335
+
336
+ **Output (if still processing):**
337
+ ```
338
+ ⏳ Export still processing
339
+
340
+ Export: Q4 Analytics
341
+ Status: processing
342
+ Progress: 67%
343
+ Estimated time: 2 minutes
344
+
345
+ Try again in a few minutes.
346
+ ```
347
+
348
+ **JSON output:**
349
+ ```bash
350
+ $ cakemail -f json logs campaign-export-download 789 abc-123-def
351
+ ```
352
+
353
+ **Output:**
354
+ ```json
355
+ {
356
+ "export_id": "abc-123-def",
357
+ "status": "completed",
358
+ "download_url": "https://exports.cakemail.com/logs/789/abc-123-def.csv?expires=1697040000",
359
+ "size_bytes": 2516582,
360
+ "row_count": 12345,
361
+ "expires_at": "2025-10-12T15:30:00Z"
362
+ }
363
+ ```
364
+
365
+ ### Downloading the File
366
+
367
+ **Using curl:**
368
+ ```bash
369
+ # Get URL first
370
+ URL=$(cakemail -f json logs campaign-export-download 789 abc-123-def | jq -r '.download_url')
371
+
372
+ # Download
373
+ curl -o campaign-789-logs.csv "$URL"
374
+ ```
375
+
376
+ **Using wget:**
377
+ ```bash
378
+ wget -O campaign-789-logs.csv "https://exports.cakemail.com/..."
379
+ ```
380
+
381
+ ---
382
+
383
+ ## logs list-export
384
+
385
+ Create a CSV export of list activity logs.
386
+
387
+ ### Usage
388
+
389
+ ```bash
390
+ cakemail logs list-export [list-id] [options]
391
+ ```
392
+
393
+ ### Arguments
394
+
395
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
396
+
397
+ ### Options
398
+
399
+ - `--description <text>` - Export description (optional)
400
+ - `--filter <filter>` - Filter logs to export
401
+ - `--start-time <timestamp>` - Start time
402
+ - `--end-time <timestamp>` - End time
403
+
404
+ ### Examples
405
+
406
+ **Create export (auto-detect list):**
407
+ ```bash
408
+ $ cakemail logs list-export --description "Monthly Activity Report"
409
+ ```
410
+
411
+ **Output:**
412
+ ```
413
+ ✓ Auto-detected list: 123 (Newsletter Subscribers)
414
+ ✓ Export created successfully
415
+
416
+ Export ID: xyz-456-abc
417
+ Status: processing
418
+ Description: Monthly Activity Report
419
+
420
+ To download:
421
+ cakemail logs list-export-download xyz-456-abc
422
+ ```
423
+
424
+ **Export with filters:**
425
+ ```bash
426
+ $ cakemail logs list-export 123 \
427
+ --filter "type==subscribe" \
428
+ --description "New Subscribers"
429
+ ```
430
+
431
+ **Export time range:**
432
+ ```bash
433
+ $ cakemail logs list-export \
434
+ --start-time 1696118400 \
435
+ --description "October Subscriptions"
436
+ ```
437
+
438
+ ---
439
+
440
+ ## logs list-export-download
441
+
442
+ Get download URL for a list log export.
443
+
444
+ ### Usage
445
+
446
+ ```bash
447
+ cakemail logs list-export-download [list-id] <export-id>
448
+ ```
449
+
450
+ ### Arguments
451
+
452
+ - `[list-id]` - List ID (optional - auto-detects if only one list exists)
453
+ - `<export-id>` - Export ID from list-export command (required)
454
+
455
+ ### Examples
456
+
457
+ **Get download URL (auto-detect list):**
458
+ ```bash
459
+ $ cakemail logs list-export-download xyz-456-abc
460
+ ```
461
+
462
+ **Output:**
463
+ ```
464
+ ✓ Auto-detected list: 123 (Newsletter Subscribers)
465
+ ✓ Export ready for download
466
+
467
+ Export: Monthly Activity Report
468
+ Status: completed
469
+ Rows: 5,678
470
+
471
+ Download URL:
472
+ https://exports.cakemail.com/logs/lists/123/xyz-456-abc.csv?expires=1697040000
473
+ ```
474
+
475
+ **Specific list:**
476
+ ```bash
477
+ $ cakemail logs list-export-download 123 xyz-456-abc
478
+ ```
479
+
480
+ ---
481
+
482
+ ## Common Workflows
483
+
484
+ ### Workflow 1: Campaign Performance Analysis
485
+
486
+ ```bash
487
+ # View opens
488
+ cakemail logs campaign 789 --filter "type==open" --sort "-time"
489
+
490
+ # View clicks
491
+ cakemail logs campaign 789 --filter "type==click"
492
+
493
+ # Export for detailed analysis
494
+ cakemail logs campaign-export 789 --description "Campaign Performance"
495
+
496
+ # Download when ready
497
+ cakemail logs campaign-export-download 789 export-id
498
+ ```
499
+
500
+ ---
501
+
502
+ ### Workflow 2: Identify Inactive Contacts
503
+
504
+ ```bash
505
+ # Export campaign logs
506
+ cakemail logs campaign-export 789 --filter "type==open"
507
+
508
+ # Compare with contact list to find non-openers
509
+ # (Process CSV externally)
510
+ ```
511
+
512
+ ---
513
+
514
+ ### Workflow 3: List Growth Tracking
515
+
516
+ ```bash
517
+ # View recent subscriptions
518
+ cakemail logs list --filter "type==subscribe" --sort "-time"
519
+
520
+ # View unsubscribes
521
+ cakemail logs list --filter "type==unsubscribe" --sort "-time"
522
+
523
+ # Export monthly report
524
+ cakemail logs list-export \
525
+ --start-time 1696118400 \
526
+ --end-time 1698796800 \
527
+ --description "October List Activity"
528
+ ```
529
+
530
+ ---
531
+
532
+ ### Workflow 4: Bounce Analysis
533
+
534
+ ```bash
535
+ # View all bounces for campaign
536
+ cakemail logs campaign 789 --filter "type==bounce"
537
+
538
+ # Export bounces for cleanup
539
+ cakemail logs campaign-export 789 \
540
+ --filter "type==bounce" \
541
+ --description "Bounced Emails"
542
+
543
+ # Download and process
544
+ cakemail logs campaign-export-download 789 export-id
545
+ ```
546
+
547
+ ---
548
+
549
+ ## Best Practices
550
+
551
+ ### 1. Use Filters for Large Datasets
552
+
553
+ ```bash
554
+ # Good - filter first
555
+ cakemail logs campaign 789 --filter "type==open" --per-page 100
556
+
557
+ # Avoid - fetching all logs
558
+ cakemail logs campaign 789 # May be too large
559
+ ```
560
+
561
+ ### 2. Export for Complex Analysis
562
+
563
+ Don't try to analyze large datasets through the CLI - export to CSV:
564
+
565
+ ```bash
566
+ # Create export
567
+ cakemail logs campaign-export 789 --description "Full Analysis"
568
+
569
+ # Download
570
+ cakemail logs campaign-export-download 789 export-id
571
+
572
+ # Analyze in Excel, Python, R, etc.
573
+ ```
574
+
575
+ ### 3. Set Reasonable Time Ranges
576
+
577
+ ```bash
578
+ # Last 7 days
579
+ START=$(date -u -d '7 days ago' +%s)
580
+ cakemail logs list --start-time $START
581
+ ```
582
+
583
+ ### 4. Use JSON for Automation
584
+
585
+ ```bash
586
+ # Get opens count
587
+ cakemail -f json logs campaign 789 --filter "type==open" \
588
+ | jq '.pagination.total'
589
+
590
+ # Check export status
591
+ cakemail -f json logs campaign-export-download 789 abc-123 \
592
+ | jq '.status'
593
+ ```
594
+
595
+ ---
596
+
597
+ ## CSV Export Format
598
+
599
+ ### Campaign Logs CSV
600
+
601
+ ```csv
602
+ contact_id,contact_email,event_type,timestamp,details,ip_address,user_agent
603
+ 456,john@example.com,open,1697025333,,192.168.1.1,Mozilla/5.0...
604
+ 456,john@example.com,click,1697025398,Link #1,192.168.1.1,Mozilla/5.0...
605
+ 789,jane@example.com,delivered,1697025120,,,,
606
+ ```
607
+
608
+ ### List Logs CSV
609
+
610
+ ```csv
611
+ contact_id,contact_email,event_type,timestamp,details
612
+ 123,new@example.com,subscribe,1697025333,Web form
613
+ 456,old@example.com,unsubscribe,1697025120,Email link
614
+ 789,user@example.com,update,1697025090,Changed email
615
+ ```
616
+
617
+ ---
618
+
619
+ ## Troubleshooting
620
+
621
+ ### Export Takes Too Long
622
+
623
+ **Problem:** Export stuck in "processing"
624
+
625
+ **Solutions:**
626
+ 1. Large campaigns take time (10k+ logs = several minutes)
627
+ 2. Check status periodically: `logs campaign-export-download ...`
628
+ 3. Use filters to reduce export size
629
+ 4. Contact support if >30 minutes
630
+
631
+ ---
632
+
633
+ ### Export Failed
634
+
635
+ **Problem:** Export status is "failed"
636
+
637
+ **Solutions:**
638
+ 1. Check error message in output
639
+ 2. Try smaller time range
640
+ 3. Reduce filters complexity
641
+ 4. Retry export creation
642
+
643
+ ---
644
+
645
+ ### No Logs Returned
646
+
647
+ **Problem:** Empty result set
648
+
649
+ **Solutions:**
650
+ 1. Check campaign has been sent: `cakemail campaigns get 789`
651
+ 2. Verify time range includes activity
652
+ 3. Remove filters to see all logs
653
+ 4. Check you're using correct campaign/list ID
654
+
655
+ ---
656
+