@walkeros/walker.js 0.0.10 โ†’ 0.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @walkeros/walker.js
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fixes
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @walkeros/web-source-datalayer@0.1.0
13
+ - @walkeros/web-source-browser@0.1.0
14
+ - @walkeros/collector@0.1.0
15
+ - @walkeros/web-core@0.1.0
16
+ - @walkeros/core@0.1.0
17
+
3
18
  ## 0.0.10
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # Walker.js
1
+ # walker.js
2
2
 
3
- A ready-to-use walkerOS bundle that combines the browser source, collector, and
4
- dataLayer support into a single JavaScript file. Perfect for quickly adding
5
- privacy-friendly event tracking to any website.
3
+ Walker.js is a pre-built walkerOS application that combines both the
4
+ [browser](/docs/sources/web/browser/) and
5
+ [dataLayer](/docs/sources/web/dataLayer/) sources with the
6
+ [collector](/docs/collector/) and a default `dataLayer` destination into a
7
+ pre-build package. It's designed for users who want instant web tracking without
8
+ complex setup or configuration.
6
9
 
7
10
  ## Features
8
11
 
@@ -16,27 +19,17 @@ privacy-friendly event tracking to any website.
16
19
  - ๐Ÿ“ฆ **Queue support** - Events are queued until walker.js loads (elbLayer)
17
20
  - ๐Ÿงช **Well tested** - Comprehensive test suite included
18
21
 
19
- ## Quick Start
22
+ ## Installation
20
23
 
21
- ### 1. Add elbLayer Function (Recommended)
24
+ ### Option 1: NPM Package
22
25
 
23
- Add this before walker.js loads to queue events:
24
-
25
- ```html
26
- <script>
27
- function elb() {
28
- (window.elbLayer = window.elbLayer || []).push(arguments);
29
- }
30
- </script>
26
+ ```bash
27
+ npm install @walkeros/walker.js
31
28
  ```
32
29
 
33
- ### 2. Include walker.js
30
+ ### Option 2: CDN
34
31
 
35
32
  ```html
36
- <!-- Recommended: Async loading with configuration -->
37
- <script async data-elbconfig="elbConfig" src="./walker.js"></script>
38
-
39
- <!-- Or from CDN -->
40
33
  <script
41
34
  async
42
35
  data-elbconfig="elbConfig"
@@ -44,98 +37,98 @@ Add this before walker.js loads to queue events:
44
37
  ></script>
45
38
  ```
46
39
 
47
- ### 3. Configure
40
+ ## Basic Setup
48
41
 
49
- #### Option A: Default Configuration
42
+ ### 1. Add Event Queueing (Recommended)
50
43
 
51
- Just load the `walker.js` script - it will look for `window.elbConfig`:
44
+ Add this script before walker.js loads to queue events during initialization:
52
45
 
53
46
  ```html
54
47
  <script>
55
- window.elbConfig = {
56
- /* your config */
57
- };
48
+ function elb() {
49
+ (window.elbLayer = window.elbLayer || []).push(arguments);
50
+ }
58
51
  </script>
59
- <script async src="./walker.js"></script>
60
52
  ```
61
53
 
62
- #### Option B: Named Configuration Object
54
+ ### 2. Include Walker.js
55
+
56
+ ```html
57
+ <script async data-elbconfig="elbConfig" src="./walker.js"></script>
58
+ ```
63
59
 
64
- Use `data-elbconfig` on the script tag to define the configuration object.
60
+ ### 3. Configure Destinations
65
61
 
66
62
  ```html
67
63
  <script>
