@getvitops/utils 8.2.0-alpha.0 → 8.3.0-alpha.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 (115) hide show
  1. package/CHANGELOG.md +399 -23
  2. package/dist/{adc-D6aw2qgq.mjs → adc-BiW9BzqA.mjs} +2 -3
  3. package/dist/{adc-D6aw2qgq.mjs.map → adc-BiW9BzqA.mjs.map} +1 -1
  4. package/dist/{adc-BoEoogyo.d.mts → adc-DvX3-P7a.d.mts} +2 -4
  5. package/dist/adc-DvX3-P7a.d.mts.map +1 -0
  6. package/dist/ads/index.d.mts +37 -57
  7. package/dist/ads/index.d.mts.map +1 -1
  8. package/dist/ads/index.mjs +21 -10
  9. package/dist/ads/index.mjs.map +1 -1
  10. package/dist/audit/index.d.mts +180 -0
  11. package/dist/audit/index.d.mts.map +1 -0
  12. package/dist/audit/index.mjs +509 -0
  13. package/dist/audit/index.mjs.map +1 -0
  14. package/dist/color/index.d.mts +7 -5
  15. package/dist/color/index.d.mts.map +1 -1
  16. package/dist/color/index.mjs +10 -5
  17. package/dist/color/index.mjs.map +1 -1
  18. package/dist/content.d.mts +78 -0
  19. package/dist/content.d.mts.map +1 -0
  20. package/dist/content.mjs +45 -0
  21. package/dist/content.mjs.map +1 -0
  22. package/dist/crm/index.d.mts +5 -87
  23. package/dist/crm/index.d.mts.map +1 -1
  24. package/dist/crm/index.mjs +10 -19
  25. package/dist/crm/index.mjs.map +1 -1
  26. package/dist/email/index.d.mts +1 -11
  27. package/dist/email/index.d.mts.map +1 -1
  28. package/dist/email/index.mjs +6 -10
  29. package/dist/email/index.mjs.map +1 -1
  30. package/dist/favicon.d.mts +0 -2
  31. package/dist/favicon.d.mts.map +1 -1
  32. package/dist/favicon.mjs +1 -2
  33. package/dist/git/index.d.mts +0 -2
  34. package/dist/git/index.d.mts.map +1 -1
  35. package/dist/git/index.mjs +1 -2
  36. package/dist/hosting/index.d.mts +0 -8
  37. package/dist/hosting/index.d.mts.map +1 -1
  38. package/dist/hosting/index.mjs +4 -7
  39. package/dist/hosting/index.mjs.map +1 -1
  40. package/dist/{identity-BoRddTx3.mjs → identity-C4yInICW.mjs} +2 -3
  41. package/dist/{identity-BoRddTx3.mjs.map → identity-C4yInICW.mjs.map} +1 -1
  42. package/dist/index.d.mts +2 -88
  43. package/dist/index.d.mts.map +1 -1
  44. package/dist/index.mjs +36 -52
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/indexing/index.d.mts +3 -42
  47. package/dist/indexing/index.d.mts.map +1 -1
  48. package/dist/indexing/index.mjs +8 -13
  49. package/dist/indexing/index.mjs.map +1 -1
  50. package/dist/{json-store-30CFCbZZ.mjs → json-store-VJKEaoVX.mjs} +2 -3
  51. package/dist/{json-store-30CFCbZZ.mjs.map → json-store-VJKEaoVX.mjs.map} +1 -1
  52. package/dist/media/index.d.mts +0 -12
  53. package/dist/media/index.d.mts.map +1 -1
  54. package/dist/media/index.mjs +7 -13
  55. package/dist/media/index.mjs.map +1 -1
  56. package/dist/notify/index.d.mts +64 -44
  57. package/dist/notify/index.d.mts.map +1 -1
  58. package/dist/notify/index.mjs +138 -11
  59. package/dist/notify/index.mjs.map +1 -1
  60. package/dist/onboarding/index.d.mts +26 -6
  61. package/dist/onboarding/index.d.mts.map +1 -1
  62. package/dist/onboarding/index.mjs +92 -5
  63. package/dist/onboarding/index.mjs.map +1 -1
  64. package/dist/{plan-BLKikoOG.mjs → plan-B9USuc17.mjs} +3 -4
  65. package/dist/{plan-BLKikoOG.mjs.map → plan-B9USuc17.mjs.map} +1 -1
  66. package/dist/{plan-Hq8Pb0Uw.d.mts → plan-CH3Wt5ZV.d.mts} +8 -30
  67. package/dist/plan-CH3Wt5ZV.d.mts.map +1 -0
  68. package/dist/plan-CddqsmJJ.d.mts +82 -0
  69. package/dist/plan-CddqsmJJ.d.mts.map +1 -0
  70. package/dist/plan-DpHv6NO8.mjs +93 -0
  71. package/dist/plan-DpHv6NO8.mjs.map +1 -0
  72. package/dist/{plan-format-A18SvJ7C.mjs → plan-format-CIz6Feg2.mjs} +2 -3
  73. package/dist/{plan-format-A18SvJ7C.mjs.map → plan-format-CIz6Feg2.mjs.map} +1 -1
  74. package/dist/{platform-0nlOIy8h.mjs → platform-Cb_RtsF1.mjs} +3 -5
  75. package/dist/{platform-0nlOIy8h.mjs.map → platform-Cb_RtsF1.mjs.map} +1 -1
  76. package/dist/reviews/index.d.mts +4 -120
  77. package/dist/reviews/index.d.mts.map +1 -1
  78. package/dist/reviews/index.mjs +6 -99
  79. package/dist/reviews/index.mjs.map +1 -1
  80. package/dist/reviews/select.d.mts +2 -0
  81. package/dist/reviews/select.mjs +3 -0
  82. package/dist/schema/index.d.mts +0 -12
  83. package/dist/schema/index.d.mts.map +1 -1
  84. package/dist/schema/index.mjs +6 -12
  85. package/dist/schema/index.mjs.map +1 -1
  86. package/dist/security/index.d.mts +0 -2
  87. package/dist/security/index.d.mts.map +1 -1
  88. package/dist/security/index.mjs +1 -2
  89. package/dist/{token-DmmoQ7um.d.mts → token-CHR1O4w5.d.mts} +3 -3
  90. package/dist/token-CHR1O4w5.d.mts.map +1 -0
  91. package/dist/{token-DkKC5m23.mjs → token-CJSl9eIS.mjs} +33 -14
  92. package/dist/token-CJSl9eIS.mjs.map +1 -0
  93. package/dist/tracking/index.d.mts +1 -9
  94. package/dist/tracking/index.d.mts.map +1 -1
  95. package/dist/tracking/index.mjs +3 -4
  96. package/dist/turnstile/index.d.mts +105 -0
  97. package/dist/turnstile/index.d.mts.map +1 -0
  98. package/dist/turnstile/index.mjs +281 -0
  99. package/dist/turnstile/index.mjs.map +1 -0
  100. package/dist/{types-7ELci8RQ.d.mts → types-oac2P5or.d.mts} +3 -23
  101. package/dist/types-oac2P5or.d.mts.map +1 -0
  102. package/dist/url/index.d.mts +18 -0
  103. package/dist/url/index.d.mts.map +1 -0
  104. package/dist/url/index.mjs +34 -0
  105. package/dist/url/index.mjs.map +1 -0
  106. package/package.json +43 -2
  107. package/dist/adc-BoEoogyo.d.mts.map +0 -1
  108. package/dist/cloudflare-BiK61Oq4.d.mts +0 -27
  109. package/dist/cloudflare-BiK61Oq4.d.mts.map +0 -1
  110. package/dist/cloudflare-CD8vwrgj.mjs +0 -92
  111. package/dist/cloudflare-CD8vwrgj.mjs.map +0 -1
  112. package/dist/plan-Hq8Pb0Uw.d.mts.map +0 -1
  113. package/dist/token-DkKC5m23.mjs.map +0 -1
  114. package/dist/token-DmmoQ7um.d.mts.map +0 -1
  115. package/dist/types-7ELci8RQ.d.mts.map +0 -1
@@ -1,5 +1,6 @@
1
- import { t as ConversionEvent } from "../types-7ELci8RQ.mjs";
2
- //#region src/notify/types.d.ts
1
+ import { t as ConversionEvent } from "../types-oac2P5or.mjs";
2
+ import { i as GoogleOAuth } from "../token-CHR1O4w5.mjs";
3
+ import { NotificationsConfig } from "@getvitops/config";
3
4
  /**
4
5
  * The notification module's option surface.
5
6
  *
@@ -19,38 +20,7 @@ interface RenderedMessage {
19
20
  text: string;
20
21
  html: string;
21
22
  }
22
- /**
23
- * Cloudflare Email Sending — the only provider implemented this pass.
24
- *
25
- * A `z.literal` on the schema side rather than an enum with one member, so
26
- * widening it later is additive.
27
- */
28
- interface EmailChannelConfig {
29
- provider: 'cloudflare';
30
- /** Falls back to the location cascade — see `resolveRecipient`. */
31
- to?: string | undefined;
32
- /** Falls back to `noreply@<canonical>`. */
33
- from?: string | undefined;
34
- /** Display name on the From header. Defaults to the organization name. */
35
- fromName?: string | undefined;
36
- replyTo?: string | undefined;
37
- /**
38
- * Workers binding name (default `EMAIL`). Configurable because a consumer may
39
- * use a restricted binding with `allowed_sender_addresses`.
40
- */
41
- binding?: string | undefined;
42
- }
43
- interface NotificationsConfig {
44
- /** A bare address is shorthand for `{ provider: 'cloudflare', to }`. */
45
- email?: string | EmailChannelConfig | undefined;
46
- /**
47
- * Optional action-link template added to the conversion email as an
48
- * "Actions" section — `{clickId}` is replaced with the ad click ID captured
49
- * on `_ac` (gclid, fbclid, …). Omitted from the email when the event carries
50
- * no click ID, rather than rendering a broken link — see `renderEmail`.
51
- */
52
- actionUrl?: string | undefined;
53
- }
23
+ type EmailChannelConfig = Exclude<NonNullable<NotificationsConfig['email']>, string>;
54
24
  /** Everything `planNotifications` needs. Assembled by the caller from the config. */
55
25
  interface NotifyContext {
56
26
  notifications?: NotificationsConfig | undefined;
@@ -112,8 +82,6 @@ interface EmailBinding {
112
82
  replyTo?: string;
113
83
  }): Promise<unknown>;
114
84
  }
115
- //#endregion
116
- //#region src/notify/plan.d.ts
117
85
  /** Default Workers binding name for Cloudflare Email Sending. */
118
86
  export declare const DEFAULT_EMAIL_BINDING = "EMAIL";
119
87
  /** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */
