@eldrajs/theme-nuxt 0.3.4 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,11 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - **Campaign landings are captured (WS-546).** A client plugin calls `@eldrajs/sdk`'s
9
+ `captureCampaignAttribution` on the first page and after every navigation, so a theme's cart adds
10
+ carry the campaign a visitor came from (`utm_*` tags only, one `localStorage` key, 30 days). New
11
+ option `campaignAttribution: false` turns it off.
12
+
8
13
  - **The site profile carries the registered company.** `readSiteProfile`, `resolveSiteProfile` and
9
14
  `useSiteProfile()` gain `legal` (`{name, kennitala, streetAddress, postalCode, city,
10
15
  countryCode}` or `null`), from `GET /site/v1/site-profile` since public contract 5.1.0; a
package/dist/module.d.mts CHANGED
@@ -95,6 +95,8 @@ interface ModuleOptions {
95
95
  * proxy on the site's own domain. No cookie or storage identifier is written.
96
96
  */
97
97
  analytics?: AnalyticsOption;
98
+ /** Keeps a landing's campaign `utm_*` tags for cart adds once the visitor agrees (docs/themes.md, Campaign attribution); `false` leaves it out. */
99
+ campaignAttribution?: boolean;
98
100
  }
99
101
  declare const eldraModule: NuxtModule<ModuleOptions>;
100
102
 
package/dist/module.d.ts CHANGED
@@ -95,6 +95,8 @@ interface ModuleOptions {
95
95
  * proxy on the site's own domain. No cookie or storage identifier is written.
96
96
  */
97
97
  analytics?: AnalyticsOption;
98
+ /** Keeps a landing's campaign `utm_*` tags for cart adds once the visitor agrees (docs/themes.md, Campaign attribution); `false` leaves it out. */
99
+ campaignAttribution?: boolean;
98
100
  }
99
101
  declare const eldraModule: NuxtModule<ModuleOptions>;
100
102
 
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.13.0"
6
6
  },
7
- "version": "0.3.4",
7
+ "version": "0.4.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -128,6 +128,9 @@ const eldraModule = defineNuxtModule({
128
128
  const buildToken = (process.env.ELDRA_BUILD_TOKEN ?? "").trim();
129
129
  addPlugin(resolver.resolve("./runtime/plugin"));
130
130
  addPlugin(resolver.resolve("./runtime/analyticsPlugin"));
131
+ if (options.campaignAttribution !== false) {
132
+ addPlugin({ src: resolver.resolve("./runtime/attributionPlugin"), mode: "client" });
133
+ }
131
134
  addImports([
132
135
  {
133
136
  name: "useEldraBuildToken",
@@ -0,0 +1,9 @@
1
+ declare global {
2
+ interface Window {
3
+ /** The visitor's answer from the site's consent tool; the kit keeps campaign tags only while it is `true`. */
4
+ eldraCampaignAttributionConsent?: boolean;
5
+ }
6
+ }
7
+ /** Notes the campaign a visitor landed from and keeps it, for `@eldrajs/sdk`'s `cart.addItem`, once they agree. */
8
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
9
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import {
2
+ captureCampaignAttribution,
3
+ grantCampaignAttributionConsent,
4
+ withdrawCampaignAttributionConsent
5
+ } from "@eldrajs/sdk";
6
+ import { defineNuxtPlugin, useRouter } from "nuxt/app";
7
+ const CONSENT_EVENT = "eldra:campaign-attribution-consent";
8
+ function applyConsent() {
9
+ if (window.eldraCampaignAttributionConsent === true) grantCampaignAttributionConsent();
10
+ else if (window.eldraCampaignAttributionConsent === false) withdrawCampaignAttributionConsent();
11
+ }
12
+ export default defineNuxtPlugin({
13
+ name: "eldra-campaign-attribution",
14
+ setup() {
15
+ applyConsent();
16
+ window.addEventListener(CONSENT_EVENT, applyConsent);
17
+ captureCampaignAttribution(window.location.href);
18
+ useRouter().afterEach((to, _from, failure) => {
19
+ if (!failure) captureCampaignAttribution(to.fullPath);
20
+ });
21
+ }
22
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-nuxt",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Nuxt module for Eldra themes: wires @eldrajs/vite-plugin-theme, the gateway client, draft overlays and the Studio preview bridge into a Nuxt 4 site.",
5
5
  "keywords": [
6
6
  "cms",
@@ -50,10 +50,10 @@
50
50
  "dependencies": {
51
51
  "@nuxt/kit": "^4.0.0",
52
52
  "defu": "^6.1.4",
53
- "@eldrajs/sdk": "^0.3.2",
53
+ "@eldrajs/sdk": "^0.4.0",
54
54
  "@eldrajs/theme-vue": "^0.2.3",
55
- "@eldrajs/vite-plugin-theme": "^0.3.2",
56
- "@eldrajs/theme-core": "^0.3.2"
55
+ "@eldrajs/theme-core": "^0.3.2",
56
+ "@eldrajs/vite-plugin-theme": "^0.3.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@nuxt/module-builder": "^0.8.4",