@walkeros/web-destination-piwikpro 0.3.1 → 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/dist/dev.d.mts ADDED
@@ -0,0 +1,114 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$2 } from '@walkeros/core';
4
+ import { DestinationWeb } from '@walkeros/web-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ appId: z.ZodString;
8
+ url: z.ZodString;
9
+ linkTracking: z.ZodDefault<z.ZodBoolean>;
10
+ }, z.core.$strip>;
11
+ type Settings = z.infer<typeof SettingsSchema>;
12
+
13
+ declare const MappingSchema: z.ZodObject<{
14
+ goalId: z.ZodString;
15
+ goalValue: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ type Mapping$1 = z.infer<typeof MappingSchema>;
18
+
19
+ declare const settings: _walkeros_core_dev.JSONSchema;
20
+ declare const mapping$1: _walkeros_core_dev.JSONSchema;
21
+
22
+ declare const index$1_MappingSchema: typeof MappingSchema;
23
+ type index$1_Settings = Settings;
24
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
25
+ declare const index$1_settings: typeof settings;
26
+ declare namespace index$1 {
27
+ export { type Mapping$1 as Mapping, index$1_MappingSchema as MappingSchema, type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, mapping$1 as mapping, index$1_settings as settings };
28
+ }
29
+
30
+ declare global {
31
+ interface Window {
32
+ _paq?: Array<unknown>;
33
+ }
34
+ }
35
+ interface Mapping {
36
+ goalId?: string;
37
+ goalValue?: string;
38
+ }
39
+ interface Env extends DestinationWeb.Env {
40
+ window: {
41
+ _paq: Array<unknown>;
42
+ };
43
+ document: {
44
+ createElement: (tagName: string) => {
45
+ type: string;
46
+ src: string;
47
+ async?: boolean;
48
+ defer?: boolean;
49
+ };
50
+ head: {
51
+ appendChild: (node: unknown) => void;
52
+ };
53
+ };
54
+ }
55
+ type Rule = Mapping$2.Rule<Mapping>;
56
+
57
+ /**
58
+ * Example environment configurations for PiwikPro destination
59
+ *
60
+ * These environments provide standardized mock structures for testing
61
+ * and development without requiring external dependencies.
62
+ */
63
+ declare const init: Env | undefined;
64
+ declare const push: Env;
65
+
66
+ declare const env_init: typeof init;
67
+ declare const env_push: typeof push;
68
+ declare namespace env {
69
+ export { env_init as init, env_push as push };
70
+ }
71
+
72
+ declare function ecommerceOrder$1(): unknown[];
73
+ declare function ecommerceAddToCart$1(): unknown[];
74
+ declare function ecommerceProductDetailView$1(): unknown[];
75
+ declare function ecommerceCartUpdate$1(): unknown[];
76
+
77
+ declare namespace events {
78
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
79
+ }
80
+
81
+ declare const ecommerceOrder: Rule;
82
+ declare const ecommerceAddToCart: Rule;
83
+ declare const ecommerceProductDetailView: Rule;
84
+ declare const ecommerceCartUpdate: Rule;
85
+ declare const config: {
86
+ order: {
87
+ complete: Rule;
88
+ };
89
+ product: {
90
+ add: Rule;
91
+ view: Rule;
92
+ };
93
+ cart: {
94
+ view: Rule;
95
+ };
96
+ };
97
+
98
+ declare const mapping_config: typeof config;
99
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
100
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
101
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
102
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
103
+ declare namespace mapping {
104
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
105
+ }
106
+
107
+ declare const index_env: typeof env;
108
+ declare const index_events: typeof events;
109
+ declare const index_mapping: typeof mapping;
110
+ declare namespace index {
111
+ export { index_env as env, index_events as events, index_mapping as mapping };
112
+ }
113
+
114
+ export { index as examples, index$1 as schemas };
package/dist/dev.d.ts ADDED
@@ -0,0 +1,114 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$2 } from '@walkeros/core';
4
+ import { DestinationWeb } from '@walkeros/web-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ appId: z.ZodString;
8
+ url: z.ZodString;
9
+ linkTracking: z.ZodDefault<z.ZodBoolean>;
10
+ }, z.core.$strip>;
11
+ type Settings = z.infer<typeof SettingsSchema>;
12
+
13
+ declare const MappingSchema: z.ZodObject<{
14
+ goalId: z.ZodString;
15
+ goalValue: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ type Mapping$1 = z.infer<typeof MappingSchema>;
18
+
19
+ declare const settings: _walkeros_core_dev.JSONSchema;
20
+ declare const mapping$1: _walkeros_core_dev.JSONSchema;
21
+
22
+ declare const index$1_MappingSchema: typeof MappingSchema;
23
+ type index$1_Settings = Settings;
24
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
25
+ declare const index$1_settings: typeof settings;
26
+ declare namespace index$1 {
27
+ export { type Mapping$1 as Mapping, index$1_MappingSchema as MappingSchema, type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, mapping$1 as mapping, index$1_settings as settings };
28
+ }
29
+
30
+ declare global {
31
+ interface Window {
32
+ _paq?: Array<unknown>;
33
+ }
34
+ }
35
+ interface Mapping {
36
+ goalId?: string;
37
+ goalValue?: string;
38
+ }
39
+ interface Env extends DestinationWeb.Env {
40
+ window: {
41
+ _paq: Array<unknown>;
42
+ };
43
+ document: {
44
+ createElement: (tagName: string) => {
45
+ type: string;
46
+ src: string;
47
+ async?: boolean;
48
+ defer?: boolean;
49
+ };
50
+ head: {
51
+ appendChild: (node: unknown) => void;
52
+ };
53
+ };
54
+ }
55
+ type Rule = Mapping$2.Rule<Mapping>;
56
+
57
+ /**
58
+ * Example environment configurations for PiwikPro destination
59
+ *
60
+ * These environments provide standardized mock structures for testing
61
+ * and development without requiring external dependencies.
62
+ */
63
+ declare const init: Env | undefined;
64
+ declare const push: Env;
65
+
66
+ declare const env_init: typeof init;
67
+ declare const env_push: typeof push;
68
+ declare namespace env {
69
+ export { env_init as init, env_push as push };
70
+ }
71
+
72
+ declare function ecommerceOrder$1(): unknown[];
73
+ declare function ecommerceAddToCart$1(): unknown[];
74
+ declare function ecommerceProductDetailView$1(): unknown[];
75
+ declare function ecommerceCartUpdate$1(): unknown[];
76
+
77
+ declare namespace events {
78
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
79
+ }
80
+
81
+ declare const ecommerceOrder: Rule;
82
+ declare const ecommerceAddToCart: Rule;
83
+ declare const ecommerceProductDetailView: Rule;
84
+ declare const ecommerceCartUpdate: Rule;
85
+ declare const config: {
86
+ order: {
87
+ complete: Rule;
88
+ };
89
+ product: {
90
+ add: Rule;
91
+ view: Rule;
92
+ };
93
+ cart: {
94
+ view: Rule;
95
+ };
96
+ };
97
+
98
+ declare const mapping_config: typeof config;
99
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
100
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
101
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
102
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
103
+ declare namespace mapping {
104
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
105
+ }
106
+
107
+ declare const index_env: typeof env;
108
+ declare const index_events: typeof events;
109
+ declare const index_mapping: typeof mapping;
110
+ declare namespace index {
111
+ export { index_env as env, index_events as events, index_mapping as mapping };
112
+ }
113
+
114
+ export { index as examples, index$1 as schemas };
package/dist/dev.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,c=(e,a)=>{for(var r in a)t(e,r,{get:a[r],enumerable:!0})},d={};c(d,{examples:()=>g,schemas:()=>n}),module.exports=(e=d,((e,c,d,n)=>{if(c&&"object"==typeof c||"function"==typeof c)for(let i of r(c))o.call(e,i)||i===d||t(e,i,{get:()=>c[i],enumerable:!(n=a(c,i))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};c(n,{MappingSchema:()=>s,SettingsSchema:()=>p,mapping:()=>v,settings:()=>l});var i=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),p=m.z.object({appId:m.z.string().min(1).describe("ID of the Piwik PRO site (like XXX-XXX-XXX-XXX-XXX)"),url:m.z.string().url().describe("URL of your Piwik PRO account (like https://your_account_name.piwik.pro/)"),linkTracking:m.z.boolean().default(!1).describe("Enables/Disables download and outlink tracking")}),u=require("@walkeros/core/dev"),s=u.z.object({goalId:u.z.string().describe("ID to count the event as a goal (like 1)"),goalValue:u.z.string().describe("Property to be used as the goal value (like data.value)").optional()}),l=(0,i.zodToSchema)(p),v=(0,i.zodToSchema)(s),g={};c(g,{env:()=>y,events:()=>f,mapping:()=>P});var y={};c(y,{init:()=>w,push:()=>b});var w={window:{_paq:void 0},document:{createElement:()=>({type:"",src:"",async:!1,defer:!1}),head:{appendChild:()=>{}}}},b={window:{_paq:[]},document:{createElement:()=>({type:"",src:"",async:!1,defer:!1}),head:{appendChild:()=>{}}}},f={};c(f,{ecommerceAddToCart:()=>E,ecommerceCartUpdate:()=>X,ecommerceOrder:()=>C,ecommerceProductDetailView:()=>O});var h=require("@walkeros/core");function k(e){return{sku:e.data.id,name:e.data.name,price:e.data.price,quantity:1,variant:e.data.color,customDimensions:{1:e.data.size}}}function C(){const e=(0,h.getEvent)("order complete");return[["ecommerceOrder",e.nested.filter(e=>"product"===e.entity).map(k),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]}function E(){return[["ecommerceAddToCart",[k((0,h.getEvent)("product add")),,],{currencyCode:"EUR"}]]}function O(){return[["ecommerceProductDetailView",[k((0,h.getEvent)("product view")),,],{currencyCode:"EUR"}]]}function X(){const e=(0,h.getEvent)("cart view");return[["ecommerceCartUpdate",e.nested.filter(e=>"product"===e.entity).map(k),e.data.value,{currencyCode:"EUR"}]]}var P={};c(P,{config:()=>T,ecommerceAddToCart:()=>D,ecommerceCartUpdate:()=>q,ecommerceOrder:()=>R,ecommerceProductDetailView:()=>j});var U=require("@walkeros/core"),z={sku:"data.id",name:"data.name",price:"data.price",quantity:{value:1},variant:{key:"data.color"},customDimensions:{map:{1:"data.size"}}},R={name:"ecommerceOrder",data:{set:[{loop:["nested",{condition:e=>(0,U.isObject)(e)&&"product"===e.entity,map:z}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},D={name:"ecommerceAddToCart",data:{set:[{set:[{map:z}]},{map:{currencyCode:{value:"EUR"}}}]}},j={name:"ecommerceProductDetailView",data:{set:[{set:[{map:z}]},{map:{currencyCode:{value:"EUR"}}}]}},q={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:e=>(0,U.isObject)(e)&&"product"===e.entity,map:z}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},T={order:{complete:R},product:{add:D,view:j},cart:{view:q}};//# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n appId: z\n .string()\n .min(1)\n .describe('ID of the Piwik PRO site (like XXX-XXX-XXX-XXX-XXX)'),\n url: z\n .string()\n .url()\n .describe(\n 'URL of your Piwik PRO account (like https://your_account_name.piwik.pro/)',\n ),\n linkTracking: z\n .boolean()\n .default(false)\n .describe('Enables/Disables download and outlink tracking'),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n goalId: z.string().describe('ID to count the event as a goal (like 1)'),\n goalValue: z\n .string()\n .describe('Property to be used as the goal value (like data.value)')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for PiwikPro destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nexport const init: Env | undefined = {\n window: {\n _paq: undefined as unknown as Env['window']['_paq'],\n },\n document: {\n createElement: () => ({\n type: '',\n src: '',\n async: false,\n defer: false,\n }),\n head: { appendChild: () => {} },\n },\n};\n\nexport const push: Env = {\n window: {\n _paq: [] as unknown[],\n },\n document: {\n createElement: () => ({\n type: '',\n src: '',\n async: false,\n defer: false,\n }),\n head: { appendChild: () => {} },\n },\n};\n","import type { WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\nfunction getProduct(entity: WalkerOS.Entity | WalkerOS.Event) {\n return {\n sku: entity.data.id,\n name: entity.data.name,\n price: entity.data.price,\n quantity: 1,\n variant: entity.data.color,\n customDimensions: {\n 1: entity.data.size,\n },\n };\n}\n\nexport function ecommerceOrder(): unknown[] {\n const event = getEvent('order complete');\n\n return [\n [\n 'ecommerceOrder',\n event.nested.filter((item) => item.entity === 'product').map(getProduct),\n {\n orderId: event.data.id,\n grandTotal: event.data.total,\n tax: event.data.taxes,\n shipping: event.data.shipping,\n },\n { currencyCode: 'EUR' },\n ],\n ];\n}\n\nexport function ecommerceAddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n ['ecommerceAddToCart', [getProduct(event), ,], { currencyCode: 'EUR' }],\n ];\n}\n\nexport function ecommerceProductDetailView(): unknown[] {\n const event = getEvent('product view');\n\n return [\n [\n 'ecommerceProductDetailView',\n [getProduct(event), ,],\n { currencyCode: 'EUR' },\n ],\n ];\n}\n\nexport function ecommerceCartUpdate(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n [\n 'ecommerceCartUpdate',\n event.nested.filter((item) => item.entity === 'product').map(getProduct),\n event.data.value,\n { currencyCode: 'EUR' },\n ],\n ];\n}\n","import type { DestinationPiwikPro } from '..';\nimport { isObject } from '@walkeros/core';\n\nconst productMap = {\n sku: 'data.id',\n name: 'data.name',\n price: 'data.price',\n quantity: { value: 1 },\n variant: { key: 'data.color' },\n customDimensions: {\n map: {\n 1: 'data.size',\n },\n },\n};\n\nexport const ecommerceOrder: DestinationPiwikPro.Rule = {\n name: 'ecommerceOrder',\n data: {\n set: [\n {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: productMap,\n },\n ],\n },\n {\n map: {\n orderId: 'data.id',\n grandTotal: 'data.total',\n tax: 'data.taxes',\n shipping: 'data.shipping',\n },\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceAddToCart: DestinationPiwikPro.Rule = {\n name: 'ecommerceAddToCart',\n data: {\n set: [\n {\n set: [\n {\n map: productMap,\n },\n ],\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceProductDetailView: DestinationPiwikPro.Rule = {\n name: 'ecommerceProductDetailView',\n data: {\n set: [\n {\n set: [\n {\n map: productMap,\n },\n ],\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceCartUpdate: DestinationPiwikPro.Rule = {\n name: 'ecommerceCartUpdate',\n data: {\n set: [\n {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: productMap,\n },\n ],\n },\n 'data.value',\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const config = {\n order: { complete: ecommerceOrder },\n product: { add: ecommerceAddToCart, view: ecommerceProductDetailView },\n cart: { view: ecommerceCartUpdate },\n} satisfies DestinationPiwikPro.Rules;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,OAAO,aACJ,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qDAAqD;AAAA,EACjE,KAAK,aACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF;AAAA,EACF,cAAc,aACX,QAAQ,EACR,QAAQ,KAAK,EACb,SAAS,gDAAgD;AAC9D,CAAC;;;ACjBD,IAAAC,cAAkB;AAEX,IAAM,gBAAgB,cAAE,OAAO;AAAA,EACpC,QAAQ,cAAE,OAAO,EAAE,SAAS,0CAA0C;AAAA,EACtE,WAAW,cACR,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AACd,CAAC;;;AFAM,IAAM,eAAW,yBAAY,cAAc;AAC3C,IAAM,cAAU,yBAAY,aAAa;;;AGThD;AAAA;AAAA;AAAA;AAAA;AAAA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F,qBAAoB;AACpC;","names":["import_dev","import_dev","ecommerceAddToCart","ecommerceCartUpdate","ecommerceOrder","ecommerceProductDetailView","import_core"]}
package/dist/dev.mjs ADDED
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,a=(a,t)=>{for(var r in t)e(a,r,{get:t[r],enumerable:!0})},t={};a(t,{MappingSchema:()=>i,SettingsSchema:()=>c,mapping:()=>m,settings:()=>n});import{zodToSchema as r}from"@walkeros/core/dev";import{z as o}from"@walkeros/core/dev";var c=o.object({appId:o.string().min(1).describe("ID of the Piwik PRO site (like XXX-XXX-XXX-XXX-XXX)"),url:o.string().url().describe("URL of your Piwik PRO account (like https://your_account_name.piwik.pro/)"),linkTracking:o.boolean().default(!1).describe("Enables/Disables download and outlink tracking")});import{z as d}from"@walkeros/core/dev";var i=d.object({goalId:d.string().describe("ID to count the event as a goal (like 1)"),goalValue:d.string().describe("Property to be used as the goal value (like data.value)").optional()}),n=r(c),m=r(i),p={};a(p,{env:()=>s,events:()=>v,mapping:()=>h});var s={};a(s,{init:()=>u,push:()=>l});var u={window:{_paq:void 0},document:{createElement:()=>({type:"",src:"",async:!1,defer:!1}),head:{appendChild:()=>{}}}},l={window:{_paq:[]},document:{createElement:()=>({type:"",src:"",async:!1,defer:!1}),head:{appendChild:()=>{}}}},v={};a(v,{ecommerceAddToCart:()=>f,ecommerceCartUpdate:()=>C,ecommerceOrder:()=>w,ecommerceProductDetailView:()=>k});import{getEvent as g}from"@walkeros/core";function y(e){return{sku:e.data.id,name:e.data.name,price:e.data.price,quantity:1,variant:e.data.color,customDimensions:{1:e.data.size}}}function w(){const e=g("order complete");return[["ecommerceOrder",e.nested.filter(e=>"product"===e.entity).map(y),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]}function f(){return[["ecommerceAddToCart",[y(g("product add")),,],{currencyCode:"EUR"}]]}function k(){return[["ecommerceProductDetailView",[y(g("product view")),,],{currencyCode:"EUR"}]]}function C(){const e=g("cart view");return[["ecommerceCartUpdate",e.nested.filter(e=>"product"===e.entity).map(y),e.data.value,{currencyCode:"EUR"}]]}var h={};a(h,{config:()=>D,ecommerceAddToCart:()=>E,ecommerceCartUpdate:()=>P,ecommerceOrder:()=>U,ecommerceProductDetailView:()=>R});import{isObject as X}from"@walkeros/core";var b={sku:"data.id",name:"data.name",price:"data.price",quantity:{value:1},variant:{key:"data.color"},customDimensions:{map:{1:"data.size"}}},U={name:"ecommerceOrder",data:{set:[{loop:["nested",{condition:e=>X(e)&&"product"===e.entity,map:b}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},E={name:"ecommerceAddToCart",data:{set:[{set:[{map:b}]},{map:{currencyCode:{value:"EUR"}}}]}},R={name:"ecommerceProductDetailView",data:{set:[{set:[{map:b}]},{map:{currencyCode:{value:"EUR"}}}]}},P={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:e=>X(e)&&"product"===e.entity,map:b}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},D={order:{complete:U},product:{add:E,view:R},cart:{view:P}};export{p as examples,t as schemas};//# sourceMappingURL=dev.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n appId: z\n .string()\n .min(1)\n .describe('ID of the Piwik PRO site (like XXX-XXX-XXX-XXX-XXX)'),\n url: z\n .string()\n .url()\n .describe(\n 'URL of your Piwik PRO account (like https://your_account_name.piwik.pro/)',\n ),\n linkTracking: z\n .boolean()\n .default(false)\n .describe('Enables/Disables download and outlink tracking'),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n goalId: z.string().describe('ID to count the event as a goal (like 1)'),\n goalValue: z\n .string()\n .describe('Property to be used as the goal value (like data.value)')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as events from './events';\nexport * as mapping from './mapping';\n","import type { Env } from '../types';\n\n/**\n * Example environment configurations for PiwikPro destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring external dependencies.\n */\n\nexport const init: Env | undefined = {\n window: {\n _paq: undefined as unknown as Env['window']['_paq'],\n },\n document: {\n createElement: () => ({\n type: '',\n src: '',\n async: false,\n defer: false,\n }),\n head: { appendChild: () => {} },\n },\n};\n\nexport const push: Env = {\n window: {\n _paq: [] as unknown[],\n },\n document: {\n createElement: () => ({\n type: '',\n src: '',\n async: false,\n defer: false,\n }),\n head: { appendChild: () => {} },\n },\n};\n","import type { WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\nfunction getProduct(entity: WalkerOS.Entity | WalkerOS.Event) {\n return {\n sku: entity.data.id,\n name: entity.data.name,\n price: entity.data.price,\n quantity: 1,\n variant: entity.data.color,\n customDimensions: {\n 1: entity.data.size,\n },\n };\n}\n\nexport function ecommerceOrder(): unknown[] {\n const event = getEvent('order complete');\n\n return [\n [\n 'ecommerceOrder',\n event.nested.filter((item) => item.entity === 'product').map(getProduct),\n {\n orderId: event.data.id,\n grandTotal: event.data.total,\n tax: event.data.taxes,\n shipping: event.data.shipping,\n },\n { currencyCode: 'EUR' },\n ],\n ];\n}\n\nexport function ecommerceAddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n ['ecommerceAddToCart', [getProduct(event), ,], { currencyCode: 'EUR' }],\n ];\n}\n\nexport function ecommerceProductDetailView(): unknown[] {\n const event = getEvent('product view');\n\n return [\n [\n 'ecommerceProductDetailView',\n [getProduct(event), ,],\n { currencyCode: 'EUR' },\n ],\n ];\n}\n\nexport function ecommerceCartUpdate(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n [\n 'ecommerceCartUpdate',\n event.nested.filter((item) => item.entity === 'product').map(getProduct),\n event.data.value,\n { currencyCode: 'EUR' },\n ],\n ];\n}\n","import type { DestinationPiwikPro } from '..';\nimport { isObject } from '@walkeros/core';\n\nconst productMap = {\n sku: 'data.id',\n name: 'data.name',\n price: 'data.price',\n quantity: { value: 1 },\n variant: { key: 'data.color' },\n customDimensions: {\n map: {\n 1: 'data.size',\n },\n },\n};\n\nexport const ecommerceOrder: DestinationPiwikPro.Rule = {\n name: 'ecommerceOrder',\n data: {\n set: [\n {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: productMap,\n },\n ],\n },\n {\n map: {\n orderId: 'data.id',\n grandTotal: 'data.total',\n tax: 'data.taxes',\n shipping: 'data.shipping',\n },\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceAddToCart: DestinationPiwikPro.Rule = {\n name: 'ecommerceAddToCart',\n data: {\n set: [\n {\n set: [\n {\n map: productMap,\n },\n ],\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceProductDetailView: DestinationPiwikPro.Rule = {\n name: 'ecommerceProductDetailView',\n data: {\n set: [\n {\n set: [\n {\n map: productMap,\n },\n ],\n },\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const ecommerceCartUpdate: DestinationPiwikPro.Rule = {\n name: 'ecommerceCartUpdate',\n data: {\n set: [\n {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: productMap,\n },\n ],\n },\n 'data.value',\n {\n map: {\n currencyCode: { value: 'EUR' },\n },\n },\n ],\n },\n};\n\nexport const config = {\n order: { complete: ecommerceOrder },\n product: { add: ecommerceAddToCart, view: ecommerceProductDetailView },\n cart: { view: ecommerceCartUpdate },\n} satisfies DestinationPiwikPro.Rules;\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,OAAO,EACJ,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qDAAqD;AAAA,EACjE,KAAK,EACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF;AAAA,EACF,cAAc,EACX,QAAQ,EACR,QAAQ,KAAK,EACb,SAAS,gDAAgD;AAC9D,CAAC;;;ACjBD,SAAS,KAAAA,UAAS;AAEX,IAAM,gBAAgBA,GAAE,OAAO;AAAA,EACpC,QAAQA,GAAE,OAAO,EAAE,SAAS,0CAA0C;AAAA,EACtE,WAAWA,GACR,OAAO,EACP,SAAS,yDAAyD,EAClE,SAAS;AACd,CAAC;;;AFAM,IAAM,WAAW,YAAY,cAAc;AAC3C,IAAM,UAAU,YAAY,aAAa;;;AGThD;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AASO,IAAM,OAAwB;AAAA,EACnC,QAAQ;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA,UAAU;AAAA,IACR,eAAe,OAAO;AAAA,MACpB,MAAM;AAAA,MACN,KAAK;AAAA,MACL,OAAO;AAAA,MACP,OAAO;AAAA,IACT;AAAA,IACA,MAAM,EAAE,aAAa,MAAM;AAAA,IAAC,EAAE;AAAA,EAChC;AACF;AAEO,IAAM,OAAY;AAAA,EACvB,QAAQ;AAAA,IACN,MAAM,CAAC;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,eAAe,OAAO;AAAA,MACpB,MAAM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/B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAMG,8BAAuD;AAAA,EAClE,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH;AAAA,QACE,KAAK;AAAA,UACH;AAAA,YACE,KAAK;AAAA,UACP;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,QACE,KAAK;AAAA,UACH,cAAc,EAAE,OAAO,MAAM;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAMF,uBAAgD;AAAA,EAC3D,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH;AAAA,QACE,MAAM;AAAA,UACJ;AAAA,UACA;AAAA,YACE,WAAW,CAAC,WACV,SAAS,MAAM,KAAK,OAAO,WAAW;AAAA,YACxC,KAAK;AAAA,UACP;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,QACE,KAAK;AAAA,UACH,cAAc,EAAE,OAAO,MAAM;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,OAAO,EAAE,UAAUC,gBAAe;AAAA,EAClC,SAAS,EAAE,KAAKF,qBAAoB,MAAMG,4BAA2B;AAAA,EACrE,MAAM,EAAE,MAAMF,qBAAoB;AACpC;","names":["z","ecommerceAddToCart","ecommerceCartUpdate","ecommerceOrder","ecommerceProductDetailView"]}