@ampless/plugin-cookie-consent 0.1.0-alpha.1 → 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -31,7 +31,7 @@ export default defineConfig({
31
31
  // cookie-consent を最初に登録し、後続の analytics プラグインが
32
32
  // window.amplessConsent を参照できるようにする。
33
33
  cookieConsentPlugin(),
34
- // analyticsGa4Plugin({ ... }), // PR D 以降
34
+ // analyticsGa4Plugin({ measurementId: 'G-XXXXXXXX', consentCategory: 'analytics' }),
35
35
  ],
36
36
  })
37
37
  ```
@@ -46,9 +46,10 @@ export default defineConfig({
46
46
 
47
47
  | キー | 型 | デフォルト | 備考 |
48
48
  |---|---|---|---|
49
- | `bannerText` | textarea | `'このサイトは…'` | バナー上部に表示するメッセージ。 |
49
+ | `bannerText` | textarea | `'This site uses cookies…'` | バナー上部に表示するメッセージ。デフォルトは英語、日本語サイトでは `/admin/plugins` から日本語に上書きします。 |
50
50
  | `acceptLabel` | text | `'Accept all'` | 「すべて同意」ボタンのラベル。 |
51
51
  | `rejectLabel` | text | `'Reject non-essential'` | 「拒否」ボタンのラベル。 |
52
+ | `saveLabel` | text | `'Save selected'` | 個別トグルの状態をそのまま保存するボタンのラベル。「全て同意」「全て拒否」とは別の選択肢。 |
52
53
  | `position` | select | `'bottom'` | `'bottom'` / `'top'` / `'modal'`。 |
53
54
  | `categories` | repeatable | `[]` | 同意カテゴリのリスト。 |
54
55
 
@@ -97,9 +98,9 @@ analytics の gate には `has`、バナーが「再プロンプトすべきか
97
98
 
98
99
  詳細な API 仕様と analytics 側の consume パターンは [`docs/architecture/08-plugin-architecture.ja.md` — Consent Convention](https://github.com/heavymoons/ampless/blob/main/docs/architecture/08-plugin-architecture.ja.md#consent-convention) を参照してください。
99
100
 
100
- ## analytics プラグインとの組み合わせ(PR D 以降)
101
+ ## analytics プラグインとの組み合わせ
101
102
 
102
- GA4 / GTM / Plausible プラグインに `consentCategory` サポートが追加された後(Phase 3b PR D)、次のように組み合わせられます:
103
+ 公式バンドルの `@ampless/plugin-analytics-ga4` / `@ampless/plugin-gtm` / `@ampless/plugin-plausible` はいずれも `consentCategory` をサポートしています:
103
104
 
104
105
  ```ts
