Skip to content

Commit ff7ef49

Browse files
committed
test mode logging support
1 parent e075101 commit ff7ef49

9 files changed

+93
-56
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
**v0.1.0-alpha.4:**
4+
- `README.md`: notice about test mode
5+
- Support for test mode logging
6+
- npm updates
7+
38
**v0.1.0-alpha.3:**
49
- `README.md` cleanup (listing of components)
510
- `Image` component now requires only `src`; the other params are optional

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ There are more examples in the [examples](examples) folder ✨
9595
> [!NOTE]
9696
> 🚧 **The SDK is not stable yet.** This API might change as more features are added. Please watch the repo for the changes in the [CHANGELOG](CHANGELOG.md).
9797
98+
## 🏗 Debugging
99+
100+
You can generate _test API keys_ by activating the **Test Mode** in your dashboard. By using these keys, you'll be able to view your fully rendered emails without actually sending them.
101+
102+
When you use a test API key in your SDK, the following output will appear in your logs when you try to send an email:
103+
104+
```log
105+
Templateless [TEST MODE]: Emailed [email protected], preview: https://tmpl.sh/ATMxHLX4r9aE
106+
```
107+
108+
The preview link will display the email, but you must be logged in to Templateless to view it.
109+
98110
## 🔳 Components
99111

100112
Emails are crafted programmatically by making function calls. There's no dealing with HTML or drag-and-drop builders.
@@ -246,7 +258,7 @@ If you'd like your recipients to be able to read the email in a browser, you can
246258

247259
You can optionally provide the text for the link. If none is provided, default is used: "View in browser"
248260

249-
**This will make the email public to anyone that has access to the link.**
261+
**Anyone who knows the link will be able to see the email.**
250262

251263
```javascript
252264
Content.builder()

dist/bundle.cjs.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.esm.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.umd.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/templateless.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Email, ObjectId } from '.';
2+
export interface EmailResponsePreviews {
3+
email: string;
4+
preview: string;
5+
}
26
export interface EmailResponse {
37
emails: ObjectId[];
8+
previews?: EmailResponsePreviews[];
49
}
510
export declare class Templateless {
611
private _apiKey;

package-lock.json

+46-46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "templateless-js",
3-
"version": "0.1.0-alpha.3",
3+
"version": "0.1.0-alpha.4",
44
"description": "Ship faster by sending elegant emails using just code",
55
"author": "",
66
"keywords": [
@@ -51,8 +51,8 @@
5151
"@rollup/plugin-terser": "0.4.4",
5252
"@rollup/plugin-typescript": "11.1.6",
5353
"@types/jest": "29.5.12",
54-
"@typescript-eslint/eslint-plugin": "7.1.0",
55-
"@typescript-eslint/parser": "7.1.0",
54+
"@typescript-eslint/eslint-plugin": "7.1.1",
55+
"@typescript-eslint/parser": "7.1.1",
5656
"eslint": "8.57.0",
5757
"eslint-config-prettier": "9.1.0",
5858
"eslint-plugin-prettier": "5.1.3",

src/templateless.ts

+15
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ import {
1212
UnknownError,
1313
} from '.'
1414

15+
export interface EmailResponsePreviews {
16+
email: string
17+
preview: string
18+
}
19+
1520
export interface EmailResponse {
1621
emails: ObjectId[]
22+
previews?: EmailResponsePreviews[]
1723
}
1824

1925
export class Templateless {
@@ -62,6 +68,15 @@ export class Templateless {
6268
throw new UnavailableError()
6369
case 200:
6470
const emailResponse = response.data as EmailResponse
71+
72+
if (emailResponse.previews) {
73+
for (const preview of emailResponse.previews) {
74+
console.log(
75+
`Templateless [TEST MODE]: Emailed ${preview.email}, preview: https://tmpl.sh/${preview.preview}`,
76+
)
77+
}
78+
}
79+
6580
return emailResponse.emails
6681
default:
6782
throw new UnknownError()

0 commit comments

Comments
 (0)