@walkeros/web-destination-meta 0.0.8 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,23 @@
1
1
  <p align="left">
2
2
  <a href="https://elbwalker.com">
3
- <img title="elbwalker" src='https://www.elbwalker.com/img/elbwalker_logo.png' width="256px"/>
3
+ <img title="elbwalker" src="https://www.elbwalker.com/img/elbwalker_logo.png" width="256px"/>
4
4
  </a>
5
5
  </p>
6
6
 
7
7
  # Meta Pixel Destination for walkerOS
8
8
 
9
- This package provides a Meta Pixel (formerly Facebook Pixel) destination for
10
- walkerOS. It allows you to send events to Meta Pixel.
11
-
12
- [View documentation](https://www.elbwalker.com/docs/destinations/web/meta/)
13
-
14
- ## Role in walkerOS Ecosystem
15
-
16
- walkerOS follows a **source → collector → destination** architecture:
9
+ [Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/destinations/meta)
10
+ &bull;
11
+ [NPM Package](https://www.npmjs.com/package/@walkeros/web-destination-meta)
17
12
 
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)
13
+ This package provides a Meta Pixel (formerly Facebook Pixel) destination for
14
+ walkerOS. It sends events to Meta Pixel to track visitor activity and
15
+ conversions for Facebook and Instagram advertising campaigns.
23
16
 
24
- This Meta Pixel destination receives processed events from the walkerOS
25
- collector and transforms them into Meta's Pixel API format, handling conversion
26
- events, custom events, and audience building data to optimize your Meta
27
- advertising campaigns.
17
+ walkerOS follows a **source collector destination** architecture. This Meta
18
+ Pixel destination receives processed events from the walkerOS collector and
19
+ transforms them into Meta's Pixel API format, handling conversion events, custom
20
+ events, and audience building data to optimize your Meta advertising campaigns.
28
21
 
29
22
  ## Installation
30
23
 
@@ -37,16 +30,26 @@ npm install @walkeros/web-destination-meta
37
30
  Here's a basic example of how to use the Meta Pixel destination:
38
31
 
39
32
  ```typescript
40
- import { elb } from '@walkeros/collector';
33
+ import { createCollector } from '@walkeros/collector';
41
34
  import { destinationMeta } from '@walkeros/web-destination-meta';
42
35
 
36
+ const { elb } = await createCollector();
37
+
43
38
  elb('walker destination', destinationMeta, {
44
- custom: {
45
- pixelId: '1234567890',
39
+ settings: {
40
+ pixelId: '1234567890', // Your Meta Pixel ID
46
41
  },
42
+ loadScript: true, // Load Meta Pixel script automatically
47
43
  });
48
44
  ```
49
45
 
46
+ ## Configuration
47
+
48
+ | Name | Type | Description | Required | Example |
49
+ | ------------ | --------- | ----------------------------------------------------------------- | -------- | -------------- |
50
+ | `pixelId` | `string` | Your Meta Pixel ID from Facebook Business Manager | Yes | `'1234567890'` |
51
+ | `loadScript` | `boolean` | Whether to automatically load the Meta Pixel script (fbevents.js) | No | `true` |
52
+
50
53
  ## Contribute
51
54
 
52
55
  Feel free to contribute by submitting an
@@ -38,7 +38,7 @@ var e;
38
38
  var t;
39
39
  var n = Object.getOwnPropertyNames;
40
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.8", 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" }] };
41
+ t2.exports = { name: "@walkeros/core", description: "Core types and platform-agnostic utilities for walkerOS", version: "0.1.1", 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
42
  } }, function() {
43
43
  return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
44
44
  });