105
106
  plugins: [
@@ -109,9 +110,7 @@ plugins: [
109
110
  ]
110
111
  ```
111
112
 
112
- `consentCategory` を設定した analytics プラグインは、訪問者が該当カテゴリに同意するまで発火しません。`window.amplessConsent` がインストールされていない場合(`cookieConsentPlugin` が `cms.config.ts` に未登録の場合)、トラッキングは**永久に発火しません** — これは意図した fail-closed 設計です。
113
-
114
- > **注意:** GA4 / GTM / Plausible の `consentCategory` 対応は Phase 3b PR D で実装予定(未リリース)です。
113
+ `consentCategory` を設定した analytics プラグインは、訪問者が該当カテゴリに同意するまで発火しません。`window.amplessConsent` がインストールされていない場合(`cookieConsentPlugin` が `cms.config.ts` に未登録の場合)、トラッキングは**永久に発火しません** — これは意図した fail-closed 設計です(5 秒後に `console.warn` で設定ミスを通知)。
115
114
 
116
115
  ## トラストレベル
117
116
 
package/README.md CHANGED
@@ -31,7 +31,7 @@ export default defineConfig({
31
31
  // List cookie-consent FIRST so its window.amplessConsent API is
32
32
  // available when subsequent analytics plugins initialise.
33
33
  cookieConsentPlugin(),
34
- // analyticsGa4Plugin({ ... }), // PR D — coming soon
34
+ // analyticsGa4Plugin({ measurementId: 'G-XXXXXXXX', consentCategory: 'analytics' }),
35
35
  ],
36
36
  })
37
37
  ```
@@ -49,6 +49,7 @@ Configure from `/admin/plugins → Cookie Consent`:
49
49
  | `bannerText` | textarea | `'This site uses cookies…'` | Message shown at the top of the banner. |
50
50
  | `acceptLabel` | text | `'Accept all'` | Label for the "accept all" button. |
51
51
  | `rejectLabel` | text | `'Reject non-essential'` | Label for the "reject" button. |
52
+ | `saveLabel` | text | `'Save selected'` | Label for the button that persists the per-category toggle state as the visitor checked it. |
52
53
  | `position` | select | `'bottom'` | `'bottom'` / `'top'` / `'modal'`. |
53
54
  | `categories` | repeatable | `[]` | List of consent categories. |
54
55
 
@@ -97,9 +98,9 @@ Consent state is persisted in `localStorage` under the key `'ampless:consent'` a
97
98
 
98
99
  For the full API specification and the analytics consume pattern see [`docs/architecture/08-plugin-architecture.md` — Consent Convention](https://github.com/heavymoons/ampless/blob/main/docs/architecture/08-plugin-architecture.md#consent-convention).
99
100
 
100
- ## Combining with analytics plugins (coming in PR D)
101
+ ## Combining with analytics plugins
101
102
 
102
- Once GA4, GTM, and Plausible plugins add `consentCategory` support (Phase 3b PR D), you can gate them like this:
103
+ The bundled `@ampless/plugin-analytics-ga4`, `@ampless/plugin-gtm`, and `@ampless/plugin-plausible` plugins all support `consentCategory`:
103
104
 
104
105
  ```ts
105
106
  plugins: [
@@ -109,9 +110,7 @@ plugins: [
109
110
  ]
110
111
  ```
111
112
 
112
- With `consentCategory` set, the analytics plugin will not fire until the visitor grants consent for that category. If `window.amplessConsent` is not installed (i.e. `cookieConsentPlugin` is missing from `cms.config.ts`), tracking will **never fire** — this is the intended fail-closed design.
113
-
114
- > **Note:** `consentCategory` support in GA4, GTM, and Plausible is implemented in Phase 3b PR D (not yet released).
113
+ With `consentCategory` set, the analytics plugin will not fire until the visitor grants consent for that category. If `window.amplessConsent` is not installed (i.e. `cookieConsentPlugin` is missing from `cms.config.ts`), tracking will **never fire** — this is the intended fail-closed design (a `console.warn` surfaces the misconfiguration after 5s).
115
114
 
116
115
  ## Trust level
117
116
 
package/dist/index.js CHANGED
@@ -71,6 +71,20 @@ function cookieConsentPlugin(options = {}) {
71
71
  },
72
72
  default: "Reject non-essential"
73
73
  },
74
+ {
75
+ type: "text",
76
+ key: "saveLabel",
77
+ maxLength: 50,
78
+ label: {
79
+ en: "Save-selected button label",
80
+ ja: "\u300C\u9078\u629E\u3092\u4FDD\u5B58\u300D\u30DC\u30BF\u30F3\u306E\u30E9\u30D9\u30EB"
81
+ },
82
+ description: {
83
+ en: "Label for the button that saves the per-category toggle state without granting (or rejecting) everything.",
84
+ ja: "\u500B\u5225\u30C8\u30B0\u30EB\u306E\u72B6\u614B\u3092\u305D\u306E\u307E\u307E\u4FDD\u5B58\u3059\u308B\u30DC\u30BF\u30F3\u306E\u30E9\u30D9\u30EB\u3002\u300C\u5168\u3066\u540C\u610F\u300D\u300C\u5168\u3066\u62D2\u5426\u300D\u3068\u306F\u5225\u306E\u9078\u629E\u80A2\u3002"
85
+ },
86
+ default: "Save selected"
87
+ },
74
88
  {
75
89
  type: "select",
76
90
  key: "position",
@@ -240,10 +254,12 @@ function cookieConsentPlugin(options = {}) {
240
254
  const bannerText = (ctx.setting("bannerText") ?? "").trim() || "This site uses cookies to enhance your browsing experience. You can manage your preferences below.";
241
255
  const acceptLabel = (ctx.setting("acceptLabel") ?? "").trim() || "Accept all";
242
256
  const rejectLabel = (ctx.setting("rejectLabel") ?? "").trim() || "Reject non-essential";
257
+ const saveLabel = (ctx.setting("saveLabel") ?? "").trim() || "Save selected";
243
258
  const position = ctx.setting("position") ?? "bottom";
244
259
  const bannerTextJs = escapeJsString(bannerText);
245
260
  const acceptLabelJs = escapeJsString(acceptLabel);
246
261
  const rejectLabelJs = escapeJsString(rejectLabel);
262
+ const saveLabelJs = escapeJsString(saveLabel);
247
263
  const nonEssentialJson = JSON.stringify(
248
264
  nonEssential.map((c) => ({
249
265
  id: c.id,
@@ -289,6 +305,7 @@ function cookieConsentPlugin(options = {}) {
289
305
  ` var bannerText = '${bannerTextJs}';`,
290
306
  ` var acceptLabel = '${acceptLabelJs}';`,
291
307
  ` var rejectLabel = '${rejectLabelJs}';`,
308
+ ` var saveLabel = '${saveLabelJs}';`,
292
309
  "",
293
310
  " // Build banner DOM outside React tree (avoids hydration conflicts).",
294
311
  " var container = document.createElement('div');",
@@ -375,7 +392,7 @@ function cookieConsentPlugin(options = {}) {
375
392
  " // Save selected (granular toggle state).",
376
393
  " var saveBtn = document.createElement('button');",
377
394
  " saveBtn.style.cssText = btnBase + 'background:#fff;color:#111;';",
378
- " saveBtn.textContent = 'Save selected';",
395
+ " saveBtn.textContent = saveLabel;",
379
396
  " saveBtn.addEventListener('click', function() {",
380
397
  " nonEssential.forEach(function(cat) {",
381
398
  " if (window.amplessConsent) window.amplessConsent.set(cat.id, toggleState[cat.id] === true);",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampless/plugin-cookie-consent",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "description": "Cookie consent banner plugin for ampless — installs window.amplessConsent API and renders a configurable consent banner",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "homepage": "https://github.com/heavymoons/ampless/tree/main/packages/plugin-cookie-consent#readme",
27
27
  "bugs": "https://github.com/heavymoons/ampless/issues",
28
28
  "dependencies": {
29
- "ampless": "1.0.0-alpha.26"
29
+ "ampless": "1.0.0-alpha.27"
30
30
  },
31
31
  "keywords": [
32
32
  "ampless",