68
- window.trackingConfig = {
69
- elb: 'elb', // Global function name
70
- name: 'walkerjs', // Global instance name
71
- dataLayer: true, // Enable dataLayer integration
64
+ window.elbConfig = {
72
65
  collector: {
73
66
  destinations: {
74
- // Add your destinations here
67
+ console: {
68
+ push: (event) => console.log('Event:', event),
69
+ },
70
+ api: {
71
+ push: async (event) => {
72
+ await fetch('/api/events', {
73
+ method: 'POST',
74
+ body: JSON.stringify(event),
75
+ });
76
+ },
77
+ },
75
78
  },
76
79
  },
77
80
  };
78
81
  </script>
79
- <script async data-elbconfig="trackingConfig" src="./walker.js"></script>
80
- ```
81
-
82
- #### Option C: Inline Configuration
83
-
84
- Configure directly in the script tag. Use simple key:value pairs separated by
85
- semicolon.
86
-
87
- ```html
88
- <script
89
- async
90
- data-elbconfig="elb:track;run:true;instance:myWalker"
91
- src="./walker.js"
92
- ></script>
93
82
  ```
94
83
 
95
- ### 3. Track Events
84
+ ## Configuration Options
96
85
 
97
- #### Automatic DOM Tracking
86
+ Walker.js supports multiple configuration approaches with different priorities:
98
87
 
99
- Add data attributes to your HTML:
100
-
101
- ```html
102
- <!-- Product tracking -->
103
- <div data-elb="product" data-elb-product="id:123;name:Blue T-Shirt;price:29.99">
104
- <button data-elbaction="click:add">Add to Cart</button>
105
- </div>
88
+ 1. **Script tag `data-elbconfig`** (highest priority)
89
+ 2. **`window.elbConfig`** (default fallback)
90
+ 3. **Manual initialization** (when `run: false`)
106
91
 
107
- <!-- Global properties -->
108
- <div data-elbglobals="pagetype:product_detail"></div>
92
+ ### Settings
109
93
 
110
- <!-- Context information -->
111
- <div data-elbcontext="section:recommendations"></div>
112
- ```
94
+ | Name | Type | Default | Description |
95
+ | :---------- | :------------------ | :------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
96
+ | `elb` | `string` | `"elb"` | Global function name for event tracking |
97
+ | `name` | `string` | `"walkerjs"` | Global instance name |
98
+ | `run` | `boolean` | `true` | Auto-initialize walker.js on load |
99
+ | `browser` | `object \| boolean` | `{ run: true, session: true, scope: document.body, pageview: true }` | [Browser source configuration](https://www.elbwalker.com/docs/sources/web/browser/) |
100
+ | `dataLayer` | `object \| boolean` | `false` | [DataLayer source configuration](https://www.elbwalker.com/docs/sources/web/dataLayer) |
101
+ | `collector` | `object` | `{}` | [Collector configuration](https://www.elbwalker.com/docs/collector/) including destinations and consent settings |
113
102
 
114
- #### Manual Event Tracking
103
+ #### Browser Source Settings
115
104
 
116
- ```javascript
117
- // Using the global elb function
118
- elb('product add', {
119
- id: '123',
120
- price: 29.99,
121
- });
122
- ```
105
+ | Name | Type | Default | Description |
106
+ | :----------------- | :-------- | :-------------- | :-------------------------------- |
107
+ | `browser.run` | `boolean` | `true` | Auto-start DOM tracking |
108
+ | `browser.session` | `boolean` | `true` | Enable session tracking |
109
+ | `browser.scope` | `Element` | `document.body` | DOM element scope for tracking |
110
+ | `browser.pageview` | `boolean` | `true` | Enable automatic page view events |
123
111
 
124
- ## Configuration
112
+ #### DataLayer Settings
125
113
 
126
- ### Configuration Options
114
+ | Name | Type | Default | Description |
115
+ | :----------------- | :-------- | :------------ | :----------------------------------------- |
116
+ | `dataLayer` | `boolean` | `false` | Enable dataLayer integration with defaults |
117
+ | `dataLayer.name` | `string` | `"dataLayer"` | DataLayer variable name |
118
+ | `dataLayer.prefix` | `string` | `"dataLayer"` | Event prefix for dataLayer events |
127
119
 
128
- Walker.js can be configured in multiple ways:
120
+ #### Collector Settings
129
121
 
130
- 1. **Script tag with `data-elbconfig`** - Highest priority
131
- 2. **`window.elbConfig`** - Default fallback
132
- 3. **Manual initialization** - When `run: false`
122
+ | Name | Type | Default | Description |
123
+ | :----------------------- | :------- | :--------------------- | :------------------------------------------------------------------------ |
124
+ | `collector.consent` | `object` | `{ functional: true }` | Default consent state |
125
+ | `collector.destinations` | `object` | `{}` | [Destination configurations](https://www.elbwalker.com/docs/destinations) |
133
126
 
134
127
  ### Full Configuration Object
135
128
 
136
129
  ```javascript
137
130
  window.elbConfig = {
138
- // Global configuration
131
+ // Global settings
139
132
  elb: 'elb', // Global function name (default: 'elb')
140
133
  name: 'walkerjs', // Global instance name
141
134
  run: true, // Auto-initialize (default: true)
@@ -145,56 +138,118 @@ window.elbConfig = {
145
138
  run: true, // Auto-start DOM tracking
146
139
  session: true, // Enable session tracking
147
140
  scope: document.body, // Tracking scope
141
+ pageview: true, // Enable automatic page views
148
142
  },
149
143
 
150
144
  // DataLayer integration
151
145
  dataLayer: true, // Enable dataLayer
152
146
  // or detailed config:
153
- dataLayer: {
154
- name: 'dataLayer', // DataLayer variable name
155
- prefix: 'dataLayer', // Event prefix
156
- },
147
+ // dataLayer: {
148
+ // name: 'dataLayer', // DataLayer variable name
149
+ // prefix: 'dataLayer', // Event prefix
150
+ // },
157
151
 
158
152
  // Collector configuration
159
153
  collector: {
160
154
  consent: { functional: true }, // Default consent state
161
155
  destinations: {
162
- // Your destinations
156
+ // Your destinations here
157
+ console: {
158
+ push: (event) => console.log('Event:', event),
159
+ },
163
160
  },
164
161
  },
165
162
  };
166
163
  ```
167
164
 
168
- ### Destination Configuration
165
+ ### Inline Configuration
169
166
 
170
- ```javascript
171
- const walkerjs = Walkerjs({
172
- collector: {
173
- destinations: {
174
- console: {
175
- type: 'console',
176
- push: (event) => console.log(event),
177
- },
167
+ Configure directly in the script tag using simple key:value pairs:
178
168
 
179
- api: {
180
- type: 'custom-api',
181
- push: async (event) => {
182
- await fetch('/api/events', {
183
- method: 'POST',
184
- body: JSON.stringify(event),
185
- });
186
- },
169
+ ```html
170
+ <script
171
+ async
172
+ data-elbconfig="elb:track;run:true;instance:myWalker"
173
+ src="./walker.js"
174
+ ></script>
175
+ ```
176
+
177
+ ### Named Configuration Object
178
+
179
+ Use a custom configuration object name:
180
+
181
+ ```html
182
+ <script>
183
+ window.trackingConfig = {
184
+ elb: 'track',
185
+ collector: {
186
+ destinations: {
187
+ // Your destinations
187
188
  },
188
189
  },
190
+ };
191
+ </script>
192
+ <script async data-elbconfig="trackingConfig" src="./walker.js"></script>
193
+ ```
194
+
195
+ ## Usage
196
+
197
+ ### Automatic DOM Tracking
198
+
199
+ Walker.js automatically tracks events based on HTML data attributes:
200
+
201
+ ```html
202
+ <!-- Product tracking -->
203
+ <div data-elb="product" data-elb-product="id:123;name:Blue T-Shirt;price:29.99">
204
+ <button data-elbaction="click:add">Add to Cart</button>
205
+ </div>
206
+
207
+ <!-- Global properties -->
208
+ <div data-elbglobals="pagetype:product_detail"></div>
209
+
210
+ <!-- Context information -->
211
+ <div data-elbcontext="section:recommendations"></div>
212
+ ```
213
+
214
+ For detailed information on data attributes, see the
215
+ [Browser Source documentation](https://www.elbwalker.com/docs/sources/web/browser/tagging).
216
+
217
+ ### Manual Event Tracking
218
+
219
+ Use the global `elb` function for manual tracking:
220
+
221
+ ```javascript
222
+ // Simple event
223
+ elb('button click', {
224
+ label: 'interesting',
225
+ });
226
+ ```
227
+
228
+ ### DataLayer Integration
229
+
230
+ Walker.js can integrate with existing dataLayer implementations:
231
+
232
+ ```javascript
233
+ // Enable dataLayer integration
234
+ window.elbConfig = {
235
+ dataLayer: true, // Uses window.dataLayer by default
236
+ };
237
+
238
+ // Existing dataLayer events will be processed
239
+ dataLayer.push({
240
+ event: 'purchase',
241
+ ecommerce: {
242
+ transaction_id: '12345',
243
+ value: 25.42,
189
244
  },
190
245
  });
191
246
  ```
192
247
 
193
- ## Advanced Usage
248
+ ## Advanced Features
194
249
 
195
250
  ### Async Loading & Event Queueing
196
251
 
197
- Walker.js supports async loading with automatic event queueing:
252
+ Walker.js handles async loading gracefully with automatic event queueing:
198
253
 
199
254
  ```html
200
255
  <script>
@@ -204,35 +259,91 @@ Walker.js supports async loading with automatic event queueing:
204
259
  }
205
260
 
206
261
  // 2. Track events immediately (even before walker.js loads)
207
- elb('page view');
208
262
  elb('product view', { id: '123', name: 'Blue T-Shirt' });
209
263
  </script>
210
264
 
211
- <!-- 3. Walker.js will process queued events when it loads -->
265
+ <!-- 3. Walker.js processes queued events when it loads -->
212
266
  <script async data-elbconfig="elbConfig" src="./walker.js"></script>
213
267
  ```
214
268
 
215
- **Benefits:**
216
-
217
- - No timing issues with async scripts
218
- - Events are never lost
219
- - Works with any loading strategy (async, defer, dynamic)
220
- - Zero dependencies for the queue function
221
-
222
269
  ### Build Variants
223
270
 
224
- Walker.js provides multiple build formats:
271
+ Walker.js provides multiple build formats for different environments:
225
272
 
226
273
  - `walker.js` - Standard IIFE bundle for browsers
227
274
  - `index.es5.js` - GTM-compatible ES2015 build
228
275
  - `index.mjs` - ES modules for modern bundlers
229
276
  - `index.js` - CommonJS for Node.js environments
230
277
 
278
+ ### Programmatic Usage
279
+
280
+ Use walker.js programmatically in applications:
281
+
282
+ ```javascript
283
+ import { createWalkerjs } from '@walkeros/walker.js';
284
+
285
+ const { collector, elb } = await createWalkerjs({
286
+ collector: {
287
+ destinations: {
288
+ console: { push: console.log },
289
+ },
290
+ },
291
+ browser: {
292
+ session: true,
293
+ pageview: true,
294
+ },
295
+ });
296
+ ```
297
+
298
+ ## Destination Configuration
299
+
300
+ Configure multiple destinations for your events:
301
+
302
+ ```javascript
303
+ window.elbConfig = {
304
+ collector: {
305
+ destinations: {
306
+ // Console logging for development
307
+ console: {
308
+ push: (event) => console.log('Walker.js Event:', event),
309
+ },
310
+
311
+ // Custom API endpoint
312
+ api: {
313
+ push: async (event) => {
314
+ await fetch('/api/events', {
315
+ method: 'POST',
316
+ headers: { 'Content-Type': 'application/json' },
317
+ body: JSON.stringify(event),
318
+ });
319
+ },
320
+ },
321
+ },
322
+ },
323
+ };
324
+ ```
325
+
326
+ For comprehensive destination options, see the
327
+ [Destinations documentation](https://www.elbwalker.com/docs/destinations/).
328
+
329
+ ## Troubleshooting
330
+
331
+ ### Common Issues
332
+
333
+ **Events not firing:** Check that walker.js loaded and configuration is valid.
334
+
335
+ **Missing events:** Ensure event queueing function is added before walker.js.
336
+
337
+ **Configuration not applied:** Verify `data-elbconfig` points to the correct
338
+ object name.
339
+
231
340
  ## API Reference
232
341
 
233
342
  ### Factory Function
234
343
 
235
- #### `createWalkerjs(config?): Walkerjs.Instance`
344
+ ```typescript
345
+ createWalkerjs(config?: Config): Promise<Instance>
346
+ ```
236
347
 
237
348
  Creates a new walker.js instance with the provided configuration.
238
349
 
@@ -241,28 +352,19 @@ Creates a new walker.js instance with the provided configuration.
241
352
  - `collector` - The walkerOS collector instance
242
353
  - `elb` - Browser push function for event tracking
243
354
 
244
- ### Additional Methods
245
-
246
- - `getAllEvents(scope?, prefix?)` - Get all trackable events on the page
247
- - `getEvents(target, trigger, prefix?)` - Get events for a specific element and
248
- trigger
249
- - `getGlobals(prefix?, scope?)` - Get global properties from the page
250
-
251
355
  ### Utility Functions
252
356
 
253
- You can also import and use the utility functions directly:
254
-
255
357
  ```javascript
256
358
  import { getAllEvents, getEvents, getGlobals } from '@walkeros/walker.js';
257
359
 
258
- // Get all events on the page
360
+ // Get all trackable events on the page
259
361
  const events = getAllEvents();
260
362
 
261
- // Get events for a specific button click
363
+ // Get events for a specific element and trigger
262
364
  const button = document.querySelector('button');
263
365
  const clickEvents = getEvents(button, 'click');
264
366
 
265
- // Get global properties
367
+ // Get global properties from the page
266
368
  const globals = getGlobals();
267
369
  ```
268
370
 
@@ -287,19 +389,25 @@ npm run dev # Watch mode
287
389
  npm run preview # Serve examples on localhost:3333
288
390
  ```
289
391
 
290
- ## License
392
+ ## Related Documentation
291
393
 
292
- MIT License - see LICENSE file for details.
394
+ - **[Browser Source](https://www.elbwalker.com/docs/sources/web/browser/)** -
395
+ Detailed DOM tracking capabilities
396
+ - **[Collector](https://www.elbwalker.com/docs/collector/)** - Event processing
397
+ and routing
398
+ - **[Destinations](https://www.elbwalker.com/docs/destinations/)** - Available
399
+ destination options
400
+ - **[DataLayer Source](https://www.elbwalker.com/docs/sources/web/dataLayer/)** -
401
+ DataLayer integration details
402
+
403
+ Walker.js combines all these components into a single, easy-to-use package
404
+ perfect for getting started with walkerOS quickly.
293
405
 
294
406
  ## Contributing
295
407
 
296
408
  This package is part of the walkerOS monorepo. Please see the main repository
297
409
  for contribution guidelines.
298
410
 
299
- ## Related Packages
411
+ ## License
300
412
 
301
- - [@walkeros/collector](../../../packages/collector) - Core collector
302
- - [@walkeros/web-source-browser](../../../packages/web/sources/browser) -
303
- Browser source
304
- - [@walkeros/web-source-datalayer](../../../packages/web/sources/dataLayer) -
305
- DataLayer source
413
+ MIT License - see LICENSE file for details.