@@ -141,8 +109,6 @@ export declare function resolveSender(channel: EmailChannelConfig, ctx: NotifyCo
141
109
  * report the misconfiguration instead of reporting success over a no-op.
142
110
  */
143
111
  export declare function planNotifications(ctx: NotifyContext): NotificationPlan;
144
- //#endregion
145
- //#region src/notify/render.d.ts
146
112
  /** One section: a heading and its lines. Empty sections are dropped by the caller. */
147
113
  interface Section {
148
114
  heading: string;
@@ -163,8 +129,6 @@ export declare function renderEmail(event: ConversionEvent, extra?: {
163
129
  notes?: string[] | undefined;
164
130
  actionUrl?: string | undefined;
165
131
  }): RenderedMessage;
166
- //#endregion
167
- //#region src/notify/email.d.ts
168
132
  interface SendEmailOptions {
169
133
  /** Attempts for a retryable failure (default 3). */
170
134
  attempts?: number;
@@ -201,8 +165,65 @@ export declare function sendEmail(plan: EmailPlan, message: RenderedMessage, bin
201
165
  * integration and a working one nobody could observe.
202
166
  */
203
167
  export declare function logEmail(plan: EmailPlan, message: RenderedMessage, log?: (line: string) => void): ChannelResult;
204
- //#endregion
205
- //#region src/notify/index.d.ts
168
+ interface GoogleAdsCredentials {
169
+ /** Issued against a Google Ads manager (MCC) account — a Google review, not
170
+ * a self-service toggle. Never config. */
171
+ developerToken: string;
172
+ oauth: GoogleOAuth;
173
+ /** The MCC's own (dashes-or-not) customer id — required when `customerId`
174
+ * in the upload input is a client account managed under it, which is the
175
+ * common case for an agency running this on a client's behalf. */
176
+ loginCustomerId?: string | undefined;
177
+ }
178
+ interface GoogleAdsUploadInput {
179
+ /** Google Ads customer id, as shown in the UI (`"123-456-7890"`) or bare
180
+ * digits — either works, dashes are stripped before the call. */
181
+ customerId: string;
182
+ /** A numeric conversion action id, or a full
183
+ * `customers/…/conversionActions/…` resource name. */
184
+ conversionActionId: string;
185
+ /** The click id captured on `_ac` — `getPrimaryClickId()`'s result. */
186
+ clickId: {
187
+ param: string;
188
+ value: string;
189
+ };
190
+ /** Epoch ms — converted to the Ads API's own
191
+ * `"yyyy-MM-dd HH:mm:ss+00:00"` format. */
192
+ at: number;
193
+ conversionValue?: number | undefined;
194
+ currencyCode?: string | undefined;
195
+ orderId?: string | undefined;
196
+ }
197
+ /** Never thrown — an Ads API outage or a malformed request both come back as
198
+ * `ok: false`, the same "structured result, not an exception" rule every
199
+ * other executor in this toolchain follows. */
200
+ interface GoogleAdsUploadResult {
201
+ ok: boolean;
202
+ reason?: string | undefined;
203
+ code?: string | undefined;
204
+ }
205
+ /** A bare numeric id becomes a full resource name under `customerId`; a value
206
+ * already shaped like one (the escape hatch, matching `txtRecord`'s `=`
207
+ * check in `@getvitops/utils/ads`) passes through unchanged. */
208
+ export declare function conversionActionResourceName(customerId: string, conversionActionId: string): string;
209
+ /** The Ads API's documented click-conversion datetime format, always
210
+ * rendered in UTC — there is no per-account timezone lookup here to do
211
+ * better, and UTC is unambiguous. */
212
+ export declare function toGoogleConversionDateTime(atMs: number): string;
213
+ /**
214
+ * Upload one click conversion via `ConversionUploadService.UploadClickConversions`.
215
+ *
216
+ * `partialFailure: true` is always sent, and a 200 response carrying
217
+ * `partialFailureError` is treated as a failure, not a success — a single-
218
+ * conversion batch makes "partial" and "total" failure the same case, and
219
+ * Google Ads API responses are 200 for a partial failure by design (silently
220
+ * treating that as success is exactly the trap `@getvitops/utils/crm`'s
221
+ * Jobber executor documents for its own GraphQL transport).
222
+ */
223
+ export declare function uploadClickConversion(input: GoogleAdsUploadInput, credentials: GoogleAdsCredentials, fetchImpl?: typeof fetch): Promise<GoogleAdsUploadResult>;
224
+ /** A one-line delivery note, matching `describeCrmResult`'s shape — what
225
+ * `conversion.ts` folds into the notification email's "Delivery" section. */
226
+ export declare function describeGoogleAdsOfflineResult(result: GoogleAdsUploadResult | null): string | null;
206
227
  export interface NotifyDeps {
207
228
  /**
208
229
  * The Workers `send_email` binding (`env.EMAIL`). Omit it and the notification
@@ -225,6 +246,5 @@ export interface NotifyResult {
225
246
  export declare function notify(event: ConversionEvent, ctx: NotifyContext, deps?: NotifyDeps, extra?: {
226
247
  notes?: string[] | undefined;
227
248
  }): Promise<NotifyResult>;
228
- //#endregion
229
- export type { ChannelPlan, ChannelResult, EmailBinding, EmailChannelConfig, EmailPlan, NotificationPlan, NotificationsConfig, NotifyContext, RenderedMessage };
249
+ export type { ChannelPlan, ChannelResult, EmailBinding, EmailChannelConfig, EmailPlan, GoogleAdsCredentials, GoogleAdsUploadInput, GoogleAdsUploadResult, NotificationPlan, NotificationsConfig, NotifyContext, RenderedMessage };
230
250
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/notify/types.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/email.ts","../../src/notify/index.ts"],"mappings":";;;;;;;;;;;;;;;;UAeiB;EACf;EACA;EACA;;;;;;;;UASe;EACf;;EAEA;;EAEA;;EAEA;EACA;;;;;EAKA;;UAGe;;EAEf,iBAAiB;;;;;;;EAOjB;;;UAOe;EACf,gBAAgB;;EAEhB;;EAEA;;;;;EAKA;;;UAIe;EACf;;EAEA;;UAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;;EAEP;;UAGe;EACf;EACA;;EAEA;;EAEA;;;;;;;;;;UAWe;EACf,KAAK;IACH;IACA;MAAiB;MAAe;;IAChC;IACA;IACA;IACA;MACE;;;;;qBCrGO;;wBAGG,sBACd,gBAAgB,iCACf;;;;;;;;wBAYa,iBACd,SAAS,oBACT,KAAK;;;;;;;;wBAaS,cAAc,SAAS,oBAAoB,KAAK;;;;;;;wBAmBhD,kBAAkB,KAAK,gBAAgB;;;;UC7B7C;EACR;EACA;;;;;;;;wBAyDc,cAAc,OAAO;EAAoB;EAAiB,UAAU;;;wBA4DpE,YACd,OAAO,iBACP;EAAS;EAA8B;IACtC;;;UCxHc;;EAEf;;;;;;;;;;;;;EAaA;;EAEA,SAAS,eAAe;;;;;;;;;;wBA0CJ,UACpB,MAAM,WACN,SAAS,iBACT,SAAS,cACT,UAAS,mBACR,QAAQ;;;;;;;;wBAkDK,SACd,MAAM,WACN,SAAS,iBACT,OAAM,wBACL;;;iBC/Hc;;;;;EAKf,QAAQ;;iBAGO;EACf,SAAS;;EAET;;;;;;;;;wBAUoB,OACpB,OAAO,iBACP,KAAK,eACL,OAAM,YACN;EAAS;IACR,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/notify/types.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/email.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"mappings":";;;;;;;;;;;;;;;;;UAeiB;EACf;EACA;EACA;;KAQU,qBAAqB,QAAQ,YAAY;;UAGpC;EACf,gBAAgB;;EAEhB;;EAEA;;;;;EAKA;;;UAIe;EACf;;EAEA;;UAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,OAAO;;EAEP;;UAGe;EACf;EACA;;EAEA;;EAEA;;;;;;;;;;UAWe;EACf,KAAK;IACH;IACA;MAAiB;MAAe;;IAChC;IACA;IACA;IACA;MACE;;;qBCvEO;;wBAGG,sBACd,gBAAgB,iCACf;;;;;;;;wBAYa,iBACd,SAAS,oBACT,KAAK;;;;;;;;wBAaS,cAAc,SAAS,oBAAoB,KAAK;;;;;;;wBAmBhD,kBAAkB,KAAK,gBAAgB;;UC7B7C;EACR;EACA;;;;;;;;wBAyDc,cAAc,OAAO;EAAoB;EAAiB,UAAU;;;wBA4DpE,YACd,OAAO,iBACP;EAAS;EAA8B;IACtC;UCxHc;;EAEf;;;;;;;;;;;;;EAaA;;EAEA,SAAS,eAAe;;;;;;;;;;wBA0CJ,UACpB,MAAM,WACN,SAAS,iBACT,SAAS,cACT,UAAS,mBACR,QAAQ;;;;;;;;wBAkDK,SACd,MAAM,WACN,SAAS,iBACT,OAAM,wBACL;UC9Hc;;;EAGf;EACA,OAAO;;;;EAIP;;UAGe;;;EAGf;;;EAGA;;EAEA;IAAW;IAAe;;;;EAG1B;EACA;EACA;EACA;;;;;UAMe;EACf;EACA;EACA;;;;;wBAUc,6BACd,oBACA;;;;wBASc,2BAA2B;;;;;;;;;;;wBA4BrB,sBACpB,OAAO,sBACP,aAAa,sBACb,mBAAkB,QACjB,QAAQ;;;wBA6EK,+BACd,QAAQ;iBC9JO;;;;;EAKf,QAAQ;;iBAGO;EACf,SAAS;;EAET;;;;;;;;;wBAUoB,OACpB,OAAO,iBACP,KAAK,eACL,OAAM,YACN;EAAS;IACR,QAAQ"}
@@ -1,7 +1,8 @@
1
- import { t as identifySubmitter } from "../identity-BoRddTx3.mjs";
2
- import { n as identifyPlatform, t as getPrimaryClickId } from "../platform-0nlOIy8h.mjs";
1
+ import { a as googleHeaders, i as googleAccessToken, r as errorDetail } from "../token-CJSl9eIS.mjs";
2
+ import { t as identifySubmitter } from "../identity-C4yInICW.mjs";
3
+ import { n as identifyPlatform, t as getPrimaryClickId } from "../platform-Cb_RtsF1.mjs";
3
4
 
4
- //#region src/notify/email.ts
5
+ // src/notify/email.ts
5
6
  /**
6
7
  * Provider errors worth retrying.
7
8
  *
@@ -120,8 +121,7 @@ function logEmail(plan, message, log = console.log) {
120
121
  };
121
122
  }
122
123
 
123
- //#endregion
124
- //#region src/notify/plan.ts
124
+ // src/notify/plan.ts
125
125
  /** Default Workers binding name for Cloudflare Email Sending. */
126
126
  const DEFAULT_EMAIL_BINDING = "EMAIL";
127
127
  /** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */
@@ -209,8 +209,7 @@ function planEmail(ctx) {
209
209
  };
210
210
  }
211
211
 
212
- //#endregion
213
- //#region src/notify/render.ts
212
+ // src/notify/render.ts
214
213
  /**
215
214
  * Turning a `ConversionEvent` into something a person reads.
216
215
  *
@@ -365,8 +364,137 @@ function renderEmail(event, extra = {}) {
365
364
  };
366
365
  }
367
366
 
368
- //#endregion
369
- //#region src/notify/index.ts
367
+ // src/notify/google-ads.ts
368
+ /**
369
+ * Google Ads offline conversion upload — the server-side counterpart to the
370
+ * client-side `gtag('event', 'conversion', …)` call `gtagBootstrap`
371
+ * (`@getvitops/utils/ads`) wires up. Reads `site.ads.google.reporting: 'server'`
372
+ * and a matching `conversionActionId` (see that field's own docblock for why
373
+ * it is a different identifier from `conversionLabel`, not an alternate
374
+ * spelling of it) and calls `ConversionUploadService.UploadClickConversions`
375
+ * instead of relying on a visitor's browser to fire the tag.
376
+ *
377
+ * Same reasoning as `@getvitops/utils/crm`'s executors: credentials are a
378
+ * structurally-typed shape the consumer's route supplies from env vars, never
379
+ * config, and a failed upload is a `GoogleAdsUploadResult` to log or fold into
380
+ * the notification email — never an exception, and never something that fails
381
+ * the conversion request it's attached to. A lost ad report is not a lost
382
+ * lead; the visitor has already submitted.
383
+ *
384
+ * **Structurally typed against Google's documented REST shape, not verified
385
+ * against a live Ads account** — no developer-token/MCC access exists
386
+ * anywhere in this toolchain's own setup to test against (the same blocker
387
+ * `vitops ads provision` is waiting on). Same caveat, and the same reason, as
388
+ * `@getvitops/utils/crm`'s Jobber executor: wrapped so a wrong guess about the
389
+ * exact request/response shape degrades to a stated failure reason rather
390
+ * than breaking. Re-verify against `googleads.googleapis.com`'s current API
391
+ * version and `ClickConversion` message shape before depending on this in
392
+ * production, and update this docblock with what was found.
393
+ */
394
+ /** Bumped independently of everything else here — the Ads API deprecates
395
+ * versions on its own rolling schedule. Last checked against Google's public
396
+ * docs at the time this file was written; not re-verified since. */
397
+ const API_VERSION = "v17";
398
+ function digitsOnly(id) {
399
+ return id.replace(/\D/g, "");
400
+ }
401
+ /** A bare numeric id becomes a full resource name under `customerId`; a value
402
+ * already shaped like one (the escape hatch, matching `txtRecord`'s `=`
403
+ * check in `@getvitops/utils/ads`) passes through unchanged. */
404
+ function conversionActionResourceName(customerId, conversionActionId) {
405
+ if (conversionActionId.includes("customers/")) return conversionActionId;
406
+ return `customers/${digitsOnly(customerId)}/conversionActions/${conversionActionId}`;
407
+ }
408
+ /** The Ads API's documented click-conversion datetime format, always
409
+ * rendered in UTC — there is no per-account timezone lookup here to do
410
+ * better, and UTC is unambiguous. */
411
+ function toGoogleConversionDateTime(atMs) {
412
+ const d = new Date(atMs);
413
+ const pad = (n) => String(n).padStart(2, "0");
414
+ return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`;
415
+ }
416
+ /** The request field a click id param maps to — the API takes `gclid`/
417
+ * `gbraid`/`wbraid` as distinct fields, not one generic "click id" field.
418
+ * Anything else this toolchain's `PLATFORM_PARAMS` maps to Google (today,
419
+ * only these three) falls back to `gclid`. */
420
+ function clickIdField(param) {
421
+ if (param === "gbraid" || param === "wbraid") return param;
422
+ return "gclid";
423
+ }
424
+ /**
425
+ * Upload one click conversion via `ConversionUploadService.UploadClickConversions`.
426
+ *
427
+ * `partialFailure: true` is always sent, and a 200 response carrying
428
+ * `partialFailureError` is treated as a failure, not a success — a single-
429
+ * conversion batch makes "partial" and "total" failure the same case, and
430
+ * Google Ads API responses are 200 for a partial failure by design (silently
431
+ * treating that as success is exactly the trap `@getvitops/utils/crm`'s
432
+ * Jobber executor documents for its own GraphQL transport).
433
+ */
434
+ async function uploadClickConversion(input, credentials, fetchImpl = fetch) {
435
+ let token;
436
+ try {
437
+ token = await googleAccessToken({
438
+ kind: "oauth",
439
+ oauth: credentials.oauth
440
+ }, fetchImpl);
441
+ } catch (err) {
442
+ return {
443
+ ok: false,
444
+ reason: `Google Ads token exchange failed: ${err instanceof Error ? err.message : String(err)}`
445
+ };
446
+ }
447
+ const customerId = digitsOnly(input.customerId);
448
+ const url = `https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}:uploadClickConversions`;
449
+ const body = {
450
+ conversions: [{
451
+ conversionAction: conversionActionResourceName(customerId, input.conversionActionId),
452
+ [clickIdField(input.clickId.param)]: input.clickId.value,
453
+ conversionDateTime: toGoogleConversionDateTime(input.at),
454
+ ...input.conversionValue != null ? { conversionValue: input.conversionValue } : {},
455
+ ...input.currencyCode ? { currencyCode: input.currencyCode } : {},
456
+ ...input.orderId ? { orderId: input.orderId } : {}
457
+ }],
458
+ partialFailure: true
459
+ };
460
+ let res;
461
+ try {
462
+ res = await fetchImpl(url, {
463
+ method: "POST",
464
+ headers: googleHeaders(token, {
465
+ "developer-token": credentials.developerToken,
466
+ "content-type": "application/json",
467
+ ...credentials.loginCustomerId ? { "login-customer-id": digitsOnly(credentials.loginCustomerId) } : {}
468
+ }),
469
+ body: JSON.stringify(body)
470
+ });
471
+ } catch (err) {
472
+ return {
473
+ ok: false,
474
+ reason: `Google Ads request failed: ${err instanceof Error ? err.message : String(err)}`
475
+ };
476
+ }
477
+ if (!res.ok) return {
478
+ ok: false,
479
+ code: String(res.status),
480
+ reason: await errorDetail(res, (status) => status === 401 ? "Google Ads rejected the access token." : status === 403 ? "Google Ads refused the request — check the developer token is approved and `login-customer-id` is set for an MCC-managed account." : void 0)
481
+ };
482
+ const json = await res.json().catch(() => ({}));
483
+ if (json.partialFailureError) return {
484
+ ok: false,
485
+ reason: `Google Ads rejected the conversion: ${json.partialFailureError.message ?? "no detail given"}`
486
+ };
487
+ return { ok: true };
488
+ }
489
+ /** A one-line delivery note, matching `describeCrmResult`'s shape — what
490
+ * `conversion.ts` folds into the notification email's "Delivery" section. */
491
+ function describeGoogleAdsOfflineResult(result) {
492
+ if (!result) return null;
493
+ if (result.ok) return "Reported to Google Ads (server-side)";
494
+ return `⚠ Not reported to Google Ads: ${result.reason ?? "unknown reason"}`;
495
+ }
496
+
497
+ // src/notify/index.ts
370
498
  /**
371
499
  * Notify every configured channel about a conversion.
372
500
  *
@@ -394,6 +522,5 @@ async function notify(event, ctx, deps = {}, extra = {}) {
394
522
  };
395
523
  }
396
524
 
397
- //#endregion
398
- export { DEFAULT_EMAIL_BINDING, describeEvent, logEmail, normalizeEmailChannel, notify, planNotifications, renderEmail, resolveRecipient, resolveSender, sendEmail };
525
+ export { DEFAULT_EMAIL_BINDING, conversionActionResourceName, describeEvent, describeGoogleAdsOfflineResult, logEmail, normalizeEmailChannel, notify, planNotifications, renderEmail, resolveRecipient, resolveSender, sendEmail, toGoogleConversionDateTime, uploadClickConversion };
399
526
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/notify/email.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/index.ts"],"sourcesContent":["/**\n * The e-mail channel — Cloudflare Email Sending.\n *\n * I/O only: it executes an `EmailPlan` and decides nothing. Whether to send, to\n * whom, and from where were all settled in `plan.ts`.\n *\n * **The binding is passed in, never imported.** `@getvitops/utils` does not depend\n * on `cloudflare:workers`, so this module runs in Node and in a test with a stub,\n * and the Astro package gains no Cloudflare coupling. The consumer's route hands\n * over `env.EMAIL`.\n *\n * Uses the current Email Sending binding — a structured `send({ to, from,\n * subject, html, text })` — not the legacy `EmailMessage` + hand-built MIME path.\n * The domain in `from` must have been onboarded (`wrangler email sending enable\n * <domain>`); nothing here can check that, which is why `E_SENDER_NOT_VERIFIED`\n * is surfaced verbatim rather than collapsed into \"send failed\".\n */\nimport type { RenderedMessage } from './types.ts';\nimport type { ChannelResult, EmailBinding, EmailPlan } from './types.ts';\n\n/**\n * Provider errors worth retrying.\n *\n * Everything else is a configuration fault — an unverified sender, a malformed\n * payload, a suppressed recipient — where a retry is pure latency and the send\n * will fail identically. Retrying those also burns the daily quota.\n */\nconst RETRYABLE = new Set([\n 'E_RATE_LIMIT_EXCEEDED',\n 'E_DELIVERY_FAILED',\n 'E_INTERNAL_SERVER_ERROR',\n]);\n\nfunction codeOf(error: unknown): string | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport interface SendEmailOptions {\n /** Attempts for a retryable failure (default 3). */\n attempts?: number;\n /**\n * Per-attempt ceiling in milliseconds (default 10000; `0` disables).\n *\n * `binding.send()` is a network call with no deadline of its own, so without\n * this one hung attempt hangs the request that produced it — forever, in the\n * one module otherwise built on always saying why. A conversion endpoint\n * cannot be the thing that makes a form submission time out, so the bound\n * belongs here rather than in every consumer's wrapper.\n *\n * A timeout is treated as retryable: it is a transient condition by\n * definition, unlike `E_SENDER_NOT_VERIFIED` and friends.\n */\n timeoutMs?: number;\n /** Injected for tests; real callers let it default to a real delay. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\n/** Marker for a send that exceeded its deadline, so the retry rule can see it. */\nconst TIMEOUT_CODE = 'E_SEND_TIMEOUT';\n\n/**\n * Race a send against its deadline.\n *\n * The timer is always cleared — a pending `setTimeout` keeps a Worker's event\n * loop alive past the response, which turns a bounded send into an unbounded\n * invocation and bills for the difference.\n */\nasync function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {\n if (ms <= 0) return work;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n work,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const err = new Error(`Email send exceeded ${ms}ms.`) as Error & { code: string };\n err.code = TIMEOUT_CODE;\n reject(err);\n }, ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/**\n * Send one rendered message according to a plan.\n *\n * Never throws: a failed notification must not take down the request that\n * produced it. The visitor has already submitted their form, and failing their\n * response because our mail didn't go out would turn a lost notification into a\n * lost conversion. The failure is returned instead, for the caller to log.\n */\nexport async function sendEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n binding: EmailBinding,\n options: SendEmailOptions = {},\n): Promise<ChannelResult> {\n if (!plan.enabled || !plan.to || !plan.from) {\n return { channel: 'email', sent: false, reason: plan.skip ?? 'Channel not enabled.' };\n }\n\n const attempts = Math.max(1, options.attempts ?? 3);\n const sleep = options.sleep ?? wait;\n const timeoutMs = options.timeoutMs ?? 10_000;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n await withTimeout(\n binding.send({\n to: plan.to,\n from: plan.fromName ? { email: plan.from, name: plan.fromName } : { email: plan.from },\n subject: message.subject,\n text: message.text,\n html: message.html,\n ...(plan.replyTo ? { replyTo: plan.replyTo } : {}),\n }),\n timeoutMs,\n );\n return { channel: 'email', sent: true };\n } catch (error) {\n const code = codeOf(error);\n if (attempt === attempts || !code || !(RETRYABLE.has(code) || code === TIMEOUT_CODE)) {\n return {\n channel: 'email',\n sent: false,\n reason: messageOf(error),\n ...(code ? { code } : {}),\n };\n }\n // Exponential backoff. Cloudflare's rate limit is per-account, so a burst\n // of conversions retrying in lockstep would keep colliding.\n await sleep(2 ** (attempt - 1) * 250);\n }\n }\n\n /* c8 ignore next -- the loop always returns; this satisfies the type checker. */\n return { channel: 'email', sent: false, reason: 'Exhausted attempts.' };\n}\n\n/**\n * Print the message instead of sending it.\n *\n * The dev path, for a machine with no binding. Explicit rather than a silent\n * no-op, because \"I never saw the notification\" is the symptom of both a broken\n * integration and a working one nobody could observe.\n */\nexport function logEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n log: (line: string) => void = console.log,\n): ChannelResult {\n log(\n [\n '\\n========== NOTIFICATION EMAIL (not sent — no binding) ==========',\n `To: ${plan.to ?? '(unresolved)'}`,\n `From: ${plan.from ?? '(unresolved)'}`,\n `Subject: ${message.subject}`,\n '---',\n message.text,\n '================================================================\\n',\n ].join('\\n'),\n );\n return { channel: 'email', sent: false, reason: 'No binding — logged to the console.' };\n}\n","/**\n * Every decision a notification makes, as one pure function.\n *\n * Pure in the load-bearing sense: no `fetch`, no binding, no clock. Whether a\n * channel fires, who it reaches, and *why* it was skipped are all decided here and\n * asserted in `plan.test.ts`; the senders beside this file do what they are told\n * and decide nothing. That is the same split `indexing/plan.ts` makes against\n * `gsc.ts`, and `@getvitops/core`'s consent store makes against its DOM wiring,\n * for the same reason: the consequential logic has to be testable without the\n * environment it runs in.\n *\n * The practical payoff is that a misconfigured site can be told exactly what will\n * and won't happen without sending anything — a silently unsent conversion\n * notification is indistinguishable from no conversion.\n */\nimport type { EmailChannelConfig, EmailPlan, NotificationPlan, NotifyContext } from './types.ts';\n\n/** Default Workers binding name for Cloudflare Email Sending. */\nexport const DEFAULT_EMAIL_BINDING = 'EMAIL';\n\n/** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */\nexport function normalizeEmailChannel(\n input: string | EmailChannelConfig | undefined,\n): EmailChannelConfig | undefined {\n if (input === undefined) return undefined;\n return typeof input === 'string' ? { provider: 'cloudflare', to: input } : input;\n}\n\n/**\n * Who the notification reaches.\n *\n * An explicit recipient wins; otherwise it falls to the site's own contact\n * addresses, primary first. This cascade is why a site that has already said\n * where it receives mail doesn't have to say it twice.\n */\nexport function resolveRecipient(\n channel: EmailChannelConfig,\n ctx: NotifyContext,\n): string | undefined {\n if (channel.to) return channel.to;\n return ctx.locationEmails?.find((e) => !!e);\n}\n\n/**\n * The From address.\n *\n * `noreply@<canonical>` by default, because the sending domain has to be one the\n * site controls — Cloudflare rejects anything else with `E_SENDER_NOT_VERIFIED`,\n * and guessing from the recipient's domain would send that failure every time.\n */\nexport function resolveSender(channel: EmailChannelConfig, ctx: NotifyContext): string | undefined {\n if (channel.from) return channel.from;\n if (!ctx.canonical) return undefined;\n let host: string;\n try {\n host = new URL(ctx.canonical).hostname;\n } catch {\n // A bare hostname is a legitimate way to write `domains.canonical`.\n host = ctx.canonical.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '');\n }\n return host ? `noreply@${host}` : undefined;\n}\n\n/**\n * Decide what will be sent, and say why anything won't be.\n *\n * Every \"off\" carries a reason rather than being an absence, so a caller can\n * report the misconfiguration instead of reporting success over a no-op.\n */\nexport function planNotifications(ctx: NotifyContext): NotificationPlan {\n const email = planEmail(ctx);\n return { email, empty: !email.enabled };\n}\n\nfunction planEmail(ctx: NotifyContext): EmailPlan {\n const channel = normalizeEmailChannel(ctx.notifications?.email);\n const binding = channel?.binding ?? DEFAULT_EMAIL_BINDING;\n\n if (!channel) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip: 'No `notifications.email` configured.',\n };\n }\n\n const to = resolveRecipient(channel, ctx);\n if (!to) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip:\n 'No recipient: set `notifications.email.to`, or give a location an `email` ' +\n 'so the notification has somewhere to go.',\n };\n }\n\n const from = resolveSender(channel, ctx);\n if (!from) {\n return {\n provider: 'cloudflare',\n binding,\n to,\n enabled: false,\n skip:\n 'No sender: set `notifications.email.from`, or `domains.canonical` so ' +\n '`noreply@<host>` can be derived. Cloudflare only sends from a domain you have onboarded.',\n };\n }\n\n return {\n provider: 'cloudflare',\n binding,\n to,\n from,\n fromName: channel.fromName ?? ctx.organizationName,\n replyTo: channel.replyTo,\n enabled: true,\n };\n}\n","/**\n * Turning a `ConversionEvent` into something a person reads.\n *\n * Pure, and separate from both the plan and the sender, because rendering is the\n * part that differs per channel: an SMS channel will render the same event in 160\n * characters, a portal log as a row. The event stays the fact; only this file has\n * an opinion about prose.\n *\n * The layout is three sections — who got in touch, which ad sent them, and what\n * the request looked like — because that is the order the reader needs them in.\n * The contact details are the point; attribution is why it matters; the visitor\n * context is for when something looks wrong.\n */\nimport { identifySubmitter } from '../tracking/identity.ts';\nimport { getPrimaryClickId, identifyPlatform } from '../tracking/platform.ts';\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport type { RenderedMessage } from './types.ts';\n\n/**\n * Fields never worth putting in a notification.\n *\n * A honeypot is not visitor-supplied — it is bait, and reporting it as something\n * they submitted is untrue. The same rule `legal/derive.ts` applies when deriving\n * `piiCollected`, and for the same reason. Callers may strip more.\n */\nconst OMIT_FIELDS = new Set(['website', '_honeypot', 'honeypot', 'cf-turnstile-response']);\n\nfunction label(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1).replace(/[_-]/g, ' ');\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\n/** One section: a heading and its lines. Empty sections are dropped by the caller. */\ninterface Section {\n heading: string;\n lines: [string, string][];\n}\n\n/**\n * One line, already rendered both ways — a plain fact (`html` is just the\n * escaped `text`) or a link (`html` an anchor, `text` the bare href). Built at\n * the point each line is known rather than carried as a union and branched on\n * later: `describeEvent`'s lines are always plain `[label, value]` pairs (see\n * `Section` above, which `render.test.ts` destructures as such), and the one\n * line shape `renderEmail` adds itself — the \"Actions\" link — is turned into\n * this same rendered shape immediately, so the two renderers below share one\n * line format instead of branching on what kind of line each one is.\n */\ninterface RenderedLine {\n label: string;\n text: string;\n html: string;\n}\n\n/** A section as `renderEmail` assembles it — `describeEvent`'s output plus its own additions. */\ninterface RenderSection {\n heading: string;\n lines: RenderedLine[];\n}\n\nfunction factLine([label, value]: readonly [string, string]): RenderedLine {\n return { label, text: value, html: escapeHtml(value) };\n}\n\nfunction linkLine(label: string, href: string): RenderedLine {\n return { label, text: href, html: `<a href=\"${escapeHtml(href)}\">${escapeHtml(href)}</a>` };\n}\n\nfunction toRenderSection(section: Section): RenderSection {\n return { heading: section.heading, lines: section.lines.map(factLine) };\n}\n\n/**\n * Who submitted the form, for the subject line.\n *\n * `formData['name']` alone is the shape a form has when someone writes it that\n * way, and most don't: a downstream site had `first_name`/`last_name` on five of\n * six forms, so every notification read \"from Unknown\" and the renderer could\n * not be adopted at all. The cascade is ordered most-specific first, and falls\n * back to the email rather than to nothing — an address identifies the person\n * even when no name field exists.\n */\nfunction submitterName(formData: Record<string, string>): string {\n return identifySubmitter(formData).fullName;\n}\n\n/**\n * The event as sections — the shared structure behind both renderings.\n *\n * Extracted so the text and HTML versions cannot disagree about content. They\n * differ only in markup; a field added here appears in both.\n */\nexport function describeEvent(event: ConversionEvent): { subject: string; sections: Section[] } {\n const t = event.tracking;\n const platform = t ? identifyPlatform(t) : null;\n const clickId = t ? getPrimaryClickId(t) : null;\n\n const contact: [string, string][] = [];\n let subject: string;\n\n if (event.type === 'form' && event.formData) {\n const name = submitterName(event.formData);\n subject = `[Contact Form] New submission from ${name}`;\n for (const [key, value] of Object.entries(event.formData)) {\n if (!OMIT_FIELDS.has(key) && value) contact.push([label(key), value]);\n }\n } else if (event.type === 'email') {\n const email = event.email ?? 'unknown';\n subject = `[Email Click] Visitor emailing ${email}`;\n contact.push(['Email', email]);\n } else {\n const phone = event.phone ?? 'unknown';\n subject = `[Phone Call] Visitor calling ${phone}`;\n contact.push(['Phone', phone]);\n }\n\n const attribution: [string, string][] = [];\n if (t) {\n if (platform) attribution.push(['Platform', platform]);\n if (clickId) attribution.push([`Click ID (${clickId.param})`, clickId.value]);\n for (const key of ['utm_campaign', 'utm_source', 'utm_medium', 'utm_content', 'utm_term']) {\n const value = t[key];\n if (value) attribution.push([label(key.replace('utm_', '')), String(value)]);\n }\n if (t.ab_variant) attribution.push(['A/B variant', t.ab_variant]);\n }\n\n const context: [string, string][] = [];\n if (t?.landingPage) context.push(['Landing page', t.landingPage]);\n if (t?.referrer) context.push(['Referrer', t.referrer]);\n if (t?.ts) context.push(['First visit', new Date(t.ts).toISOString()]);\n context.push(['Received', new Date(event.at).toISOString()]);\n if (event.userAgent) context.push(['User agent', event.userAgent]);\n if (event.ip) context.push(['IP', event.ip]);\n\n const sections: Section[] = [\n { heading: 'Contact details', lines: contact },\n // Stated rather than omitted: \"we don't know where this came from\" is a\n // useful answer, and a silently missing section reads as a bug in the tool.\n {\n heading: 'Ad attribution',\n lines: attribution.length\n ? attribution\n : [['Source', 'None — visitor arrived without ad tracking']],\n },\n { heading: 'Visitor context', lines: context },\n ];\n\n return { subject, sections: sections.filter((s) => s.lines.length) };\n}\n\n/** Render for e-mail. Both halves, always — see `RenderedMessage`. */\nexport function renderEmail(\n event: ConversionEvent,\n extra: { notes?: string[] | undefined; actionUrl?: string | undefined } = {},\n): RenderedMessage {\n const { subject, sections: eventSections } = describeEvent(event);\n\n // `{clickId}` is the only placeholder — an event has no durable id nothing\n // in this toolchain could look back up (there's no store), so interpolating\n // one would be decorative. Omitted entirely when there's no click ID to\n // interpolate, rather than emailing a link with a literal `{clickId}` in it.\n const clickId = event.tracking ? getPrimaryClickId(event.tracking) : null;\n const actionSection: RenderSection | null =\n extra.actionUrl && clickId\n ? {\n heading: 'Actions',\n lines: [\n linkLine(\n 'View in ad platform',\n extra.actionUrl.replace(/\\{clickId\\}/g, encodeURIComponent(clickId.value)),\n ),\n ],\n }\n : null;\n\n // Deliberately a channel-neutral `string[]` rather than a typed CRM result —\n // this module gains no dependency on `crm`, and the seam serves any future\n // sink the same way.\n const sections: RenderSection[] = [\n ...eventSections.map(toRenderSection),\n ...(actionSection ? [actionSection] : []),\n ...(extra.notes && extra.notes.length\n ? [{ heading: 'Delivery', lines: extra.notes.map((n) => factLine(['CRM', n])) }]\n : []),\n ];\n\n const text = sections\n .map((s) => [`--- ${s.heading} ---`, ...s.lines.map((l) => `${l.label}: ${l.text}`)].join('\\n'))\n .join('\\n\\n');\n\n const html = sections\n .map(\n (s) =>\n `<h2 style=\"font:600 14px system-ui;margin:24px 0 8px\">${escapeHtml(s.heading)}</h2>` +\n `<table style=\"font:14px system-ui;border-collapse:collapse\">${s.lines\n .map(\n (l) =>\n `<tr><td style=\"padding:2px 12px 2px 0;color:#666;vertical-align:top\">${escapeHtml(l.label)}</td>` +\n `<td style=\"padding:2px 0\">${l.html}</td></tr>`,\n )\n .join('')}</table>`,\n )\n .join('');\n\n return { subject, text, html };\n}\n","/**\n * Conversion notifications — plan, render, dispatch.\n *\n * The seam between \"a conversion happened\" and \"someone found out about it\".\n * A `ConversionEvent` from `@getvitops/utils/tracking` goes in; where it goes and\n * how it reads are config, not code at the call site.\n *\n * Three files, three jobs, matching `indexing/`:\n * - `plan.ts` decides everything, purely — which channels, which recipients,\n * and why anything is off.\n * - `render.ts` turns the event into prose, purely.\n * - `email.ts` executes, and decides nothing.\n *\n * ---\n *\n * **TODO — further channels.** Only `email` is implemented. The seam is\n * `NotificationsConfig` + a sender with `sendEmail`'s signature `(plan, message,\n * transport) => ChannelResult`; adding one should mean a new sender file, a new\n * branch in `planNotifications`, and a schema variant — touching neither\n * `ConversionEvent` nor the recipient cascade. Planned:\n * - `sms` — the same event rendered short. `render.ts` already separates\n * `describeEvent` from `renderEmail` for exactly this.\n * - `persist` — append to a store (D1, a portal log) the client reviews.\n * The generic `email`/`text`/`persist` helpers taking content + provider config\n * belong at that point, not before: one implemented channel is not enough to know\n * what the abstraction should be.\n */\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport { logEmail, sendEmail } from './email.ts';\nimport { planNotifications } from './plan.ts';\nimport { renderEmail } from './render.ts';\nimport type { ChannelResult, EmailBinding, NotifyContext } from './types.ts';\n\nexport interface NotifyDeps {\n /**\n * The Workers `send_email` binding (`env.EMAIL`). Omit it and the notification\n * is printed instead — the dev path.\n */\n email?: EmailBinding | undefined;\n}\n\nexport interface NotifyResult {\n results: ChannelResult[];\n /** True when at least one channel delivered. */\n delivered: boolean;\n}\n\n/**\n * Notify every configured channel about a conversion.\n *\n * Channels are independent: one failing must not stop the others, and none of\n * them may throw into the request that produced the event. Every outcome —\n * delivered, skipped, failed — comes back as data for the caller to log.\n */\nexport async function notify(\n event: ConversionEvent,\n ctx: NotifyContext,\n deps: NotifyDeps = {},\n extra: { notes?: string[] | undefined } = {},\n): Promise<NotifyResult> {\n const plan = planNotifications(ctx);\n const results: ChannelResult[] = [];\n\n if (plan.email.enabled) {\n const message = renderEmail(event, { ...extra, actionUrl: ctx.notifications?.actionUrl });\n results.push(\n deps.email ? await sendEmail(plan.email, message, deps.email) : logEmail(plan.email, message),\n );\n } else {\n results.push({ channel: 'email', sent: false, reason: plan.email.skip ?? 'Not configured.' });\n }\n\n return { results, delivered: results.some((r) => r.sent) };\n}\n\nexport {\n DEFAULT_EMAIL_BINDING,\n normalizeEmailChannel,\n planNotifications,\n resolveRecipient,\n resolveSender,\n} from './plan.ts';\nexport { describeEvent, renderEmail } from './render.ts';\nexport { logEmail, sendEmail } from './email.ts';\nexport type {\n ChannelPlan,\n ChannelResult,\n EmailBinding,\n EmailChannelConfig,\n EmailPlan,\n NotificationPlan,\n NotificationsConfig,\n NotifyContext,\n RenderedMessage,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;AA2BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;AACF,CAAC;AAED,SAAS,OAAO,OAAoC;CAClD,MAAM,OAAQ,OAAqC;CACnD,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAsBA,MAAM,QAAQ,OAA8B,IAAI,SAAS,MAAM,WAAW,GAAG,EAAE,CAAC;;AAGhF,MAAM,eAAe;;;;;;;;AASrB,eAAe,YAAe,MAAkB,IAAwB;CACtE,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI;CACJ,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CACxB,MACA,IAAI,SAAgB,GAAG,WAAW;GAChC,QAAQ,iBAAiB;IACvB,MAAM,sBAAM,IAAI,MAAM,uBAAuB,GAAG,IAAI;IACpD,IAAI,OAAO;IACX,OAAO,GAAG;GACZ,GAAG,EAAE;EACP,CAAC,CACH,CAAC;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C,wEAAwE,WAAW,EAAE,KAAK,EAAE,iCAC/D,EAAE,KAAK,WACxC,CAAC,CACA,KAAK,EAAE,EAAE,SAChB,CAAC,CACA,KAAK,EAEmB;CAAE;AAC/B;;;;;;;;;;;AC/JA,eAAsB,OACpB,OACA,KACA,OAAmB,CAAC,GACpB,QAA0C,CAAC,GACpB;CACvB,MAAM,OAAO,kBAAkB,GAAG;CAClC,MAAM,UAA2B,CAAC;CAElC,IAAI,KAAK,MAAM,SAAS;EACtB,MAAM,UAAU,YAAY,OAAO;GAAE,GAAG;GAAO,WAAW,IAAI,eAAe;EAAU,CAAC;EACxF,QAAQ,KACN,KAAK,QAAQ,MAAM,UAAU,KAAK,OAAO,SAAS,KAAK,KAAK,IAAI,SAAS,KAAK,OAAO,OAAO,CAC9F;CACF,OACE,QAAQ,KAAK;EAAE,SAAS;EAAS,MAAM;EAAO,QAAQ,KAAK,MAAM,QAAQ;CAAkB,CAAC;CAG9F,OAAO;EAAE;EAAS,WAAW,QAAQ,MAAM,MAAM,EAAE,IAAI;CAAE;AAC3D"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/notify/email.ts","../../src/notify/plan.ts","../../src/notify/render.ts","../../src/notify/google-ads.ts","../../src/notify/index.ts"],"sourcesContent":["/**\n * The e-mail channel — Cloudflare Email Sending.\n *\n * I/O only: it executes an `EmailPlan` and decides nothing. Whether to send, to\n * whom, and from where were all settled in `plan.ts`.\n *\n * **The binding is passed in, never imported.** `@getvitops/utils` does not depend\n * on `cloudflare:workers`, so this module runs in Node and in a test with a stub,\n * and the Astro package gains no Cloudflare coupling. The consumer's route hands\n * over `env.EMAIL`.\n *\n * Uses the current Email Sending binding — a structured `send({ to, from,\n * subject, html, text })` — not the legacy `EmailMessage` + hand-built MIME path.\n * The domain in `from` must have been onboarded (`wrangler email sending enable\n * <domain>`); nothing here can check that, which is why `E_SENDER_NOT_VERIFIED`\n * is surfaced verbatim rather than collapsed into \"send failed\".\n */\nimport type { RenderedMessage } from './types.ts';\nimport type { ChannelResult, EmailBinding, EmailPlan } from './types.ts';\n\n/**\n * Provider errors worth retrying.\n *\n * Everything else is a configuration fault — an unverified sender, a malformed\n * payload, a suppressed recipient — where a retry is pure latency and the send\n * will fail identically. Retrying those also burns the daily quota.\n */\nconst RETRYABLE = new Set([\n 'E_RATE_LIMIT_EXCEEDED',\n 'E_DELIVERY_FAILED',\n 'E_INTERNAL_SERVER_ERROR',\n]);\n\nfunction codeOf(error: unknown): string | undefined {\n const code = (error as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : undefined;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport interface SendEmailOptions {\n /** Attempts for a retryable failure (default 3). */\n attempts?: number;\n /**\n * Per-attempt ceiling in milliseconds (default 10000; `0` disables).\n *\n * `binding.send()` is a network call with no deadline of its own, so without\n * this one hung attempt hangs the request that produced it — forever, in the\n * one module otherwise built on always saying why. A conversion endpoint\n * cannot be the thing that makes a form submission time out, so the bound\n * belongs here rather than in every consumer's wrapper.\n *\n * A timeout is treated as retryable: it is a transient condition by\n * definition, unlike `E_SENDER_NOT_VERIFIED` and friends.\n */\n timeoutMs?: number;\n /** Injected for tests; real callers let it default to a real delay. */\n sleep?: (ms: number) => Promise<void>;\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\n/** Marker for a send that exceeded its deadline, so the retry rule can see it. */\nconst TIMEOUT_CODE = 'E_SEND_TIMEOUT';\n\n/**\n * Race a send against its deadline.\n *\n * The timer is always cleared — a pending `setTimeout` keeps a Worker's event\n * loop alive past the response, which turns a bounded send into an unbounded\n * invocation and bills for the difference.\n */\nasync function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {\n if (ms <= 0) return work;\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n work,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => {\n const err = new Error(`Email send exceeded ${ms}ms.`) as Error & { code: string };\n err.code = TIMEOUT_CODE;\n reject(err);\n }, ms);\n }),\n ]);\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/**\n * Send one rendered message according to a plan.\n *\n * Never throws: a failed notification must not take down the request that\n * produced it. The visitor has already submitted their form, and failing their\n * response because our mail didn't go out would turn a lost notification into a\n * lost conversion. The failure is returned instead, for the caller to log.\n */\nexport async function sendEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n binding: EmailBinding,\n options: SendEmailOptions = {},\n): Promise<ChannelResult> {\n if (!plan.enabled || !plan.to || !plan.from) {\n return { channel: 'email', sent: false, reason: plan.skip ?? 'Channel not enabled.' };\n }\n\n const attempts = Math.max(1, options.attempts ?? 3);\n const sleep = options.sleep ?? wait;\n const timeoutMs = options.timeoutMs ?? 10_000;\n\n for (let attempt = 1; attempt <= attempts; attempt++) {\n try {\n await withTimeout(\n binding.send({\n to: plan.to,\n from: plan.fromName ? { email: plan.from, name: plan.fromName } : { email: plan.from },\n subject: message.subject,\n text: message.text,\n html: message.html,\n ...(plan.replyTo ? { replyTo: plan.replyTo } : {}),\n }),\n timeoutMs,\n );\n return { channel: 'email', sent: true };\n } catch (error) {\n const code = codeOf(error);\n if (attempt === attempts || !code || !(RETRYABLE.has(code) || code === TIMEOUT_CODE)) {\n return {\n channel: 'email',\n sent: false,\n reason: messageOf(error),\n ...(code ? { code } : {}),\n };\n }\n // Exponential backoff. Cloudflare's rate limit is per-account, so a burst\n // of conversions retrying in lockstep would keep colliding.\n await sleep(2 ** (attempt - 1) * 250);\n }\n }\n\n /* c8 ignore next -- the loop always returns; this satisfies the type checker. */\n return { channel: 'email', sent: false, reason: 'Exhausted attempts.' };\n}\n\n/**\n * Print the message instead of sending it.\n *\n * The dev path, for a machine with no binding. Explicit rather than a silent\n * no-op, because \"I never saw the notification\" is the symptom of both a broken\n * integration and a working one nobody could observe.\n */\nexport function logEmail(\n plan: EmailPlan,\n message: RenderedMessage,\n log: (line: string) => void = console.log,\n): ChannelResult {\n log(\n [\n '\\n========== NOTIFICATION EMAIL (not sent — no binding) ==========',\n `To: ${plan.to ?? '(unresolved)'}`,\n `From: ${plan.from ?? '(unresolved)'}`,\n `Subject: ${message.subject}`,\n '---',\n message.text,\n '================================================================\\n',\n ].join('\\n'),\n );\n return { channel: 'email', sent: false, reason: 'No binding — logged to the console.' };\n}\n","/**\n * Every decision a notification makes, as one pure function.\n *\n * Pure in the load-bearing sense: no `fetch`, no binding, no clock. Whether a\n * channel fires, who it reaches, and *why* it was skipped are all decided here and\n * asserted in `plan.test.ts`; the senders beside this file do what they are told\n * and decide nothing. That is the same split `indexing/plan.ts` makes against\n * `gsc.ts`, and `@getvitops/core`'s consent store makes against its DOM wiring,\n * for the same reason: the consequential logic has to be testable without the\n * environment it runs in.\n *\n * The practical payoff is that a misconfigured site can be told exactly what will\n * and won't happen without sending anything — a silently unsent conversion\n * notification is indistinguishable from no conversion.\n */\nimport type { EmailChannelConfig, EmailPlan, NotificationPlan, NotifyContext } from './types.ts';\n\n/** Default Workers binding name for Cloudflare Email Sending. */\nexport const DEFAULT_EMAIL_BINDING = 'EMAIL';\n\n/** Normalise the `email` shorthand: a bare address means a Cloudflare send to it. */\nexport function normalizeEmailChannel(\n input: string | EmailChannelConfig | undefined,\n): EmailChannelConfig | undefined {\n if (input === undefined) return undefined;\n return typeof input === 'string' ? { provider: 'cloudflare', to: input } : input;\n}\n\n/**\n * Who the notification reaches.\n *\n * An explicit recipient wins; otherwise it falls to the site's own contact\n * addresses, primary first. This cascade is why a site that has already said\n * where it receives mail doesn't have to say it twice.\n */\nexport function resolveRecipient(\n channel: EmailChannelConfig,\n ctx: NotifyContext,\n): string | undefined {\n if (channel.to) return channel.to;\n return ctx.locationEmails?.find((e) => !!e);\n}\n\n/**\n * The From address.\n *\n * `noreply@<canonical>` by default, because the sending domain has to be one the\n * site controls — Cloudflare rejects anything else with `E_SENDER_NOT_VERIFIED`,\n * and guessing from the recipient's domain would send that failure every time.\n */\nexport function resolveSender(channel: EmailChannelConfig, ctx: NotifyContext): string | undefined {\n if (channel.from) return channel.from;\n if (!ctx.canonical) return undefined;\n let host: string;\n try {\n host = new URL(ctx.canonical).hostname;\n } catch {\n // A bare hostname is a legitimate way to write `domains.canonical`.\n host = ctx.canonical.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '');\n }\n return host ? `noreply@${host}` : undefined;\n}\n\n/**\n * Decide what will be sent, and say why anything won't be.\n *\n * Every \"off\" carries a reason rather than being an absence, so a caller can\n * report the misconfiguration instead of reporting success over a no-op.\n */\nexport function planNotifications(ctx: NotifyContext): NotificationPlan {\n const email = planEmail(ctx);\n return { email, empty: !email.enabled };\n}\n\nfunction planEmail(ctx: NotifyContext): EmailPlan {\n const channel = normalizeEmailChannel(ctx.notifications?.email);\n const binding = channel?.binding ?? DEFAULT_EMAIL_BINDING;\n\n if (!channel) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip: 'No `notifications.email` configured.',\n };\n }\n\n const to = resolveRecipient(channel, ctx);\n if (!to) {\n return {\n provider: 'cloudflare',\n binding,\n enabled: false,\n skip:\n 'No recipient: set `notifications.email.to`, or give a location an `email` ' +\n 'so the notification has somewhere to go.',\n };\n }\n\n const from = resolveSender(channel, ctx);\n if (!from) {\n return {\n provider: 'cloudflare',\n binding,\n to,\n enabled: false,\n skip:\n 'No sender: set `notifications.email.from`, or `domains.canonical` so ' +\n '`noreply@<host>` can be derived. Cloudflare only sends from a domain you have onboarded.',\n };\n }\n\n return {\n provider: 'cloudflare',\n binding,\n to,\n from,\n fromName: channel.fromName ?? ctx.organizationName,\n replyTo: channel.replyTo,\n enabled: true,\n };\n}\n","/**\n * Turning a `ConversionEvent` into something a person reads.\n *\n * Pure, and separate from both the plan and the sender, because rendering is the\n * part that differs per channel: an SMS channel will render the same event in 160\n * characters, a portal log as a row. The event stays the fact; only this file has\n * an opinion about prose.\n *\n * The layout is three sections — who got in touch, which ad sent them, and what\n * the request looked like — because that is the order the reader needs them in.\n * The contact details are the point; attribution is why it matters; the visitor\n * context is for when something looks wrong.\n */\nimport { identifySubmitter } from '../tracking/identity.ts';\nimport { getPrimaryClickId, identifyPlatform } from '../tracking/platform.ts';\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport type { RenderedMessage } from './types.ts';\n\n/**\n * Fields never worth putting in a notification.\n *\n * A honeypot is not visitor-supplied — it is bait, and reporting it as something\n * they submitted is untrue. The same rule `legal/derive.ts` applies when deriving\n * `piiCollected`, and for the same reason. Callers may strip more.\n */\nconst OMIT_FIELDS = new Set(['website', '_honeypot', 'honeypot', 'cf-turnstile-response']);\n\nfunction label(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1).replace(/[_-]/g, ' ');\n}\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\n/** One section: a heading and its lines. Empty sections are dropped by the caller. */\ninterface Section {\n heading: string;\n lines: [string, string][];\n}\n\n/**\n * One line, already rendered both ways — a plain fact (`html` is just the\n * escaped `text`) or a link (`html` an anchor, `text` the bare href). Built at\n * the point each line is known rather than carried as a union and branched on\n * later: `describeEvent`'s lines are always plain `[label, value]` pairs (see\n * `Section` above, which `render.test.ts` destructures as such), and the one\n * line shape `renderEmail` adds itself — the \"Actions\" link — is turned into\n * this same rendered shape immediately, so the two renderers below share one\n * line format instead of branching on what kind of line each one is.\n */\ninterface RenderedLine {\n label: string;\n text: string;\n html: string;\n}\n\n/** A section as `renderEmail` assembles it — `describeEvent`'s output plus its own additions. */\ninterface RenderSection {\n heading: string;\n lines: RenderedLine[];\n}\n\nfunction factLine([label, value]: readonly [string, string]): RenderedLine {\n return { label, text: value, html: escapeHtml(value) };\n}\n\nfunction linkLine(label: string, href: string): RenderedLine {\n return { label, text: href, html: `<a href=\"${escapeHtml(href)}\">${escapeHtml(href)}</a>` };\n}\n\nfunction toRenderSection(section: Section): RenderSection {\n return { heading: section.heading, lines: section.lines.map(factLine) };\n}\n\n/**\n * Who submitted the form, for the subject line.\n *\n * `formData['name']` alone is the shape a form has when someone writes it that\n * way, and most don't: a downstream site had `first_name`/`last_name` on five of\n * six forms, so every notification read \"from Unknown\" and the renderer could\n * not be adopted at all. The cascade is ordered most-specific first, and falls\n * back to the email rather than to nothing — an address identifies the person\n * even when no name field exists.\n */\nfunction submitterName(formData: Record<string, string>): string {\n return identifySubmitter(formData).fullName;\n}\n\n/**\n * The event as sections — the shared structure behind both renderings.\n *\n * Extracted so the text and HTML versions cannot disagree about content. They\n * differ only in markup; a field added here appears in both.\n */\nexport function describeEvent(event: ConversionEvent): { subject: string; sections: Section[] } {\n const t = event.tracking;\n const platform = t ? identifyPlatform(t) : null;\n const clickId = t ? getPrimaryClickId(t) : null;\n\n const contact: [string, string][] = [];\n let subject: string;\n\n if (event.type === 'form' && event.formData) {\n const name = submitterName(event.formData);\n subject = `[Contact Form] New submission from ${name}`;\n for (const [key, value] of Object.entries(event.formData)) {\n if (!OMIT_FIELDS.has(key) && value) contact.push([label(key), value]);\n }\n } else if (event.type === 'email') {\n const email = event.email ?? 'unknown';\n subject = `[Email Click] Visitor emailing ${email}`;\n contact.push(['Email', email]);\n } else {\n const phone = event.phone ?? 'unknown';\n subject = `[Phone Call] Visitor calling ${phone}`;\n contact.push(['Phone', phone]);\n }\n\n const attribution: [string, string][] = [];\n if (t) {\n if (platform) attribution.push(['Platform', platform]);\n if (clickId) attribution.push([`Click ID (${clickId.param})`, clickId.value]);\n for (const key of ['utm_campaign', 'utm_source', 'utm_medium', 'utm_content', 'utm_term']) {\n const value = t[key];\n if (value) attribution.push([label(key.replace('utm_', '')), String(value)]);\n }\n if (t.ab_variant) attribution.push(['A/B variant', t.ab_variant]);\n }\n\n const context: [string, string][] = [];\n if (t?.landingPage) context.push(['Landing page', t.landingPage]);\n if (t?.referrer) context.push(['Referrer', t.referrer]);\n if (t?.ts) context.push(['First visit', new Date(t.ts).toISOString()]);\n context.push(['Received', new Date(event.at).toISOString()]);\n if (event.userAgent) context.push(['User agent', event.userAgent]);\n if (event.ip) context.push(['IP', event.ip]);\n\n const sections: Section[] = [\n { heading: 'Contact details', lines: contact },\n // Stated rather than omitted: \"we don't know where this came from\" is a\n // useful answer, and a silently missing section reads as a bug in the tool.\n {\n heading: 'Ad attribution',\n lines: attribution.length\n ? attribution\n : [['Source', 'None — visitor arrived without ad tracking']],\n },\n { heading: 'Visitor context', lines: context },\n ];\n\n return { subject, sections: sections.filter((s) => s.lines.length) };\n}\n\n/** Render for e-mail. Both halves, always — see `RenderedMessage`. */\nexport function renderEmail(\n event: ConversionEvent,\n extra: { notes?: string[] | undefined; actionUrl?: string | undefined } = {},\n): RenderedMessage {\n const { subject, sections: eventSections } = describeEvent(event);\n\n // `{clickId}` is the only placeholder — an event has no durable id nothing\n // in this toolchain could look back up (there's no store), so interpolating\n // one would be decorative. Omitted entirely when there's no click ID to\n // interpolate, rather than emailing a link with a literal `{clickId}` in it.\n const clickId = event.tracking ? getPrimaryClickId(event.tracking) : null;\n const actionSection: RenderSection | null =\n extra.actionUrl && clickId\n ? {\n heading: 'Actions',\n lines: [\n linkLine(\n 'View in ad platform',\n extra.actionUrl.replace(/\\{clickId\\}/g, encodeURIComponent(clickId.value)),\n ),\n ],\n }\n : null;\n\n // Deliberately a channel-neutral `string[]` rather than a typed CRM result —\n // this module gains no dependency on `crm`, and the seam serves any future\n // sink the same way.\n const sections: RenderSection[] = [\n ...eventSections.map(toRenderSection),\n ...(actionSection ? [actionSection] : []),\n ...(extra.notes && extra.notes.length\n ? [{ heading: 'Delivery', lines: extra.notes.map((n) => factLine(['CRM', n])) }]\n : []),\n ];\n\n const text = sections\n .map((s) => [`--- ${s.heading} ---`, ...s.lines.map((l) => `${l.label}: ${l.text}`)].join('\\n'))\n .join('\\n\\n');\n\n const html = sections\n .map(\n (s) =>\n `<h2 style=\"font:600 14px system-ui;margin:24px 0 8px\">${escapeHtml(s.heading)}</h2>` +\n `<table style=\"font:14px system-ui;border-collapse:collapse\">${s.lines\n .map(\n (l) =>\n `<tr><td style=\"padding:2px 12px 2px 0;color:#666;vertical-align:top\">${escapeHtml(l.label)}</td>` +\n `<td style=\"padding:2px 0\">${l.html}</td></tr>`,\n )\n .join('')}</table>`,\n )\n .join('');\n\n return { subject, text, html };\n}\n","/**\n * Google Ads offline conversion upload — the server-side counterpart to the\n * client-side `gtag('event', 'conversion', …)` call `gtagBootstrap`\n * (`@getvitops/utils/ads`) wires up. Reads `site.ads.google.reporting: 'server'`\n * and a matching `conversionActionId` (see that field's own docblock for why\n * it is a different identifier from `conversionLabel`, not an alternate\n * spelling of it) and calls `ConversionUploadService.UploadClickConversions`\n * instead of relying on a visitor's browser to fire the tag.\n *\n * Same reasoning as `@getvitops/utils/crm`'s executors: credentials are a\n * structurally-typed shape the consumer's route supplies from env vars, never\n * config, and a failed upload is a `GoogleAdsUploadResult` to log or fold into\n * the notification email — never an exception, and never something that fails\n * the conversion request it's attached to. A lost ad report is not a lost\n * lead; the visitor has already submitted.\n *\n * **Structurally typed against Google's documented REST shape, not verified\n * against a live Ads account** — no developer-token/MCC access exists\n * anywhere in this toolchain's own setup to test against (the same blocker\n * `vitops ads provision` is waiting on). Same caveat, and the same reason, as\n * `@getvitops/utils/crm`'s Jobber executor: wrapped so a wrong guess about the\n * exact request/response shape degrades to a stated failure reason rather\n * than breaking. Re-verify against `googleads.googleapis.com`'s current API\n * version and `ClickConversion` message shape before depending on this in\n * production, and update this docblock with what was found.\n */\nimport { errorDetail, googleAccessToken, googleHeaders } from '../google/token.ts';\nimport type { GoogleOAuth } from '../google/token.ts';\n\n/** Bumped independently of everything else here — the Ads API deprecates\n * versions on its own rolling schedule. Last checked against Google's public\n * docs at the time this file was written; not re-verified since. */\nconst API_VERSION = 'v17';\n\nexport interface GoogleAdsCredentials {\n /** Issued against a Google Ads manager (MCC) account — a Google review, not\n * a self-service toggle. Never config. */\n developerToken: string;\n oauth: GoogleOAuth;\n /** The MCC's own (dashes-or-not) customer id — required when `customerId`\n * in the upload input is a client account managed under it, which is the\n * common case for an agency running this on a client's behalf. */\n loginCustomerId?: string | undefined;\n}\n\nexport interface GoogleAdsUploadInput {\n /** Google Ads customer id, as shown in the UI (`\"123-456-7890\"`) or bare\n * digits — either works, dashes are stripped before the call. */\n customerId: string;\n /** A numeric conversion action id, or a full\n * `customers/…/conversionActions/…` resource name. */\n conversionActionId: string;\n /** The click id captured on `_ac` — `getPrimaryClickId()`'s result. */\n clickId: { param: string; value: string };\n /** Epoch ms — converted to the Ads API's own\n * `\"yyyy-MM-dd HH:mm:ss+00:00\"` format. */\n at: number;\n conversionValue?: number | undefined;\n currencyCode?: string | undefined;\n orderId?: string | undefined;\n}\n\n/** Never thrown — an Ads API outage or a malformed request both come back as\n * `ok: false`, the same \"structured result, not an exception\" rule every\n * other executor in this toolchain follows. */\nexport interface GoogleAdsUploadResult {\n ok: boolean;\n reason?: string | undefined;\n code?: string | undefined;\n}\n\nfunction digitsOnly(id: string): string {\n return id.replace(/\\D/g, '');\n}\n\n/** A bare numeric id becomes a full resource name under `customerId`; a value\n * already shaped like one (the escape hatch, matching `txtRecord`'s `=`\n * check in `@getvitops/utils/ads`) passes through unchanged. */\nexport function conversionActionResourceName(\n customerId: string,\n conversionActionId: string,\n): string {\n if (conversionActionId.includes('customers/')) return conversionActionId;\n return `customers/${digitsOnly(customerId)}/conversionActions/${conversionActionId}`;\n}\n\n/** The Ads API's documented click-conversion datetime format, always\n * rendered in UTC — there is no per-account timezone lookup here to do\n * better, and UTC is unambiguous. */\nexport function toGoogleConversionDateTime(atMs: number): string {\n const d = new Date(atMs);\n const pad = (n: number): string => String(n).padStart(2, '0');\n return (\n `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ` +\n `${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}+00:00`\n );\n}\n\n/** The request field a click id param maps to — the API takes `gclid`/\n * `gbraid`/`wbraid` as distinct fields, not one generic \"click id\" field.\n * Anything else this toolchain's `PLATFORM_PARAMS` maps to Google (today,\n * only these three) falls back to `gclid`. */\nfunction clickIdField(param: string): 'gclid' | 'gbraid' | 'wbraid' {\n if (param === 'gbraid' || param === 'wbraid') return param;\n return 'gclid';\n}\n\n/**\n * Upload one click conversion via `ConversionUploadService.UploadClickConversions`.\n *\n * `partialFailure: true` is always sent, and a 200 response carrying\n * `partialFailureError` is treated as a failure, not a success — a single-\n * conversion batch makes \"partial\" and \"total\" failure the same case, and\n * Google Ads API responses are 200 for a partial failure by design (silently\n * treating that as success is exactly the trap `@getvitops/utils/crm`'s\n * Jobber executor documents for its own GraphQL transport).\n */\nexport async function uploadClickConversion(\n input: GoogleAdsUploadInput,\n credentials: GoogleAdsCredentials,\n fetchImpl: typeof fetch = fetch,\n): Promise<GoogleAdsUploadResult> {\n let token: string;\n try {\n token = await googleAccessToken({ kind: 'oauth', oauth: credentials.oauth }, fetchImpl);\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads token exchange failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n const customerId = digitsOnly(input.customerId);\n const url = `https://googleads.googleapis.com/${API_VERSION}/customers/${customerId}:uploadClickConversions`;\n\n const body = {\n conversions: [\n {\n conversionAction: conversionActionResourceName(customerId, input.conversionActionId),\n [clickIdField(input.clickId.param)]: input.clickId.value,\n conversionDateTime: toGoogleConversionDateTime(input.at),\n ...(input.conversionValue != null ? { conversionValue: input.conversionValue } : {}),\n ...(input.currencyCode ? { currencyCode: input.currencyCode } : {}),\n ...(input.orderId ? { orderId: input.orderId } : {}),\n },\n ],\n partialFailure: true,\n };\n\n let res: Response;\n try {\n res = await fetchImpl(url, {\n method: 'POST',\n headers: googleHeaders(token, {\n 'developer-token': credentials.developerToken,\n 'content-type': 'application/json',\n ...(credentials.loginCustomerId\n ? { 'login-customer-id': digitsOnly(credentials.loginCustomerId) }\n : {}),\n }),\n body: JSON.stringify(body),\n });\n } catch (err) {\n return {\n ok: false,\n reason: `Google Ads request failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n\n if (!res.ok) {\n return {\n ok: false,\n code: String(res.status),\n reason: await errorDetail(res, (status) =>\n status === 401\n ? 'Google Ads rejected the access token.'\n : status === 403\n ? 'Google Ads refused the request — check the developer token is approved and `login-customer-id` is set for an MCC-managed account.'\n : undefined,\n ),\n };\n }\n\n const json = (await res.json().catch(() => ({}))) as {\n partialFailureError?: { message?: string };\n };\n if (json.partialFailureError) {\n return {\n ok: false,\n reason: `Google Ads rejected the conversion: ${json.partialFailureError.message ?? 'no detail given'}`,\n };\n }\n\n return { ok: true };\n}\n\n/** A one-line delivery note, matching `describeCrmResult`'s shape — what\n * `conversion.ts` folds into the notification email's \"Delivery\" section. */\nexport function describeGoogleAdsOfflineResult(\n result: GoogleAdsUploadResult | null,\n): string | null {\n if (!result) return null;\n if (result.ok) return 'Reported to Google Ads (server-side)';\n return `⚠ Not reported to Google Ads: ${result.reason ?? 'unknown reason'}`;\n}\n","/**\n * Conversion notifications — plan, render, dispatch.\n *\n * The seam between \"a conversion happened\" and \"someone found out about it\".\n * A `ConversionEvent` from `@getvitops/utils/tracking` goes in; where it goes and\n * how it reads are config, not code at the call site.\n *\n * Three files, three jobs, matching `indexing/`:\n * - `plan.ts` decides everything, purely — which channels, which recipients,\n * and why anything is off.\n * - `render.ts` turns the event into prose, purely.\n * - `email.ts` executes, and decides nothing.\n *\n * `google-ads.ts` is a fourth file, added later, that does **not** follow the\n * three-file shape above: it isn't a `NotificationsConfig` channel `notify()`\n * plans and dispatches, it's a separate delivery keyed to `site.ads.google`,\n * wired in by `createConversionRoute`'s own `googleAdsOffline` option and\n * folded into the email's \"Delivery\" section exactly like `@getvitops/utils/\n * crm`'s `CrmResult` — see that module's `describeCrmResult` for the\n * precedent this follows (`describeGoogleAdsOfflineResult` here).\n *\n * ---\n *\n * **TODO — further channels.** Only `email` is implemented. The seam is\n * `NotificationsConfig` + a sender with `sendEmail`'s signature `(plan, message,\n * transport) => ChannelResult`; adding one should mean a new sender file, a new\n * branch in `planNotifications`, and a schema variant — touching neither\n * `ConversionEvent` nor the recipient cascade. Planned:\n * - `sms` — the same event rendered short. `render.ts` already separates\n * `describeEvent` from `renderEmail` for exactly this.\n * - `persist` — append to a store (D1, a portal log) the client reviews.\n * The generic `email`/`text`/`persist` helpers taking content + provider config\n * belong at that point, not before: one implemented channel is not enough to know\n * what the abstraction should be.\n */\nimport type { ConversionEvent } from '../tracking/types.ts';\nimport { logEmail, sendEmail } from './email.ts';\nimport { planNotifications } from './plan.ts';\nimport { renderEmail } from './render.ts';\nimport type { ChannelResult, EmailBinding, NotifyContext } from './types.ts';\n\nexport interface NotifyDeps {\n /**\n * The Workers `send_email` binding (`env.EMAIL`). Omit it and the notification\n * is printed instead — the dev path.\n */\n email?: EmailBinding | undefined;\n}\n\nexport interface NotifyResult {\n results: ChannelResult[];\n /** True when at least one channel delivered. */\n delivered: boolean;\n}\n\n/**\n * Notify every configured channel about a conversion.\n *\n * Channels are independent: one failing must not stop the others, and none of\n * them may throw into the request that produced the event. Every outcome —\n * delivered, skipped, failed — comes back as data for the caller to log.\n */\nexport async function notify(\n event: ConversionEvent,\n ctx: NotifyContext,\n deps: NotifyDeps = {},\n extra: { notes?: string[] | undefined } = {},\n): Promise<NotifyResult> {\n const plan = planNotifications(ctx);\n const results: ChannelResult[] = [];\n\n if (plan.email.enabled) {\n const message = renderEmail(event, { ...extra, actionUrl: ctx.notifications?.actionUrl });\n results.push(\n deps.email ? await sendEmail(plan.email, message, deps.email) : logEmail(plan.email, message),\n );\n } else {\n results.push({ channel: 'email', sent: false, reason: plan.email.skip ?? 'Not configured.' });\n }\n\n return { results, delivered: results.some((r) => r.sent) };\n}\n\nexport {\n DEFAULT_EMAIL_BINDING,\n normalizeEmailChannel,\n planNotifications,\n resolveRecipient,\n resolveSender,\n} from './plan.ts';\nexport { describeEvent, renderEmail } from './render.ts';\nexport { logEmail, sendEmail } from './email.ts';\nexport {\n conversionActionResourceName,\n describeGoogleAdsOfflineResult,\n toGoogleConversionDateTime,\n uploadClickConversion,\n} from './google-ads.ts';\nexport type {\n GoogleAdsCredentials,\n GoogleAdsUploadInput,\n GoogleAdsUploadResult,\n} from './google-ads.ts';\nexport type {\n ChannelPlan,\n ChannelResult,\n EmailBinding,\n EmailChannelConfig,\n EmailPlan,\n NotificationPlan,\n NotificationsConfig,\n NotifyContext,\n RenderedMessage,\n} from './types.ts';\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;AACF,CAAC;AAED,SAAS,OAAO,OAAoC;CAClD,MAAM,OAAQ,OAAqC;CACnD,OAAO,OAAO,SAAS,WAAW,OAAO;AAC3C;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;AAsBA,MAAM,QAAQ,OAA8B,IAAI,SAAS,MAAM,WAAW,GAAG,EAAE,CAAC;;AAGhF,MAAM,eAAe;;;;;;;;AASrB,eAAe,YAAe,MAAkB,IAAwB;CACtE,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI;CACJ,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CACxB,MACA,IAAI,SAAgB,GAAG,WAAW;GAChC,QAAQ,iBAAiB;IACvB,MAAM,sBAAM,IAAI,MAAM,uBAAuB,GAAG,IAAI;IACpD,IAAI,OAAO;IACX,OAAO,GAAG;GACZ,GAAG,EAAE;EACP,CAAC,CACH,CAAC;CACH,UAAU;EACR,IAAI,UAAU,QAAW,aAAa,KAAK;CAC7C;AACF;;;;;;;;;AAUA,eAAsB,UACpB,MACA,SACA,SACA,UAA4B,CAAC,GACL;CACxB,IAAI,CAAC,KAAK,WAAW,CAAC,KAAK,MAAM,CAAC,KAAK,MACrC,OAAO;EAAE,SAAS;EAAS,MAAM;EAAO,QAAQ,KAAK,QAAQ;CAAuB;CAGtF,MAAM,WAAW,KAAK,IAAI,GAAG,QAAQ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K,OAAO,OAAO,CAC9F;CACF,OACE,QAAQ,KAAK;EAAE,SAAS;EAAS,MAAM;EAAO,QAAQ,KAAK,MAAM,QAAQ;CAAkB,CAAC;CAG9F,OAAO;EAAE;EAAS,WAAW,QAAQ,MAAM,MAAM,EAAE,IAAI;CAAE;AAC3D"}
@@ -1,7 +1,28 @@
1
- import { n as findZoneId, r as listApexTxt, t as createApexTxt } from "../cloudflare-BiK61Oq4.mjs";
2
- import { i as GoogleOAuth, n as GoogleAuthLike } from "../token-DmmoQ7um.mjs";
3
- import { a as StepPlan, c as formatSummary, d as plan, f as planDomain, g as OnboardingConfig, h as DomainState, i as StepAction, l as hasDrift, m as DomainSetup, n as DomainResult, o as backoffSchedule, p as siteUrlFor, r as OnboardingPlan, s as formatPlan, t as DomainPlan, u as ownerUnion } from "../plan-Hq8Pb0Uw.mjs";
4
- //#region src/onboarding/google.d.ts
1
+ import { i as GoogleOAuth, n as GoogleAuthLike } from "../token-CHR1O4w5.mjs";
2
+ import { a as StepPlan, c as formatSummary, d as plan, f as planDomain, g as OnboardingConfig, h as DomainState, i as StepAction, l as hasDrift, m as DomainSetup, n as DomainResult, o as backoffSchedule, p as siteUrlFor, r as OnboardingPlan, s as formatPlan, t as DomainPlan, u as ownerUnion } from "../plan-CH3Wt5ZV.mjs";
3
+ /** Find the zone id for a domain (`GET /zones?name=`). */
4
+ export declare function findZoneId(token: string, domain: string, fetchImpl?: typeof fetch): Promise<{
5
+ ok: boolean;
6
+ status: number;
7
+ zoneId?: string;
8
+ message?: string;
9
+ }>;
10
+ /** List the apex TXT record contents for a zone. */
11
+ export declare function listApexTxt(token: string, zoneId: string, domain: string, fetchImpl?: typeof fetch): Promise<{
12
+ ok: boolean;
13
+ status: number;
14
+ contents: string[];
15
+ message?: string;
16
+ }>;
17
+ /**
18
+ * Create an apex TXT record. **Create only** — never called when one already
19
+ * exists (the planner decides that), and there is no sibling that edits or removes.
20
+ */
21
+ export declare function createApexTxt(token: string, zoneId: string, domain: string, content: string, fetchImpl?: typeof fetch): Promise<{
22
+ ok: boolean;
23
+ status: number;
24
+ message?: string;
25
+ }>;
5
26
  /** Exchange a user OAuth refresh token for a short-lived access token. */
6
27
  export declare function refreshTokenGrant(oauth: GoogleOAuth, fetchImpl?: typeof fetch): Promise<string>;
7
28
  /**
@@ -71,6 +92,5 @@ export declare function addSite(auth: GoogleAuthLike, siteUrl: string, fetchImpl
71
92
  status: number;
72
93
  message?: string;
73
94
  }>;
74
- //#endregion
75
- export { type DomainPlan, type DomainResult, type DomainSetup, type DomainState, type GoogleOAuth, type OnboardingConfig, type OnboardingPlan, type StepAction, type StepPlan, backoffSchedule, createApexTxt, findZoneId, formatPlan, formatSummary, hasDrift, listApexTxt, ownerUnion, plan, planDomain, siteUrlFor };
95
+ export { type DomainPlan, type DomainResult, type DomainSetup, type DomainState, type GoogleOAuth, type OnboardingConfig, type OnboardingPlan, type StepAction, type StepPlan, backoffSchedule, formatPlan, formatSummary, hasDrift, ownerUnion, plan, planDomain, siteUrlFor };
76
96
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/onboarding/google.ts"],"mappings":";;;;;wBA+BgB,kBACd,OAAO,aACP,mBAAkB,QACjB;;;;;;;;wBAamB,qBACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAgB;;;;;;;;;;wBAoBpC,eACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EACD;EACA;EACA;EACA;EACA;EACA;;;wBAwBoB,kBACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAa;EAAkB;;;;;;;;;wBAuBnD,aACpB,MAAM,gBACN,YACA,gBACA,kBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;;;wBAWpB,QACpB,MAAM,gBACN,iBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAiB;;;;;;;;wBAerC,QACpB,MAAM,gBACN,iBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/onboarding/cloudflare.ts","../../src/onboarding/google.ts"],"mappings":";;;wBA8BsB,WACpB,eACA,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAiB;;;wBAsBrC,YACpB,eACA,gBACA,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAoB;;;;;;wBAiBxC,cACpB,eACA,gBACA,gBACA,iBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;;;wBCrD1B,kBACd,OAAO,aACP,mBAAkB,QACjB;;;;;;;;wBAamB,qBACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAgB;;;;;;;;;;wBAoBpC,eACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EACD;EACA;EACA;EACA;EACA;EACA;;;wBAwBoB,kBACpB,MAAM,gBACN,gBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAa;EAAkB;;;;;;;;;wBAuBnD,aACpB,MAAM,gBACN,YACA,gBACA,kBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;;;wBAWpB,QACpB,MAAM,gBACN,iBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB;EAAiB;;;;;;;;wBAerC,QACpB,MAAM,gBACN,iBACA,mBAAkB,QACjB;EAAU;EAAa;EAAgB"}