@walkeros/web-destination-meta 0.0.0-next-20251219153324

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.
@@ -0,0 +1,285 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/examples/env.ts
8
+ var env_exports = {};
9
+ __export(env_exports, {
10
+ init: () => init,
11
+ push: () => push
12
+ });
13
+ var noop = () => {
14
+ };
15
+ var init = {
16
+ // Environment before initialization (fbq not loaded yet)
17
+ window: {
18
+ fbq: void 0,
19
+ _fbq: void 0
20
+ },
21
+ document: {
22
+ createElement: () => ({
23
+ src: "",
24
+ async: false,
25
+ setAttribute: () => {
26
+ },
27
+ removeAttribute: () => {
28
+ }
29
+ }),
30
+ head: { appendChild: () => {
31
+ } }
32
+ }
33
+ };
34
+ var push = {
35
+ // Standard mock environment for testing
36
+ window: {
37
+ fbq: Object.assign(noop, {
38
+ // Add Meta Pixel specific properties
39
+ callMethod: noop,
40
+ queue: [],
41
+ push: noop,
42
+ loaded: true,
43
+ version: "2.0"
44
+ }),
45
+ _fbq: Object.assign(noop, {
46
+ callMethod: noop,
47
+ queue: [],
48
+ push: noop,
49
+ loaded: true,
50
+ version: "2.0"
51
+ })
52
+ },
53
+ document: {
54
+ createElement: () => ({
55
+ src: "",
56
+ async: false,
57
+ setAttribute: () => {
58
+ },
59
+ removeAttribute: () => {
60
+ }
61
+ }),
62
+ head: { appendChild: () => {
63
+ } }
64
+ }
65
+ };
66
+
67
+ // src/examples/events.ts
68
+ var events_exports = {};
69
+ __export(events_exports, {
70
+ AddToCart: () => AddToCart,
71
+ InitiateCheckout: () => InitiateCheckout,
72
+ Purchase: () => Purchase,
73
+ ViewContent: () => ViewContent
74
+ });
75
+
76
+ // ../../../core/dist/index.mjs
77
+ var e = Object.defineProperty;
78
+ var c = {};
79
+ ((t, n) => {
80
+ for (var r in n) e(t, r, { get: n[r], enumerable: true });
81
+ })(c, { Level: () => a });
82
+ var a = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.INFO = 1] = "INFO", e2[e2.DEBUG = 2] = "DEBUG", e2))(a || {});
83
+ var E = { merge: true, shallow: true, extend: true };
84
+ function S(e2, t = {}, n = {}) {
85
+ n = { ...E, ...n };
86
+ const r = Object.entries(t).reduce((t2, [r2, o]) => {
87
+ const i = e2[r2];
88
+ return n.merge && Array.isArray(i) && Array.isArray(o) ? t2[r2] = o.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || r2 in e2) && (t2[r2] = o), t2;
89
+ }, {});
90
+ return n.shallow ? { ...e2, ...r } : (Object.assign(e2, r), e2);
91
+ }
92
+ function A(e2) {
93
+ return Array.isArray(e2);
94
+ }
95
+ function _(e2) {
96
+ return "object" == typeof e2 && null !== e2 && !A(e2) && "[object Object]" === Object.prototype.toString.call(e2);
97
+ }
98
+ function W(e2 = {}) {
99
+ var _a;
100
+ const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", r = e2.count || 1, o = S({ 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: `${t}-${n}-${r}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: r, version: { source: "0.5.1-next.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
101
+ if (e2.name) {
102
+ const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
103
+ t2 && n2 && (o.entity = t2, o.action = n2);
104
+ }
105
+ return o;
106
+ }
107
+ function B(e2 = "entity action", t = {}) {
108
+ const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r = { 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 } };
109
+ return W({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, 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", ...r, 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.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r.data, position: 3, promo: 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: n, 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], ...t, name: e2 });
110
+ }
111
+
112
+ // src/examples/events.ts
113
+ function Purchase() {
114
+ const event = B("order complete");
115
+ return [
116
+ "track",
117
+ "Purchase",
118
+ {
119
+ value: event.data.total,
120
+ currency: "EUR",
121
+ contents: event.nested.filter((item) => item.entity === "product").map((item) => ({ id: item.data.id, quantity: 1 })),
122
+ content_type: "product",
123
+ num_items: 2
124
+ },
125
+ { eventID: event.id }
126
+ ];
127
+ }
128
+ function AddToCart() {
129
+ const event = B("product add");
130
+ return [
131
+ "track",
132
+ "AddToCart",
133
+ {
134
+ currency: "EUR",
135
+ value: event.data.price,
136
+ contents: [{ id: event.data.id, quantity: 1 }],
137
+ content_type: "product"
138
+ },
139
+ { eventID: event.id }
140
+ ];
141
+ }
142
+ function InitiateCheckout() {
143
+ const event = B("cart view");
144
+ return [
145
+ "track",
146
+ "InitiateCheckout",
147
+ {
148
+ currency: "EUR",
149
+ value: event.data.value,
150
+ contents: event.nested.filter((entity) => entity.entity === "product").map((entity) => ({
151
+ id: entity.data.id,
152
+ quantity: entity.data.quantity
153
+ })),
154
+ num_items: event.nested.filter((item) => item.entity === "product").length
155
+ },
156
+ { eventID: event.id }
157
+ ];
158
+ }
159
+ function ViewContent() {
160
+ const event = B("product view");
161
+ return [
162
+ "track",
163
+ "ViewContent",
164
+ {
165
+ currency: "EUR",
166
+ value: event.data.price,
167
+ contents: [{ id: event.data.id, quantity: 1 }],
168
+ content_type: "product"
169
+ },
170
+ { eventID: event.id }
171
+ ];
172
+ }
173
+
174
+ // src/examples/mapping.ts
175
+ var mapping_exports = {};
176
+ __export(mapping_exports, {
177
+ AddToCart: () => AddToCart2,
178
+ InitiateCheckout: () => InitiateCheckout2,
179
+ Purchase: () => Purchase2,
180
+ ViewContent: () => ViewContent2,
181
+ config: () => config
182
+ });
183
+ var Purchase2 = {
184
+ name: "Purchase",
185
+ data: {
186
+ map: {
187
+ value: "data.total",
188
+ currency: { value: "EUR" },
189
+ contents: {
190
+ loop: [
191
+ "nested",
192
+ {
193
+ condition: (entity) => _(entity) && entity.entity === "product",
194
+ map: {
195
+ id: "data.id",
196
+ quantity: { key: "data.quantity", value: 1 }
197
+ }
198
+ }
199
+ ]
200
+ },
201
+ content_type: { value: "product" },
202
+ num_items: {
203
+ fn: (event) => event.nested.filter(
204
+ (item) => item.entity === "product"
205
+ ).length
206
+ }
207
+ }
208
+ }
209
+ };
210
+ var AddToCart2 = {
211
+ name: "AddToCart",
212
+ data: {
213
+ map: {
214
+ value: "data.price",
215
+ currency: { value: "EUR" },
216
+ contents: {
217
+ set: [
218
+ {
219
+ map: {
220
+ id: "data.id",
221
+ quantity: { key: "data.quantity", value: 1 }
222
+ }
223
+ }
224
+ ]
225
+ },
226
+ content_type: { value: "product" }
227
+ }
228
+ }
229
+ };
230
+ var InitiateCheckout2 = {
231
+ name: "InitiateCheckout",
232
+ data: {
233
+ map: {
234
+ value: "data.value",
235
+ currency: { value: "EUR" },
236
+ contents: {
237
+ loop: [
238
+ "nested",
239
+ {
240
+ condition: (entity) => _(entity) && entity.entity === "product",
241
+ map: {
242
+ id: "data.id",
243
+ quantity: { key: "data.quantity", value: 1 }
244
+ }
245
+ }
246
+ ]
247
+ },
248
+ num_items: {
249
+ fn: (event) => event.nested.filter(
250
+ (item) => item.entity === "product"
251
+ ).length
252
+ }
253
+ }
254
+ }
255
+ };
256
+ var ViewContent2 = {
257
+ name: "ViewContent",
258
+ data: {
259
+ map: {
260
+ value: "data.price",
261
+ currency: { value: "EUR" },
262
+ content_type: { value: "product" },
263
+ contents: {
264
+ set: [
265
+ {
266
+ map: {
267
+ id: "data.id",
268
+ quantity: { key: "data.quantity", value: 1 }
269
+ }
270
+ }
271
+ ]
272
+ }
273
+ }
274
+ }
275
+ };
276
+ var config = {
277
+ order: { complete: Purchase2 },
278
+ product: { view: ViewContent2, add: AddToCart2 },
279
+ cart: { view: InitiateCheckout2 }
280
+ };
281
+ export {
282
+ env_exports as env,
283
+ events_exports as events,
284
+ mapping_exports as mapping
285
+ };
@@ -0,0 +1 @@
1
+ "use strict";var Destination=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(i,{DestinationMeta:()=>d,default:()=>p,destinationMeta:()=>l});var r=Object.defineProperty;((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>a});var c,a=((c=a||{})[c.ERROR=0]="ERROR",c[c.INFO=1]="INFO",c[c.DEBUG=2]="DEBUG",c);function s(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}function u(e){return{window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e}}var f,d={},l={type:"meta-pixel",config:{},init({config:e,env:t,logger:n}){const{settings:o,loadScript:i}=e,{pixelId:r}=o||{};i&&function(e,t="https://connect.facebook.net/en_US/fbevents.js"){const{document:n}=u(e),o=n.createElement("script");o.src=t,o.async=!0,n.head.appendChild(o)}(t),r||n.throw("Config settings pixelId missing"),function(e){const{window:t}=u(e),n=t;if(n.fbq)return;const o=function(...e){o.callMethod?o.callMethod.apply(o,e):o.queue.push(e)};n.fbq=o,n._fbq||(n._fbq=o),o.push=o,o.loaded=!0,o.version="2.0",o.queue=[]}(t);const{window:c}=u(t);(0,c.fbq)("init",r)},push(e,{config:t,mapping:n={},data:o,env:i}){const{track:r,trackCustom:c}=n.settings||{},{window:a}=u(i),f=a.fbq;"page view"!==e.name||n.settings||(e.name="PageView");const d=r||c||e.name;f(c?"trackCustom":"track",String(d),s(o)?o:{},{eventID:e.id})}},p=l;return f=i,((i,r,c,a)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let s of n(r))o.call(i,s)||s===c||e(i,s,{get:()=>r[s],enumerable:!(a=t(r,s))||a.enumerable});return i})(e({},"__esModule",{value:!0}),f)})();
@@ -0,0 +1,53 @@
1
+ import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare global {
5
+ interface Window {
6
+ _fbq?: facebook.Pixel.Event;
7
+ fbq?: facebook.Pixel.Event;
8
+ }
9
+ }
10
+ interface Settings {
11
+ pixelId: string;
12
+ }
13
+ type InitSettings = Partial<Settings>;
14
+ interface Mapping {
15
+ track?: StandardEventNames;
16
+ trackCustom?: string;
17
+ }
18
+ interface Env extends DestinationWeb.Env {
19
+ window: {
20
+ fbq: facebook.Pixel.Event;
21
+ _fbq?: facebook.Pixel.Event;
22
+ };
23
+ document: {
24
+ createElement: (tagName: string) => Element;
25
+ head: {
26
+ appendChild: (node: unknown) => void;
27
+ };
28
+ };
29
+ }
30
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
31
+ type Destination = DestinationWeb.Destination<Types>;
32
+ type Config = DestinationWeb.Config<Types>;
33
+ type Rule = Mapping$1.Rule<Mapping>;
34
+ type Rules = Mapping$1.Rules<Rule>;
35
+ type StandardEventNames = 'PageView' | 'AddPaymentInfo' | 'AddToCart' | 'AddToWishlist' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'InitiateCheckout' | 'Lead' | 'Purchase' | 'Schedule' | 'Search' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'ViewContent' | string;
36
+
37
+ type index_Config = Config;
38
+ type index_Destination = Destination;
39
+ type index_Env = Env;
40
+ type index_InitSettings = InitSettings;
41
+ type index_Mapping = Mapping;
42
+ type index_Rule = Rule;
43
+ type index_Rules = Rules;
44
+ type index_Settings = Settings;
45
+ type index_StandardEventNames = StandardEventNames;
46
+ type index_Types = Types;
47
+ declare namespace index {
48
+ export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_StandardEventNames as StandardEventNames, index_Types as Types };
49
+ }
50
+
51
+ declare const destinationMeta: Destination;
52
+
53
+ export { index as DestinationMeta, destinationMeta as default, destinationMeta };
@@ -0,0 +1,53 @@
1
+ import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
2
+ import { DestinationWeb } from '@walkeros/web-core';
3
+
4
+ declare global {
5
+ interface Window {
6
+ _fbq?: facebook.Pixel.Event;
7
+ fbq?: facebook.Pixel.Event;
8
+ }
9
+ }
10
+ interface Settings {
11
+ pixelId: string;
12
+ }
13
+ type InitSettings = Partial<Settings>;
14
+ interface Mapping {
15
+ track?: StandardEventNames;
16
+ trackCustom?: string;
17
+ }
18
+ interface Env extends DestinationWeb.Env {
19
+ window: {
20
+ fbq: facebook.Pixel.Event;
21
+ _fbq?: facebook.Pixel.Event;
22
+ };
23
+ document: {
24
+ createElement: (tagName: string) => Element;
25
+ head: {
26
+ appendChild: (node: unknown) => void;
27
+ };
28
+ };
29
+ }
30
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
31
+ type Destination = DestinationWeb.Destination<Types>;
32
+ type Config = DestinationWeb.Config<Types>;
33
+ type Rule = Mapping$1.Rule<Mapping>;
34
+ type Rules = Mapping$1.Rules<Rule>;
35
+ type StandardEventNames = 'PageView' | 'AddPaymentInfo' | 'AddToCart' | 'AddToWishlist' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'InitiateCheckout' | 'Lead' | 'Purchase' | 'Schedule' | 'Search' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'ViewContent' | string;
36
+
37
+ type index_Config = Config;
38
+ type index_Destination = Destination;
39
+ type index_Env = Env;
40
+ type index_InitSettings = InitSettings;
41
+ type index_Mapping = Mapping;
42
+ type index_Rule = Rule;
43
+ type index_Rules = Rules;
44
+ type index_Settings = Settings;
45
+ type index_StandardEventNames = StandardEventNames;
46
+ type index_Types = Types;
47
+ declare namespace index {
48
+ export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_StandardEventNames as StandardEventNames, index_Types as Types };
49
+ }
50
+
51
+ declare const destinationMeta: Destination;
52
+
53
+ export { index as DestinationMeta, destinationMeta as default, destinationMeta };
@@ -0,0 +1 @@
1
+ "use strict";function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var Destination=function(){var e=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)},t=function(e){return _object_spread({window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document},e)},n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,c={};!function(e,t){for(var r in t)n(e,r,{get:t[r],enumerable:!0})}(c,{DestinationMeta:function(){return d},default:function(){return s},destinationMeta:function(){return p}});var u=Object.defineProperty;!function(e,t){for(var n in t)u(e,n,{get:t[n],enumerable:!0})}({},{Level:function(){return l}});var a,f,l=((a=l||{})[a.ERROR=0]="ERROR",a[a.INFO=1]="INFO",a[a.DEBUG=2]="DEBUG",a),d={},p={type:"meta-pixel",config:{},init:function(e){var n=e.config,r=e.env,o=e.logger,i=n.settings,c=n.loadScript,u=(i||{}).pixelId;c&&function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://connect.facebook.net/en_US/fbevents.js",r=t(e).document,o=r.createElement("script");o.src=n,o.async=!0,r.head.appendChild(o)}(r),u||o.throw("Config settings pixelId missing"),function(e){var n=t(e).window;if(!n.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)};n.fbq=r,n._fbq||(n._fbq=r),r.push=r,r.loaded=!0,r.version="2.0",r.queue=[]}}(r),(0,t(r).window.fbq)("init",u)},push:function(n,r){r.config;var o=r.mapping,i=void 0===o?{}:o,c=r.data,u=r.env,a=i.settings||{},f=a.track,l=a.trackCustom,d=t(u).window.fbq;"page view"!==n.name||i.settings||(n.name="PageView");var p=f||l||n.name;d(l?"trackCustom":"track",String(p),e(c)?c:{},{eventID:n.id})}},s=p;return f=c,function(e,t,c,u){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var a=!0,f=!1,l=void 0;try{for(var d,p=function(){var o=d.value;i.call(e,o)||o===c||n(e,o,{get:function(){return t[o]},enumerable:!(u=r(t,o))||u.enumerable})},s=o(t)[Symbol.iterator]();!(a=(d=s.next()).done);a=!0)p()}catch(e){f=!0,l=e}finally{try{a||null==s.return||s.return()}finally{if(f)throw l}}}return e}(n({},"__esModule",{value:!0}),f)}();
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i={};((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})(i,{DestinationMeta:()=>f,default:()=>b,destinationMeta:()=>g}),module.exports=(e=i,((e,i,a,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of o(i))r.call(e,s)||s===a||t(e,s,{get:()=>i[s],enumerable:!(c=n(i,s))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a=require("@walkeros/web-core");var c=Object.defineProperty;((e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})})({},{Level:()=>u});var s,u=((s=u||{})[s.ERROR=0]="ERROR",s[s.INFO=1]="INFO",s[s.DEBUG=2]="DEBUG",s);function l(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}var p=require("@walkeros/web-core"),f={},g={type:"meta-pixel",config:{},init({config:e,env:t,logger:n}){const{settings:o,loadScript:r}=e,{pixelId:i}=o||{};r&&function(e,t="https://connect.facebook.net/en_US/fbevents.js"){const{document:n}=(0,a.getEnv)(e),o=n.createElement("script");o.src=t,o.async=!0,n.head.appendChild(o)}(t),i||n.throw("Config settings pixelId missing"),function(e){const{window:t}=(0,a.getEnv)(e),n=t;if(n.fbq)return;const o=function(...e){o.callMethod?o.callMethod.apply(o,e):o.queue.push(e)};n.fbq=o,n._fbq||(n._fbq=o),o.push=o,o.loaded=!0,o.version="2.0",o.queue=[]}(t);const{window:c}=(0,p.getEnv)(t);(0,c.fbq)("init",i)},push(e,{config:t,mapping:n={},data:o,env:r}){const{track:i,trackCustom:a}=n.settings||{},{window:c}=(0,p.getEnv)(r),s=c.fbq;"page view"!==e.name||n.settings||(e.name="PageView");const u=i||a||e.name;s(a?"trackCustom":"track",String(u),l(o)?o:{},{eventID:e.id})}},b=g;//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/setup.ts","../src/types/index.ts"],"sourcesContent":["import type { Settings, Destination } from './types';\nimport { addScript, setup } from './setup';\nimport { isObject } from '@walkeros/core';\nimport { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, env, logger }) {\n const { 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) logger.throw('Config settings pixelId missing');\n\n // fbq function setup\n setup(env);\n\n const { window } = getEnv(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n fbq('init', pixelId!);\n },\n\n push(event, { config, mapping = {}, data, env }) {\n const { track, trackCustom } = mapping.settings || {};\n const { window } = getEnv(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 { getEnv } from '@walkeros/web-core';\n\nexport function addScript(\n env?: DestinationWeb.Env,\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const { document } = getEnv(env);\n const script = (document as Document).createElement('script');\n script.src = src;\n script.async = true;\n (document as 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.Env) {\n const { window } = getEnv(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 {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\n }\n}\n\nexport interface Settings {\n pixelId: string;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n track?: StandardEventNames;\n trackCustom?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n fbq: facebook.Pixel.Event;\n _fbq?: facebook.Pixel.Event;\n };\n document: {\n createElement: (tagName: string) => Element;\n head: { appendChild: (node: unknown) => void };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,sBAAuB;AAEhB,SAAS,UACd,KACA,MAAM,kDACN;AACA,QAAM,EAAE,UAAAA,UAAS,QAAI,wBAAO,GAAG;AAC/B,QAAM,SAAUA,UAAsB,cAAc,QAAQ;AAC5D,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,EAACA,UAAsB,KAAK,YAAY,MAAM;AAChD;AAWO,SAAS,MAAM,KAA0B;AAC9C,QAAM,EAAE,OAAO,QAAI,wBAAO,GAAG;AAC7B,QAAM,IAAI;AAIV,MAAI,EAAE,IAAgB;AAEtB,QAAM,IAAI,YAAa,MAAuB;AAC5C,MAAE,aAAa,EAAE,WAAW,MAAM,GAAG,IAAI,IAAI,EAAE,MAAM,KAAK,IAAI;AAAA,EAChE;AAEA,IAAE,MAAM;AACR,MAAI,CAAC,EAAE,KAAM,GAAE,OAAO;AACtB,IAAE,OAAO;AACT,IAAE,SAAS;AACX,IAAE,UAAU;AACZ,IAAE,QAAQ,CAAC;AACb;A;;;;;;;;;;;;;;;;ADtCA,IAAAC,mBAAuB;;;AEHvB;;;AFQO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,KAAK,OAAO,GAAG;AAC5B,UAAM,EAAE,UAAU,WAAW,IAAI;AACjC,UAAM,EAAE,QAAQ,IAAI,YAAY,CAAC;AAGjC,QAAI,WAAY,WAAU,GAAG;AAG7B,QAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAG5D,UAAM,GAAG;AAET,UAAM,EAAE,OAAO,QAAI,yBAAO,GAAG;AAC7B,UAAM,MAAM,OAAO;AACnB,QAAI,QAAQ,OAAQ;AAAA,EACtB;AAAA,EAEA,KAAK,OAAO,EAAE,QAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AAC/C,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,EAAE,OAAO,QAAI,yBAAO,GAAG;AAC7B,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","import_web_core"]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{getEnv as e}from"@walkeros/web-core";var t=Object.defineProperty;((e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})})({},{Level:()=>o});var n,o=((n=o||{})[n.ERROR=0]="ERROR",n[n.INFO=1]="INFO",n[n.DEBUG=2]="DEBUG",n);function i(e){return"object"==typeof e&&null!==e&&!function(e){return Array.isArray(e)}(e)&&"[object Object]"===Object.prototype.toString.call(e)}import{getEnv as r}from"@walkeros/web-core";var a={},c={type:"meta-pixel",config:{},init({config:t,env:n,logger:o}){const{settings:i,loadScript:a}=t,{pixelId:c}=i||{};a&&function(t,n="https://connect.facebook.net/en_US/fbevents.js"){const{document:o}=e(t),i=o.createElement("script");i.src=n,i.async=!0,o.head.appendChild(i)}(n),c||o.throw("Config settings pixelId missing"),function(t){const{window:n}=e(t),o=n;if(o.fbq)return;const i=function(...e){i.callMethod?i.callMethod.apply(i,e):i.queue.push(e)};o.fbq=i,o._fbq||(o._fbq=i),i.push=i,i.loaded=!0,i.version="2.0",i.queue=[]}(n);const{window:s}=r(n);(0,s.fbq)("init",c)},push(e,{config:t,mapping:n={},data:o,env:a}){const{track:c,trackCustom:s}=n.settings||{},{window:f}=r(a),p=f.fbq;"page view"!==e.name||n.settings||(e.name="PageView");const l=c||s||e.name;p(s?"trackCustom":"track",String(l),i(o)?o:{},{eventID:e.id})}},s=c;export{a as DestinationMeta,s as default,c as destinationMeta};//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/setup.ts","../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { DestinationWeb } from '@walkeros/web-core';\nimport { getEnv } from '@walkeros/web-core';\n\nexport function addScript(\n env?: DestinationWeb.Env,\n src = 'https://connect.facebook.net/en_US/fbevents.js',\n) {\n const { document } = getEnv(env);\n const script = (document as Document).createElement('script');\n script.src = src;\n script.async = true;\n (document as 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.Env) {\n const { window } = getEnv(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 { getEnv } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta-pixel',\n\n config: {},\n\n init({ config, env, logger }) {\n const { 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) logger.throw('Config settings pixelId missing');\n\n // fbq function setup\n setup(env);\n\n const { window } = getEnv(env);\n const fbq = window.fbq as facebook.Pixel.Event;\n fbq('init', pixelId!);\n },\n\n push(event, { config, mapping = {}, data, env }) {\n const { track, trackCustom } = mapping.settings || {};\n const { window } = getEnv(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 {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb } from '@walkeros/web-core';\n\ndeclare global {\n interface Window {\n _fbq?: facebook.Pixel.Event;\n fbq?: facebook.Pixel.Event;\n }\n}\n\nexport interface Settings {\n pixelId: string;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n track?: StandardEventNames;\n trackCustom?: string;\n}\n\nexport interface Env extends DestinationWeb.Env {\n window: {\n fbq: facebook.Pixel.Event;\n _fbq?: facebook.Pixel.Event;\n };\n document: {\n createElement: (tagName: string) => Element;\n head: { appendChild: (node: unknown) => void };\n };\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\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"],"mappings":";AACA,SAAS,cAAc;AAEhB,SAAS,UACd,KACA,MAAM,kDACN;AACA,QAAM,EAAE,UAAAA,UAAS,IAAI,OAAO,GAAG;AAC/B,QAAM,SAAUA,UAAsB,cAAc,QAAQ;AAC5D,SAAO,MAAM;AACb,SAAO,QAAQ;AACf,EAACA,UAAsB,KAAK,YAAY,MAAM;AAChD;AAWO,SAAS,MAAM,KAA0B;AAC9C,QAAM,EAAE,OAAO,IAAI,OAAO,GAAG;AAC7B,QAAM,IAAI;AAIV,MAAI,EAAE,IAAgB;AAEtB,QAAM,IAAI,YAAa,MAAuB;AAC5C,MAAE,aAAa,EAAE,WAAW,MAAM,GAAG,IAAI,IAAI,EAAE,MAAM,KAAK,IAAI;AAAA,EAChE;AAEA,IAAE,MAAM;AACR,MAAI,CAAC,EAAE,KAAM,GAAE,OAAO;AACtB,IAAE,OAAO;AACT,IAAE,SAAS;AACX,IAAE,UAAU;AACZ,IAAE,QAAQ,CAAC;AACb;A;;;;;;;;;;;;;;;;ACtCA,SAAS,UAAAC,eAAc;;;ACHvB;;;ADQO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,KAAK,OAAO,GAAG;AAC5B,UAAM,EAAE,UAAU,WAAW,IAAI;AACjC,UAAM,EAAE,QAAQ,IAAI,YAAY,CAAC;AAGjC,QAAI,WAAY,WAAU,GAAG;AAG7B,QAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAG5D,UAAM,GAAG;AAET,UAAM,EAAE,OAAO,IAAIC,QAAO,GAAG;AAC7B,UAAM,MAAM,OAAO;AACnB,QAAI,QAAQ,OAAQ;AAAA,EACtB;AAAA,EAEA,KAAK,OAAO,EAAE,QAAQ,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG;AAC/C,UAAM,EAAE,OAAO,YAAY,IAAI,QAAQ,YAAY,CAAC;AACpD,UAAM,EAAE,OAAO,IAAIA,QAAO,GAAG;AAC7B,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","getEnv","getEnv"]}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@walkeros/web-destination-meta",
3
+ "description": "Meta pixel web destination for walkerOS",
4
+ "version": "0.0.0-next-20251219153324",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ },
15
+ "./examples": {
16
+ "types": "./dist/examples/index.d.ts",
17
+ "import": "./dist/examples/index.mjs",
18
+ "require": "./dist/examples/index.js"
19
+ },
20
+ "./dev": {
21
+ "types": "./dist/dev.d.ts",
22
+ "import": "./dist/dev.mjs",
23
+ "require": "./dist/dev.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist/**"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsup --silent",
31
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
32
+ "dev": "jest --watchAll --colors",
33
+ "lint": "tsc && eslint \"**/*.ts*\"",
34
+ "test": "jest",
35
+ "update": "npx npm-check-updates -u && npm update"
36
+ },
37
+ "dependencies": {
38
+ "@walkeros/web-core": "0.0.0-next-20251219153324"
39
+ },
40
+ "devDependencies": {
41
+ "@types/facebook-pixel": "^0.0.31"
42
+ },
43
+ "repository": {
44
+ "url": "git+https://github.com/elbwalker/walkerOS.git",
45
+ "directory": "packages/web/destinations/meta"
46
+ },
47
+ "author": "elbwalker <hello@elbwalker.com>",
48
+ "homepage": "https://github.com/elbwalker/walkerOS#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/elbwalker/walkerOS/issues"
51
+ },
52
+ "keywords": [
53
+ "walker",
54
+ "walkerOS",
55
+ "destination",
56
+ "web",
57
+ "meta",
58
+ "pixel"
59
+ ],
60
+ "funding": [
61
+ {
62
+ "type": "GitHub Sponsors",
63
+ "url": "https://github.com/sponsors/elbwalker"
64
+ }
65
+ ]
66
+ }