@walkeros/web-destination-piwikpro 0.0.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 elbWalker GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ <p align="left">
2
+ <a href="https://elbwalker.com">
3
+ <img title="elbwalker" src='https://www.elbwalker.com/img/elbwalker_logo.png' width="256px"/>
4
+ </a>
5
+ </p>
6
+
7
+ # Piwik PRO Destination for walkerOS
8
+
9
+ This package provides a Piwik PRO destination for walkerOS. It allows you to
10
+ send events to Piwik PRO.
11
+
12
+ [View documentation](https://www.elbwalker.com/docs/destinations/web/piwikpro/)
13
+
14
+ ## Role in walkerOS Ecosystem
15
+
16
+ walkerOS follows a **source → collector → destination** architecture:
17
+
18
+ - **Sources**: Capture events from various environments (browser DOM, dataLayer,
19
+ server requests)
20
+ - **Collector**: Processes, validates, and routes events with consent awareness
21
+ - **Destinations**: Send processed events to analytics platforms (GA4, Meta,
22
+ custom APIs)
23
+
24
+ This Piwik PRO destination receives processed events from the walkerOS collector
25
+ and transforms them into Piwik PRO's analytics format, providing
26
+ privacy-compliant analytics with GDPR compliance and data ownership control.
27
+
28
+ ## Installation
29
+
30
+ ```sh
31
+ npm install @walkeros/web-destination-piwikpro
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Here's a basic example of how to use the Piwik PRO destination:
37
+
38
+ ```typescript
39
+ import { elb } from '@walkeros/collector';
40
+ import { destinationPiwikPro } from '@walkeros/web-destination-piwikpro';
41
+
42
+ elb('walker destination', destinationPiwikPro, {
43
+ custom: {
44
+ appId: 'YOUR_APP_ID',
45
+ url: 'https://your-account.piwik.pro/',
46
+ },
47
+ });
48
+ ```
49
+
50
+ ## Contribute
51
+
52
+ Feel free to contribute by submitting an
53
+ [issue](https://github.com/elbwalker/walkerOS/issues), starting a
54
+ [discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
55
+ [contact](https://calendly.com/elb-alexander/30min).
56
+
57
+ ## License
58
+
59
+ This project is licensed under the MIT License.
@@ -0,0 +1,66 @@
1
+ import { Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare function ecommerceOrder$1(): unknown[];
5
+ declare function ecommerceAddToCart$1(): unknown[];
6
+ declare function ecommerceProductDetailView$1(): unknown[];
7
+ declare function ecommerceCartUpdate$1(): unknown[];
8
+
9
+ declare namespace events {
10
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
11
+ }
12
+
13
+ declare global {
14
+ namespace WalkerOS {
15
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
16
+ }
17
+ }
18
+ interface Window {
19
+ _paq?: Array<unknown>;
20
+ }
21
+ }
22
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
23
+ type Config = DestinationWeb.Config<Settings, Mapping>;
24
+ interface Settings {
25
+ appId: string;
26
+ linkTracking?: boolean;
27
+ url: string;
28
+ }
29
+ interface Mapping {
30
+ goalId?: string;
31
+ goalValue?: string;
32
+ }
33
+ type Rule = Mapping$1.Rule<Mapping>;
34
+
35
+ declare const ecommerceOrder: Rule;
36
+ declare const ecommerceAddToCart: Rule;
37
+ declare const ecommerceProductDetailView: Rule;
38
+ declare const ecommerceCartUpdate: Rule;
39
+ declare const config: {
40
+ order: {
41
+ complete: Rule;
42
+ };
43
+ product: {
44
+ add: Rule;
45
+ view: Rule;
46
+ };
47
+ cart: {
48
+ view: Rule;
49
+ };
50
+ };
51
+
52
+ declare const mapping_config: typeof config;
53
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
54
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
55
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
56
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
57
+ declare namespace mapping {
58
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
59
+ }
60
+
61
+ declare const destinationPiwikProExamples: {
62
+ events: typeof events;
63
+ mapping: typeof mapping;
64
+ };
65
+
66
+ export { destinationPiwikProExamples };
@@ -0,0 +1,66 @@
1
+ import { Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare function ecommerceOrder$1(): unknown[];
5
+ declare function ecommerceAddToCart$1(): unknown[];
6
+ declare function ecommerceProductDetailView$1(): unknown[];
7
+ declare function ecommerceCartUpdate$1(): unknown[];
8
+
9
+ declare namespace events {
10
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
11
+ }
12
+
13
+ declare global {
14
+ namespace WalkerOS {
15
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
16
+ }
17
+ }
18
+ interface Window {
19
+ _paq?: Array<unknown>;
20
+ }
21
+ }
22
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
23
+ type Config = DestinationWeb.Config<Settings, Mapping>;
24
+ interface Settings {
25
+ appId: string;
26
+ linkTracking?: boolean;
27
+ url: string;
28
+ }
29
+ interface Mapping {
30
+ goalId?: string;
31
+ goalValue?: string;
32
+ }
33
+ type Rule = Mapping$1.Rule<Mapping>;
34
+
35
+ declare const ecommerceOrder: Rule;
36
+ declare const ecommerceAddToCart: Rule;
37
+ declare const ecommerceProductDetailView: Rule;
38
+ declare const ecommerceCartUpdate: Rule;
39
+ declare const config: {
40
+ order: {
41
+ complete: Rule;
42
+ };
43
+ product: {
44
+ add: Rule;
45
+ view: Rule;
46
+ };
47
+ cart: {
48
+ view: Rule;
49
+ };
50
+ };
51
+
52
+ declare const mapping_config: typeof config;
53
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
54
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
55
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
56
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
57
+ declare namespace mapping {
58
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
59
+ }
60
+
61
+ declare const destinationPiwikProExamples: {
62
+ events: typeof events;
63
+ mapping: typeof mapping;
64
+ };
65
+
66
+ export { destinationPiwikProExamples };
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/examples/index.ts
21
+ var examples_exports = {};
22
+ __export(examples_exports, {
23
+ destinationPiwikProExamples: () => destinationPiwikProExamples
24
+ });
25
+ module.exports = __toCommonJS(examples_exports);
26
+
27
+ // src/examples/events.ts
28
+ var events_exports = {};
29
+ __export(events_exports, {
30
+ ecommerceAddToCart: () => ecommerceAddToCart,
31
+ ecommerceCartUpdate: () => ecommerceCartUpdate,
32
+ ecommerceOrder: () => ecommerceOrder,
33
+ ecommerceProductDetailView: () => ecommerceProductDetailView
34
+ });
35
+
36
+ // ../../../core/dist/index.mjs
37
+ var e;
38
+ var t;
39
+ var n = Object.getOwnPropertyNames;
40
+ var r = (e = { "package.json"(e2, t2) {
41
+ t2.exports = { name: "@walkeros/core", description: "Core types and platform-agnostic utilities for walkerOS", version: "0.0.7", main: "./dist/index.js", module: "./dist/index.mjs", types: "./dist/index.d.ts", license: "MIT", files: ["dist/**"], scripts: { build: "tsup --silent", clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist", dev: "jest --watchAll --colors", lint: 'tsc && eslint "**/*.ts*"', test: "jest", update: "npx npm-check-updates -u && npm update" }, dependencies: {}, devDependencies: {}, repository: { url: "git+https://github.com/elbwalker/walkerOS.git", directory: "packages/core" }, author: "elbwalker <hello@elbwalker.com>", homepage: "https://github.com/elbwalker/walkerOS#readme", bugs: { url: "https://github.com/elbwalker/walkerOS/issues" }, keywords: ["walker", "walkerOS", "analytics", "tracking", "data collection", "measurement", "data privacy", "privacy friendly", "web analytics", "product analytics", "core", "types", "utils"], funding: [{ type: "GitHub Sponsors", url: "https://github.com/sponsors/elbwalker" }] };
42
+ } }, function() {
43
+ return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
44
+ });
45
+ var w = { merge: true, shallow: true, extend: true };
46
+ function v(e2, t2 = {}, n2 = {}) {
47
+ n2 = { ...w, ...n2 };
48
+ const r2 = Object.entries(t2).reduce((t3, [r3, o]) => {
49
+ const i = e2[r3];
50
+ return n2.merge && Array.isArray(i) && Array.isArray(o) ? t3[r3] = o.reduce((e3, t4) => e3.includes(t4) ? e3 : [...e3, t4], [...i]) : (n2.extend || r3 in e2) && (t3[r3] = o), t3;
51
+ }, {});
52
+ return n2.shallow ? { ...e2, ...r2 } : (Object.assign(e2, r2), e2);
53
+ }
54
+ function k(e2) {
55
+ return Array.isArray(e2);
56
+ }
57
+ function M(e2) {
58
+ return "object" == typeof e2 && null !== e2 && !k(e2) && "[object Object]" === Object.prototype.toString.call(e2);
59
+ }
60
+ var { version: V } = r();
61
+ function H(e2 = {}) {
62
+ var _a;
63
+ const t2 = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n2 = e2.group || "gr0up", r2 = e2.count || 1, o = v({ event: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ type: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t2}-${n2}-${r2}`, trigger: "test", entity: "entity", action: "action", timestamp: t2, timing: 3.14, group: n2, count: r2, version: { source: V, tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
64
+ if (e2.event) {
65
+ const [t3, n3] = (_a = e2.event.split(" ")) != null ? _a : [];
66
+ t3 && n3 && (o.entity = t3, o.action = n3);
67
+ }
68
+ return o;
69
+ }
70
+ function z(e2 = "entity action", t2 = {}) {
71
+ const n2 = t2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r2 = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
72
+ return H({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r2.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", data: { ...r2.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r2.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", ...r2, context: { shopping: ["checkout", 0] }, nested: [] }, { type: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", ...r2, context: { shopping: ["complete", 0] }, nested: [] }, { type: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { type: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.elbwalker.com/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r2, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r2, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r2.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n2, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t2, event: e2 });
73
+ }
74
+
75
+ // src/examples/events.ts
76
+ function getProduct(entity) {
77
+ return {
78
+ sku: entity.data.id,
79
+ name: entity.data.name,
80
+ price: entity.data.price,
81
+ quantity: 1,
82
+ variant: entity.data.color,
83
+ customDimensions: {
84
+ 1: entity.data.size
85
+ }
86
+ };
87
+ }
88
+ function ecommerceOrder() {
89
+ const event = z("order complete");
90
+ return [
91
+ [
92
+ "ecommerceOrder",
93
+ event.nested.filter((item) => item.type === "product").map(getProduct),
94
+ {
95
+ orderId: event.data.id,
96
+ grandTotal: event.data.total,
97
+ tax: event.data.taxes,
98
+ shipping: event.data.shipping
99
+ },
100
+ { currencyCode: "EUR" }
101
+ ]
102
+ ];
103
+ }
104
+ function ecommerceAddToCart() {
105
+ const event = z("product add");
106
+ return [
107
+ ["ecommerceAddToCart", [getProduct(event), ,], { currencyCode: "EUR" }]
108
+ ];
109
+ }
110
+ function ecommerceProductDetailView() {
111
+ const event = z("product view");
112
+ return [
113
+ [
114
+ "ecommerceProductDetailView",
115
+ [getProduct(event), ,],
116
+ { currencyCode: "EUR" }
117
+ ]
118
+ ];
119
+ }
120
+ function ecommerceCartUpdate() {
121
+ const event = z("cart view");
122
+ return [
123
+ [
124
+ "ecommerceCartUpdate",
125
+ event.nested.filter((item) => item.type === "product").map(getProduct),
126
+ event.data.value,
127
+ { currencyCode: "EUR" }
128
+ ]
129
+ ];
130
+ }
131
+
132
+ // src/examples/mapping.ts
133
+ var mapping_exports = {};
134
+ __export(mapping_exports, {
135
+ config: () => config,
136
+ ecommerceAddToCart: () => ecommerceAddToCart2,
137
+ ecommerceCartUpdate: () => ecommerceCartUpdate2,
138
+ ecommerceOrder: () => ecommerceOrder2,
139
+ ecommerceProductDetailView: () => ecommerceProductDetailView2
140
+ });
141
+ var productMap = {
142
+ sku: "data.id",
143
+ name: "data.name",
144
+ price: "data.price",
145
+ quantity: { value: 1 },
146
+ variant: { key: "data.color" },
147
+ customDimensions: {
148
+ map: {
149
+ 1: "data.size"
150
+ }
151
+ }
152
+ };
153
+ var ecommerceOrder2 = {
154
+ name: "ecommerceOrder",
155
+ data: {
156
+ set: [
157
+ {
158
+ loop: [
159
+ "nested",
160
+ {
161
+ condition: (entity) => M(entity) && entity.type === "product",
162
+ map: productMap
163
+ }
164
+ ]
165
+ },
166
+ {
167
+ map: {
168
+ orderId: "data.id",
169
+ grandTotal: "data.total",
170
+ tax: "data.taxes",
171
+ shipping: "data.shipping"
172
+ }
173
+ },
174
+ {
175
+ map: {
176
+ currencyCode: { value: "EUR" }
177
+ }
178
+ }
179
+ ]
180
+ }
181
+ };
182
+ var ecommerceAddToCart2 = {
183
+ name: "ecommerceAddToCart",
184
+ data: {
185
+ set: [
186
+ {
187
+ set: [
188
+ {
189
+ map: productMap
190
+ }
191
+ ]
192
+ },
193
+ {
194
+ map: {
195
+ currencyCode: { value: "EUR" }
196
+ }
197
+ }
198
+ ]
199
+ }
200
+ };
201
+ var ecommerceProductDetailView2 = {
202
+ name: "ecommerceProductDetailView",
203
+ data: {
204
+ set: [
205
+ {
206
+ set: [
207
+ {
208
+ map: productMap
209
+ }
210
+ ]
211
+ },
212
+ {
213
+ map: {
214
+ currencyCode: { value: "EUR" }
215
+ }
216
+ }
217
+ ]
218
+ }
219
+ };
220
+ var ecommerceCartUpdate2 = {
221
+ name: "ecommerceCartUpdate",
222
+ data: {
223
+ set: [
224
+ {
225
+ loop: [
226
+ "nested",
227
+ {
228
+ condition: (entity) => M(entity) && entity.type === "product",
229
+ map: productMap
230
+ }
231
+ ]
232
+ },
233
+ "data.value",
234
+ {
235
+ map: {
236
+ currencyCode: { value: "EUR" }
237
+ }
238
+ }
239
+ ]
240
+ }
241
+ };
242
+ var config = {
243
+ order: { complete: ecommerceOrder2 },
244
+ product: { add: ecommerceAddToCart2, view: ecommerceProductDetailView2 },
245
+ cart: { view: ecommerceCartUpdate2 }
246
+ };
247
+
248
+ // src/examples/index.ts
249
+ var destinationPiwikProExamples = {
250
+ events: events_exports,
251
+ mapping: mapping_exports
252
+ };
253
+ // Annotate the CommonJS export names for ESM import in node:
254
+ 0 && (module.exports = {
255
+ destinationPiwikProExamples
256
+ });
@@ -0,0 +1,235 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/examples/events.ts
8
+ var events_exports = {};
9
+ __export(events_exports, {
10
+ ecommerceAddToCart: () => ecommerceAddToCart,
11
+ ecommerceCartUpdate: () => ecommerceCartUpdate,
12
+ ecommerceOrder: () => ecommerceOrder,
13
+ ecommerceProductDetailView: () => ecommerceProductDetailView
14
+ });
15
+
16
+ // ../../../core/dist/index.mjs
17
+ var e;
18
+ var t;
19
+ var n = Object.getOwnPropertyNames;
20
+ var r = (e = { "package.json"(e2, t2) {
21
+ t2.exports = { name: "@walkeros/core", description: "Core types and platform-agnostic utilities for walkerOS", version: "0.0.7", main: "./dist/index.js", module: "./dist/index.mjs", types: "./dist/index.d.ts", license: "MIT", files: ["dist/**"], scripts: { build: "tsup --silent", clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist", dev: "jest --watchAll --colors", lint: 'tsc && eslint "**/*.ts*"', test: "jest", update: "npx npm-check-updates -u && npm update" }, dependencies: {}, devDependencies: {}, repository: { url: "git+https://github.com/elbwalker/walkerOS.git", directory: "packages/core" }, author: "elbwalker <hello@elbwalker.com>", homepage: "https://github.com/elbwalker/walkerOS#readme", bugs: { url: "https://github.com/elbwalker/walkerOS/issues" }, keywords: ["walker", "walkerOS", "analytics", "tracking", "data collection", "measurement", "data privacy", "privacy friendly", "web analytics", "product analytics", "core", "types", "utils"], funding: [{ type: "GitHub Sponsors", url: "https://github.com/sponsors/elbwalker" }] };
22
+ } }, function() {
23
+ return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
24
+ });
25
+ var w = { merge: true, shallow: true, extend: true };
26
+ function v(e2, t2 = {}, n2 = {}) {
27
+ n2 = { ...w, ...n2 };
28
+ const r2 = Object.entries(t2).reduce((t3, [r3, o]) => {
29
+ const i = e2[r3];
30
+ return n2.merge && Array.isArray(i) && Array.isArray(o) ? t3[r3] = o.reduce((e3, t4) => e3.includes(t4) ? e3 : [...e3, t4], [...i]) : (n2.extend || r3 in e2) && (t3[r3] = o), t3;
31
+ }, {});
32
+ return n2.shallow ? { ...e2, ...r2 } : (Object.assign(e2, r2), e2);
33
+ }
34
+ function k(e2) {
35
+ return Array.isArray(e2);
36
+ }
37
+ function M(e2) {
38
+ return "object" == typeof e2 && null !== e2 && !k(e2) && "[object Object]" === Object.prototype.toString.call(e2);
39
+ }
40
+ var { version: V } = r();
41
+ function H(e2 = {}) {
42
+ var _a;
43
+ const t2 = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n2 = e2.group || "gr0up", r2 = e2.count || 1, o = v({ event: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ type: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t2}-${n2}-${r2}`, trigger: "test", entity: "entity", action: "action", timestamp: t2, timing: 3.14, group: n2, count: r2, version: { source: V, tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
44
+ if (e2.event) {
45
+ const [t3, n3] = (_a = e2.event.split(" ")) != null ? _a : [];
46
+ t3 && n3 && (o.entity = t3, o.action = n3);
47
+ }
48
+ return o;
49
+ }
50
+ function z(e2 = "entity action", t2 = {}) {
51
+ const n2 = t2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r2 = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
52
+ return H({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r2.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", data: { ...r2.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r2.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", ...r2, context: { shopping: ["checkout", 0] }, nested: [] }, { type: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ type: "product", ...r2, context: { shopping: ["complete", 0] }, nested: [] }, { type: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { type: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.elbwalker.com/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r2, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r2, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r2.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n2, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t2, event: e2 });
53
+ }
54
+
55
+ // src/examples/events.ts
56
+ function getProduct(entity) {
57
+ return {
58
+ sku: entity.data.id,
59
+ name: entity.data.name,
60
+ price: entity.data.price,
61
+ quantity: 1,
62
+ variant: entity.data.color,
63
+ customDimensions: {
64
+ 1: entity.data.size
65
+ }
66
+ };
67
+ }
68
+ function ecommerceOrder() {
69
+ const event = z("order complete");
70
+ return [
71
+ [
72
+ "ecommerceOrder",
73
+ event.nested.filter((item) => item.type === "product").map(getProduct),
74
+ {
75
+ orderId: event.data.id,
76
+ grandTotal: event.data.total,
77
+ tax: event.data.taxes,
78
+ shipping: event.data.shipping
79
+ },
80
+ { currencyCode: "EUR" }
81
+ ]
82
+ ];
83
+ }
84
+ function ecommerceAddToCart() {
85
+ const event = z("product add");
86
+ return [
87
+ ["ecommerceAddToCart", [getProduct(event), ,], { currencyCode: "EUR" }]
88
+ ];
89
+ }
90
+ function ecommerceProductDetailView() {
91
+ const event = z("product view");
92
+ return [
93
+ [
94
+ "ecommerceProductDetailView",
95
+ [getProduct(event), ,],
96
+ { currencyCode: "EUR" }
97
+ ]
98
+ ];
99
+ }
100
+ function ecommerceCartUpdate() {
101
+ const event = z("cart view");
102
+ return [
103
+ [
104
+ "ecommerceCartUpdate",
105
+ event.nested.filter((item) => item.type === "product").map(getProduct),
106
+ event.data.value,
107
+ { currencyCode: "EUR" }
108
+ ]
109
+ ];
110
+ }
111
+
112
+ // src/examples/mapping.ts
113
+ var mapping_exports = {};
114
+ __export(mapping_exports, {
115
+ config: () => config,
116
+ ecommerceAddToCart: () => ecommerceAddToCart2,
117
+ ecommerceCartUpdate: () => ecommerceCartUpdate2,
118
+ ecommerceOrder: () => ecommerceOrder2,
119
+ ecommerceProductDetailView: () => ecommerceProductDetailView2
120
+ });
121
+ var productMap = {
122
+ sku: "data.id",
123
+ name: "data.name",
124
+ price: "data.price",
125
+ quantity: { value: 1 },
126
+ variant: { key: "data.color" },
127
+ customDimensions: {
128
+ map: {
129
+ 1: "data.size"
130
+ }
131
+ }
132
+ };
133
+ var ecommerceOrder2 = {
134
+ name: "ecommerceOrder",
135
+ data: {
136
+ set: [
137
+ {
138
+ loop: [
139
+ "nested",
140
+ {
141
+ condition: (entity) => M(entity) && entity.type === "product",
142
+ map: productMap
143
+ }
144
+ ]
145
+ },
146
+ {
147
+ map: {
148
+ orderId: "data.id",
149
+ grandTotal: "data.total",
150
+ tax: "data.taxes",
151
+ shipping: "data.shipping"
152
+ }
153
+ },
154
+ {
155
+ map: {
156
+ currencyCode: { value: "EUR" }
157
+ }
158
+ }
159
+ ]
160
+ }
161
+ };
162
+ var ecommerceAddToCart2 = {
163
+ name: "ecommerceAddToCart",
164
+ data: {
165
+ set: [
166
+ {
167
+ set: [
168
+ {
169
+ map: productMap
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ map: {
175
+ currencyCode: { value: "EUR" }
176
+ }
177
+ }
178
+ ]
179
+ }
180
+ };
181
+ var ecommerceProductDetailView2 = {
182
+ name: "ecommerceProductDetailView",
183
+ data: {
184
+ set: [
185
+ {
186
+ set: [
187
+ {
188
+ map: productMap
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ map: {
194
+ currencyCode: { value: "EUR" }
195
+ }
196
+ }
197
+ ]
198
+ }
199
+ };
200
+ var ecommerceCartUpdate2 = {
201
+ name: "ecommerceCartUpdate",
202
+ data: {
203
+ set: [
204
+ {
205
+ loop: [
206
+ "nested",
207
+ {
208
+ condition: (entity) => M(entity) && entity.type === "product",
209
+ map: productMap
210
+ }
211
+ ]
212
+ },
213
+ "data.value",
214
+ {
215
+ map: {
216
+ currencyCode: { value: "EUR" }
217
+ }
218
+ }
219
+ ]
220
+ }
221
+ };
222
+ var config = {
223
+ order: { complete: ecommerceOrder2 },
224
+ product: { add: ecommerceAddToCart2, view: ecommerceProductDetailView2 },
225
+ cart: { view: ecommerceCartUpdate2 }
226
+ };
227
+
228
+ // src/examples/index.ts
229
+ var destinationPiwikProExamples = {
230
+ events: events_exports,
231
+ mapping: mapping_exports
232
+ };
233
+ export {
234
+ destinationPiwikProExamples
235
+ };
@@ -0,0 +1 @@
1
+ "use strict";var Destination=(()=>{var e,t,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},c={};i(c,{DestinationPiwikPro:()=>j,default:()=>$,destinationPiwikPro:()=>N,destinationPiwikProExamples:()=>P});var s=Object.getOwnPropertyNames,p=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[s(e)[0]])((t={exports:{}}).exports,t),t.exports}),d={merge:!0,shallow:!0,extend:!0};function u(e){return Array.isArray(e)}function l(e){return void 0!==e}function m(e){return"object"==typeof e&&null!==e&&!u(e)&&"[object Object]"===Object.prototype.toString.call(e)}function g(e){return"string"==typeof e}function y(e,t="",r){const a=t.split(".");let o=e;for(let e=0;e<a.length;e++){const t=a[e];if("*"===t&&u(o)){const t=a.slice(e+1).join("."),n=[];for(const e of o){const a=y(e,t,r);n.push(a)}return n}if(o=o instanceof Object?o[t]:void 0,!o)break}return l(o)?o:r}var{version:f}=p();function v(e={}){var t;const r=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,n=function(e,t={},r={}){r={...d,...r};const a=Object.entries(t).reduce((t,[a,o])=>{const n=e[a];return r.merge&&Array.isArray(n)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...n]):(r.extend||a in e)&&(t[a]=o),t},{});return r.shallow?{...e,...a}:(Object.assign(e,a),e)}({event:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{type:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${r}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:r,timing:3.14,group:a,count:o,version:{source:f,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[r,a]=null!=(t=e.event.split(" "))?t:[];r&&a&&(n.entity=r,n.action=a)}return n}function h(e="entity action",t={}){const r=t.timestamp||(new Date).setHours(0,13,37,0),a={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return v({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...a.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:a.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["checkout",0]},nested:[]},{type:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["complete",0]},nested:[]},{type:"product",...o,context:{shopping:["complete",0]},nested:[]},{type:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...a,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...a,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...a.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:r,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,event:e})}function w(e){return function(e){return"boolean"==typeof e}(e)||g(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!l(e)||u(e)&&e.every(w)||m(e)&&Object.values(e).every(w)}function b(e){return w(e)?e:void 0}function k(e,t,r){return async function(...a){try{return await e(...a)}catch(e){if(!t)return;return await t(e)}finally{await(null==r?void 0:r())}}}async function x(e,t={},r={}){var a;if(!l(e))return;const o=m(e)&&e.consent||r.consent||(null==(a=r.collector)?void 0:a.consent),n=u(t)?t:[t];for(const t of n){const a=await k(O)(e,t,{...r,consent:o});if(l(a))return a}}async function O(e,t,r={}){const{collector:a,consent:o}=r;return(u(t)?t:[t]).reduce(async(t,n)=>{const i=await t;if(i)return i;const c=g(n)?{key:n}:n;if(!Object.keys(c).length)return;const{condition:s,consent:p,fn:d,key:m,loop:f,map:v,set:h,validate:w,value:j}=c;if(s&&!await k(s)(e,n,a))return;if(p&&!function(e,t={},r={}){const a={...t,...r},o={};let n=void 0===e;return Object.keys(a).forEach(t=>{a[t]&&(o[t]=!0,e&&e[t]&&(n=!0))}),!!n&&o}(p,o))return j;let P=l(j)?j:e;if(d&&(P=await k(d)(e,n,r)),m&&(P=y(e,m,j)),f){const[t,a]=f,o="this"===t?[e]:await x(e,t,r);u(o)&&(P=(await Promise.all(o.map(e=>x(e,a,r)))).filter(l))}else v?P=await Object.entries(v).reduce(async(t,[a,o])=>{const n=await t,i=await x(e,o,r);return l(i)&&(n[a]=i),n},Promise.resolve({})):h&&(P=await Promise.all(h.map(t=>O(e,t,r))));w&&!await k(w)(P)&&(P=void 0);const C=b(P);return l(C)?C:b(j)},Promise.resolve(void 0))}var j={},P={};i(P,{destinationPiwikProExamples:()=>H});var C={};function E(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 S(){const e=h("order complete");return[["ecommerceOrder",e.nested.filter(e=>"product"===e.type).map(E),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]}function U(){return[["ecommerceAddToCart",[E(h("product add")),,],{currencyCode:"EUR"}]]}function D(){return[["ecommerceProductDetailView",[E(h("product view")),,],{currencyCode:"EUR"}]]}function A(){const e=h("cart view");return[["ecommerceCartUpdate",e.nested.filter(e=>"product"===e.type).map(E),e.data.value,{currencyCode:"EUR"}]]}i(C,{ecommerceAddToCart:()=>U,ecommerceCartUpdate:()=>A,ecommerceOrder:()=>S,ecommerceProductDetailView:()=>D});var R={};i(R,{config:()=>I,ecommerceAddToCart:()=>q,ecommerceCartUpdate:()=>V,ecommerceOrder:()=>_,ecommerceProductDetailView:()=>z});var T={sku:"data.id",name:"data.name",price:"data.price",quantity:{value:1},variant:{key:"data.color"},customDimensions:{map:{1:"data.size"}}},_={name:"ecommerceOrder",data:{set:[{loop:["nested",{condition:e=>m(e)&&"product"===e.type,map:T}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},q={name:"ecommerceAddToCart",data:{set:[{set:[{map:T}]},{map:{currencyCode:{value:"EUR"}}}]}},z={name:"ecommerceProductDetailView",data:{set:[{set:[{map:T}]},{map:{currencyCode:{value:"EUR"}}}]}},V={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:e=>m(e)&&"product"===e.type,map:T}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},I={order:{complete:_},product:{add:q,view:z},cart:{view:V}},H={events:C,mapping:R},N={type:"piwikpro",config:{},init({config:e,wrap:t}){const r=window,{settings:a={},loadScript:o}=e,{appId:n,url:i}=a;if(!n||!i)return!1;r._paq=r._paq||[];const c=t("_paq.push",r._paq.push);o&&(!function(e){const t=document.createElement("script");t.type="text/javascript",t.src=e+"ppms.js",t.async=!0,t.defer=!0,document.head.appendChild(t)}(i),c(["setTrackerUrl",i+"ppms.php"]),c(["setSiteId",n])),!1!==a.linkTracking&&c(["enableLinkTracking"])},async push(e,{config:t,mapping:r={},data:a,wrap:o}){const n=o("_paq.push",window._paq.push);if("page view"===e.event&&!r.settings)return void n(["trackPageView",await x(e,"data.title")]);const i=r.settings||{},c=u(a)?a:[a];if(n([e.event,...c]),i.goalId){const t=i.goalValue?x(e,i.goalValue):void 0;n(["trackGoal",i.goalId,t])}}};var M,$=N;return M=c,((e,t,i,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))n.call(e,s)||s===i||r(e,s,{get:()=>t[s],enumerable:!(c=a(t,s))||c.enumerable});return e})(r({},"__esModule",{value:!0}),M)})();
@@ -0,0 +1,88 @@
1
+ import { Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare global {
5
+ namespace WalkerOS {
6
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
7
+ }
8
+ }
9
+ interface Window {
10
+ _paq?: Array<unknown>;
11
+ }
12
+ }
13
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
14
+ type Config = DestinationWeb.Config<Settings, Mapping>;
15
+ interface Settings {
16
+ appId: string;
17
+ linkTracking?: boolean;
18
+ url: string;
19
+ }
20
+ interface Mapping {
21
+ goalId?: string;
22
+ goalValue?: string;
23
+ }
24
+ type Rule = Mapping$1.Rule<Mapping>;
25
+ type Rules = Mapping$1.Rules<Rule>;
26
+ interface Dimensions {
27
+ [i: number]: string;
28
+ }
29
+
30
+ type index$1_Config = Config;
31
+ type index$1_Destination = Destination;
32
+ type index$1_Dimensions = Dimensions;
33
+ type index$1_Mapping = Mapping;
34
+ type index$1_Rule = Rule;
35
+ type index$1_Rules = Rules;
36
+ type index$1_Settings = Settings;
37
+ declare namespace index$1 {
38
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Dimensions as Dimensions, index$1_Mapping as Mapping, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
39
+ }
40
+
41
+ declare function ecommerceOrder$1(): unknown[];
42
+ declare function ecommerceAddToCart$1(): unknown[];
43
+ declare function ecommerceProductDetailView$1(): unknown[];
44
+ declare function ecommerceCartUpdate$1(): unknown[];
45
+
46
+ declare namespace events {
47
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
48
+ }
49
+
50
+ declare const ecommerceOrder: Rule;
51
+ declare const ecommerceAddToCart: Rule;
52
+ declare const ecommerceProductDetailView: Rule;
53
+ declare const ecommerceCartUpdate: Rule;
54
+ declare const config: {
55
+ order: {
56
+ complete: Rule;
57
+ };
58
+ product: {
59
+ add: Rule;
60
+ view: Rule;
61
+ };
62
+ cart: {
63
+ view: Rule;
64
+ };
65
+ };
66
+
67
+ declare const mapping_config: typeof config;
68
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
69
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
70
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
71
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
72
+ declare namespace mapping {
73
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
74
+ }
75
+
76
+ declare const destinationPiwikProExamples: {
77
+ events: typeof events;
78
+ mapping: typeof mapping;
79
+ };
80
+
81
+ declare const index_destinationPiwikProExamples: typeof destinationPiwikProExamples;
82
+ declare namespace index {
83
+ export { index_destinationPiwikProExamples as destinationPiwikProExamples };
84
+ }
85
+
86
+ declare const destinationPiwikPro: Destination;
87
+
88
+ export { index$1 as DestinationPiwikPro, destinationPiwikPro as default, destinationPiwikPro, index as destinationPiwikProExamples };
@@ -0,0 +1,88 @@
1
+ import { Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare global {
5
+ namespace WalkerOS {
6
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
7
+ }
8
+ }
9
+ interface Window {
10
+ _paq?: Array<unknown>;
11
+ }
12
+ }
13
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
14
+ type Config = DestinationWeb.Config<Settings, Mapping>;
15
+ interface Settings {
16
+ appId: string;
17
+ linkTracking?: boolean;
18
+ url: string;
19
+ }
20
+ interface Mapping {
21
+ goalId?: string;
22
+ goalValue?: string;
23
+ }
24
+ type Rule = Mapping$1.Rule<Mapping>;
25
+ type Rules = Mapping$1.Rules<Rule>;
26
+ interface Dimensions {
27
+ [i: number]: string;
28
+ }
29
+
30
+ type index$1_Config = Config;
31
+ type index$1_Destination = Destination;
32
+ type index$1_Dimensions = Dimensions;
33
+ type index$1_Mapping = Mapping;
34
+ type index$1_Rule = Rule;
35
+ type index$1_Rules = Rules;
36
+ type index$1_Settings = Settings;
37
+ declare namespace index$1 {
38
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Dimensions as Dimensions, index$1_Mapping as Mapping, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
39
+ }
40
+
41
+ declare function ecommerceOrder$1(): unknown[];
42
+ declare function ecommerceAddToCart$1(): unknown[];
43
+ declare function ecommerceProductDetailView$1(): unknown[];
44
+ declare function ecommerceCartUpdate$1(): unknown[];
45
+
46
+ declare namespace events {
47
+ export { ecommerceAddToCart$1 as ecommerceAddToCart, ecommerceCartUpdate$1 as ecommerceCartUpdate, ecommerceOrder$1 as ecommerceOrder, ecommerceProductDetailView$1 as ecommerceProductDetailView };
48
+ }
49
+
50
+ declare const ecommerceOrder: Rule;
51
+ declare const ecommerceAddToCart: Rule;
52
+ declare const ecommerceProductDetailView: Rule;
53
+ declare const ecommerceCartUpdate: Rule;
54
+ declare const config: {
55
+ order: {
56
+ complete: Rule;
57
+ };
58
+ product: {
59
+ add: Rule;
60
+ view: Rule;
61
+ };
62
+ cart: {
63
+ view: Rule;
64
+ };
65
+ };
66
+
67
+ declare const mapping_config: typeof config;
68
+ declare const mapping_ecommerceAddToCart: typeof ecommerceAddToCart;
69
+ declare const mapping_ecommerceCartUpdate: typeof ecommerceCartUpdate;
70
+ declare const mapping_ecommerceOrder: typeof ecommerceOrder;
71
+ declare const mapping_ecommerceProductDetailView: typeof ecommerceProductDetailView;
72
+ declare namespace mapping {
73
+ export { mapping_config as config, mapping_ecommerceAddToCart as ecommerceAddToCart, mapping_ecommerceCartUpdate as ecommerceCartUpdate, mapping_ecommerceOrder as ecommerceOrder, mapping_ecommerceProductDetailView as ecommerceProductDetailView };
74
+ }
75
+
76
+ declare const destinationPiwikProExamples: {
77
+ events: typeof events;
78
+ mapping: typeof mapping;
79
+ };
80
+
81
+ declare const index_destinationPiwikProExamples: typeof destinationPiwikProExamples;
82
+ declare namespace index {
83
+ export { index_destinationPiwikProExamples as destinationPiwikProExamples };
84
+ }
85
+
86
+ declare const destinationPiwikPro: Destination;
87
+
88
+ export { index$1 as DestinationPiwikPro, destinationPiwikPro as default, destinationPiwikPro, index as destinationPiwikProExamples };
@@ -0,0 +1 @@
1
+ "use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,r,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){asyncGeneratorStep(a,n,o,i,c,"next",e)}function c(e){asyncGeneratorStep(a,n,o,i,c,"throw",e)}i(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_define_property(e,t,r[t])})}return e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var Destination=function(){var e,t,r=function(e){return Array.isArray(e)},n=function(e){return void 0!==e},o=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},a=function(e){return"string"==typeof e},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.timestamp||(new Date).setHours(0,13,37,0),r=e.group||"gr0up",n=e.count||1,o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r=_object_spread({},O,r);var n=Object.entries(t).reduce(function(t,n){var o=_sliced_to_array(n,2),a=o[0],i=o[1],c=e[a];return r.merge&&Array.isArray(c)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(r.extend||a in e)&&(t[a]=i),t},{});return r.shallow?_object_spread({},e,n):(Object.assign(e,n),e)}({event:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{type:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:"".concat(t,"-").concat(r,"-").concat(n),trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:r,count:n,version:{source:S,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){var a,i=_sliced_to_array(null!==(a=e.event.split(" "))&&void 0!==a?a:[],2),c=i[0],s=i[1];c&&s&&(o.entity=c,o.action=s)}return o},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"entity action",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.timestamp||(new Date).setHours(0,13,37,0),n={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return i(_object_spread_props(_object_spread({},{"cart view":{data:{currency:"EUR",value:2*n.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:_object_spread_props(_object_spread({},n.data),{quantity:2}),context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:n.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[_object_spread_props(_object_spread({type:"product"},n),{context:{shopping:["checkout",0]},nested:[]}),_object_spread_props(_object_spread({type:"product"},o),{context:{shopping:["checkout",0]},nested:[]})],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[_object_spread_props(_object_spread({type:"product"},n),{context:{shopping:["complete",0]},nested:[]}),_object_spread_props(_object_spread({type:"product"},o),{context:{shopping:["complete",0]},nested:[]}),{type:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":_object_spread_props(_object_spread({},n),{context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"}),"product view":_object_spread_props(_object_spread({},n),{context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"}),"product visible":{data:_object_spread_props(_object_spread({},n.data),{position:3,promo:!0}),context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:r,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],t),{event:e}))},s=function(e){return P(e)?e:void 0},u=function(e,t,r){return function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return _async_to_generator(function(){var n;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,e.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return n=a.sent(),t?[4,t(n)]:[2];case 4:return[4,null==r?void 0:r()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},l=function(e){return _async_to_generator(function(e){var t,a,i,c,s,l,p,d,y,_,f,m,b,g=arguments;return _ts_generator(this,function(v){switch(v.label){case 0:if(t=g.length>1&&void 0!==g[1]?g[1]:{},a=g.length>2&&void 0!==g[2]?g[2]:{},!n(e))return[2];c=o(e)&&e.consent||a.consent||(null===(i=a.collector)||void 0===i?void 0:i.consent),s=r(t)?t:[t],l=!0,p=!1,d=void 0,v.label=1;case 1:v.trys.push([1,6,7,8]),y=s[Symbol.iterator](),v.label=2;case 2:return(l=(_=y.next()).done)?[3,5]:(f=_.value,[4,u(E)(e,f,_object_spread_props(_object_spread({},a),{consent:c}))]);case 3:if(m=v.sent(),n(m))return[2,m];v.label=4;case 4:return l=!0,[3,2];case 5:return[3,8];case 6:return b=v.sent(),p=!0,d=b,[3,8];case 7:try{l||null==y.return||y.return()}finally{if(p)throw d}return[7];case 8:return[2]}})}).apply(this,arguments)},p=function(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}}},d=function(){var e=c("order complete");return[["ecommerceOrder",e.nested.filter(function(e){return"product"===e.type}).map(p),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]},y=function(){var e=c("product add");return[["ecommerceAddToCart",[p(e),,],{currencyCode:"EUR"}]]},_=function(){var e=c("product view");return[["ecommerceProductDetailView",[p(e),,],{currencyCode:"EUR"}]]},f=function(){var e=c("cart view");return[["ecommerceCartUpdate",e.nested.filter(function(e){return"product"===e.type}).map(p),e.data.value,{currencyCode:"EUR"}]]},m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,h=function(e,t){for(var r in t)m(e,r,{get:t[r],enumerable:!0})},w={};h(w,{DestinationPiwikPro:function(){return A},default:function(){return M},destinationPiwikPro:function(){return N},destinationPiwikProExamples:function(){return C}});var j=Object.getOwnPropertyNames,k=(e={"package.json":function(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[j(e)[0]])((t={exports:{}}).exports,t),t.exports}),O={merge:!0,shallow:!0,extend:!0};function x(e){for(var t=arguments.length>2?arguments[2]:void 0,o=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"").split("."),a=e,i=0;i<o.length;i++){var c=o[i];if("*"===c&&r(a)){var s=o.slice(i+1).join("."),u=[],l=!0,p=!1,d=void 0;try{for(var y,_=a[Symbol.iterator]();!(l=(y=_.next()).done);l=!0){var f=x(y.value,s,t);u.push(f)}}catch(e){p=!0,d=e}finally{try{l||null==_.return||_.return()}finally{if(p)throw d}}return u}if(!(a=_instanceof(a,Object)?a[c]:void 0))break}return n(a)?a:t}var S=k().version;function P(e){return function(e){return"boolean"==typeof e}(e)||a(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!n(e)||r(e)&&e.every(P)||o(e)&&Object.values(e).every(P)}function E(e,t){return _async_to_generator(function(e,t){var o,i,c,p=arguments;return _ts_generator(this,function(d){return i=(o=p.length>2&&void 0!==p[2]?p[2]:{}).collector,c=o.consent,[2,(r(t)?t:[t]).reduce(function(t,p){return _async_to_generator(function(){var d,y,_,f,m,b,g,v,h,w,j,k,O,S,P,A,C,D,U,I,T;return _ts_generator(this,function(R){switch(R.label){case 0:return[4,t];case 1:return(d=R.sent())?[2,d]:(y=a(p)?{key:p}:p,Object.keys(y).length?(_=y.condition,f=y.consent,m=y.fn,b=y.key,g=y.loop,v=y.map,h=y.set,w=y.validate,j=y.value,(k=_)?[4,u(_)(e,p,i)]:[3,3]):[2]);case 2:k=!R.sent(),R.label=3;case 3:return k?[2]:f&&!function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),r={},n=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(r[o]=!0,e&&e[o]&&(n=!0))}),!!n&&r}(f,c)?[2,j]:(O=n(j)?j:e,m?[4,u(m)(e,p,o)]:[3,5]);case 4:O=R.sent(),R.label=5;case 5:return b&&(O=x(e,b,j)),g?(S=_sliced_to_array(g,2),P=S[0],A=S[1],"this"!==P?[3,6]:(D=[e],[3,8])):[3,11];case 6:return[4,l(e,P,o)];case 7:D=R.sent(),R.label=8;case 8:return r(C=D)?[4,Promise.all(C.map(function(e){return l(e,A,o)}))]:[3,10];case 9:O=R.sent().filter(n),R.label=10;case 10:return[3,17];case 11:return v?[4,Object.entries(v).reduce(function(t,r){var a=_sliced_to_array(r,2),i=a[0],c=a[1];return _async_to_generator(function(){var r,a;return _ts_generator(this,function(s){switch(s.label){case 0:return[4,t];case 1:return r=s.sent(),[4,l(e,c,o)];case 2:return a=s.sent(),[2,(n(a)&&(r[i]=a),r)]}})})()},Promise.resolve({}))]:[3,13];case 12:return O=R.sent(),[3,16];case 13:return(U=h)?[4,Promise.all(h.map(function(t){return E(e,t,o)}))]:[3,15];case 14:U=O=R.sent(),R.label=15;case 15:R.label=16;case 16:R.label=17;case 17:return(I=w)?[4,u(w)(O)]:[3,19];case 18:I=!R.sent(),R.label=19;case 19:return I&&(O=void 0),T=s(O),[2,n(T)?T:s(j)]}})})()},Promise.resolve(void 0))]})}).apply(this,arguments)}var A={},C={};h(C,{destinationPiwikProExamples:function(){return H}});var D={};h(D,{ecommerceAddToCart:function(){return y},ecommerceCartUpdate:function(){return f},ecommerceOrder:function(){return d},ecommerceProductDetailView:function(){return _}});var U={};h(U,{config:function(){return G},ecommerceAddToCart:function(){return q},ecommerceCartUpdate:function(){return V},ecommerceOrder:function(){return R},ecommerceProductDetailView:function(){return z}});var I,T={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:function(e){return o(e)&&"product"===e.type},map:T}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},q={name:"ecommerceAddToCart",data:{set:[{set:[{map:T}]},{map:{currencyCode:{value:"EUR"}}}]}},z={name:"ecommerceProductDetailView",data:{set:[{set:[{map:T}]},{map:{currencyCode:{value:"EUR"}}}]}},V={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:function(e){return o(e)&&"product"===e.type},map:T}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},G={order:{complete:R},product:{add:q,view:z},cart:{view:V}},H={events:D,mapping:U},N={type:"piwikpro",config:{},init:function(e){var t=e.config,r=e.wrap,n=window,o=t.settings,a=void 0===o?{}:o,i=t.loadScript,c=a.appId,s=a.url;if(!c||!s)return!1;n._paq=n._paq||[];var u=r("_paq.push",n._paq.push);i&&(!function(e){var t=document.createElement("script");t.type="text/javascript",t.src=e+"ppms.js",t.async=!0,t.defer=!0,document.head.appendChild(t)}(s),u(["setTrackerUrl",s+"ppms.php"]),u(["setSiteId",c])),!1!==a.linkTracking&&u(["enableLinkTracking"])},push:function(e,t){return _async_to_generator(function(e,t){var n,o,a,i,c,s,u,p,d;return _ts_generator(this,function(y){switch(y.label){case 0:return t.config,n=t.mapping,o=void 0===n?{}:n,a=t.data,i=t.wrap,c=i("_paq.push",window._paq.push),"page view"!==e.event||o.settings?[3,2]:(s=["trackPageView"],[4,l(e,"data.title")]);case 1:return c.apply(void 0,[s.concat([y.sent()])]),[2];case 2:return u=o.settings||{},p=r(a)?a:[a],c([e.event].concat(_to_consumable_array(p))),u.goalId&&(d=u.goalValue?l(e,u.goalValue):void 0,c(["trackGoal",u.goalId,d])),[2]}})}).apply(this,arguments)}},M=N;return I=w,function(e,t,r,n){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,a=!1,i=void 0;try{for(var c,s=function(){var o=c.value;v.call(e,o)||o===r||m(e,o,{get:function(){return t[o]},enumerable:!(n=b(t,o))||n.enumerable})},u=g(t)[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)s()}catch(e){a=!0,i=e}finally{try{o||null==u.return||u.return()}finally{if(a)throw i}}}return e}(m({},"__esModule",{value:!0}),I)}();
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t,r,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},s={};c(s,{DestinationPiwikPro:()=>P,default:()=>$,destinationPiwikPro:()=>M,destinationPiwikProExamples:()=>C}),module.exports=(e=s,((e,t,r,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of n(t))i.call(e,s)||s===r||a(e,s,{get:()=>t[s],enumerable:!(c=o(t,s))||c.enumerable});return e})(a({},"__esModule",{value:!0}),e));var p=Object.getOwnPropertyNames,d=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return r||(0,t[p(t)[0]])((r={exports:{}}).exports,r),r.exports}),u={merge:!0,shallow:!0,extend:!0};function l(e){return Array.isArray(e)}function m(e){return void 0!==e}function g(e){return"object"==typeof e&&null!==e&&!l(e)&&"[object Object]"===Object.prototype.toString.call(e)}function y(e){return"string"==typeof e}function f(e,t="",r){const a=t.split(".");let o=e;for(let e=0;e<a.length;e++){const t=a[e];if("*"===t&&l(o)){const t=a.slice(e+1).join("."),n=[];for(const e of o){const a=f(e,t,r);n.push(a)}return n}if(o=o instanceof Object?o[t]:void 0,!o)break}return m(o)?o:r}var{version:h}=d();function v(e={}){var t;const r=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,n=function(e,t={},r={}){r={...u,...r};const a=Object.entries(t).reduce((t,[a,o])=>{const n=e[a];return r.merge&&Array.isArray(n)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...n]):(r.extend||a in e)&&(t[a]=o),t},{});return r.shallow?{...e,...a}:(Object.assign(e,a),e)}({event:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{type:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${r}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:r,timing:3.14,group:a,count:o,version:{source:h,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[r,a]=null!=(t=e.event.split(" "))?t:[];r&&a&&(n.entity=r,n.action=a)}return n}function w(e="entity action",t={}){const r=t.timestamp||(new Date).setHours(0,13,37,0),a={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return v({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...a.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:a.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["checkout",0]},nested:[]},{type:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["complete",0]},nested:[]},{type:"product",...o,context:{shopping:["complete",0]},nested:[]},{type:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...a,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...a,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...a.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:r,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,event:e})}function b(e){return function(e){return"boolean"==typeof e}(e)||y(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!m(e)||l(e)&&e.every(b)||g(e)&&Object.values(e).every(b)}function k(e){return b(e)?e:void 0}function x(e,t,r){return async function(...a){try{return await e(...a)}catch(e){if(!t)return;return await t(e)}finally{await(null==r?void 0:r())}}}async function O(e,t={},r={}){var a;if(!m(e))return;const o=g(e)&&e.consent||r.consent||(null==(a=r.collector)?void 0:a.consent),n=l(t)?t:[t];for(const t of n){const a=await x(j)(e,t,{...r,consent:o});if(m(a))return a}}async function j(e,t,r={}){const{collector:a,consent:o}=r;return(l(t)?t:[t]).reduce(async(t,n)=>{const i=await t;if(i)return i;const c=y(n)?{key:n}:n;if(!Object.keys(c).length)return;const{condition:s,consent:p,fn:d,key:u,loop:g,map:h,set:v,validate:w,value:b}=c;if(s&&!await x(s)(e,n,a))return;if(p&&!function(e,t={},r={}){const a={...t,...r},o={};let n=void 0===e;return Object.keys(a).forEach(t=>{a[t]&&(o[t]=!0,e&&e[t]&&(n=!0))}),!!n&&o}(p,o))return b;let P=m(b)?b:e;if(d&&(P=await x(d)(e,n,r)),u&&(P=f(e,u,b)),g){const[t,a]=g,o="this"===t?[e]:await O(e,t,r);l(o)&&(P=(await Promise.all(o.map(e=>O(e,a,r)))).filter(m))}else h?P=await Object.entries(h).reduce(async(t,[a,o])=>{const n=await t,i=await O(e,o,r);return m(i)&&(n[a]=i),n},Promise.resolve({})):v&&(P=await Promise.all(v.map(t=>j(e,t,r))));w&&!await x(w)(P)&&(P=void 0);const C=k(P);return m(C)?C:k(b)},Promise.resolve(void 0))}var P={},C={};c(C,{destinationPiwikProExamples:()=>N});var E={};function S(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 U(){const e=w("order complete");return[["ecommerceOrder",e.nested.filter(e=>"product"===e.type).map(S),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]}function D(){return[["ecommerceAddToCart",[S(w("product add")),,],{currencyCode:"EUR"}]]}function A(){return[["ecommerceProductDetailView",[S(w("product view")),,],{currencyCode:"EUR"}]]}function R(){const e=w("cart view");return[["ecommerceCartUpdate",e.nested.filter(e=>"product"===e.type).map(S),e.data.value,{currencyCode:"EUR"}]]}c(E,{ecommerceAddToCart:()=>D,ecommerceCartUpdate:()=>R,ecommerceOrder:()=>U,ecommerceProductDetailView:()=>A});var T={};c(T,{config:()=>H,ecommerceAddToCart:()=>z,ecommerceCartUpdate:()=>I,ecommerceOrder:()=>q,ecommerceProductDetailView:()=>V});var _={sku:"data.id",name:"data.name",price:"data.price",quantity:{value:1},variant:{key:"data.color"},customDimensions:{map:{1:"data.size"}}},q={name:"ecommerceOrder",data:{set:[{loop:["nested",{condition:e=>g(e)&&"product"===e.type,map:_}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},z={name:"ecommerceAddToCart",data:{set:[{set:[{map:_}]},{map:{currencyCode:{value:"EUR"}}}]}},V={name:"ecommerceProductDetailView",data:{set:[{set:[{map:_}]},{map:{currencyCode:{value:"EUR"}}}]}},I={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:e=>g(e)&&"product"===e.type,map:_}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},H={order:{complete:q},product:{add:z,view:V},cart:{view:I}},N={events:E,mapping:T},M={type:"piwikpro",config:{},init({config:e,wrap:t}){const r=window,{settings:a={},loadScript:o}=e,{appId:n,url:i}=a;if(!n||!i)return!1;r._paq=r._paq||[];const c=t("_paq.push",r._paq.push);o&&(!function(e){const t=document.createElement("script");t.type="text/javascript",t.src=e+"ppms.js",t.async=!0,t.defer=!0,document.head.appendChild(t)}(i),c(["setTrackerUrl",i+"ppms.php"]),c(["setSiteId",n])),!1!==a.linkTracking&&c(["enableLinkTracking"])},async push(e,{config:t,mapping:r={},data:a,wrap:o}){const n=o("_paq.push",window._paq.push);if("page view"===e.event&&!r.settings)return void n(["trackPageView",await O(e,"data.title")]);const i=r.settings||{},c=l(a)?a:[a];if(n([e.event,...c]),i.goalId){const t=i.goalValue?O(e,i.goalValue):void 0;n(["trackGoal",i.goalId,t])}}};var $=M;//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["import type { Settings, Mapping, Destination } from './types';\nimport { getMappingValue, isArray } from '@walkeros/core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\n// Examples\nexport * as destinationPiwikProExamples from './examples';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, wrap }) {\n const w = window;\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { appId, url } = settings;\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = wrap('_paq.push', w._paq.push);\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, wrap }) {\n const paq = wrap('_paq.push', window._paq!.push);\n\n // Send pageviews if not disabled\n if (event.event === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.event, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string) {\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n","import type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport type Destination = DestinationWeb.Destination<Settings, Mapping>;\nexport type Config = DestinationWeb.Config<Settings, Mapping>;\n\n// Destination-specific settings (internal usage)\nexport interface Settings {\n appId: string;\n // dimensions?: Dimensions;\n linkTracking?: boolean;\n url: string;\n}\n\n// Single event transformation rule\nexport interface Mapping {\n // dimensions?: Dimensions;\n goalId?: string;\n goalValue?: string;\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface Dimensions {\n [i: number]: string;\n}\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationPiwikProExamples = {\n events,\n mapping\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.type === '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.type === 'product').map(getProduct),\n event.data.value,\n { currencyCode: 'EUR' },\n ],\n ];\n}\n","import type { Mapping } from '@walkeros/core';\nimport 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.type === '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.type === '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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AK,QAAO;AAG3B,IAAAC,GAAE,OAAOA,GAAE,QAAQ,CAAC;AAEpB,UAAM,MAAM,KAAK,aAAaA,GAAE,KAAK,IAAI;AACzC,QAAI,YAAY;AAEd,gBAAU,GAAG;AAGb,UAAI,CAAC,iBAAiB,MAAM,UAAU,CAAC;AAGvC,UAAI,CAAC,aAAa,KAAK,CAAC;AAAA,IAC1B;AAGA,QAAI,SAAS,iBAAiB,MAAO,KAAI,CAAC,oBAAoB,CAAC;AAAA,EACjE;AAAA,EAEA,MAAM,KAAK,OAAO,EAAE,QAAAD,SAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,GAAG;AACtD,UAAM,MAAM,KAAK,aAAa,OAAO,KAAM,IAAI;AAG/C,QAAI,MAAM,UAAU,eAAe,CAAC,QAAQ,UAAU;AACpD,UAAI,CAAC,iBAAiB,MAAM,EAAgB,OAAO,YAAY,CAAC,CAAC;AACjE;AAAA,IACF;AAEA,UAAM,eAAwB,QAAQ,YAAY,CAAC;AAEnD,UAAM,aAAa,EAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAE/C,QAAI,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;AAEhC,QAAI,aAAa,QAAQ;AACvB,YAAM,YAAY,aAAa,YAC3B,EAAgB,OAAO,aAAa,SAAS,IAC7C;AAEJ,UAAI;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb;AAAA;AAAA,MAEF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAa;AAC9B,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAO,gBAAQ;","names":["ecommerceAddToCart","ecommerceCartUpdate","ecommerceOrder","ecommerceProductDetailView","ecommerceOrder","ecommerceAddToCart","ecommerceProductDetailView","ecommerceCartUpdate","config","w"]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var e,t,r=Object.defineProperty,a=(e,t)=>{for(var a in t)r(e,a,{get:t[a],enumerable:!0})},o=Object.getOwnPropertyNames,n=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports}),i={merge:!0,shallow:!0,extend:!0};function s(e){return Array.isArray(e)}function c(e){return void 0!==e}function d(e){return"object"==typeof e&&null!==e&&!s(e)&&"[object Object]"===Object.prototype.toString.call(e)}function p(e){return"string"==typeof e}function u(e,t="",r){const a=t.split(".");let o=e;for(let e=0;e<a.length;e++){const t=a[e];if("*"===t&&s(o)){const t=a.slice(e+1).join("."),n=[];for(const e of o){const a=u(e,t,r);n.push(a)}return n}if(o=o instanceof Object?o[t]:void 0,!o)break}return c(o)?o:r}var{version:l}=n();function m(e={}){var t;const r=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,n=function(e,t={},r={}){r={...i,...r};const a=Object.entries(t).reduce((t,[a,o])=>{const n=e[a];return r.merge&&Array.isArray(n)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...n]):(r.extend||a in e)&&(t[a]=o),t},{});return r.shallow?{...e,...a}:(Object.assign(e,a),e)}({event:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{type:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${r}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:r,timing:3.14,group:a,count:o,version:{source:l,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[r,a]=null!=(t=e.event.split(" "))?t:[];r&&a&&(n.entity=r,n.action=a)}return n}function g(e="entity action",t={}){const r=t.timestamp||(new Date).setHours(0,13,37,0),a={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return m({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...a.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:a.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["checkout",0]},nested:[]},{type:"product",...o,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...a,context:{shopping:["complete",0]},nested:[]},{type:"product",...o,context:{shopping:["complete",0]},nested:[]},{type:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...a,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...a,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...a.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:r,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,event:e})}function y(e){return function(e){return"boolean"==typeof e}(e)||p(e)||function(e){return"number"==typeof e&&!Number.isNaN(e)}(e)||!c(e)||s(e)&&e.every(y)||d(e)&&Object.values(e).every(y)}function f(e){return y(e)?e:void 0}function h(e,t,r){return async function(...a){try{return await e(...a)}catch(e){if(!t)return;return await t(e)}finally{await(null==r?void 0:r())}}}async function v(e,t={},r={}){var a;if(!c(e))return;const o=d(e)&&e.consent||r.consent||(null==(a=r.collector)?void 0:a.consent),n=s(t)?t:[t];for(const t of n){const a=await h(w)(e,t,{...r,consent:o});if(c(a))return a}}async function w(e,t,r={}){const{collector:a,consent:o}=r;return(s(t)?t:[t]).reduce(async(t,n)=>{const i=await t;if(i)return i;const d=p(n)?{key:n}:n;if(!Object.keys(d).length)return;const{condition:l,consent:m,fn:g,key:y,loop:b,map:k,set:x,validate:O,value:j}=d;if(l&&!await h(l)(e,n,a))return;if(m&&!function(e,t={},r={}){const a={...t,...r},o={};let n=void 0===e;return Object.keys(a).forEach(t=>{a[t]&&(o[t]=!0,e&&e[t]&&(n=!0))}),!!n&&o}(m,o))return j;let C=c(j)?j:e;if(g&&(C=await h(g)(e,n,r)),y&&(C=u(e,y,j)),b){const[t,a]=b,o="this"===t?[e]:await v(e,t,r);s(o)&&(C=(await Promise.all(o.map(e=>v(e,a,r)))).filter(c))}else k?C=await Object.entries(k).reduce(async(t,[a,o])=>{const n=await t,i=await v(e,o,r);return c(i)&&(n[a]=i),n},Promise.resolve({})):x&&(C=await Promise.all(x.map(t=>w(e,t,r))));O&&!await h(O)(C)&&(C=void 0);const E=f(C);return c(E)?E:f(j)},Promise.resolve(void 0))}var b={},k={};a(k,{destinationPiwikProExamples:()=>z});var x={};function O(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 j(){const e=g("order complete");return[["ecommerceOrder",e.nested.filter(e=>"product"===e.type).map(O),{orderId:e.data.id,grandTotal:e.data.total,tax:e.data.taxes,shipping:e.data.shipping},{currencyCode:"EUR"}]]}function C(){return[["ecommerceAddToCart",[O(g("product add")),,],{currencyCode:"EUR"}]]}function E(){return[["ecommerceProductDetailView",[O(g("product view")),,],{currencyCode:"EUR"}]]}function P(){const e=g("cart view");return[["ecommerceCartUpdate",e.nested.filter(e=>"product"===e.type).map(O),e.data.value,{currencyCode:"EUR"}]]}a(x,{ecommerceAddToCart:()=>C,ecommerceCartUpdate:()=>P,ecommerceOrder:()=>j,ecommerceProductDetailView:()=>E});var S={};a(S,{config:()=>q,ecommerceAddToCart:()=>D,ecommerceCartUpdate:()=>T,ecommerceOrder:()=>A,ecommerceProductDetailView:()=>R});var U={sku:"data.id",name:"data.name",price:"data.price",quantity:{value:1},variant:{key:"data.color"},customDimensions:{map:{1:"data.size"}}},A={name:"ecommerceOrder",data:{set:[{loop:["nested",{condition:e=>d(e)&&"product"===e.type,map:U}]},{map:{orderId:"data.id",grandTotal:"data.total",tax:"data.taxes",shipping:"data.shipping"}},{map:{currencyCode:{value:"EUR"}}}]}},D={name:"ecommerceAddToCart",data:{set:[{set:[{map:U}]},{map:{currencyCode:{value:"EUR"}}}]}},R={name:"ecommerceProductDetailView",data:{set:[{set:[{map:U}]},{map:{currencyCode:{value:"EUR"}}}]}},T={name:"ecommerceCartUpdate",data:{set:[{loop:["nested",{condition:e=>d(e)&&"product"===e.type,map:U}]},"data.value",{map:{currencyCode:{value:"EUR"}}}]}},q={order:{complete:A},product:{add:D,view:R},cart:{view:T}},z={events:x,mapping:S},V={type:"piwikpro",config:{},init({config:e,wrap:t}){const r=window,{settings:a={},loadScript:o}=e,{appId:n,url:i}=a;if(!n||!i)return!1;r._paq=r._paq||[];const s=t("_paq.push",r._paq.push);o&&(!function(e){const t=document.createElement("script");t.type="text/javascript",t.src=e+"ppms.js",t.async=!0,t.defer=!0,document.head.appendChild(t)}(i),s(["setTrackerUrl",i+"ppms.php"]),s(["setSiteId",n])),!1!==a.linkTracking&&s(["enableLinkTracking"])},async push(e,{config:t,mapping:r={},data:a,wrap:o}){const n=o("_paq.push",window._paq.push);if("page view"===e.event&&!r.settings)return void n(["trackPageView",await v(e,"data.title")]);const i=r.settings||{},c=s(a)?a:[a];if(n([e.event,...c]),i.goalId){const t=i.goalValue?v(e,i.goalValue):void 0;n(["trackGoal",i.goalId,t])}}};var _=V;export{b as DestinationPiwikPro,_ as default,V as destinationPiwikPro,k as destinationPiwikProExamples};//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/index.ts"],"sourcesContent":["import type { Mapping as WalkerOSMapping, Elb } from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n // Augment the global WalkerOS namespace with destination-specific types\n namespace WalkerOS {\n interface Elb extends Elb.RegisterDestination<Destination, Config> {}\n }\n\n interface Window {\n _paq?: Array<unknown>;\n }\n}\n\nexport type Destination = DestinationWeb.Destination<Settings, Mapping>;\nexport type Config = DestinationWeb.Config<Settings, Mapping>;\n\n// Destination-specific settings (internal usage)\nexport interface Settings {\n appId: string;\n // dimensions?: Dimensions;\n linkTracking?: boolean;\n url: string;\n}\n\n// Single event transformation rule\nexport interface Mapping {\n // dimensions?: Dimensions;\n goalId?: string;\n goalValue?: string;\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport interface Dimensions {\n [i: number]: string;\n}\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationPiwikProExamples = {\n events,\n mapping\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.type === '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.type === 'product').map(getProduct),\n event.data.value,\n { currencyCode: 'EUR' },\n ],\n ];\n}\n","import type { Mapping } from '@walkeros/core';\nimport 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.type === '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.type === '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","import type { Settings, Mapping, Destination } from './types';\nimport { getMappingValue, isArray } from '@walkeros/core';\n\n// Types\nexport * as DestinationPiwikPro from './types';\n\n// Examples\nexport * as destinationPiwikProExamples from './examples';\n\nexport const destinationPiwikPro: Destination = {\n type: 'piwikpro',\n\n config: {},\n\n init({ config, wrap }) {\n const w = window;\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { appId, url } = settings;\n\n // Required parameters\n if (!appId || !url) return false;\n\n // Set up the Piwik Pro interface _paq\n w._paq = w._paq || [];\n\n const paq = wrap('_paq.push', w._paq.push);\n if (loadScript) {\n // Load the JavaScript Tracking Client\n addScript(url);\n\n // Register the tracker url only with script loading\n paq(['setTrackerUrl', url + 'ppms.php']);\n\n // Register app id\n paq(['setSiteId', appId]);\n }\n\n // Enable download and outlink tracking if not disabled\n if (settings.linkTracking !== false) paq(['enableLinkTracking']);\n },\n\n async push(event, { config, mapping = {}, data, wrap }) {\n const paq = wrap('_paq.push', window._paq!.push);\n\n // Send pageviews if not disabled\n if (event.event === 'page view' && !mapping.settings) {\n paq(['trackPageView', await getMappingValue(event, 'data.title')]);\n return;\n }\n\n const eventMapping: Mapping = mapping.settings || {};\n\n const parameters = isArray(data) ? data : [data];\n\n paq([event.event, ...parameters]);\n\n if (eventMapping.goalId) {\n const goalValue = eventMapping.goalValue\n ? getMappingValue(event, eventMapping.goalValue)\n : undefined;\n\n paq([\n 'trackGoal',\n eventMapping.goalId,\n goalValue,\n // @TODO dimensions\n ]);\n }\n },\n};\n\nfunction addScript(url: string) {\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = url + 'ppms.js';\n script.async = true;\n script.defer = true;\n document.head.appendChild(script);\n}\n\nexport default destinationPiwikPro;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAS,W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AM,KAAK,OAAO,EAAE,QAAAD,SAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,GAAG;AACtD,UAAM,MAAM,KAAK,aAAa,OAAO,KAAM,IAAI;AAG/C,QAAI,MAAM,UAAU,eAAe,CAAC,QAAQ,UAAU;AACpD,UAAI,CAAC,iBAAiB,MAAM,EAAgB,OAAO,YAAY,CAAC,CAAC;AACjE;AAAA,IACF;AAEA,UAAM,eAAwB,QAAQ,YAAY,CAAC;AAEnD,UAAM,aAAa,EAAQ,IAAI,IAAI,OAAO,CAAC,IAAI;AAE/C,QAAI,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;AAEhC,QAAI,aAAa,QAAQ;AACvB,YAAM,YAAY,aAAa,YAC3B,EAAgB,OAAO,aAAa,SAAS,IAC7C;AAEJ,UAAI;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb;AAAA;AAAA,MAEF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAa;AAC9B,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,OAAO;AACd,SAAO,MAAM,MAAM;AACnB,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAO,gBAAQ;","names":["ecommerceAddToCart","ecommerceCartUpdate","ecommerceOrder","ecommerceProductDetailView","ecommerceOrder","ecommerceAddToCart","ecommerceProductDetailView","ecommerceCartUpdate","config","w"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@walkeros/web-destination-piwikpro",
3
+ "description": "Piwik PRO destination for walkerOS",
4
+ "version": "0.0.7",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ },
15
+ "./examples": {
16
+ "types": "./dist/examples/index.d.ts",
17
+ "import": "./dist/examples/index.mjs",
18
+ "require": "./dist/examples/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist/**"
23
+ ],
24
+ "scripts": {
25
+ "build": "tsup --silent",
26
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
27
+ "dev": "jest --watchAll --colors",
28
+ "lint": "tsc && eslint \"**/*.ts*\"",
29
+ "test": "jest",
30
+ "update": "npx npm-check-updates -u && npm update"
31
+ },
32
+ "dependencies": {
33
+ "@walkeros/web-core": "0.0.7"
34
+ },
35
+ "devDependencies": {},
36
+ "repository": {
37
+ "url": "git+https://github.com/elbwalker/walkerOS.git",
38
+ "directory": "packages/web/destinations/piwikpro"
39
+ },
40
+ "author": "elbwalker <hello@elbwalker.com>",
41
+ "homepage": "https://github.com/elbwalker/walkerOS#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/elbwalker/walkerOS/issues"
44
+ },
45
+ "keywords": [
46
+ "walker",
47
+ "walkerOS",
48
+ "destination",
49
+ "web",
50
+ "piwik pro"
51
+ ],
52
+ "funding": [
53
+ {
54
+ "type": "GitHub Sponsors",
55
+ "url": "https://github.com/sponsors/elbwalker"
56
+ }
57
+ ]
58
+ }