@@ -57,31 +57,31 @@ function k(e2) {
57
57
  function M(e2) {
58
58
  return "object" == typeof e2 && null !== e2 && !k(e2) && "[object Object]" === Object.prototype.toString.call(e2);
59
59
  }
60
- var { version: V } = r();
61
- function H(e2 = {}) {
60
+ var { version: R } = r();
61
+ function V(e2 = {}) {
62
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 : [];
63
+ const t2 = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n2 = e2.group || "gr0up", r2 = e2.count || 1, o = v({ name: "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: [{ entity: "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: R, tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
64
+ if (e2.name) {
65
+ const [t3, n3] = (_a = e2.name.split(" ")) != null ? _a : [];
66
66
  t3 && n3 && (o.entity = t3, o.action = n3);
67
67
  }
68
68
  return o;
69
69
  }
70
- function z(e2 = "entity action", t2 = {}) {
70
+ function H(e2 = "entity action", t2 = {}) {
71
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 });
72
+ return V({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r2.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "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: [{ entity: "product", ...r2, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "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: [{ entity: "product", ...r2, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "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, name: e2 });
73
73
  }
74
74
 
75
75
  // src/examples/events.ts
76
76
  function Purchase() {
77
- const event = z("order complete");
77
+ const event = H("order complete");
78
78
  return [
79
79
  "track",
80
80
  "Purchase",
81
81
  {
82
82
  value: event.data.total,
83
83
  currency: "EUR",
84
- contents: event.nested.filter((item) => item.type === "product").map((item) => ({ id: item.data.id, quantity: 1 })),
84
+ contents: event.nested.filter((item) => item.entity === "product").map((item) => ({ id: item.data.id, quantity: 1 })),
85
85
  content_type: "product",
86
86
  num_items: 2
87
87
  },
@@ -89,7 +89,7 @@ function Purchase() {
89
89
  ];
90
90
  }
91
91
  function AddToCart() {
92
- const event = z("product add");
92
+ const event = H("product add");
93
93
  return [
94
94
  "track",
95
95
  "AddToCart",
@@ -103,24 +103,24 @@ function AddToCart() {
103
103
  ];
104
104
  }
105
105
  function InitiateCheckout() {
106
- const event = z("cart view");
106
+ const event = H("cart view");
107
107
  return [
108
108
  "track",
109
109
  "InitiateCheckout",
110
110
  {
111
111
  currency: "EUR",
112
112
  value: event.data.value,
113
- contents: event.nested.filter((entity) => entity.type === "product").map((entity) => ({
113
+ contents: event.nested.filter((entity) => entity.entity === "product").map((entity) => ({
114
114
  id: entity.data.id,
115
115
  quantity: entity.data.quantity
116
116
  })),
117
- num_items: event.nested.filter((item) => item.type === "product").length
117
+ num_items: event.nested.filter((item) => item.entity === "product").length
118
118
  },
119
119
  { eventID: event.id }
120
120
  ];
121
121
  }
122
122
  function ViewContent() {
123
- const event = z("product view");
123
+ const event = H("product view");
124
124
  return [
125
125
  "track",
126
126
  "ViewContent",
@@ -153,7 +153,7 @@ var Purchase2 = {
153
153
  loop: [
154
154
  "nested",
155
155
  {
156
- condition: (entity) => M(entity) && entity.type === "product",
156
+ condition: (entity) => M(entity) && entity.entity === "product",
157
157
  map: {
158
158
  id: "data.id",
159
159
  quantity: { key: "data.quantity", value: 1 }
@@ -164,7 +164,7 @@ var Purchase2 = {
164
164
  content_type: { value: "product" },
165
165
  num_items: {
166
166
  fn: (event) => event.nested.filter(
167
- (item) => item.type === "product"
167
+ (item) => item.entity === "product"
168
168
  ).length
169
169
  }
170
170
  }
@@ -200,7 +200,7 @@ var InitiateCheckout2 = {
200
200
  loop: [
201
201
  "nested",
202
202
  {
203
- condition: (entity) => M(entity) && entity.type === "product",
203
+ condition: (entity) => M(entity) && entity.entity === "product",
204
204
  map: {
205
205
  id: "data.id",
206
206
  quantity: { key: "data.quantity", value: 1 }
@@ -210,7 +210,7 @@ var InitiateCheckout2 = {
210
210
  },
211
211
  num_items: {
212
212
  fn: (event) => event.nested.filter(
213
- (item) => item.type === "product"
213
+ (item) => item.entity === "product"
214
214
  ).length
215
215
  }
216
216
  }
@@ -18,7 +18,7 @@ var e;
18
18
  var t;
19
19
  var n = Object.getOwnPropertyNames;
20
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.8", 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" }] };
21
+ t2.exports = { name: "@walkeros/core", description: "Core types and platform-agnostic utilities for walkerOS", version: "0.1.1", 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
22
  } }, function() {
23
23
  return t || (0, e[n(e)[0]])((t = { exports: {} }).exports, t), t.exports;
24
24
  });
@@ -37,31 +37,31 @@ function k(e2) {
37
37
  function M(e2) {
38
38
  return "object" == typeof e2 && null !== e2 && !k(e2) && "[object Object]" === Object.prototype.toString.call(e2);
39
39
  }
40
- var { version: V } = r();
41
- function H(e2 = {}) {
40
+ var { version: R } = r();
41
+ function V(e2 = {}) {
42
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 : [];
43
+ const t2 = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n2 = e2.group || "gr0up", r2 = e2.count || 1, o = v({ name: "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: [{ entity: "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: R, tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
44
+ if (e2.name) {
45
+ const [t3, n3] = (_a = e2.name.split(" ")) != null ? _a : [];
46
46
  t3 && n3 && (o.entity = t3, o.action = n3);
47
47
  }
48
48
  return o;
49
49
  }
50
- function z(e2 = "entity action", t2 = {}) {
50
+ function H(e2 = "entity action", t2 = {}) {
51
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 });
52
+ return V({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r2.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "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: [{ entity: "product", ...r2, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "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: [{ entity: "product", ...r2, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "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, name: e2 });
53
53
  }
54
54
 
55
55
  // src/examples/events.ts
56
56
  function Purchase() {
57
- const event = z("order complete");
57
+ const event = H("order complete");
58
58
  return [
59
59
  "track",
60
60
  "Purchase",
61
61
  {
62
62
  value: event.data.total,
63
63
  currency: "EUR",
64
- contents: event.nested.filter((item) => item.type === "product").map((item) => ({ id: item.data.id, quantity: 1 })),
64
+ contents: event.nested.filter((item) => item.entity === "product").map((item) => ({ id: item.data.id, quantity: 1 })),
65
65
  content_type: "product",
66
66
  num_items: 2
67
67
  },
@@ -69,7 +69,7 @@ function Purchase() {
69
69
  ];
70
70
  }
71
71
  function AddToCart() {
72
- const event = z("product add");
72
+ const event = H("product add");
73
73
  return [
74
74
  "track",
75
75
  "AddToCart",
@@ -83,24 +83,24 @@ function AddToCart() {
83
83
  ];
84
84
  }
85
85
  function InitiateCheckout() {
86
- const event = z("cart view");
86
+ const event = H("cart view");
87
87
  return [
88
88
  "track",
89
89
  "InitiateCheckout",
90
90
  {
91
91
  currency: "EUR",
92
92
  value: event.data.value,
93
- contents: event.nested.filter((entity) => entity.type === "product").map((entity) => ({
93
+ contents: event.nested.filter((entity) => entity.entity === "product").map((entity) => ({
94
94
  id: entity.data.id,
95
95
  quantity: entity.data.quantity
96
96
  })),
97
- num_items: event.nested.filter((item) => item.type === "product").length
97
+ num_items: event.nested.filter((item) => item.entity === "product").length
98
98
  },
99
99
  { eventID: event.id }
100
100
  ];
101
101
  }
102
102
  function ViewContent() {
103
- const event = z("product view");
103
+ const event = H("product view");
104
104
  return [
105
105
  "track",
106
106
  "ViewContent",
@@ -133,7 +133,7 @@ var Purchase2 = {
133
133
  loop: [
134
134
  "nested",
135
135
  {
136
- condition: (entity) => M(entity) && entity.type === "product",
136
+ condition: (entity) => M(entity) && entity.entity === "product",
137
137
  map: {
138
138
  id: "data.id",
139
139
  quantity: { key: "data.quantity", value: 1 }
@@ -144,7 +144,7 @@ var Purchase2 = {
144
144
  content_type: { value: "product" },
145
145
  num_items: {
146
146
  fn: (event) => event.nested.filter(
147
- (item) => item.type === "product"
147
+ (item) => item.entity === "product"
148
148
  ).length
149
149
  }
150
150
  }
@@ -180,7 +180,7 @@ var InitiateCheckout2 = {
180
180
  loop: [
181
181
  "nested",
182
182
  {
183
- condition: (entity) => M(entity) && entity.type === "product",
183
+ condition: (entity) => M(entity) && entity.entity === "product",
184
184
  map: {
185
185
  id: "data.id",
186
186
  quantity: { key: "data.quantity", value: 1 }
@@ -190,7 +190,7 @@ var InitiateCheckout2 = {
190
190
  },
191
191
  num_items: {
192
192
  fn: (event) => event.nested.filter(
193
- (item) => item.type === "product"
193
+ (item) => item.entity === "product"
194
194
  ).length
195
195
  }
196
196
  }
@@ -1 +1 @@
1
- "use strict";var Destination=(()=>{var e,t,n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},s={};i(s,{DestinationMeta:()=>y,default:()=>A,destinationMeta:()=>D,destinationMetaExamples:()=>h});var c=Object.getOwnPropertyNames,d=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",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}),p={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:l}=d();function g(e={}){var t;const n=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,r=function(e,t={},n={}){n={...p,...n};const a=Object.entries(t).reduce((t,[a,o])=>{const r=e[a];return n.merge&&Array.isArray(r)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||a in e)&&(t[a]=o),t},{});return n.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:`${n}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:n,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[n,a]=null!=(t=e.event.split(" "))?t:[];n&&a&&(r.entity=n,r.action=a)}return r}function m(e="entity action",t={}){const n=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 g({...{"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:n,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 y={},h={};i(h,{destinationMetaExamples:()=>S});var v={};function b(){const e=m("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:e.id}]}function f(){const e=m("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}function w(){const e=m("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:e.data.quantity})),num_items:e.nested.filter(e=>"product"===e.type).length},{eventID:e.id}]}function k(){const e=m("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}i(v,{AddToCart:()=>f,InitiateCheckout:()=>w,Purchase:()=>b,ViewContent:()=>k});var x={};i(x,{AddToCart:()=>C,InitiateCheckout:()=>j,Purchase:()=>O,ViewContent:()=>_,config:()=>E});var q,O={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>u(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},C={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},j={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>u(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},_={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},E={order:{complete:O},product:{view:_,add:C},cart:{view:j}},S={events:v,mapping:x},D={type:"meta-pixel",config:{},init({config:e,wrap:t}){const{settings:n={},loadScript:a}=e,{pixelId:o}=n;if(a&&function(e="https://connect.facebook.net/en_US/fbevents.js"){const t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}(),!o)return!1;!function(){const e=window;if(e.fbq)return;const t=function(...e){t.callMethod?t.callMethod.apply(t,e):t.queue.push(e)};e.fbq=t,e._fbq||(e._fbq=t),t.push=t,t.loaded=!0,t.version="2.0",t.queue=[]}();t("fbq",window.fbq)("init",o)},push(e,{config:t,mapping:n={},data:a,wrap:o}){const{track:r,trackCustom:i}=n.settings||{},s=o("fbq",window.fbq);"page view"!==e.event||n.settings||(e.event="PageView");const c=r||i||e.event;s(i?"trackCustom":"track",String(c),u(a)?a:{},{eventID:e.id})}},A=D;return q=s,((e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of o(t))r.call(e,c)||c===i||n(e,c,{get:()=>t[c],enumerable:!(s=a(t,c))||s.enumerable});return e})(n({},"__esModule",{value:!0}),q)})();
1
+ "use strict";var Destination=(()=>{var t,e,n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,e)=>{for(var a in e)n(t,a,{get:e[a],enumerable:!0})},s={};i(s,{DestinationMeta:()=>h,default:()=>R,destinationMeta:()=>A,destinationMetaExamples:()=>v});var c=Object.getOwnPropertyNames,d=(t={"package.json"(t,e){e.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",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 e||(0,t[c(t)[0]])((e={exports:{}}).exports,e),e.exports}),u={merge:!0,shallow:!0,extend:!0};function p(t){return"object"==typeof t&&null!==t&&!function(t){return Array.isArray(t)}(t)&&"[object Object]"===Object.prototype.toString.call(t)}var{version:l}=d();function g(t={}){var e;const n=t.timestamp||(new Date).setHours(0,13,37,0),a=t.group||"gr0up",o=t.count||1,r=function(t,e={},n={}){n={...u,...n};const a=Object.entries(e).reduce((e,[a,o])=>{const r=t[a];return n.merge&&Array.isArray(r)&&Array.isArray(o)?e[a]=o.reduce((t,e)=>t.includes(e)?t:[...t,e],[...r]):(n.extend||a in t)&&(e[a]=o),e},{});return n.shallow?{...t,...a}:(Object.assign(t,a),t)}({name:"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:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${n}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:n,timing:3.14,group:a,count:o,version:{source:l,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},t,{merge:!1});if(t.name){const[n,a]=null!=(e=t.name.split(" "))?e:[];n&&a&&(r.entity=n,r.action=a)}return r}function m(t="entity action",e={}){const n=e.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 g({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"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:[{entity:"product",...a,context:{shopping:["checkout",0]},nested:[]},{entity:"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:[{entity:"product",...a,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"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:n,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"}}}[t],...e,name:t})}function y(t){const e={window:globalThis.window,document:globalThis.document};return t?{...e,...t}:e}var h={},v={};i(v,{destinationMetaExamples:()=>D});var b={};function w(){const t=m("order complete");return["track","Purchase",{value:t.data.total,currency:"EUR",contents:t.nested.filter(t=>"product"===t.entity).map(t=>({id:t.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:t.id}]}function f(){const t=m("product add");return["track","AddToCart",{currency:"EUR",value:t.data.price,contents:[{id:t.data.id,quantity:1}],content_type:"product"},{eventID:t.id}]}function k(){const t=m("cart view");return["track","InitiateCheckout",{currency:"EUR",value:t.data.value,contents:t.nested.filter(t=>"product"===t.entity).map(t=>({id:t.data.id,quantity:t.data.quantity})),num_items:t.nested.filter(t=>"product"===t.entity).length},{eventID:t.id}]}function x(){const t=m("product view");return["track","ViewContent",{currency:"EUR",value:t.data.price,contents:[{id:t.data.id,quantity:1}],content_type:"product"},{eventID:t.id}]}i(b,{AddToCart:()=>f,InitiateCheckout:()=>k,Purchase:()=>w,ViewContent:()=>x});var q={};i(q,{AddToCart:()=>j,InitiateCheckout:()=>_,Purchase:()=>C,ViewContent:()=>E,config:()=>S});var O,C={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:t=>p(t)&&"product"===t.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:t=>t.nested.filter(t=>"product"===t.entity).length}}}},j={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},_={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:t=>p(t)&&"product"===t.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:t=>t.nested.filter(t=>"product"===t.entity).length}}}},E={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},S={order:{complete:C},product:{view:E,add:j},cart:{view:_}},D={events:b,mapping:q},A={type:"meta-pixel",config:{},init({config:t,env:e}){const{settings:n={},loadScript:a}=t,{pixelId:o}=n;if(a&&function(t,e="https://connect.facebook.net/en_US/fbevents.js"){const{document:n}=y(t),a=n.createElement("script");a.src=e,a.async=!0,n.head.appendChild(a)}(e),!o)return!1;!function(t){const{window:e}=y(t),n=e;if(n.fbq)return;const a=function(...t){a.callMethod?a.callMethod.apply(a,t):a.queue.push(t)};n.fbq=a,n._fbq||(n._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[]}(e);const{window:r}=y(e);return(0,r.fbq)("init",o),t},push(t,{config:e,mapping:n={},data:a,env:o}){const{track:r,trackCustom:i}=n.settings||{},{window:s}=y(o),c=s.fbq;"page view"!==t.name||n.settings||(t.name="PageView");const d=r||i||t.name;c(i?"trackCustom":"track",String(d),p(a)?a:{},{eventID:t.id})}},R=A;return O=s,((t,e,i,s)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let c of o(e))r.call(t,c)||c===i||n(t,c,{get:()=>e[c],enumerable:!(s=a(e,c))||s.enumerable});return t})(n({},"__esModule",{value:!0}),O)})();
package/dist/index.d.mts CHANGED
@@ -11,6 +11,13 @@ declare global {
11
11
  fbq?: facebook.Pixel.Event;
12
12
  }
13
13
  }
14
+ interface MetaEnvironment {
15
+ window: {
16
+ fbq: facebook.Pixel.Event;
17
+ _fbq?: facebook.Pixel.Event;
18
+ };
19
+ document: Document;
20
+ }
14
21
  type Destination = DestinationWeb.Destination<Settings, Mapping>;
15
22
  type Config = DestinationWeb.Config<Settings, Mapping>;
16
23
  interface Settings {
@@ -27,12 +34,13 @@ type StandardEventNames = 'PageView' | 'AddPaymentInfo' | 'AddToCart' | 'AddToWi
27
34
  type index$1_Config = Config;
28
35
  type index$1_Destination = Destination;
29
36
  type index$1_Mapping = Mapping;
37
+ type index$1_MetaEnvironment = MetaEnvironment;
30
38
  type index$1_Rule = Rule;
31
39
  type index$1_Rules = Rules;
32
40
  type index$1_Settings = Settings;
33
41
  type index$1_StandardEventNames = StandardEventNames;
34
42
  declare namespace index$1 {
35
- export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_StandardEventNames as StandardEventNames };
43
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_MetaEnvironment as MetaEnvironment, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_StandardEventNames as StandardEventNames };
36
44
  }
37
45
 
38
46
  declare function Purchase$1(): unknown[];
package/dist/index.d.ts CHANGED
@@ -11,6 +11,13 @@ declare global {
11
11
  fbq?: facebook.Pixel.Event;
12
12
  }
13
13
  }
14
+ interface MetaEnvironment {
15
+ window: {
16
+ fbq: facebook.Pixel.Event;
17
+ _fbq?: facebook.Pixel.Event;
18
+ };
19
+ document: Document;
20
+ }
14
21
  type Destination = DestinationWeb.Destination<Settings, Mapping>;
15
22
  type Config = DestinationWeb.Config<Settings, Mapping>;
16
23
  interface Settings {
@@ -27,12 +34,13 @@ type StandardEventNames = 'PageView' | 'AddPaymentInfo' | 'AddToCart' | 'AddToWi
27
34
  type index$1_Config = Config;
28
35
  type index$1_Destination = Destination;
29
36
  type index$1_Mapping = Mapping;
37
+ type index$1_MetaEnvironment = MetaEnvironment;
30
38
  type index$1_Rule = Rule;
31
39
  type index$1_Rules = Rules;
32
40
  type index$1_Settings = Settings;
33
41
  type index$1_StandardEventNames = StandardEventNames;
34
42
  declare namespace index$1 {
35
- export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_StandardEventNames as StandardEventNames };
43
+ export type { index$1_Config as Config, index$1_Destination as Destination, index$1_Mapping as Mapping, index$1_MetaEnvironment as MetaEnvironment, index$1_Rule as Rule, index$1_Rules as Rules, index$1_Settings as Settings, index$1_StandardEventNames as StandardEventNames };
36
44
  }
37
45
 
38
46
  declare function Purchase$1(): unknown[];
package/dist/index.es5.js CHANGED
@@ -1 +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,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}}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({},g,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:m,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],u=i[1];c&&u&&(o.entity=c,o.action=u)}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(){var e=o("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(function(e){return"product"===e.type}).map(function(e){return{id:e.data.id,quantity:1}}),content_type:"product",num_items:2},{eventID:e.id}]},i=function(){var e=o("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]},c=function(){var e=o("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(function(e){return"product"===e.type}).map(function(e){return{id:e.data.id,quantity:e.data.quantity}}),num_items:e.nested.filter(function(e){return"product"===e.type}).length},{eventID:e.id}]},u=function(){var e=o("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]},s=Object.defineProperty,p=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,y=function(e,t){for(var r in t)s(e,r,{get:t[r],enumerable:!0})},_={};y(_,{DestinationMeta:function(){return v},default:function(){return C},destinationMeta:function(){return E},destinationMetaExamples:function(){return h}});var f=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.8",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[f(e)[0]])((t={exports:{}}).exports,t),t.exports}),g={merge:!0,shallow:!0,extend:!0},m=b().version,v={},h={};y(h,{destinationMetaExamples:function(){return P}});var w={};y(w,{AddToCart:function(){return i},InitiateCheckout:function(){return c},Purchase:function(){return a},ViewContent:function(){return u}});var j={};y(j,{AddToCart:function(){return x},InitiateCheckout:function(){return S},Purchase:function(){return O},ViewContent:function(){return q},config:function(){return A}});var k,O={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:function(e){return r(e)&&"product"===e.type},map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:function(e){return e.nested.filter(function(e){return"product"===e.type}).length}}}}},x={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},S={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:function(e){return r(e)&&"product"===e.type},map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:function(e){return e.nested.filter(function(e){return"product"===e.type}).length}}}}},q={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},A={order:{complete:O},product:{view:q,add:x},cart:{view:S}},P={events:w,mapping:j},E={type:"meta-pixel",config:{},init:function(e){var t=e.config,r=e.wrap,n=t.settings,o=void 0===n?{}:n,a=t.loadScript,i=o.pixelId;if(a&&function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://connect.facebook.net/en_US/fbevents.js",t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}(),!i)return!1;!function(){var e=window;if(!e.fbq){var t=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];t.callMethod?t.callMethod.apply(t,r):t.queue.push(r)};e.fbq=t,e._fbq||(e._fbq=t),t.push=t,t.loaded=!0,t.version="2.0",t.queue=[]}}(),r("fbq",window.fbq)("init",i)},push:function(e,t){t.config;var n=t.mapping,o=void 0===n?{}:n,a=t.data,i=t.wrap,c=o.settings||{},u=c.track,s=c.trackCustom,p=i("fbq",window.fbq);"page view"!==e.event||o.settings||(e.event="PageView");var d=u||s||e.event;p(s?"trackCustom":"track",String(d),r(a)?a:{},{eventID:e.id})}},C=E;return k=_,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,u=function(){var o=c.value;l.call(e,o)||o===r||s(e,o,{get:function(){return t[o]},enumerable:!(n=p(t,o))||n.enumerable})},y=d(t)[Symbol.iterator]();!(o=(c=y.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==y.return||y.return()}finally{if(a)throw i}}}return e}(s({},"__esModule",{value:!0}),k)}();
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,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}}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({},g,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)}({name:"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:[{entity:"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:v,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){var a,i=_sliced_to_array(null!==(a=e.name.split(" "))&&void 0!==a?a:[],2),c=i[0],u=i[1];c&&u&&(o.entity=c,o.action=u)}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:[{entity:"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({entity:"product"},o),{context:{shopping:["checkout",0]},nested:[]}),_object_spread_props(_object_spread({entity:"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({entity:"product"},o),{context:{shopping:["complete",0]},nested:[]}),_object_spread_props(_object_spread({entity:"product"},a),{context:{shopping:["complete",0]},nested:[]}),{entity:"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),{name:e}))},a=function(e){var t={window:globalThis.window,document:globalThis.document};return e?_object_spread({},t,e):t},i=function(){var e=o("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(function(e){return"product"===e.entity}).map(function(e){return{id:e.data.id,quantity:1}}),content_type:"product",num_items:2},{eventID:e.id}]},c=function(){var e=o("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]},u=function(){var e=o("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(function(e){return"product"===e.entity}).map(function(e){return{id:e.data.id,quantity:e.data.quantity}}),num_items:e.nested.filter(function(e){return"product"===e.entity}).length},{eventID:e.id}]},s=function(){var e=o("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]},d=Object.defineProperty,p=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,y=Object.prototype.hasOwnProperty,_=function(e,t){for(var r in t)d(e,r,{get:t[r],enumerable:!0})},f={};_(f,{DestinationMeta:function(){return h},default:function(){return D},destinationMeta:function(){return C},destinationMetaExamples:function(){return w}});var b=Object.getOwnPropertyNames,m=(e={"package.json":function(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",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[b(e)[0]])((t={exports:{}}).exports,t),t.exports}),g={merge:!0,shallow:!0,extend:!0},v=m().version,h={},w={};_(w,{destinationMetaExamples:function(){return E}});var j={};_(j,{AddToCart:function(){return c},InitiateCheckout:function(){return u},Purchase:function(){return i},ViewContent:function(){return s}});var k={};_(k,{AddToCart:function(){return S},InitiateCheckout:function(){return q},Purchase:function(){return x},ViewContent:function(){return A},config:function(){return P}});var O,x={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:function(e){return r(e)&&"product"===e.entity},map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:function(e){return e.nested.filter(function(e){return"product"===e.entity}).length}}}}},S={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},q={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:function(e){return r(e)&&"product"===e.entity},map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:function(e){return e.nested.filter(function(e){return"product"===e.entity}).length}}}}},A={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},P={order:{complete:x},product:{view:A,add:S},cart:{view:q}},E={events:j,mapping:k},C={type:"meta-pixel",config:{},init:function(e){var t=e.config,r=e.env,n=t.settings,o=void 0===n?{}:n,i=t.loadScript,c=o.pixelId;return i&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://connect.facebook.net/en_US/fbevents.js",r=a(e).document,n=r.createElement("script");n.src=t,n.async=!0,r.head.appendChild(n)}(r),!!c&&(function(e){var t=a(e).window;if(!t.fbq){var r=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];r.callMethod?r.callMethod.apply(r,t):r.queue.push(t)};t.fbq=r,t._fbq||(t._fbq=r),r.push=r,r.loaded=!0,r.version="2.0",r.queue=[]}}(r),(0,a(r).window.fbq)("init",c),t)},push:function(e,t){t.config;var n=t.mapping,o=void 0===n?{}:n,i=t.data,c=t.env,u=o.settings||{},s=u.track,d=u.trackCustom,p=a(c).window.fbq;"page view"!==e.name||o.settings||(e.name="PageView");var l=s||d||e.name;p(d?"trackCustom":"track",String(l),r(i)?i:{},{eventID:e.id})}},D=C;return O=f,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,u=function(){var o=c.value;y.call(e,o)||o===r||d(e,o,{get:function(){return t[o]},enumerable:!(n=p(t,o))||n.enumerable})},s=l(t)[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)u()}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return e}(d({},"__esModule",{value:!0}),O)}();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t,n,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},c={};s(c,{DestinationMeta:()=>h,default:()=>D,destinationMeta:()=>A,destinationMetaExamples:()=>v}),module.exports=(e=c,((e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))i.call(e,c)||c===n||a(e,c,{get:()=>t[c],enumerable:!(s=o(t,c))||s.enumerable});return e})(a({},"__esModule",{value:!0}),e));var d=Object.getOwnPropertyNames,p=(t={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",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 n||(0,t[d(t)[0]])((n={exports:{}}).exports,n),n.exports}),u={merge:!0,shallow:!0,extend:!0};function l(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:g}=p();function m(e={}){var t;const n=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,r=function(e,t={},n={}){n={...u,...n};const a=Object.entries(t).reduce((t,[a,o])=>{const r=e[a];return n.merge&&Array.isArray(r)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||a in e)&&(t[a]=o),t},{});return n.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:`${n}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:n,timing:3.14,group:a,count:o,version:{source:g,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.event){const[n,a]=null!=(t=e.event.split(" "))?t:[];n&&a&&(r.entity=n,r.action=a)}return r}function y(e="entity action",t={}){const n=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:n,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={},v={};s(v,{destinationMetaExamples:()=>S});var b={};function f(){const e=y("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:e.id}]}function w(){const e=y("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}function k(){const e=y("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:e.data.quantity})),num_items:e.nested.filter(e=>"product"===e.type).length},{eventID:e.id}]}function x(){const e=y("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}s(b,{AddToCart:()=>w,InitiateCheckout:()=>k,Purchase:()=>f,ViewContent:()=>x});var q={};s(q,{AddToCart:()=>C,InitiateCheckout:()=>j,Purchase:()=>O,ViewContent:()=>_,config:()=>E});var O={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>l(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},C={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},j={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>l(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},_={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},E={order:{complete:O},product:{view:_,add:C},cart:{view:j}},S={events:b,mapping:q},A={type:"meta-pixel",config:{},init({config:e,wrap:t}){const{settings:n={},loadScript:a}=e,{pixelId:o}=n;if(a&&function(e="https://connect.facebook.net/en_US/fbevents.js"){const t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}(),!o)return!1;!function(){const e=window;if(e.fbq)return;const t=function(...e){t.callMethod?t.callMethod.apply(t,e):t.queue.push(e)};e.fbq=t,e._fbq||(e._fbq=t),t.push=t,t.loaded=!0,t.version="2.0",t.queue=[]}();t("fbq",window.fbq)("init",o)},push(e,{config:t,mapping:n={},data:a,wrap:o}){const{track:r,trackCustom:i}=n.settings||{},s=o("fbq",window.fbq);"page view"!==e.event||n.settings||(e.event="PageView");const c=r||i||e.event;s(i?"trackCustom":"track",String(c),l(a)?a:{},{eventID:e.id})}},D=A;//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var a in n)t(e,a,{get:n[a],enumerable:!0})},i={};r(i,{DestinationMeta:()=>b,default:()=>U,destinationMeta:()=>R,destinationMetaExamples:()=>w}),module.exports=(e=i,((e,r,i,s)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let c of a(r))o.call(e,c)||c===i||t(e,c,{get:()=>r[c],enumerable:!(s=n(r,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s,c,d=require("@walkeros/web-core");var u=Object.getOwnPropertyNames,p=(s={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",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 c||(0,s[u(s)[0]])((c={exports:{}}).exports,c),c.exports}),l={merge:!0,shallow:!0,extend:!0};function g(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:m}=p();function y(e={}){var t;const n=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,r=function(e,t={},n={}){n={...l,...n};const a=Object.entries(t).reduce((t,[a,o])=>{const r=e[a];return n.merge&&Array.isArray(r)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||a in e)&&(t[a]=o),t},{});return n.shallow?{...e,...a}:(Object.assign(e,a),e)}({name:"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:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${n}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:n,timing:3.14,group:a,count:o,version:{source:m,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[n,a]=null!=(t=e.name.split(" "))?t:[];n&&a&&(r.entity=n,r.action=a)}return r}function h(e="entity action",t={}){const n=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 y({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"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:[{entity:"product",...a,context:{shopping:["checkout",0]},nested:[]},{entity:"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:[{entity:"product",...a,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"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:n,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,name:e})}var v=require("@walkeros/web-core"),b={},w={};r(w,{destinationMetaExamples:()=>D});var f={};function k(){const e=h("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(e=>"product"===e.entity).map(e=>({id:e.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:e.id}]}function x(){const e=h("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}function q(){const e=h("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(e=>"product"===e.entity).map(e=>({id:e.data.id,quantity:e.data.quantity})),num_items:e.nested.filter(e=>"product"===e.entity).length},{eventID:e.id}]}function E(){const e=h("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}r(f,{AddToCart:()=>x,InitiateCheckout:()=>q,Purchase:()=>k,ViewContent:()=>E});var O={};r(O,{AddToCart:()=>j,InitiateCheckout:()=>_,Purchase:()=>C,ViewContent:()=>S,config:()=>A});var C={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>g(e)&&"product"===e.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},j={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},_={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>g(e)&&"product"===e.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},S={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},A={order:{complete:C},product:{view:S,add:j},cart:{view:_}},D={events:f,mapping:O},R={type:"meta-pixel",config:{},init({config:e,env:t}){const{settings:n={},loadScript:a}=e,{pixelId:o}=n;if(a&&function(e,t="https://connect.facebook.net/en_US/fbevents.js"){const{document:n}=(0,d.getEnvironment)(e),a=n.createElement("script");a.src=t,a.async=!0,n.head.appendChild(a)}(t),!o)return!1;!function(e){const{window:t}=(0,d.getEnvironment)(e),n=t;if(n.fbq)return;const a=function(...e){a.callMethod?a.callMethod.apply(a,e):a.queue.push(e)};n.fbq=a,n._fbq||(n._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[]}(t);const{window:r}=(0,v.getEnvironment)(t);return(0,r.fbq)("init",o),e},push(e,{config:t,mapping:n={},data:a,env:o}){const{track:r,trackCustom:i}=n.settings||{},{window:s}=(0,v.getEnvironment)(o),c=s.fbq;"page view"!==e.name||n.settings||(e.name="PageView");const d=r||i||e.name;c(i?"trackCustom":"track",String(d),g(a)?a:{},{eventID:e.id})}},U=R;//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/setup.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["import type { Settings, Destination } from './types';\nimport { addScript, setup } from './setup';\nimport { isObject } from '@walkeros/core';\n\n// Types\nexport * as DestinationMeta from './types';\n\n// Examples\nexport * as destinationMetaExamples from './examples';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, wrap }) {\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { pixelId } = settings;\n\n // Load Meta Pixel script if required (fbevents.js)\n if (loadScript) addScript();\n\n // Required pixel id\n if (!pixelId) return false;\n\n // fbq function setup\n setup();\n\n const fbq = wrap('fbq', window.fbq);\n fbq('init', pixelId);\n },\n\n push(event, { config, mapping = {}, data, wrap }) {\n const { track, trackCustom } = mapping.settings || {};\n const fbq = wrap('fbq', window.fbq);\n\n // page view\n if (event.event === 'page view' && !mapping.settings) {\n // Define a custom mapping\n event.event = 'PageView';\n }\n\n const eventName = track || trackCustom || event.event;\n\n fbq(\n trackCustom ? 'trackCustom' : 'track',\n String(eventName),\n isObject(data) ? data : {},\n { eventID: event.id },\n );\n },\n};\n\nexport default destinationMeta;\n","export function addScript(\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n}\n\ninterface FBQFunction {\n (...args: unknown[]): void;\n callMethod?: (this: FBQFunction, ...args: unknown[]) => void;\n queue: unknown[];\n push: FBQFunction;\n loaded: boolean;\n version: string;\n}\n\nexport function setup() {\n const w = window as unknown as {\n fbq?: FBQFunction;\n _fbq?: FBQFunction;\n };\n if (w.fbq as unknown) return;\n\n const n = function (...args: unknown[]): void {\n n.callMethod ? n.callMethod.apply(n, args) : n.queue.push(args);\n } as FBQFunction;\n\n w.fbq = n;\n if (!w._fbq) w._fbq = n;\n n.push = n;\n n.loaded = true;\n n.version = '2.0';\n n.queue = [];\n}\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 _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\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 pixelId?: string; // Required pixel id\n}\n\n// Single event transformation rule\nexport interface Mapping {\n track?: StandardEventNames; // Name of a standard event to track\n trackCustom?: string; // Name of a custom event to track\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type StandardEventNames =\n | 'PageView'\n | 'AddPaymentInfo'\n | 'AddToCart'\n | 'AddToWishlist'\n | 'CompleteRegistration'\n | 'Contact'\n | 'CustomizeProduct'\n | 'Donate'\n | 'FindLocation'\n | 'InitiateCheckout'\n | 'Lead'\n | 'Purchase'\n | 'Schedule'\n | 'Search'\n | 'StartTrial'\n | 'SubmitApplication'\n | 'Subscribe'\n | 'ViewContent'\n | string;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationMetaExamples = {\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 'track',\n 'Purchase',\n {\n value: event.data.total,\n currency: 'EUR',\n contents: event.nested\n .filter((item) => item.type === 'product')\n .map((item) => ({ id: item.data.id, quantity: 1 })),\n content_type: 'product',\n num_items: 2,\n },\n { eventID: event.id },\n ];\n}\n\nexport function AddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n 'track',\n 'AddToCart',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n\nexport function InitiateCheckout(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n 'track',\n 'InitiateCheckout',\n {\n currency: 'EUR',\n value: event.data.value,\n contents: event.nested\n .filter((entity) => entity.type === 'product')\n .map((entity) => ({\n id: entity.data.id,\n quantity: entity.data.quantity,\n })),\n num_items: event.nested.filter((item) => item.type === 'product').length,\n },\n { eventID: event.id },\n ];\n}\n\nexport function ViewContent(): unknown[] {\n const event = getEvent('product view');\n\n return [\n 'track',\n 'ViewContent',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n","import type { Mapping, WalkerOS } from '@walkeros/core';\nimport type { DestinationMeta } from '..';\nimport { isObject } from '@walkeros/core';\n\nexport const Purchase: DestinationMeta.Rule = {\n name: 'Purchase',\n data: {\n map: {\n value: 'data.total',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.type === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.type === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const AddToCart: DestinationMeta.Rule = {\n name: 'AddToCart',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n },\n },\n};\n\nexport const InitiateCheckout: DestinationMeta.Rule = {\n name: 'InitiateCheckout',\n data: {\n map: {\n value: 'data.value',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.type === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.type === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const ViewContent: DestinationMeta.Rule = {\n name: 'ViewContent',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n content_type: { value: 'product' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n },\n },\n};\n\nexport const config = {\n order: { complete: Purchase },\n product: { view: ViewContent, add: AddToCart },\n cart: { view: InitiateCheckout },\n} satisfies DestinationMeta.Rules;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,SAAS,UACd,MAAM,kDACN;AACA,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAWO,SAAS,QAAQ;AACtB,QAAMA,KAAI;AAIV,MAAIA,GAAE,IAAgB;AAEtB,QAAMC,KAAI,YAAa,MAAuB;AAC5C,IAAAA,GAAE,aAAaA,GAAE,WAAW,MAAMA,IAAG,IAAI,IAAIA,GAAE,MAAM,KAAK,IAAI;AAAA,EAChE;AAEA,EAAAD,GAAE,MAAMC;AACR,MAAI,CAACD,GAAE,KAAM,CAAAA,GAAE,OAAOC;AACtB,EAAAA,GAAE,OAAOA;AACT,EAAAA,GAAE,SAAS;AACX,EAAAA,GAAE,UAAU;AACZ,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AA,EACA;AACF;;;AHIO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAAE,SAAQ,KAAK,GAAG;AACrB,UAAM,EAAE,WAAW,CAAC,GAAwB,WAAW,IAAIA;AAC3D,UAAM,EAAE,QAAQ,IAAI;AAGpB,QAAI,WAAY,WAAU;AAG1B,QAAI,CAAC,QAAS,QAAO;AAGrB,UAAM;AAEN,UAAM,MAAM,KAAK,OAAO,OAAO,GAAG;AAClC,QAAI,QAAQ,OAAO;AAAA,EACrB;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAA,SAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,GAAG;AAChD,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,MAAM,KAAK,OAAO,OAAO,GAAG;AAGlC,QAAI,MAAM,UAAU,eAAe,CAAC,QAAQ,UAAU;AAEpD,YAAM,QAAQ;AAAA,IAChB;AAEA,UAAM,YAAY,SAAS,eAAe,MAAM;AAEhD;AAAA,MACE,cAAc,gBAAgB;AAAA,MAC9B,OAAO,SAAS;AAAA,MAChB,EAAS,IAAI,IAAI,OAAO,CAAC;AAAA,MACzB,EAAE,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["w","n","AddToCart","InitiateCheckout","Purchase","ViewContent","Purchase","AddToCart","InitiateCheckout","ViewContent","config"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/setup.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["import type { Settings, Destination } from './types';\nimport { addScript, setup } from './setup';\nimport { isObject } from '@walkeros/core';\nimport { getEnvironment } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationMeta from './types';\n\n// Examples\nexport * as destinationMetaExamples from './examples';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, env }) {\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { pixelId } = settings;\n\n // Load Meta Pixel script if required (fbevents.js)\n if (loadScript) addScript(env);\n\n // Required pixel id\n if (!pixelId) return false;\n\n // fbq function setup\n setup(env);\n\n const { window } = getEnvironment(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n fbq('init', pixelId);\n\n return config;\n },\n\n push(event, { config, mapping = {}, data, env }) {\n const { track, trackCustom } = mapping.settings || {};\n const { window } = getEnvironment(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n\n // page view\n if (event.name === 'page view' && !mapping.settings) {\n // Define a custom mapping\n event.name = 'PageView';\n }\n\n const eventName = track || trackCustom || event.name;\n\n fbq(\n trackCustom ? 'trackCustom' : 'track',\n String(eventName),\n isObject(data) ? data : {},\n { eventID: event.id },\n );\n },\n};\n\nexport default destinationMeta;\n","import type { DestinationWeb } from '@walkeros/web-core';\nimport { getEnvironment } from '@walkeros/web-core';\n\nexport function addScript(\n env?: DestinationWeb.Environment,\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const { document } = getEnvironment(env);\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n}\n\ninterface FBQFunction {\n (...args: unknown[]): void;\n callMethod?: (this: FBQFunction, ...args: unknown[]) => void;\n queue: unknown[];\n push: FBQFunction;\n loaded: boolean;\n version: string;\n}\n\nexport function setup(env?: DestinationWeb.Environment) {\n const { window } = getEnvironment(env);\n const w = window as unknown as {\n fbq?: FBQFunction;\n _fbq?: FBQFunction;\n };\n if (w.fbq as unknown) return;\n\n const n = function (...args: unknown[]): void {\n n.callMethod ? n.callMethod.apply(n, args) : n.queue.push(args);\n } as FBQFunction;\n\n w.fbq = n;\n if (!w._fbq) w._fbq = n;\n n.push = n;\n n.loaded = true;\n n.version = '2.0';\n n.queue = [];\n}\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 _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\n }\n}\n\n// Meta-specific environment that includes fbq\nexport interface MetaEnvironment {\n window: {\n fbq: facebook.Pixel.Event;\n _fbq?: facebook.Pixel.Event;\n };\n document: Document;\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 pixelId?: string; // Required pixel id\n}\n\n// Single event transformation rule\nexport interface Mapping {\n track?: StandardEventNames; // Name of a standard event to track\n trackCustom?: string; // Name of a custom event to track\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type StandardEventNames =\n | 'PageView'\n | 'AddPaymentInfo'\n | 'AddToCart'\n | 'AddToWishlist'\n | 'CompleteRegistration'\n | 'Contact'\n | 'CustomizeProduct'\n | 'Donate'\n | 'FindLocation'\n | 'InitiateCheckout'\n | 'Lead'\n | 'Purchase'\n | 'Schedule'\n | 'Search'\n | 'StartTrial'\n | 'SubmitApplication'\n | 'Subscribe'\n | 'ViewContent'\n | string;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationMetaExamples = {\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 'track',\n 'Purchase',\n {\n value: event.data.total,\n currency: 'EUR',\n contents: event.nested\n .filter((item) => item.entity === 'product')\n .map((item) => ({ id: item.data.id, quantity: 1 })),\n content_type: 'product',\n num_items: 2,\n },\n { eventID: event.id },\n ];\n}\n\nexport function AddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n 'track',\n 'AddToCart',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n\nexport function InitiateCheckout(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n 'track',\n 'InitiateCheckout',\n {\n currency: 'EUR',\n value: event.data.value,\n contents: event.nested\n .filter((entity) => entity.entity === 'product')\n .map((entity) => ({\n id: entity.data.id,\n quantity: entity.data.quantity,\n })),\n num_items: event.nested.filter((item) => item.entity === 'product')\n .length,\n },\n { eventID: event.id },\n ];\n}\n\nexport function ViewContent(): unknown[] {\n const event = getEvent('product view');\n\n return [\n 'track',\n 'ViewContent',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n","import type { Mapping, WalkerOS } from '@walkeros/core';\nimport type { DestinationMeta } from '..';\nimport { isObject } from '@walkeros/core';\n\nexport const Purchase: DestinationMeta.Rule = {\n name: 'Purchase',\n data: {\n map: {\n value: 'data.total',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const AddToCart: DestinationMeta.Rule = {\n name: 'AddToCart',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n },\n },\n};\n\nexport const InitiateCheckout: DestinationMeta.Rule = {\n name: 'InitiateCheckout',\n data: {\n map: {\n value: 'data.value',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const ViewContent: DestinationMeta.Rule = {\n name: 'ViewContent',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n content_type: { value: 'product' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n },\n },\n};\n\nexport const config = {\n order: { complete: Purchase },\n product: { view: ViewContent, add: AddToCart },\n cart: { view: InitiateCheckout },\n} satisfies DestinationMeta.Rules;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAA+B;AAExB,SAAS,UACd,KACA,MAAM,kDACN;AACA,QAAM,EAAE,UAAAA,UAAS,QAAI,gCAAe,GAAG;AACvC,QAAM,SAASA,UAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,EAAAA,UAAS,KAAK,YAAY,MAAM;AAClC;AAWO,SAAS,MAAM,KAAkC;AACtD,QAAM,EAAE,OAAO,QAAI,gCAAe,GAAG;AACrC,QAAMC,KAAI;AAIV,MAAIA,GAAE,IAAgB;AAEtB,QAAMC,KAAI,YAAa,MAAuB;AAC5C,IAAAA,GAAE,aAAaA,GAAE,WAAW,MAAMA,IAAG,IAAI,IAAIA,GAAE,MAAM,KAAK,IAAI;AAAA,EAChE;AAEA,EAAAD,GAAE,MAAMC;AACR,MAAI,CAACD,GAAE,KAAM,CAAAA,GAAE,OAAOC;AACtB,EAAAA,GAAE,OAAOA;AACT,EAAAA,GAAE,SAAS;AACX,EAAAA,GAAE,UAAU;AACZ,EAAAA,GAAE,QAAQ,CAAC;AACb;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ADtCA,IAAAC,mBAA+B;;;AEH/B;;;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,KAAK,EAAE,QAAAE,SAAQ,IAAI,GAAG;AACpB,UAAM,EAAE,WAAW,CAAC,GAAwB,WAAW,IAAIA;AAC3D,UAAM,EAAE,QAAQ,IAAI;AAGpB,QAAI,WAAY,WAAU,GAAG;AAG7B,QAAI,CAAC,QAAS,QAAO;AAGrB,UAAM,GAAG;AAET,UAAM,EAAE,OAAO,QAAI,iCAAe,GAAG;AACrC,UAAM,MAAM,OAAO;AACnB,QAAI,QAAQ,OAAO;AAEnB,WAAOA;AAAA,EACT;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAA,SAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AAC/C,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,EAAE,OAAO,QAAI,iCAAe,GAAG;AACrC,UAAM,MAAM,OAAO;AAGnB,QAAI,MAAM,SAAS,eAAe,CAAC,QAAQ,UAAU;AAEnD,YAAM,OAAO;AAAA,IACf;AAEA,UAAM,YAAY,SAAS,eAAe,MAAM;AAEhD;AAAA,MACE,cAAc,gBAAgB;AAAA,MAC9B,OAAO,SAAS;AAAA,MAChB,EAAS,IAAI,IAAI,OAAO,CAAC;AAAA,MACzB,EAAE,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["document","w","n","import_web_core","AddToCart","InitiateCheckout","Purchase","ViewContent","Purchase","AddToCart","InitiateCheckout","ViewContent","config"]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var e,t,a=Object.defineProperty,n=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})};var o=Object.getOwnPropertyNames,r=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",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"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:c}=r();function d(e={}){var t;const a=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",o=e.count||1,r=function(e,t={},a={}){a={...i,...a};const n=Object.entries(t).reduce((t,[n,o])=>{const r=e[n];return a.merge&&Array.isArray(r)&&Array.isArray(o)?t[n]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(a.extend||n in e)&&(t[n]=o),t},{});return a.shallow?{...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:`${a}-${n}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:a,timing:3.14,group:n,count:o,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,n]=null!=(t=e.event.split(" "))?t:[];a&&n&&(r.entity=a,r.action=n)}return r}function p(e="entity action",t={}){const a=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 d({...{"cart view":{data:{currency:"EUR",value:2*n.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{type:"product",data:{...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:[{type:"product",...n,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",...n,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":{...n,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...n,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...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: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 u={},l={};n(l,{destinationMetaExamples:()=>C});var g={};function m(){const e=p("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:e.id}]}function y(){const e=p("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}function h(){const e=p("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(e=>"product"===e.type).map(e=>({id:e.data.id,quantity:e.data.quantity})),num_items:e.nested.filter(e=>"product"===e.type).length},{eventID:e.id}]}function v(){const e=p("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}n(g,{AddToCart:()=>y,InitiateCheckout:()=>h,Purchase:()=>m,ViewContent:()=>v});var b={};n(b,{AddToCart:()=>f,InitiateCheckout:()=>k,Purchase:()=>w,ViewContent:()=>x,config:()=>q});var w={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>s(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},f={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},k={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>s(e)&&"product"===e.type,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.type).length}}}},x={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},q={order:{complete:w},product:{view:x,add:f},cart:{view:k}},C={events:g,mapping:b},E={type:"meta-pixel",config:{},init({config:e,wrap:t}){const{settings:a={},loadScript:n}=e,{pixelId:o}=a;if(n&&function(e="https://connect.facebook.net/en_US/fbevents.js"){const t=document.createElement("script");t.src=e,t.async=!0,document.head.appendChild(t)}(),!o)return!1;!function(){const e=window;if(e.fbq)return;const t=function(...e){t.callMethod?t.callMethod.apply(t,e):t.queue.push(e)};e.fbq=t,e._fbq||(e._fbq=t),t.push=t,t.loaded=!0,t.version="2.0",t.queue=[]}();t("fbq",window.fbq)("init",o)},push(e,{config:t,mapping:a={},data:n,wrap:o}){const{track:r,trackCustom:i}=a.settings||{},c=o("fbq",window.fbq);"page view"!==e.event||a.settings||(e.event="PageView");const d=r||i||e.event;c(i?"trackCustom":"track",String(d),s(n)?n:{},{eventID:e.id})}},S=E;export{u as DestinationMeta,S as default,E as destinationMeta,l as destinationMetaExamples};//# sourceMappingURL=index.mjs.map
1
+ var e,t,n=Object.defineProperty,a=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})};import{getEnvironment as o}from"@walkeros/web-core";var r=Object.getOwnPropertyNames,i=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",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}),s={merge:!0,shallow:!0,extend:!0};function c(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var{version:d}=i();function p(e={}){var t;const n=e.timestamp||(new Date).setHours(0,13,37,0),a=e.group||"gr0up",o=e.count||1,r=function(e,t={},n={}){n={...s,...n};const a=Object.entries(t).reduce((t,[a,o])=>{const r=e[a];return n.merge&&Array.isArray(r)&&Array.isArray(o)?t[a]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...r]):(n.extend||a in e)&&(t[a]=o),t},{});return n.shallow?{...e,...a}:(Object.assign(e,a),e)}({name:"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:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${n}-${a}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:n,timing:3.14,group:a,count:o,version:{source:d,tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[n,a]=null!=(t=e.name.split(" "))?t:[];n&&a&&(r.entity=n,r.action=a)}return r}function u(e="entity action",t={}){const n=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 p({...{"cart view":{data:{currency:"EUR",value:2*a.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"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:[{entity:"product",...a,context:{shopping:["checkout",0]},nested:[]},{entity:"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:[{entity:"product",...a,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"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:n,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,name:e})}import{getEnvironment as l}from"@walkeros/web-core";var g={},m={};a(m,{destinationMetaExamples:()=>S});var y={};function h(){const e=u("order complete");return["track","Purchase",{value:e.data.total,currency:"EUR",contents:e.nested.filter(e=>"product"===e.entity).map(e=>({id:e.data.id,quantity:1})),content_type:"product",num_items:2},{eventID:e.id}]}function v(){const e=u("product add");return["track","AddToCart",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}function b(){const e=u("cart view");return["track","InitiateCheckout",{currency:"EUR",value:e.data.value,contents:e.nested.filter(e=>"product"===e.entity).map(e=>({id:e.data.id,quantity:e.data.quantity})),num_items:e.nested.filter(e=>"product"===e.entity).length},{eventID:e.id}]}function w(){const e=u("product view");return["track","ViewContent",{currency:"EUR",value:e.data.price,contents:[{id:e.data.id,quantity:1}],content_type:"product"},{eventID:e.id}]}a(y,{AddToCart:()=>v,InitiateCheckout:()=>b,Purchase:()=>h,ViewContent:()=>w});var f={};a(f,{AddToCart:()=>x,InitiateCheckout:()=>q,Purchase:()=>k,ViewContent:()=>C,config:()=>E});var k={name:"Purchase",data:{map:{value:"data.total",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>c(e)&&"product"===e.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},x={name:"AddToCart",data:{map:{value:"data.price",currency:{value:"EUR"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},content_type:{value:"product"}}}},q={name:"InitiateCheckout",data:{map:{value:"data.value",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>c(e)&&"product"===e.entity,map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},C={name:"ViewContent",data:{map:{value:"data.price",currency:{value:"EUR"},content_type:{value:"product"},contents:{set:[{map:{id:"data.id",quantity:{key:"data.quantity",value:1}}}]}}}},E={order:{complete:k},product:{view:C,add:x},cart:{view:q}},S={events:y,mapping:f},_={type:"meta-pixel",config:{},init({config:e,env:t}){const{settings:n={},loadScript:a}=e,{pixelId:r}=n;if(a&&function(e,t="https://connect.facebook.net/en_US/fbevents.js"){const{document:n}=o(e),a=n.createElement("script");a.src=t,a.async=!0,n.head.appendChild(a)}(t),!r)return!1;!function(e){const{window:t}=o(e),n=t;if(n.fbq)return;const a=function(...e){a.callMethod?a.callMethod.apply(a,e):a.queue.push(e)};n.fbq=a,n._fbq||(n._fbq=a),a.push=a,a.loaded=!0,a.version="2.0",a.queue=[]}(t);const{window:i}=l(t);return(0,i.fbq)("init",r),e},push(e,{config:t,mapping:n={},data:a,env:o}){const{track:r,trackCustom:i}=n.settings||{},{window:s}=l(o),d=s.fbq;"page view"!==e.name||n.settings||(e.name="PageView");const p=r||i||e.name;d(i?"trackCustom":"track",String(p),c(a)?a:{},{eventID:e.id})}},j=_;export{g as DestinationMeta,j as default,_ as destinationMeta,m as destinationMetaExamples};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/setup.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts","../src/index.ts"],"sourcesContent":["export function addScript(\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n}\n\ninterface FBQFunction {\n (...args: unknown[]): void;\n callMethod?: (this: FBQFunction, ...args: unknown[]) => void;\n queue: unknown[];\n push: FBQFunction;\n loaded: boolean;\n version: string;\n}\n\nexport function setup() {\n const w = window as unknown as {\n fbq?: FBQFunction;\n _fbq?: FBQFunction;\n };\n if (w.fbq as unknown) return;\n\n const n = function (...args: unknown[]): void {\n n.callMethod ? n.callMethod.apply(n, args) : n.queue.push(args);\n } as FBQFunction;\n\n w.fbq = n;\n if (!w._fbq) w._fbq = n;\n n.push = n;\n n.loaded = true;\n n.version = '2.0';\n n.queue = [];\n}\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 _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\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 pixelId?: string; // Required pixel id\n}\n\n// Single event transformation rule\nexport interface Mapping {\n track?: StandardEventNames; // Name of a standard event to track\n trackCustom?: string; // Name of a custom event to track\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type StandardEventNames =\n | 'PageView'\n | 'AddPaymentInfo'\n | 'AddToCart'\n | 'AddToWishlist'\n | 'CompleteRegistration'\n | 'Contact'\n | 'CustomizeProduct'\n | 'Donate'\n | 'FindLocation'\n | 'InitiateCheckout'\n | 'Lead'\n | 'Purchase'\n | 'Schedule'\n | 'Search'\n | 'StartTrial'\n | 'SubmitApplication'\n | 'Subscribe'\n | 'ViewContent'\n | string;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationMetaExamples = {\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 'track',\n 'Purchase',\n {\n value: event.data.total,\n currency: 'EUR',\n contents: event.nested\n .filter((item) => item.type === 'product')\n .map((item) => ({ id: item.data.id, quantity: 1 })),\n content_type: 'product',\n num_items: 2,\n },\n { eventID: event.id },\n ];\n}\n\nexport function AddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n 'track',\n 'AddToCart',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n\nexport function InitiateCheckout(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n 'track',\n 'InitiateCheckout',\n {\n currency: 'EUR',\n value: event.data.value,\n contents: event.nested\n .filter((entity) => entity.type === 'product')\n .map((entity) => ({\n id: entity.data.id,\n quantity: entity.data.quantity,\n })),\n num_items: event.nested.filter((item) => item.type === 'product').length,\n },\n { eventID: event.id },\n ];\n}\n\nexport function ViewContent(): unknown[] {\n const event = getEvent('product view');\n\n return [\n 'track',\n 'ViewContent',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n","import type { Mapping, WalkerOS } from '@walkeros/core';\nimport type { DestinationMeta } from '..';\nimport { isObject } from '@walkeros/core';\n\nexport const Purchase: DestinationMeta.Rule = {\n name: 'Purchase',\n data: {\n map: {\n value: 'data.total',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.type === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.type === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const AddToCart: DestinationMeta.Rule = {\n name: 'AddToCart',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n },\n },\n};\n\nexport const InitiateCheckout: DestinationMeta.Rule = {\n name: 'InitiateCheckout',\n data: {\n map: {\n value: 'data.value',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.type === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.type === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const ViewContent: DestinationMeta.Rule = {\n name: 'ViewContent',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n content_type: { value: 'product' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n },\n },\n};\n\nexport const config = {\n order: { complete: Purchase },\n product: { view: ViewContent, add: AddToCart },\n cart: { view: InitiateCheckout },\n} satisfies DestinationMeta.Rules;\n","import type { Settings, Destination } from './types';\nimport { addScript, setup } from './setup';\nimport { isObject } from '@walkeros/core';\n\n// Types\nexport * as DestinationMeta from './types';\n\n// Examples\nexport * as destinationMetaExamples from './examples';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, wrap }) {\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { pixelId } = settings;\n\n // Load Meta Pixel script if required (fbevents.js)\n if (loadScript) addScript();\n\n // Required pixel id\n if (!pixelId) return false;\n\n // fbq function setup\n setup();\n\n const fbq = wrap('fbq', window.fbq);\n fbq('init', pixelId);\n },\n\n push(event, { config, mapping = {}, data, wrap }) {\n const { track, trackCustom } = mapping.settings || {};\n const fbq = wrap('fbq', window.fbq);\n\n // page view\n if (event.event === 'page view' && !mapping.settings) {\n // Define a custom mapping\n event.event = 'PageView';\n }\n\n const eventName = track || trackCustom || event.event;\n\n fbq(\n trackCustom ? 'trackCustom' : 'track',\n String(eventName),\n isObject(data) ? data : {},\n { eventID: event.id },\n );\n },\n};\n\nexport default destinationMeta;\n"],"mappings":";;;;;;;AAAO,SAAS,UACd,MAAM,kDACN;AACA,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,WAAS,KAAK,YAAY,MAAM;AAClC;AAWO,SAAS,QAAQ;AACtB,QAAMA,KAAI;AAIV,MAAIA,GAAE,IAAgB;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,KAAK,iBAAiB,OAAO,EAAE;AAAA,YAC7C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,OAAO,EAAE,UAAUH,UAAS;AAAA,EAC5B,SAAS,EAAE,MAAMG,cAAa,KAAKF,WAAU;AAAA,EAC7C,MAAM,EAAE,MAAMC,kBAAiB;AACjC;;;AF1GO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AACF;;;AGIO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAAE,SAAQ,KAAK,GAAG;AACrB,UAAM,EAAE,WAAW,CAAC,GAAwB,WAAW,IAAIA;AAC3D,UAAM,EAAE,QAAQ,IAAI;AAGpB,QAAI,WAAY,WAAU;AAG1B,QAAI,CAAC,QAAS,QAAO;AAGrB,UAAM;AAEN,UAAM,MAAM,KAAK,OAAO,OAAO,GAAG;AAClC,QAAI,QAAQ,OAAO;AAAA,EACrB;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAA,SAAQ,UAAU,CAAC,GAAG,MAAM,KAAK,GAAG;AAChD,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,MAAM,KAAK,OAAO,OAAO,GAAG;AAGlC,QAAI,MAAM,UAAU,eAAe,CAAC,QAAQ,UAAU;AAEpD,YAAM,QAAQ;AAAA,IAChB;AAEA,UAAM,YAAY,SAAS,eAAe,MAAM;AAEhD;AAAA,MACE,cAAc,gBAAgB;AAAA,MAC9B,OAAO,SAAS;AAAA,MAChB,EAAS,IAAI,IAAI,OAAO,CAAC;AAAA,MACzB,EAAE,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["w","n","AddToCart","InitiateCheckout","Purchase","ViewContent","Purchase","AddToCart","InitiateCheckout","ViewContent","config"]}
1
+ {"version":3,"sources":["../src/setup.ts","../src/index.ts","../src/types/index.ts","../src/examples/index.ts","../src/examples/events.ts","../src/examples/mapping.ts"],"sourcesContent":["import type { DestinationWeb } from '@walkeros/web-core';\nimport { getEnvironment } from '@walkeros/web-core';\n\nexport function addScript(\n env?: DestinationWeb.Environment,\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const { document } = getEnvironment(env);\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n}\n\ninterface FBQFunction {\n (...args: unknown[]): void;\n callMethod?: (this: FBQFunction, ...args: unknown[]) => void;\n queue: unknown[];\n push: FBQFunction;\n loaded: boolean;\n version: string;\n}\n\nexport function setup(env?: DestinationWeb.Environment) {\n const { window } = getEnvironment(env);\n const w = window as unknown as {\n fbq?: FBQFunction;\n _fbq?: FBQFunction;\n };\n if (w.fbq as unknown) return;\n\n const n = function (...args: unknown[]): void {\n n.callMethod ? n.callMethod.apply(n, args) : n.queue.push(args);\n } as FBQFunction;\n\n w.fbq = n;\n if (!w._fbq) w._fbq = n;\n n.push = n;\n n.loaded = true;\n n.version = '2.0';\n n.queue = [];\n}\n","import type { Settings, Destination } from './types';\nimport { addScript, setup } from './setup';\nimport { isObject } from '@walkeros/core';\nimport { getEnvironment } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationMeta from './types';\n\n// Examples\nexport * as destinationMetaExamples from './examples';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, env }) {\n const { settings = {} as Partial<Settings>, loadScript } = config;\n const { pixelId } = settings;\n\n // Load Meta Pixel script if required (fbevents.js)\n if (loadScript) addScript(env);\n\n // Required pixel id\n if (!pixelId) return false;\n\n // fbq function setup\n setup(env);\n\n const { window } = getEnvironment(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n fbq('init', pixelId);\n\n return config;\n },\n\n push(event, { config, mapping = {}, data, env }) {\n const { track, trackCustom } = mapping.settings || {};\n const { window } = getEnvironment(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n\n // page view\n if (event.name === 'page view' && !mapping.settings) {\n // Define a custom mapping\n event.name = 'PageView';\n }\n\n const eventName = track || trackCustom || event.name;\n\n fbq(\n trackCustom ? 'trackCustom' : 'track',\n String(eventName),\n isObject(data) ? data : {},\n { eventID: event.id },\n );\n },\n};\n\nexport default destinationMeta;\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 _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\n }\n}\n\n// Meta-specific environment that includes fbq\nexport interface MetaEnvironment {\n window: {\n fbq: facebook.Pixel.Event;\n _fbq?: facebook.Pixel.Event;\n };\n document: Document;\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 pixelId?: string; // Required pixel id\n}\n\n// Single event transformation rule\nexport interface Mapping {\n track?: StandardEventNames; // Name of a standard event to track\n trackCustom?: string; // Name of a custom event to track\n}\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type StandardEventNames =\n | 'PageView'\n | 'AddPaymentInfo'\n | 'AddToCart'\n | 'AddToWishlist'\n | 'CompleteRegistration'\n | 'Contact'\n | 'CustomizeProduct'\n | 'Donate'\n | 'FindLocation'\n | 'InitiateCheckout'\n | 'Lead'\n | 'Purchase'\n | 'Schedule'\n | 'Search'\n | 'StartTrial'\n | 'SubmitApplication'\n | 'Subscribe'\n | 'ViewContent'\n | string;\n","import * as events from './events';\nimport * as mapping from './mapping';\n\nexport const destinationMetaExamples = {\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 'track',\n 'Purchase',\n {\n value: event.data.total,\n currency: 'EUR',\n contents: event.nested\n .filter((item) => item.entity === 'product')\n .map((item) => ({ id: item.data.id, quantity: 1 })),\n content_type: 'product',\n num_items: 2,\n },\n { eventID: event.id },\n ];\n}\n\nexport function AddToCart(): unknown[] {\n const event = getEvent('product add');\n\n return [\n 'track',\n 'AddToCart',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n\nexport function InitiateCheckout(): unknown[] {\n const event = getEvent('cart view');\n\n return [\n 'track',\n 'InitiateCheckout',\n {\n currency: 'EUR',\n value: event.data.value,\n contents: event.nested\n .filter((entity) => entity.entity === 'product')\n .map((entity) => ({\n id: entity.data.id,\n quantity: entity.data.quantity,\n })),\n num_items: event.nested.filter((item) => item.entity === 'product')\n .length,\n },\n { eventID: event.id },\n ];\n}\n\nexport function ViewContent(): unknown[] {\n const event = getEvent('product view');\n\n return [\n 'track',\n 'ViewContent',\n {\n currency: 'EUR',\n value: event.data.price,\n contents: [{ id: event.data.id, quantity: 1 }],\n content_type: 'product',\n },\n { eventID: event.id },\n ];\n}\n","import type { Mapping, WalkerOS } from '@walkeros/core';\nimport type { DestinationMeta } from '..';\nimport { isObject } from '@walkeros/core';\n\nexport const Purchase: DestinationMeta.Rule = {\n name: 'Purchase',\n data: {\n map: {\n value: 'data.total',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const AddToCart: DestinationMeta.Rule = {\n name: 'AddToCart',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n content_type: { value: 'product' },\n },\n },\n};\n\nexport const InitiateCheckout: DestinationMeta.Rule = {\n name: 'InitiateCheckout',\n data: {\n map: {\n value: 'data.value',\n currency: { value: 'EUR' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n};\n\nexport const ViewContent: DestinationMeta.Rule = {\n name: 'ViewContent',\n data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\n content_type: { value: 'product' },\n contents: {\n set: [\n {\n map: {\n id: 'data.id',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n },\n },\n};\n\nexport const config = {\n order: { complete: Purchase },\n product: { view: ViewContent, add: AddToCart },\n cart: { view: InitiateCheckout },\n} satisfies DestinationMeta.Rules;\n"],"mappings":";;;;;;;AACA,SAAS,sBAAsB;AAExB,SAAS,UACd,KACA,MAAM,kDACN;AACA,QAAM,EAAE,UAAAA,UAAS,IAAI,eAAe,GAAG;AACvC,QAAM,SAASA,UAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,EAAAA,UAAS,KAAK,YAAY,MAAM;AAClC;AAWO,SAAS,MAAM,KAAkC;AACtD,QAAM,EAAE,OAAO,IAAI,eAAe,GAAG;AACrC,QAAMC,KAAI;AAIV,MAAIA,GAAE,IAAgB;AAEtB,QAAMC,KAAI,YAAa,MAAuB;AAC5C,IAAAA,GAAE,aAAaA,GAAE,WAAW,MAAMA,IAAG,IAAI,IAAIA,GAAE,MAAM,KAAK,IAAI;AAAA,EAChE;AAEA,EAAAD,GAAE,MAAMC;AACR,MAAI,CAACD,G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H,UAAS;AAAA,EAC5B,SAAS,EAAE,MAAMG,cAAa,KAAKF,WAAU;AAAA,EAC7C,MAAM,EAAE,MAAMC,kBAAiB;AACjC;;;AF1GO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AACF;;;AFKO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAAE,SAAQ,IAAI,GAAG;AACpB,UAAM,EAAE,WAAW,CAAC,GAAwB,WAAW,IAAIA;AAC3D,UAAM,EAAE,QAAQ,IAAI;AAGpB,QAAI,WAAY,WAAU,GAAG;AAG7B,QAAI,CAAC,QAAS,QAAO;AAGrB,UAAM,GAAG;AAET,UAAM,EAAE,OAAO,IAAIC,gBAAe,GAAG;AACrC,UAAM,MAAM,OAAO;AACnB,QAAI,QAAQ,OAAO;AAEnB,WAAOD;AAAA,EACT;AAAA,EAEA,KAAK,OAAO,EAAE,QAAAA,SAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AAC/C,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,EAAE,OAAO,IAAIC,gBAAe,GAAG;AACrC,UAAM,MAAM,OAAO;AAGnB,QAAI,MAAM,SAAS,eAAe,CAAC,QAAQ,UAAU;AAEnD,YAAM,OAAO;AAAA,IACf;AAEA,UAAM,YAAY,SAAS,eAAe,MAAM;AAEhD;AAAA,MACE,cAAc,gBAAgB;AAAA,MAC9B,OAAO,SAAS;AAAA,MAChB,EAAS,IAAI,IAAI,OAAO,CAAC;AAAA,MACzB,EAAE,SAAS,MAAM,GAAG;AAAA,IACtB;AAAA,EACF;AACF;AAEA,IAAO,gBAAQ;","names":["document","w","n","getEnvironment","AddToCart","InitiateCheckout","Purchase","ViewContent","Purchase","AddToCart","InitiateCheckout","ViewContent","config","getEnvironment"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/web-destination-meta",
3
3
  "description": "Meta pixel web destination for walkerOS",
4
- "version": "0.0.8",
4
+ "version": "0.1.1",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -30,7 +30,7 @@
30
30
  "update": "npx npm-check-updates -u && npm update"
31
31
  },
32
32
  "dependencies": {
33
- "@walkeros/web-core": "0.0.8"
33
+ "@walkeros/web-core": "0.1.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/facebook-pixel": "^0.0.31"