@@ -16,75 +16,81 @@ export const event = getEvent('order complete');
1616 push : (event , config , mapping , options ) => {
1717 return config .fn (options .data );
1818 },
19+ pushBatch : (batched , config , options ) => {
20+ return config .fn (batched );
21+ }
1922 }}
2023>
2124
22- Mapping is used to translate walkerOS events into a required format of another
23- tool. The mapping also defines how to process events like renaming, bundling, or
24- ignoring them. It's also checking for consent or validating a value.
25+ Mapping is used to configure and translate walkerOS events for destinations. It
26+ defines if and how to process events, by renaming, structuring, bundling, or
27+ ignoring them. It's also checking for consent and validate values.
28+
29+ ## Config
2530
26- There are common event rules for destinations like ` name ` to rename an event
27- (e.g. ` product add ` to ` add_to_cart ` ) or ` ignore ` to not process an event at
28- all. There are settings, that are individual for each destination (e.g. a GA4
29- destination might require a ` measurement_id ` while a Meta destination requires a
30- ` pixel_id ` ).
31+ Besides a general destination configuration, a mapping config is set for a
32+ specific event. Therefore it is defined as
33+ ` { [entity]: { [action]: EventConfig }} ` .
3134
3235A ` * ` can be used to match all entities or actions and set up common rules. Each
3336destination requires specific settings which can be configured in the ` custom `
3437section of the mapping.
3538
3639``` ts
37- import type { Mapping } from ' @elbwalker/types' ;
38-
39- // @TODO UPDATE
40-
41- const mapping: Mapping .Config = {
42- entity: { action: {} }, // Basic structure
43- page: {
44- view: { name: ' pageview' }, // Rename the event name
45- click: { data: { language: ' globals.language' } }, // Custom settings
46- ' *' : { ignore: true }, // Ignore all other page events
47- },
48- order: { complete: { consent: { marketing: true } } }, // Require marketing consent
49- ' *' : { visible: { batch: 2000 } }, // Bundle all visible events every 2 seconds
50- };
40+ {
41+ // Config
42+ [entity ]: {
43+ [action ]: {
44+ // EventConfig
45+ name: " event name" ,
46+ data: {
47+ // ValueConfig
48+ }
49+ }
50+ }
51+ }
5152```
5253
53- <DestinationPush event = { event } height = { ' 666px' } >
54+ <DestinationPush event = { event } height = { ' 666px' } eventConfig = { false } >
5455 { ` {
55- data: {
56- map: {
57- id: 'data.id',
58- event: { fn: (e) => e.event.replace(" ", "_") },
59- pageGroup: 'globals.pagegroup',
60- products: {
61- loop: ['nested', 'data.name']
62- },
63- user_id: {
64- consent: { marketing: true },
65- key: "user.id",
66- value: "anonymous",
67- },
68- vip: {
69- condition: (e) => e.data.total > 500,
70- value: true,
71- },
72- journeyShopping: {
73- key: 'context.shopping.0',
74- validate: (value) => typeof value == "string",
75- },
76- timings: {
77- set: ['timestamp', 'timing']
56+ order: {
57+ complete: {
58+ name: "purchase",
59+ data: {
60+ map: {
61+ event: "event",
62+ id: 'data.id',
63+ pageGroup: 'globals.pagegroup',
64+ quantity: { fn: (e) => e.nested.length },
65+ products: {
66+ loop: ['nested', 'data.name']
67+ },
68+ user_id: {
69+ consent: { marketing: true },
70+ key: "user.id",
71+ value: "anonymous",
72+ },
73+ vip: {
74+ condition: (e) => e.data.total > 500,
75+ value: true,
76+ },
77+ journeyShopping: {
78+ key: 'context.shopping.0',
79+ validate: (value) => typeof value == "string",
80+ },
81+ timings: {
82+ set: ['timestamp', 'timing']
83+ }
84+ }
7885 }
7986 },
87+ visible: { batch: 1000, data: "event" },
88+ '*' : { ignore: true }
8089 }
8190 } ` }
8291</DestinationPush >
8392
84- @TODO evtl noch ein Type Baum um zu zeigen wann Config, EventConfig,
85- ValueConfig, etc. verwendet wird.
86-
87- # EventConfig
93+ ## EventConfig
8894
8995The ` Destination.Event ` mapping for each event supports standardized default
9096options. The ` custom ` option can be used to set up custom properties for the
@@ -103,16 +109,13 @@ event and destination's individual settings.
103109To disable processing of other events, add ` {'*': {'*': { ignore: true }}} ` to
104110the mapping.
105111
106- @ TODO nicht nur auf event Ebene, auch auf value Ebene nutzbar.
107-
108- @ TODO It can be an array of multiple mappings. If a a condition isn't met, the
109- next mapping will be tried. This enables the usage of multiple mappings for the
110- same event.
112+ The destination event mapping technically uses
113+ the & nbsp ; < Link to = " /docs/utils/mapping " >mapping utils</ Link > to create the
114+ desired event structure. And
115+ the& nbsp ; < Link to = " /docs/utils/helper#getbypath " >getByPath</ Link > dot notation
116+ to access event properties (e.g. ` event.data.total ` ) .
111117
112- @TODO it uses the  ; <Link to = " /docs/utils/mapping" >mapping utils</Link > to
113- create the event structure.
114-
115- ## name
118+ ### name
116119
117120The ` name ` property is used to rename the event. It overrides the original event
118121name.
@@ -124,13 +127,34 @@ name.
124127 } ` }
125128</DestinationPush >
126129
127- ## data
130+ Example: A walkerOS ` order complete ` usually becomes a ` purchase ` event in GA4
131+ or an ` order ` event in Piwik PRO.
132+
133+ ### data
134+
135+ ### ignore
136+
137+ The ` ignore ` property is used to ignore the event.
138+
139+ ### consent
140+
141+ The ` consent ` property is used to require a specific state to process the event.
142+
143+ ### custom
144+
145+ The ` custom ` property is used to set up custom properties for the event and
146+ destination's individual settings.
147+
148+ ### batch
149+
150+ The ` batch ` property is used to bundle the events before calling ` pushBatch ` if
151+ available.
152+
153+ ## ValueConfig
128154
129155The ` data ` property is used to transform the event data. It is used to create
130156the required data structure for the destination.
131157
132- @TODO add note: it uses byPath syntax. In short.
133-
134158It can create any structure of data. With support for recursive data structures.
135159
136160### key
@@ -280,24 +304,6 @@ resolved the value, it will be validated with the `validate` function.
280304 } ` }
281305</DestinationPush >
282306
283- ## ignore
284-
285- The ` ignore ` property is used to ignore the event.
286-
287- ## consent
288-
289- The ` consent ` property is used to require a specific state to process the event.
290-
291- ## custom
292-
293- The ` custom ` property is used to set up custom properties for the event and
294- destination's individual settings.
295-
296- ## batch
297-
298- The ` batch ` property is used to bundle the events before calling ` pushBatch ` if
299- available.
300-
301307## Execution order
302308
303309If the ` data ` property is an array, the mappings will be executed in the order
0 commit comments