@walkeros/web-destination-plausible 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,58 @@
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
+ # Plausible Destination for walkerOS
8
+
9
+ This package provides a Plausible destination for walkerOS. It allows you to
10
+ send events to Plausible Analytics.
11
+
12
+ [View documentation](https://www.elbwalker.com/docs/destinations/web/plausible/)
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 Plausible destination receives processed events from the walkerOS collector
25
+ and transforms them into Plausible Analytics format, providing lightweight,
26
+ privacy-focused web analytics without cookies or personal data collection.
27
+
28
+ ## Installation
29
+
30
+ ```sh
31
+ npm install @walkeros/web-destination-plausible
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Here's a basic example of how to use the Plausible destination:
37
+
38
+ ```typescript
39
+ import { elb } from '@walkeros/collector';
40
+ import { destinationPlausible } from '@walkeros/web-destination-plausible';
41
+
42
+ elb('walker destination', destinationPlausible, {
43
+ custom: {
44
+ domain: 'your-domain.com',
45
+ },
46
+ });
47
+ ```
48
+
49
+ ## Contribute
50
+
51
+ Feel free to contribute by submitting an
52
+ [issue](https://github.com/elbwalker/walkerOS/issues), starting a
53
+ [discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
54
+ [contact](https://calendly.com/elb-alexander/30min).
55
+
56
+ ## License
57
+
58
+ This project is licensed under the MIT License.
@@ -0,0 +1,57 @@
1
+ import { WalkerOS, Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare function purchase$1(): unknown[];
5
+ declare function customEvent$1(): unknown[];
6
+
7
+ declare namespace events {
8
+ export { customEvent$1 as customEvent, purchase$1 as purchase };
9
+ }
10
+
11
+ declare global {
12
+ namespace WalkerOS {
13
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
14
+ }
15
+ }
16
+ interface Window {
17
+ plausible?: Plausible & {
18
+ q?: IArguments[];
19
+ };
20
+ }
21
+ }
22
+ type Plausible = (event: string, options?: {
23
+ props?: WalkerOS.AnyObject;
24
+ }) => void;
25
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
26
+ type Config = DestinationWeb.Config<Settings, Mapping>;
27
+ interface Settings {
28
+ domain?: string;
29
+ }
30
+ interface Mapping {
31
+ }
32
+ type Rule = Mapping$1.Rule<Mapping>;
33
+
34
+ declare const customEvent: Rule;
35
+ declare const purchase: Rule;
36
+ declare const config: {
37
+ entity: {
38
+ action: Rule;
39
+ };
40
+ order: {
41
+ complete: Rule;
42
+ };
43
+ };
44
+
45
+ declare const mapping_config: typeof config;
46
+ declare const mapping_customEvent: typeof customEvent;
47
+ declare const mapping_purchase: typeof purchase;
48
+ declare namespace mapping {
49
+ export { mapping_config as config, mapping_customEvent as customEvent, mapping_purchase as purchase };
50
+ }
51
+
52
+ declare const destinationPlausibleExamples: {
53
+ events: typeof events;
54
+ mapping: typeof mapping;
55
+ };
56
+
57
+ export { destinationPlausibleExamples };
@@ -0,0 +1,57 @@
1
+ import { WalkerOS, Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare function purchase$1(): unknown[];
5
+ declare function customEvent$1(): unknown[];
6
+
7
+ declare namespace events {
8
+ export { customEvent$1 as customEvent, purchase$1 as purchase };
9
+ }
10
+
11
+ declare global {
12
+ namespace WalkerOS {
13
+ interface Elb extends Elb.RegisterDestination<Destination, Config> {
14
+ }
15
+ }
16
+ interface Window {
17
+ plausible?: Plausible & {
18
+ q?: IArguments[];
19
+ };
20
+ }
21
+ }
22
+ type Plausible = (event: string, options?: {
23
+ props?: WalkerOS.AnyObject;
24
+ }) => void;
25
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
26
+ type Config = DestinationWeb.Config<Settings, Mapping>;
27
+ interface Settings {
28
+ domain?: string;
29
+ }
30
+ interface Mapping {
31
+ }
32
+ type Rule = Mapping$1.Rule<Mapping>;
33
+
34
+ declare const customEvent: Rule;
35
+ declare const purchase: Rule;
36
+ declare const config: {
37
+ entity: {
38
+ action: Rule;
39
+ };
40
+ order: {
41
+ complete: Rule;
42
+ };
43
+ };
44
+
45
+ declare const mapping_config: typeof config;
46
+ declare const mapping_customEvent: typeof customEvent;
47
+ declare const mapping_purchase: typeof purchase;
48
+ declare namespace mapping {
49
+ export { mapping_config as config, mapping_customEvent as customEvent, mapping_purchase as purchase };
50
+ }
51
+
52
+ declare const destinationPlausibleExamples: {
53
+ events: typeof events;
54
+ mapping: typeof mapping;
55
+ };
56
+
57
+ export { destinationPlausibleExamples };
@@ -0,0 +1,133 @@
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
+ destinationPlausibleExamples: () => destinationPlausibleExamples
24
+ });
25
+ module.exports = __toCommonJS(examples_exports);
26
+
27
+ // src/examples/events.ts
28
+ var events_exports = {};
29
+ __export(events_exports, {
30
+ customEvent: () => customEvent,
31
+ purchase: () => purchase
32
+ });
33
+
34
+ // ../../../core/dist/index.mjs
35
+ var e;
36
+ var t;
37
+ var n = Object.getOwnPropertyNames;
38
+ var r = (e = { "package.json"(e2, t2) {
39
+ 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" }] };
40
+ } }, function() {
41
+ return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
42
+ });
43
+ var w = { merge: true, shallow: true, extend: true };
44
+ function v(e2, t2 = {}, n2 = {}) {
45
+ n2 = { ...w, ...n2 };
46
+ const r2 = Object.entries(t2).reduce((t3, [r3, o]) => {
47
+ const i = e2[r3];
48
+ 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;
49
+ }, {});
50
+ return n2.shallow ? { ...e2, ...r2 } : (Object.assign(e2, r2), e2);
51
+ }
52
+ var { version: V } = r();
53
+ function H(e2 = {}) {
54
+ var _a;
55
+ 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 });
56
+ if (e2.event) {
57
+ const [t3, n3] = (_a = e2.event.split(" ")) != null ? _a : [];
58
+ t3 && n3 && (o.entity = t3, o.action = n3);
59
+ }
60
+ return o;
61
+ }
62
+ function z(e2 = "entity action", t2 = {}) {
63
+ 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 } };
64
+ 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 });
65
+ }
66
+
67
+ // src/examples/events.ts
68
+ function purchase() {
69
+ const event = z("order complete");
70
+ return [
71
+ "purchase",
72
+ {
73
+ revenue: {
74
+ currency: "EUR",
75
+ amount: event.data.total
76
+ }
77
+ }
78
+ ];
79
+ }
80
+ function customEvent() {
81
+ const event = z();
82
+ return [
83
+ "Custom Event",
84
+ {
85
+ props: event.data,
86
+ revenue: event.data.number
87
+ }
88
+ ];
89
+ }
90
+
91
+ // src/examples/mapping.ts
92
+ var mapping_exports = {};
93
+ __export(mapping_exports, {
94
+ config: () => config,
95
+ customEvent: () => customEvent2,
96
+ purchase: () => purchase2
97
+ });
98
+ var customEvent2 = {
99
+ name: "Custom Event",
100
+ data: {
101
+ map: {
102
+ props: "data",
103
+ revenue: "data.number"
104
+ }
105
+ }
106
+ };
107
+ var purchase2 = {
108
+ name: "purchase",
109
+ data: {
110
+ map: {
111
+ revenue: {
112
+ map: {
113
+ currency: { value: "EUR" },
114
+ amount: "data.total"
115
+ }
116
+ }
117
+ }
118
+ }
119
+ };
120
+ var config = {
121
+ entity: { action: customEvent2 },
122
+ order: { complete: purchase2 }
123
+ };
124
+
125
+ // src/examples/index.ts
126
+ var destinationPlausibleExamples = {
127
+ events: events_exports,
128
+ mapping: mapping_exports
129
+ };
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {
132
+ destinationPlausibleExamples
133
+ });
@@ -0,0 +1,112 @@
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
+ customEvent: () => customEvent,
11
+ purchase: () => purchase
12
+ });
13
+
14
+ // ../../../core/dist/index.mjs
15
+ var e;
16
+ var t;
17
+ var n = Object.getOwnPropertyNames;
18
+ var r = (e = { "package.json"(e2, t2) {
19
+ 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" }] };
20
+ } }, function() {
21
+ return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
22
+ });
23
+ var w = { merge: true, shallow: true, extend: true };
24
+ function v(e2, t2 = {}, n2 = {}) {
25
+ n2 = { ...w, ...n2 };
26
+ const r2 = Object.entries(t2).reduce((t3, [r3, o]) => {
27
+ const i = e2[r3];
28
+ 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;
29
+ }, {});
30
+ return n2.shallow ? { ...e2, ...r2 } : (Object.assign(e2, r2), e2);
31
+ }
32
+ var { version: V } = r();
33
+ function H(e2 = {}) {
34
+ var _a;
35
+ 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 });
36
+ if (e2.event) {
37
+ const [t3, n3] = (_a = e2.event.split(" ")) != null ? _a : [];
38
+ t3 && n3 && (o.entity = t3, o.action = n3);
39
+ }
40
+ return o;
41
+ }
42
+ function z(e2 = "entity action", t2 = {}) {
43
+ 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 } };
44
+ 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 });
45
+ }
46
+
47
+ // src/examples/events.ts
48
+ function purchase() {
49
+ const event = z("order complete");
50
+ return [
51
+ "purchase",
52
+ {
53
+ revenue: {
54
+ currency: "EUR",
55
+ amount: event.data.total
56
+ }
57
+ }
58
+ ];
59
+ }
60
+ function customEvent() {
61
+ const event = z();
62
+ return [
63
+ "Custom Event",
64
+ {
65
+ props: event.data,
66
+ revenue: event.data.number
67
+ }
68
+ ];
69
+ }
70
+
71
+ // src/examples/mapping.ts
72
+ var mapping_exports = {};
73
+ __export(mapping_exports, {
74
+ config: () => config,
75
+ customEvent: () => customEvent2,
76
+ purchase: () => purchase2
77
+ });
78
+ var customEvent2 = {
79
+ name: "Custom Event",
80
+ data: {
81
+ map: {
82
+ props: "data",
83
+ revenue: "data.number"
84
+ }
85
+ }
86
+ };
87
+ var purchase2 = {
88
+ name: "purchase",
89
+ data: {
90
+ map: {
91
+ revenue: {
92
+ map: {
93
+ currency: { value: "EUR" },
94
+ amount: "data.total"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ };
100
+ var config = {
101
+ entity: { action: customEvent2 },
102
+ order: { complete: purchase2 }
103
+ };
104
+
105
+ // src/examples/index.ts
106
+ var destinationPlausibleExamples = {
107
+ events: events_exports,
108
+ mapping: mapping_exports
109
+ };
110
+ export {
111
+ destinationPlausibleExamples
112
+ };
@@ -0,0 +1 @@
1
+ "use strict";var Destination=(()=>{var e,t,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},i={};s(i,{DestinationPlausible:()=>b,default:()=>P,destinationPlausible:()=>E,destinationPlausibleExamples:()=>h});var c=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[c(e)[0]])((t={exports:{}}).exports,t),t.exports}),l={merge:!0,shallow:!0,extend:!0};function u(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:d}=p();function g(e={}){var t;const r=e.timestamp||(new Date).setHours(0,13,37,0),o=e.group||"gr0up",a=e.count||1,n=function(e,t={},r={}){r={...l,...r};const o=Object.entries(t).reduce((t,[o,a])=>{const n=e[o];return r.merge&&Array.isArray(n)&&Array.isArray(a)?t[o]=a.reduce((e,t)=>e.includes(t)?e:[...e,t],[...n]):(r.extend||o in e)&&(t[o]=a),t},{});return r.shallow?{...e,...o}:(Object.assign(e,o),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}-${o}-${a}`,trigger:"test",entity:"entity",action:"action",timestamp:r,timing:3.14,group:o,count:a,version:{source:d,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[r,o]=null!=(t=e.event.split(" "))?t:[];r&&o&&(n.entity=r,n.action=o)}return n}function m(e="entity action",t={}){const r=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},a={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return g({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+a.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...o,context:{shopping:["checkout",0]},nested:[]},{type:"product",...a,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",...o,context:{shopping:["complete",0]},nested:[]},{type:"product",...a,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":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.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})}var b={},h={};s(h,{destinationPlausibleExamples:()=>j});var y={};function v(){return["purchase",{revenue:{currency:"EUR",amount:m("order complete").data.total}}]}function w(){const e=m();return["Custom Event",{props:e.data,revenue:e.data.number}]}s(y,{customEvent:()=>w,purchase:()=>v});var f={};s(f,{config:()=>O,customEvent:()=>k,purchase:()=>x});var k={name:"Custom Event",data:{map:{props:"data",revenue:"data.number"}}},x={name:"purchase",data:{map:{revenue:{map:{currency:{value:"EUR"},amount:"data.total"}}}}},O={entity:{action:k},order:{complete:x}},j={events:y,mapping:f},E={type:"plausible",config:{},init({config:e,wrap:t}){const r=window,o=e.settings||{};e.loadScript&&function(e,t="https://plausible.io/js/script.manual.js"){const r=document.createElement("script");r.src=t,e&&(r.dataset.domain=e);document.head.appendChild(r)}(o.domain),r.plausible=r.plausible||function(){(r.plausible.q=r.plausible.q||[]).push(arguments)}},push(e,{config:t,data:r,wrap:o}){const a=u(r)?r:{};o("plausible",window.plausible)(`${e.event}`,a)}};var S,P=E;return S=i,((e,t,s,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of a(t))n.call(e,c)||c===s||r(e,c,{get:()=>t[c],enumerable:!(i=o(t,c))||i.enumerable});return e})(r({},"__esModule",{value:!0}),S)})();
@@ -0,0 +1,76 @@
1
+ import { WalkerOS, 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
+ plausible?: Plausible & {
11
+ q?: IArguments[];
12
+ };
13
+ }
14
+ }
15
+ type Plausible = (event: string, options?: {
16
+ props?: WalkerOS.AnyObject;
17
+ }) => void;
18
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
19
+ type Config = DestinationWeb.Config<Settings, Mapping>;
20
+ interface Settings {
21
+ domain?: string;
22
+ }
23
+ interface Mapping {
24
+ }
25
+ type Rule = Mapping$1.Rule<Mapping>;
26
+ type Rules = Mapping$1.Rules<Rule>;
27
+
28
+ type index$1_Config = Config;
29
+ type index$1_Destination = Destination;
30
+ type index$1_Mapping = Mapping;
31
+ type index$1_Plausible = Plausible;
32
+ type index$1_Rule = Rule;
33
+ type index$1_Rules = Rules;
34
+ type index$1_Settings = Settings;
35
+ declare namespace index$1 {
36
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_Plausible as Plausible, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
37
+ }
38
+
39
+ declare function purchase$1(): unknown[];
40
+ declare function customEvent$1(): unknown[];
41
+
42
+ declare namespace events {
43
+ export { customEvent$1 as customEvent, purchase$1 as purchase };
44
+ }
45
+
46
+ declare const customEvent: Rule;
47
+ declare const purchase: Rule;
48
+ declare const config: {
49
+ entity: {
50
+ action: Rule;
51
+ };
52
+ order: {
53
+ complete: Rule;
54
+ };
55
+ };
56
+
57
+ declare const mapping_config: typeof config;
58
+ declare const mapping_customEvent: typeof customEvent;
59
+ declare const mapping_purchase: typeof purchase;
60
+ declare namespace mapping {
61
+ export { mapping_config as config, mapping_customEvent as customEvent, mapping_purchase as purchase };
62
+ }
63
+
64
+ declare const destinationPlausibleExamples: {
65
+ events: typeof events;
66
+ mapping: typeof mapping;
67
+ };
68
+
69
+ declare const index_destinationPlausibleExamples: typeof destinationPlausibleExamples;
70
+ declare namespace index {
71
+ export { index_destinationPlausibleExamples as destinationPlausibleExamples };
72
+ }
73
+
74
+ declare const destinationPlausible: Destination;
75
+
76
+ export { index$1 as DestinationPlausible, destinationPlausible as default, destinationPlausible, index as destinationPlausibleExamples };
@@ -0,0 +1,76 @@
1
+ import { WalkerOS, 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
+ plausible?: Plausible & {
11
+ q?: IArguments[];
12
+ };
13
+ }
14
+ }
15
+ type Plausible = (event: string, options?: {
16
+ props?: WalkerOS.AnyObject;
17
+ }) => void;
18
+ type Destination = DestinationWeb.Destination<Settings, Mapping>;
19
+ type Config = DestinationWeb.Config<Settings, Mapping>;
20
+ interface Settings {
21
+ domain?: string;
22
+ }
23
+ interface Mapping {
24
+ }
25
+ type Rule = Mapping$1.Rule<Mapping>;
26
+ type Rules = Mapping$1.Rules<Rule>;
27
+
28
+ type index$1_Config = Config;
29
+ type index$1_Destination = Destination;
30
+ type index$1_Mapping = Mapping;
31
+ type index$1_Plausible = Plausible;
32
+ type index$1_Rule = Rule;
33
+ type index$1_Rules = Rules;
34
+ type index$1_Settings = Settings;
35
+ declare namespace index$1 {
36
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_Plausible as Plausible, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings };
37
+ }
38
+
39
+ declare function purchase$1(): unknown[];
40
+ declare function customEvent$1(): unknown[];
41
+
42
+ declare namespace events {
43
+ export { customEvent$1 as customEvent, purchase$1 as purchase };
44
+ }
45
+
46
+ declare const customEvent: Rule;
47
+ declare const purchase: Rule;
48
+ declare const config: {
49
+ entity: {
50
+ action: Rule;
51
+ };
52
+ order: {
53
+ complete: Rule;
54
+ };
55
+ };
56
+
57
+ declare const mapping_config: typeof config;
58
+ declare const mapping_customEvent: typeof customEvent;
59
+ declare const mapping_purchase: typeof purchase;
60
+ declare namespace mapping {
61
+ export { mapping_config as config, mapping_customEvent as customEvent, mapping_purchase as purchase };
62
+ }
63
+
64
+ declare const destinationPlausibleExamples: {
65
+ events: typeof events;
66
+ mapping: typeof mapping;
67
+ };
68
+
69
+ declare const index_destinationPlausibleExamples: typeof destinationPlausibleExamples;
70
+ declare namespace index {
71
+ export { index_destinationPlausibleExamples as destinationPlausibleExamples };
72
+ }
73
+
74
+ declare const destinationPlausible: Destination;
75
+
76
+ export { index$1 as DestinationPlausible, destinationPlausible as default, destinationPlausible, index as destinationPlausibleExamples };
@@ -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 _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 _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,s=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(s)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}}var Destination=function(){var e,t,r=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)},n=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({},y,r);var n=Object.entries(t).reduce(function(t,n){var o=_sliced_to_array(n,2),a=o[0],i=o[1],s=e[a];return r.merge&&Array.isArray(s)&&Array.isArray(i)?t[a]=i.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(s)):(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:g,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),s=i[0],c=i[1];s&&c&&(o.entity=s,o.action=c)}return o},o=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),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},a={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return n(_object_spread_props(_object_spread({},{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:_object_spread_props(_object_spread({},o.data),{quantity:2}),context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+a.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[_object_spread_props(_object_spread({type:"product"},o),{context:{shopping:["checkout",0]},nested:[]}),_object_spread_props(_object_spread({type:"product"},a),{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"},o),{context:{shopping:["complete",0]},nested:[]}),_object_spread_props(_object_spread({type:"product"},a),{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({},o),{context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"}),"product view":_object_spread_props(_object_spread({},o),{context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"}),"product visible":{data:_object_spread_props(_object_spread({},o.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}))},a=function(){return["purchase",{revenue:{currency:"EUR",amount:o("order complete").data.total}}]},i=function(){var e=o();return["Custom Event",{props:e.data,revenue:e.data.number}]},s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,u=function(e,t){for(var r in t)s(e,r,{get:t[r],enumerable:!0})},d={};u(d,{DestinationPlausible:function(){return m},default:function(){return P},destinationPlausible:function(){return S},destinationPlausibleExamples:function(){return f}});var _=Object.getOwnPropertyNames,b=(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[_(e)[0]])((t={exports:{}}).exports,t),t.exports}),y={merge:!0,shallow:!0,extend:!0},g=b().version,m={},f={};u(f,{destinationPlausibleExamples:function(){return x}});var h={};u(h,{customEvent:function(){return i},purchase:function(){return a}});var v={};u(v,{config:function(){return k},customEvent:function(){return j},purchase:function(){return O}});var w,j={name:"Custom Event",data:{map:{props:"data",revenue:"data.number"}}},O={name:"purchase",data:{map:{revenue:{map:{currency:{value:"EUR"},amount:"data.total"}}}}},k={entity:{action:j},order:{complete:O}},x={events:h,mapping:v},S={type:"plausible",config:{},init:function(e){var t=e.config,r=(e.wrap,window),n=t.settings||{};t.loadScript&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://plausible.io/js/script.manual.js",r=document.createElement("script");r.src=t,e&&(r.dataset.domain=e),document.head.appendChild(r)}(n.domain),r.plausible=r.plausible||function(){(r.plausible.q=r.plausible.q||[]).push(arguments)}},push:function(e,t){t.config;var n=t.data,o=t.wrap,a=r(n)?n:{};o("plausible",window.plausible)("".concat(e.event),a)}},P=S;return w=d,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 u,d=function(){var o=u.value;l.call(e,o)||o===r||s(e,o,{get:function(){return t[o]},enumerable:!(n=c(t,o))||n.enumerable})},_=p(t)[Symbol.iterator]();!(o=(u=_.next()).done);o=!0)d()}catch(e){a=!0,i=e}finally{try{o||null==_.return||_.return()}finally{if(a)throw i}}}return e}(s({},"__esModule",{value:!0}),w)}();
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t,o,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,i=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},c={};i(c,{DestinationPlausible:()=>h,default:()=>P,destinationPlausible:()=>S,destinationPlausibleExamples:()=>y}),module.exports=(e=c,((e,t,o,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of n(t))s.call(e,c)||c===o||r(e,c,{get:()=>t[c],enumerable:!(i=a(t,c))||i.enumerable});return e})(r({},"__esModule",{value:!0}),e));var p=Object.getOwnPropertyNames,l=(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 o||(0,t[p(t)[0]])((o={exports:{}}).exports,o),o.exports}),u={merge:!0,shallow:!0,extend:!0};function d(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:g}=l();function m(e={}){var t;const o=e.timestamp||(new Date).setHours(0,13,37,0),r=e.group||"gr0up",a=e.count||1,n=function(e,t={},o={}){o={...u,...o};const r=Object.entries(t).reduce((t,[r,a])=>{const n=e[r];return o.merge&&Array.isArray(n)&&Array.isArray(a)?t[r]=a.reduce((e,t)=>e.includes(t)?e:[...e,t],[...n]):(o.extend||r in e)&&(t[r]=a),t},{});return o.shallow?{...e,...r}:(Object.assign(e,r),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:`${o}-${r}-${a}`,trigger:"test",entity:"entity",action:"action",timestamp:o,timing:3.14,group:r,count:a,version:{source:g,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[o,r]=null!=(t=e.event.split(" "))?t:[];o&&r&&(n.entity=o,n.action=r)}return n}function b(e="entity action",t={}){const o=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},a={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return m({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+a.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...r,context:{shopping:["checkout",0]},nested:[]},{type:"product",...a,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",...r,context:{shopping:["complete",0]},nested:[]},{type:"product",...a,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":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.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:o,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})}var h={},y={};i(y,{destinationPlausibleExamples:()=>E});var v={};function w(){return["purchase",{revenue:{currency:"EUR",amount:b("order complete").data.total}}]}function f(){const e=b();return["Custom Event",{props:e.data,revenue:e.data.number}]}i(v,{customEvent:()=>f,purchase:()=>w});var k={};i(k,{config:()=>j,customEvent:()=>x,purchase:()=>O});var x={name:"Custom Event",data:{map:{props:"data",revenue:"data.number"}}},O={name:"purchase",data:{map:{revenue:{map:{currency:{value:"EUR"},amount:"data.total"}}}}},j={entity:{action:x},order:{complete:O}},E={events:v,mapping:k},S={type:"plausible",config:{},init({config:e,wrap:t}){const o=window,r=e.settings||{};e.loadScript&&function(e,t="https://plausible.io/js/script.manual.js"){const o=document.createElement("script");o.src=t,e&&(o.dataset.domain=e);document.head.appendChild(o)}(r.domain),o.plausible=o.plausible||function(){(o.plausible.q=o.plausible.q||[]).push(arguments)}},push(e,{config:t,data:o,wrap:r}){const a=d(o)?o:{};r("plausible",window.plausible)(`${e.event}`,a)}};var P=S;//# 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 { Config, Destination } from './types';\nimport { isObject } from '@walkeros/core';\n\n// Types\nexport * as DestinationPlausible from './types';\n\n// Examples\nexport * as destinationPlausibleExamples from './examples';\n\nexport const destinationPlausible: Destination = {\n type: 'plausible',\n\n config: {},\n\n init({ config, wrap }) {\n const w = window;\n const settings = config.settings || {};\n\n if (config.loadScript) addScript(settings.domain);\n\n w.plausible =\n w.plausible ||\n function () {\n (w.plausible!.q = w.plausible!.q || []).push(arguments);\n };\n },\n\n push(event, { config, data, wrap }) {\n const params = isObject(data) ? data : {};\n\n const plausible = wrap('plausible', window.plausible!);\n plausible(`${event.event}`, params);\n },\n};\n\nfunction addScript(\n domain?: string,\n src = 'https://plausible.io/js/script.manual.js',\n) {\n const script = document.createElement('script');\n script.src = src;\n if (domain) script.dataset.domain = domain;\n document.head.appendChild(script);\n}\n\nexport default destinationPlausible;\n","import type { Mapping as WalkerOSMapping, WalkerOS, 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 plausible?: Plausible & { q?: IArguments[] };\n }\n}\n\nexport type Plausible = (\n event: string,\n options?: { props?: WalkerOS.AnyObject },\n) => void;\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 domain?: string; // Name of the domain to be tracked\n}\n\n// Single event transformation rule\nexport interface Mapping {}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationPlausibleExamples = {\n events,\n mapping\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function purchase(): unknown[] {\n const event = getEvent('order complete');\n\n return [\n 'purchase',\n {\n revenue: {\n currency: 'EUR',\n amount: event.data.total,\n },\n },\n ];\n}\n\nexport function customEvent(): unknown[] {\n const event = getEvent();\n\n return [\n 'Custom Event',\n {\n props: event.data,\n revenue: event.data.number,\n },\n ];\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { DestinationPlausible } from '..';\n\nexport const customEvent: DestinationPlausible.Rule = {\n name: 'Custom Event',\n data: {\n map: {\n props: 'data',\n revenue: 'data.number',\n },\n },\n};\n\nexport const purchase: DestinationPlausible.Rule = {\n name: 'purchase',\n data: {\n map: {\n revenue: {\n map: {\n currency: { value: 'EUR' },\n amount: 'data.total',\n },\n },\n },\n },\n};\n\nexport const config = {\n entity: { action: customEvent },\n order: { complete: purchase },\n} satisfies DestinationPlausible.Rules;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;;;ACAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,WAAsB;AACpC,QAAM,QAAQ,EAAS,gBAAgB;AAEvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,SAAS;AAAA,QACP,UAAU;AAAA,QACV,QAAQ,MAAM,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,cAAyB;AACvC,QAAM,QAAQ,EAAS;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO,MAAM;AAAA,MACb,SAAS,MAAM,KAAK;AAAA,IACtB;AAAA,EACF;AACF;;;AC1BA;AAAA;AAAA;AAAA,qBAAAA;AAAA,EAAA,gBAAAC;AAAA;AAGO,IAAMD,eAAyC;AAAA,EACpD,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,IAAMC,YAAsC;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,SAAS;AAAA,QACP,KAAK;AAAA,UACH,UAAU,EAAE,OAAO,MAAM;AAAA,UACzB,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQD,aAAY;AAAA,EAC9B,OAAO,EAAE,UAAUC,UAAS;AAC9B;;;AF3BO,IAAM,+BAA+B;AAAA,EAC1C;AAAA,EACA;AACF;;;AFGO,IAAM,uBAAoC;AAAA,EAC/C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAAC,SAAQ,KAAK,GAAG;AACrB,UAAMC,KAAI;AACV,UAAM,WAAWD,QAAO,YAAY,CAAC;AAErC,QAAIA,QAAO,WAAY,WAAU,SAAS,MAAM;AAEhD,IAAAC,GAAE,YACAA,GAAE,aACF,WAAY;AACV,OAACA,GAAE,UAAW,IAAIA,GAAE,UAAW,KAAK,CAAC,GAAG,KAAK,SAAS;AAAA,IACxD;AAAA,EACJ;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAD,SAAQ,MAAM,KAAK,GAAG;AAClC,UAAM,SAAS,EAAS,IAAI,IAAI,OAAO,CAAC;AAExC,UAAM,YAAY,KAAK,aAAa,OAAO,SAAU;AACrD,cAAU,GAAG,MAAM,KAAK,IAAI,MAAM;AAAA,EACpC;AACF;AAEA,SAAS,UACP,QACA,MAAM,4CACN;AACA,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,MAAI,OAAQ,QAAO,QAAQ,SAAS;AACpC,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAO,gBAAQ;","names":["customEvent","purchase","config","w"]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var e,t,a=Object.defineProperty,o=(e,t)=>{for(var o in t)a(e,o,{get:t[o],enumerable:!0})},r=Object.getOwnPropertyNames,s=(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[r(e)[0]])((t={exports:{}}).exports,t),t.exports}),n={merge:!0,shallow:!0,extend:!0};function i(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:c}=s();function p(e={}){var t;const a=e.timestamp||(new Date).setHours(0,13,37,0),o=e.group||"gr0up",r=e.count||1,s=function(e,t={},a={}){a={...n,...a};const o=Object.entries(t).reduce((t,[o,r])=>{const s=e[o];return a.merge&&Array.isArray(s)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...s]):(a.extend||o in e)&&(t[o]=r),t},{});return a.shallow?{...e,...o}:(Object.assign(e,o),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:`${a}-${o}-${r}`,trigger:"test",entity:"entity",action:"action",timestamp:a,timing:3.14,group:o,count:r,version:{source:c,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[a,o]=null!=(t=e.event.split(" "))?t:[];a&&o&&(s.entity=a,s.action=o)}return s}function l(e="entity action",t={}){const a=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return p({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{type:"product",...o,context:{shopping:["checkout",0]},nested:[]},{type:"product",...r,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",...o,context:{shopping:["complete",0]},nested:[]},{type:"product",...r,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":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.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:a,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})}var d={},u={};o(u,{destinationPlausibleExamples:()=>k});var g={};function m(){return["purchase",{revenue:{currency:"EUR",amount:l("order complete").data.total}}]}function h(){const e=l();return["Custom Event",{props:e.data,revenue:e.data.number}]}o(g,{customEvent:()=>h,purchase:()=>m});var b={};o(b,{config:()=>w,customEvent:()=>y,purchase:()=>v});var y={name:"Custom Event",data:{map:{props:"data",revenue:"data.number"}}},v={name:"purchase",data:{map:{revenue:{map:{currency:{value:"EUR"},amount:"data.total"}}}}},w={entity:{action:y},order:{complete:v}},k={events:g,mapping:b},f={type:"plausible",config:{},init({config:e,wrap:t}){const a=window,o=e.settings||{};e.loadScript&&function(e,t="https://plausible.io/js/script.manual.js"){const a=document.createElement("script");a.src=t,e&&(a.dataset.domain=e);document.head.appendChild(a)}(o.domain),a.plausible=a.plausible||function(){(a.plausible.q=a.plausible.q||[]).push(arguments)}},push(e,{config:t,data:a,wrap:o}){const r=i(a)?a:{};o("plausible",window.plausible)(`${e.event}`,r)}};var x=f;export{d as DestinationPlausible,x as default,f as destinationPlausible,u as destinationPlausibleExamples};//# 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, WalkerOS, 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 plausible?: Plausible & { q?: IArguments[] };\n }\n}\n\nexport type Plausible = (\n event: string,\n options?: { props?: WalkerOS.AnyObject },\n) => void;\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 domain?: string; // Name of the domain to be tracked\n}\n\n// Single event transformation rule\nexport interface Mapping {}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationPlausibleExamples = {\n events,\n mapping\n};\n","import { getEvent } from '@walkeros/core';\n\nexport function purchase(): unknown[] {\n const event = getEvent('order complete');\n\n return [\n 'purchase',\n {\n revenue: {\n currency: 'EUR',\n amount: event.data.total,\n },\n },\n ];\n}\n\nexport function customEvent(): unknown[] {\n const event = getEvent();\n\n return [\n 'Custom Event',\n {\n props: event.data,\n revenue: event.data.number,\n },\n ];\n}\n","import type { Mapping } from '@walkeros/core';\nimport type { DestinationPlausible } from '..';\n\nexport const customEvent: DestinationPlausible.Rule = {\n name: 'Custom Event',\n data: {\n map: {\n props: 'data',\n revenue: 'data.number',\n },\n },\n};\n\nexport const purchase: DestinationPlausible.Rule = {\n name: 'purchase',\n data: {\n map: {\n revenue: {\n map: {\n currency: { value: 'EUR' },\n amount: 'data.total',\n },\n },\n },\n },\n};\n\nexport const config = {\n entity: { action: customEvent },\n order: { complete: purchase },\n} satisfies DestinationPlausible.Rules;\n","import type { Config, Destination } from './types';\nimport { isObject } from '@walkeros/core';\n\n// Types\nexport * as DestinationPlausible from './types';\n\n// Examples\nexport * as destinationPlausibleExamples from './examples';\n\nexport const destinationPlausible: Destination = {\n type: 'plausible',\n\n config: {},\n\n init({ config, wrap }) {\n const w = window;\n const settings = config.settings || {};\n\n if (config.loadScript) addScript(settings.domain);\n\n w.plausible =\n w.plausible ||\n function () {\n (w.plausible!.q = w.plausible!.q || []).push(arguments);\n };\n },\n\n push(event, { config, data, wrap }) {\n const params = isObject(data) ? data : {};\n\n const plausible = wrap('plausible', window.plausible!);\n plausible(`${event.event}`, params);\n },\n};\n\nfunction addScript(\n domain?: string,\n src = 'https://plausible.io/js/script.manual.js',\n) {\n const script = document.createElement('script');\n script.src = src;\n if (domain) script.dataset.domain = domain;\n document.head.appendChild(script);\n}\n\nexport default destinationPlausible;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,WAAsB;AACpC,QAAM,QAAQ,EAAS,gBAAgB;AAEvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,SAAS;AAAA,QACP,UAAU;AAAA,QACV,QAAQ,MAAM,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,cAAyB;AACvC,QAAM,QAAQ,EAAS;AAEvB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO,MAAM;AAAA,MACb,SAAS,MAAM,KAAK;AAAA,IACtB;AAAA,EACF;AACF;;;AC1BA;AAAA;AAAA;AAAA,qBAAAA;AAAA,EAAA,gBAAAC;AAAA;AAGO,IAAMD,eAAyC;AAAA,EACpD,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEO,IAAMC,YAAsC;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,IACJ,KAAK;AAAA,MACH,SAAS;AAAA,QACP,KAAK;AAAA,UACH,UAAU,EAAE,OAAO,MAAM;AAAA,UACzB,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,QAAQ,EAAE,QAAQD,aAAY;AAAA,EAC9B,OAAO,EAAE,UAAUC,UAAS;AAC9B;;;AF3BO,IAAM,+BAA+B;AAAA,EAC1C;AAAA,EACA;AACF;;;AGGO,IAAM,uBAAoC;AAAA,EAC/C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAAC,SAAQ,KAAK,GAAG;AACrB,UAAMC,KAAI;AACV,UAAM,WAAWD,QAAO,YAAY,CAAC;AAErC,QAAIA,QAAO,WAAY,WAAU,SAAS,MAAM;AAEhD,IAAAC,GAAE,YACAA,GAAE,aACF,WAAY;AACV,OAACA,GAAE,UAAW,IAAIA,GAAE,UAAW,KAAK,CAAC,GAAG,KAAK,SAAS;AAAA,IACxD;AAAA,EACJ;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAD,SAAQ,MAAM,KAAK,GAAG;AAClC,UAAM,SAAS,EAAS,IAAI,IAAI,OAAO,CAAC;AAExC,UAAM,YAAY,KAAK,aAAa,OAAO,SAAU;AACrD,cAAU,GAAG,MAAM,KAAK,IAAI,MAAM;AAAA,EACpC;AACF;AAEA,SAAS,UACP,QACA,MAAM,4CACN;AACA,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,MAAI,OAAQ,QAAO,QAAQ,SAAS;AACpC,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAO,gBAAQ;","names":["customEvent","purchase","config","w"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@walkeros/web-destination-plausible",
3
+ "description": "Plausible web 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/plausible"
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
+ "plausible"
51
+ ],
52
+ "funding": [
53
+ {
54
+ "type": "GitHub Sponsors",
55
+ "url": "https://github.com/sponsors/elbwalker"
56
+ }
57
+ ]
58
+ }