@walkeros/web-core 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.
- package/README.md +329 -0
- package/dist/index.d.mts +316 -0
- package/dist/index.d.ts +316 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img title="elbwalker" src="https://www.walkeros.io/img/elbwalker_logo.png" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# Web Core Utilities for walkerOS
|
|
8
|
+
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/core)
|
|
10
|
+
• [NPM Package](https://www.npmjs.com/package/@walkeros/web-core)
|
|
11
|
+
|
|
12
|
+
Web core utilities are browser-specific functions designed for client-side
|
|
13
|
+
walkerOS implementations. These utilities handle DOM interactions, browser
|
|
14
|
+
information, storage, sessions, and web-based communication.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Import web utilities from the `@walkeros/web-core` package:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { getAttribute, sendWeb, sessionStart } from '@walkeros/web-core';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Utilities
|
|
25
|
+
|
|
26
|
+
### DOM Utilities
|
|
27
|
+
|
|
28
|
+
#### getAttribute
|
|
29
|
+
|
|
30
|
+
`getAttribute(element: Element, name: string): string` retrieves attribute
|
|
31
|
+
values from DOM elements with enhanced handling.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const element = document.querySelector('[data-elb="product"]');
|
|
35
|
+
const entityType = getAttribute(element, 'data-elb'); // Returns 'product'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Attribute Parsing
|
|
39
|
+
|
|
40
|
+
##### splitAttribute
|
|
41
|
+
|
|
42
|
+
`splitAttribute(str: string, separator?: string): string[]` splits attribute
|
|
43
|
+
strings using specified separators.
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
splitAttribute('id:123,name:shirt', ','); // Returns ['id:123', 'name:shirt']
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
##### splitKeyVal
|
|
50
|
+
|
|
51
|
+
`splitKeyVal(str: string): [string, string]` splits key-value pairs from
|
|
52
|
+
attribute strings.
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
splitKeyVal('id:123'); // Returns ['id', '123']
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
##### parseInlineConfig
|
|
59
|
+
|
|
60
|
+
`parseInlineConfig(str: string): Record<string, unknown>` parses inline
|
|
61
|
+
configuration strings from HTML attributes.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
parseInlineConfig('{"tracking": true, "debug": false}');
|
|
65
|
+
// Returns { tracking: true, debug: false }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Browser Information
|
|
69
|
+
|
|
70
|
+
#### getLanguage
|
|
71
|
+
|
|
72
|
+
`getLanguage(navigatorRef: Navigator): string | undefined` extracts the user's
|
|
73
|
+
preferred language.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
getLanguage(navigator); // Returns 'en-US' or user's language
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### getTimezone
|
|
80
|
+
|
|
81
|
+
`getTimezone(): string | undefined` gets the user's timezone from the Intl API.
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
getTimezone(); // Returns 'America/New_York' or user's timezone
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### getScreenSize
|
|
88
|
+
|
|
89
|
+
`getScreenSize(windowRef: Window): string` returns the window's screen
|
|
90
|
+
dimensions.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
getScreenSize(window); // Returns '1920x1080' or current screen size
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Element Visibility
|
|
97
|
+
|
|
98
|
+
#### isVisible
|
|
99
|
+
|
|
100
|
+
`isVisible(element: HTMLElement): boolean` checks if an element is visible to
|
|
101
|
+
the user.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const promoElement = document.getElementById('promotion');
|
|
105
|
+
if (isVisible(promoElement)) {
|
|
106
|
+
// Element is visible on screen
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This function considers:
|
|
111
|
+
|
|
112
|
+
- Element display and visibility styles
|
|
113
|
+
- Element position within viewport
|
|
114
|
+
- Parent element visibility
|
|
115
|
+
- Intersection with the visible area
|
|
116
|
+
|
|
117
|
+
### Storage Management
|
|
118
|
+
|
|
119
|
+
#### Storage Operations
|
|
120
|
+
|
|
121
|
+
##### storageRead
|
|
122
|
+
|
|
123
|
+
`storageRead(key: string, storage?: StorageType): WalkerOS.PropertyType` reads
|
|
124
|
+
data from browser storage with automatic type conversion.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
// Default uses localStorage
|
|
128
|
+
const userId = storageRead('walker_user_id');
|
|
129
|
+
|
|
130
|
+
// Use sessionStorage
|
|
131
|
+
const sessionData = storageRead('session_data', 'sessionStorage');
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
##### storageWrite
|
|
135
|
+
|
|
136
|
+
`storageWrite(key: string, value: WalkerOS.PropertyType, maxAgeInMinutes?: number, storage?: StorageType, domain?: string): WalkerOS.PropertyType`
|
|
137
|
+
writes data to storage with expiration and domain options.
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
// Store with 30-minute expiration
|
|
141
|
+
storageWrite('user_preference', 'dark-mode', 30);
|
|
142
|
+
|
|
143
|
+
// Store in sessionStorage
|
|
144
|
+
storageWrite('temp_data', { id: 123 }, undefined, 'sessionStorage');
|
|
145
|
+
|
|
146
|
+
// Store with custom domain for cookies
|
|
147
|
+
storageWrite('tracking_id', 'abc123', 1440, 'cookie', '.example.com');
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
##### storageDelete
|
|
151
|
+
|
|
152
|
+
`storageDelete(key: string, storage?: StorageType)` removes data from storage.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
storageDelete('expired_data');
|
|
156
|
+
storageDelete('session_temp', 'sessionStorage');
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Session Management
|
|
160
|
+
|
|
161
|
+
#### sessionStart
|
|
162
|
+
|
|
163
|
+
`sessionStart(config?: SessionConfig): WalkerOS.SessionData | void` initializes
|
|
164
|
+
and manages user sessions with automatic renewal and tracking.
|
|
165
|
+
|
|
166
|
+
```js
|
|
167
|
+
// Start session with default config
|
|
168
|
+
const session = sessionStart();
|
|
169
|
+
|
|
170
|
+
// Custom session configuration
|
|
171
|
+
const session = sessionStart({
|
|
172
|
+
storage: true,
|
|
173
|
+
domain: '.example.com',
|
|
174
|
+
maxAge: 1440, // 24 hours
|
|
175
|
+
sampling: 1.0, // 100% sampling
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Session data includes:
|
|
180
|
+
|
|
181
|
+
- `id` - Unique session identifier
|
|
182
|
+
- `start` - Session start timestamp
|
|
183
|
+
- `isNew` - Whether this is a new session
|
|
184
|
+
- `count` - Number of events in session
|
|
185
|
+
- `device` - Device identifier
|
|
186
|
+
- `storage` - Whether storage is available
|
|
187
|
+
|
|
188
|
+
#### Advanced Session Functions
|
|
189
|
+
|
|
190
|
+
- `sessionStorage` - Session-specific storage operations
|
|
191
|
+
- `sessionWindow` - Window/tab session management
|
|
192
|
+
|
|
193
|
+
### Web Communication
|
|
194
|
+
|
|
195
|
+
#### sendWeb
|
|
196
|
+
|
|
197
|
+
`sendWeb<T>(url: string, data?: SendDataValue, options?: SendWebOptionsDynamic<T>): SendWebReturn<T>`
|
|
198
|
+
sends data using various web transport methods.
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
// Default fetch transport
|
|
202
|
+
await sendWeb('https://api.example.com/events', eventData);
|
|
203
|
+
|
|
204
|
+
// Use specific transport
|
|
205
|
+
await sendWeb(url, data, { transport: 'beacon' });
|
|
206
|
+
await sendWeb(url, data, { transport: 'xhr' });
|
|
207
|
+
|
|
208
|
+
// With custom headers
|
|
209
|
+
await sendWeb(url, data, {
|
|
210
|
+
headers: { Authorization: 'Bearer token' },
|
|
211
|
+
method: 'PUT',
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### Transport-Specific Functions
|
|
216
|
+
|
|
217
|
+
##### sendWebAsFetch
|
|
218
|
+
|
|
219
|
+
`sendWebAsFetch(url: string, data?: SendDataValue, options?: SendWebOptionsFetch): Promise<SendResponse>`
|
|
220
|
+
uses the modern Fetch API with advanced options.
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
await sendWebAsFetch(url, data, {
|
|
224
|
+
credentials: 'include',
|
|
225
|
+
noCors: true,
|
|
226
|
+
headers: { 'Content-Type': 'application/json' },
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
##### sendWebAsBeacon
|
|
231
|
+
|
|
232
|
+
`sendWebAsBeacon(url: string, data?: SendDataValue): SendResponse` uses the
|
|
233
|
+
Beacon API for reliable data transmission, especially during page unload.
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
// Reliable sending during page unload
|
|
237
|
+
window.addEventListener('beforeunload', () => {
|
|
238
|
+
sendWebAsBeacon('/analytics/pageview', { duration: Date.now() - startTime });
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
##### sendWebAsXhr
|
|
243
|
+
|
|
244
|
+
`sendWebAsXhr(url: string, data?: SendDataValue, options?: SendWebOptions): SendResponse`
|
|
245
|
+
uses XMLHttpRequest for synchronous communication.
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
// Synchronous request (blocks execution)
|
|
249
|
+
const response = sendWebAsXhr(url, data, { method: 'POST' });
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Web Hashing
|
|
253
|
+
|
|
254
|
+
#### getHashWeb
|
|
255
|
+
|
|
256
|
+
`getHashWeb(str: string, length?: number): Promise<string>` generates SHA-256
|
|
257
|
+
hashes using the Web Crypto API.
|
|
258
|
+
|
|
259
|
+
```js
|
|
260
|
+
// Generate hash for fingerprinting
|
|
261
|
+
const userFingerprint = await getHashWeb(
|
|
262
|
+
navigator.userAgent + navigator.language + screen.width,
|
|
263
|
+
16,
|
|
264
|
+
);
|
|
265
|
+
// Returns shortened hash like '47e0bdd10f04ef13'
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Configuration Types
|
|
269
|
+
|
|
270
|
+
### SendWebOptions
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
interface SendWebOptions {
|
|
274
|
+
headers?: Record<string, string>;
|
|
275
|
+
method?: string; // Default: 'POST'
|
|
276
|
+
transport?: 'fetch' | 'beacon' | 'xhr'; // Default: 'fetch'
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface SendWebOptionsFetch extends SendWebOptions {
|
|
280
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
281
|
+
noCors?: boolean;
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### SessionConfig
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
interface SessionConfig {
|
|
289
|
+
storage?: boolean; // Enable storage persistence
|
|
290
|
+
domain?: string; // Cookie domain
|
|
291
|
+
maxAge?: number; // Session duration in minutes
|
|
292
|
+
sampling?: number; // Sampling rate (0-1)
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### StorageType
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
type StorageType = 'localStorage' | 'sessionStorage' | 'cookie';
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Usage Notes
|
|
303
|
+
|
|
304
|
+
- **Consent Required**: Browser information functions may require user consent
|
|
305
|
+
depending on privacy regulations
|
|
306
|
+
- **Storage Fallbacks**: Storage functions gracefully handle unavailable storage
|
|
307
|
+
with fallbacks
|
|
308
|
+
- **Transport Selection**: Choose transport based on use case:
|
|
309
|
+
- `fetch` - Modern, flexible, supports responses
|
|
310
|
+
- `beacon` - Reliable during page unload, small payloads
|
|
311
|
+
- `xhr` - Synchronous when needed, broader browser support
|
|
312
|
+
- **Performance**: Session and storage operations are optimized for minimal
|
|
313
|
+
performance impact
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
For platform-agnostic utilities, see
|
|
318
|
+
[Core Utilities](https://www.walkeros.io/docs/core).
|
|
319
|
+
|
|
320
|
+
## Contribute
|
|
321
|
+
|
|
322
|
+
Feel free to contribute by submitting an
|
|
323
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
324
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
325
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
326
|
+
|
|
327
|
+
## License
|
|
328
|
+
|
|
329
|
+
This project is licensed under the MIT License.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Elb, Destination as Destination$1, SendHeaders, SendResponse, SendDataValue, Collector as Collector$1, StorageType, WalkerOS, MarketingParameters, Source as Source$1, Hooks, On } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get attribute value from element
|
|
5
|
+
* @param element - DOM element
|
|
6
|
+
* @param name - Attribute name
|
|
7
|
+
* @returns Trimmed attribute value or empty string
|
|
8
|
+
*/
|
|
9
|
+
declare function getAttribute(element: Element, name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Split attribute string by separator (semicolon by default)
|
|
12
|
+
* Handles quoted values containing the separator
|
|
13
|
+
* @param str - String to split
|
|
14
|
+
* @param separator - Separator character (default: ';')
|
|
15
|
+
* @returns Array of attribute strings
|
|
16
|
+
*/
|
|
17
|
+
declare function splitAttribute(str: string, separator?: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Split key-value pair by first colon
|
|
20
|
+
* @param str - String in format "key:value"
|
|
21
|
+
* @returns Tuple of [key, value]
|
|
22
|
+
*/
|
|
23
|
+
declare function splitKeyVal(str: string): [string, string];
|
|
24
|
+
/**
|
|
25
|
+
* Parse inline configuration string into object
|
|
26
|
+
* Supports type conversion for boolean and numeric values
|
|
27
|
+
* @param str - Configuration string (e.g., "elb:track;run:false;port:3000")
|
|
28
|
+
* @returns Parsed configuration object
|
|
29
|
+
*/
|
|
30
|
+
declare function parseInlineConfig(str: string): Record<string, unknown>;
|
|
31
|
+
|
|
32
|
+
declare function getLanguage(navigatorRef: Navigator): string | undefined;
|
|
33
|
+
declare function getTimezone(): string | undefined;
|
|
34
|
+
declare function getScreenSize(windowRef: Window): string;
|
|
35
|
+
|
|
36
|
+
declare const elb$1: Elb.Fn<void>;
|
|
37
|
+
|
|
38
|
+
type TypesGeneric$1 = Destination$1.TypesGeneric;
|
|
39
|
+
interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
|
|
40
|
+
}
|
|
41
|
+
type Init$1 = Destination$1.Init;
|
|
42
|
+
type Config$2<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.Config<T>;
|
|
43
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PartialConfig<T>;
|
|
44
|
+
type InitFn$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.InitFn<T>;
|
|
45
|
+
type PushFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PushFn<T>;
|
|
46
|
+
type PushEvent<Mapping = unknown> = Destination$1.PushEvent<Mapping>;
|
|
47
|
+
type PushEvents<Mapping = unknown> = Destination$1.PushEvents<Mapping>;
|
|
48
|
+
/**
|
|
49
|
+
* Web-specific environment requirements interface
|
|
50
|
+
*
|
|
51
|
+
* Extends the core Env interface with web-specific
|
|
52
|
+
* globals like window and document for browser destinations.
|
|
53
|
+
*/
|
|
54
|
+
interface Env extends Destination$1.BaseEnv {
|
|
55
|
+
/**
|
|
56
|
+
* Properties to be added to the global `window` object
|
|
57
|
+
*
|
|
58
|
+
* Used by web destinations that expect browser-specific
|
|
59
|
+
* global functions like analytics APIs.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* window: {
|
|
64
|
+
* gtag: () => {},
|
|
65
|
+
* fbq: () => {},
|
|
66
|
+
* dataLayer: []
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
window?: Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Properties to be added to the global `document` object
|
|
73
|
+
*
|
|
74
|
+
* Used by destinations that need DOM manipulation capabilities
|
|
75
|
+
* for script loading or element creation.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* document: {
|
|
80
|
+
* createElement: () => ({ src: '', async: false }),
|
|
81
|
+
* head: { appendChild: () => {} }
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
document?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type destination_Destination<T extends TypesGeneric$1 = Destination$1.Types> = Destination<T>;
|
|
89
|
+
type destination_Env = Env;
|
|
90
|
+
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
91
|
+
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
92
|
+
type destination_PushFn<T extends TypesGeneric$1 = Destination$1.Types> = PushFn<T>;
|
|
93
|
+
declare namespace destination {
|
|
94
|
+
export type { Config$2 as Config, destination_Destination as Destination, destination_Env as Env, Init$1 as Init, InitFn$1 as InitFn, PartialConfig$1 as PartialConfig, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, TypesGeneric$1 as TypesGeneric };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to get environment globals with fallbacks
|
|
99
|
+
*
|
|
100
|
+
* Returns window and document by default, with optional environment overrides.
|
|
101
|
+
*
|
|
102
|
+
* @param env - Optional environment overrides
|
|
103
|
+
* @returns Env with window/document defaults and any provided overrides
|
|
104
|
+
*/
|
|
105
|
+
declare function getEnv(env?: Env): {
|
|
106
|
+
window: Record<string, unknown> | (Window & typeof globalThis);
|
|
107
|
+
document: Record<string, unknown> | Document;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
declare function getHashWeb(str: string, length?: number): Promise<string>;
|
|
111
|
+
|
|
112
|
+
declare function isVisible(element: HTMLElement): boolean;
|
|
113
|
+
|
|
114
|
+
type SendWebTransport = 'fetch' | 'beacon' | 'xhr';
|
|
115
|
+
interface SendWebOptions {
|
|
116
|
+
headers?: SendHeaders;
|
|
117
|
+
transport?: SendWebTransport;
|
|
118
|
+
method?: string;
|
|
119
|
+
}
|
|
120
|
+
interface SendWebOptionsFetch extends SendWebOptions {
|
|
121
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
122
|
+
noCors?: boolean;
|
|
123
|
+
}
|
|
124
|
+
type SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch' ? SendWebOptionsFetch : SendWebOptions;
|
|
125
|
+
type SendWebReturn<T extends SendWebTransport> = T extends 'fetch' ? Promise<SendResponse> : SendResponse;
|
|
126
|
+
declare function sendWeb<T extends SendWebTransport>(url: string, data?: SendDataValue, options?: SendWebOptionsDynamic<T> & {
|
|
127
|
+
transport?: T;
|
|
128
|
+
}): SendWebReturn<T>;
|
|
129
|
+
declare function sendWebAsFetch(url: string, data?: SendDataValue, options?: SendWebOptionsFetch): Promise<SendResponse>;
|
|
130
|
+
declare function sendWebAsBeacon(url: string, data?: SendDataValue): SendResponse;
|
|
131
|
+
declare function sendWebAsXhr(url: string, data?: SendDataValue, options?: SendWebOptions): SendResponse;
|
|
132
|
+
|
|
133
|
+
interface SessionConfig extends SessionStorageConfig {
|
|
134
|
+
consent?: string | string[];
|
|
135
|
+
storage?: boolean;
|
|
136
|
+
cb?: SessionCallback | false;
|
|
137
|
+
collector?: Collector$1.Instance;
|
|
138
|
+
}
|
|
139
|
+
type SessionFunction = typeof sessionStorage | typeof sessionWindow;
|
|
140
|
+
type SessionCallback = (session: Collector$1.SessionData, collector: Collector$1.Instance | undefined, defaultCb: SessionCallback) => void;
|
|
141
|
+
declare function sessionStart(config?: SessionConfig): Collector$1.SessionData | void;
|
|
142
|
+
|
|
143
|
+
interface SessionStorageConfig extends SessionWindowConfig {
|
|
144
|
+
deviceKey?: string;
|
|
145
|
+
deviceStorage?: StorageType;
|
|
146
|
+
deviceAge?: number;
|
|
147
|
+
sessionKey?: string;
|
|
148
|
+
sessionStorage?: StorageType;
|
|
149
|
+
length?: number;
|
|
150
|
+
pulse?: boolean;
|
|
151
|
+
}
|
|
152
|
+
declare function sessionStorage(config?: SessionStorageConfig): Collector$1.SessionData;
|
|
153
|
+
|
|
154
|
+
interface SessionWindowConfig {
|
|
155
|
+
data?: WalkerOS.Properties;
|
|
156
|
+
domains?: string[];
|
|
157
|
+
isStart?: boolean;
|
|
158
|
+
parameters?: MarketingParameters;
|
|
159
|
+
referrer?: string;
|
|
160
|
+
url?: string;
|
|
161
|
+
}
|
|
162
|
+
declare function sessionWindow(config?: SessionWindowConfig): Collector$1.SessionData;
|
|
163
|
+
|
|
164
|
+
interface StorageValue {
|
|
165
|
+
e: number;
|
|
166
|
+
v: string;
|
|
167
|
+
}
|
|
168
|
+
declare function storageDelete(key: string, storage?: StorageType): void;
|
|
169
|
+
declare function storageRead(key: string, storage?: StorageType): WalkerOS.PropertyType;
|
|
170
|
+
declare function storageWrite(key: string, value: WalkerOS.PropertyType, maxAgeInMinutes?: number, storage?: StorageType, domain?: string): WalkerOS.PropertyType;
|
|
171
|
+
|
|
172
|
+
type TypesGeneric = Source$1.TypesGeneric;
|
|
173
|
+
interface Source<T extends TypesGeneric = Source$1.Types> extends Source$1.Instance<T> {
|
|
174
|
+
settings?: Source$1.Settings<T>;
|
|
175
|
+
mapping?: Source$1.Mapping<T>;
|
|
176
|
+
}
|
|
177
|
+
type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;
|
|
178
|
+
type Config$1<T extends TypesGeneric = Source$1.Types> = Source$1.Instance<T> & {
|
|
179
|
+
settings: Source$1.Settings<T>;
|
|
180
|
+
mapping?: Source$1.Mapping<T>;
|
|
181
|
+
};
|
|
182
|
+
type PartialConfig<T extends TypesGeneric = Source$1.Types> = Partial<Config$1<T>>;
|
|
183
|
+
type InitFn<T extends TypesGeneric = Source$1.Types> = (collector: Collector$1.Instance, config: Config$1<T>) => void | Promise<void>;
|
|
184
|
+
|
|
185
|
+
type source_Init = Init;
|
|
186
|
+
type source_InitFn<T extends TypesGeneric = Source$1.Types> = InitFn<T>;
|
|
187
|
+
type source_PartialConfig<T extends TypesGeneric = Source$1.Types> = PartialConfig<T>;
|
|
188
|
+
type source_Source<T extends TypesGeneric = Source$1.Types> = Source<T>;
|
|
189
|
+
type source_TypesGeneric = TypesGeneric;
|
|
190
|
+
declare namespace source {
|
|
191
|
+
export type { Config$1 as Config, source_Init as Init, source_InitFn as InitFn, source_PartialConfig as PartialConfig, source_Source as Source, source_TypesGeneric as TypesGeneric };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type PushResult = Elb.PushResult;
|
|
195
|
+
type Layer = Elb.Layer;
|
|
196
|
+
|
|
197
|
+
type elb_Layer = Layer;
|
|
198
|
+
type elb_PushResult = PushResult;
|
|
199
|
+
declare namespace elb {
|
|
200
|
+
export type { elb_Layer as Layer, elb_PushResult as PushResult };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
type Events = Event[];
|
|
204
|
+
interface Event {
|
|
205
|
+
entity: string;
|
|
206
|
+
action: string;
|
|
207
|
+
data?: WalkerOS.Properties;
|
|
208
|
+
context?: WalkerOS.OrderedProperties;
|
|
209
|
+
trigger?: Trigger;
|
|
210
|
+
nested: WalkerOS.Entities;
|
|
211
|
+
}
|
|
212
|
+
type KeyVal = [string, string];
|
|
213
|
+
type Attributes = Array<string>;
|
|
214
|
+
type Trigger = 'click' | 'custom' | 'hover' | 'load' | 'pulse' | 'scroll' | 'submit' | 'visible' | 'visibles' | 'wait' | string;
|
|
215
|
+
interface Filter {
|
|
216
|
+
[name: string]: boolean;
|
|
217
|
+
}
|
|
218
|
+
interface TriggersActionGroups {
|
|
219
|
+
[trigger: string]: TriggerActions;
|
|
220
|
+
}
|
|
221
|
+
type TriggerActions = Array<TriggerAction>;
|
|
222
|
+
interface TriggerAction {
|
|
223
|
+
trigger: string;
|
|
224
|
+
triggerParams?: string;
|
|
225
|
+
action: string;
|
|
226
|
+
actionParams?: string;
|
|
227
|
+
}
|
|
228
|
+
type ScrollElements = Array<[HTMLElement, number]>;
|
|
229
|
+
|
|
230
|
+
type walker_Attributes = Attributes;
|
|
231
|
+
type walker_Event = Event;
|
|
232
|
+
type walker_Events = Events;
|
|
233
|
+
type walker_Filter = Filter;
|
|
234
|
+
type walker_KeyVal = KeyVal;
|
|
235
|
+
type walker_ScrollElements = ScrollElements;
|
|
236
|
+
type walker_Trigger = Trigger;
|
|
237
|
+
type walker_TriggerActions = TriggerActions;
|
|
238
|
+
type walker_TriggersActionGroups = TriggersActionGroups;
|
|
239
|
+
declare namespace walker {
|
|
240
|
+
export type { walker_Attributes as Attributes, walker_Event as Event, walker_Events as Events, walker_Filter as Filter, walker_KeyVal as KeyVal, walker_ScrollElements as ScrollElements, walker_Trigger as Trigger, walker_TriggerActions as TriggerActions, walker_TriggersActionGroups as TriggersActionGroups };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
declare global {
|
|
244
|
+
interface Window {
|
|
245
|
+
elbwalker: Collector;
|
|
246
|
+
walkerjs: Collector;
|
|
247
|
+
elbLayer: Layer;
|
|
248
|
+
dataLayer: WalkerOS.Events | unknown | unknown[];
|
|
249
|
+
elb: Elb.Fn<Promise<Elb.PushResult>>;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
interface Collector extends Omit<Collector$1.Instance, 'config'> {
|
|
253
|
+
config: Config & Collector$1.Config;
|
|
254
|
+
destinations: Destinations;
|
|
255
|
+
push: Elb.Fn<Promise<Elb.PushResult>>;
|
|
256
|
+
getAllEvents: (scope: Element, prefix: string) => Events;
|
|
257
|
+
getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;
|
|
258
|
+
getGlobals: () => WalkerOS.Properties;
|
|
259
|
+
sessionStart: (options?: SessionStartOptions) => void | Collector$1.SessionData;
|
|
260
|
+
_visibilityState?: {
|
|
261
|
+
observer: IntersectionObserver | undefined;
|
|
262
|
+
timers: WeakMap<HTMLElement, number>;
|
|
263
|
+
duration: number;
|
|
264
|
+
elementConfigs?: WeakMap<HTMLElement, {
|
|
265
|
+
multiple: boolean;
|
|
266
|
+
blocked: boolean;
|
|
267
|
+
}>;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
interface State {
|
|
271
|
+
config: Config;
|
|
272
|
+
destinations: Destinations;
|
|
273
|
+
}
|
|
274
|
+
interface Config {
|
|
275
|
+
dataLayer: boolean;
|
|
276
|
+
dataLayerConfig: Config$2;
|
|
277
|
+
elbLayer: Layer;
|
|
278
|
+
listeners: boolean;
|
|
279
|
+
pageview: boolean;
|
|
280
|
+
prefix: string;
|
|
281
|
+
run: boolean;
|
|
282
|
+
scope: Scope;
|
|
283
|
+
session: false | SessionConfig;
|
|
284
|
+
elb?: string;
|
|
285
|
+
name?: string;
|
|
286
|
+
}
|
|
287
|
+
interface InitConfig extends Partial<Config> {
|
|
288
|
+
consent?: WalkerOS.Consent;
|
|
289
|
+
custom?: WalkerOS.Properties;
|
|
290
|
+
destinations?: Destination$1.InitDestinations;
|
|
291
|
+
hooks?: Hooks.Functions;
|
|
292
|
+
on?: On.OnConfig;
|
|
293
|
+
tagging?: number;
|
|
294
|
+
user?: WalkerOS.User;
|
|
295
|
+
}
|
|
296
|
+
interface SessionStartOptions {
|
|
297
|
+
config?: SessionConfig;
|
|
298
|
+
data?: Partial<Collector$1.SessionData>;
|
|
299
|
+
}
|
|
300
|
+
interface Destinations {
|
|
301
|
+
[name: string]: Destination;
|
|
302
|
+
}
|
|
303
|
+
type Scope = Element | Document;
|
|
304
|
+
|
|
305
|
+
type collector_Collector = Collector;
|
|
306
|
+
type collector_Config = Config;
|
|
307
|
+
type collector_Destinations = Destinations;
|
|
308
|
+
type collector_InitConfig = InitConfig;
|
|
309
|
+
type collector_Scope = Scope;
|
|
310
|
+
type collector_SessionStartOptions = SessionStartOptions;
|
|
311
|
+
type collector_State = State;
|
|
312
|
+
declare namespace collector {
|
|
313
|
+
export type { collector_Collector as Collector, collector_Config as Config, collector_Destinations as Destinations, collector_InitConfig as InitConfig, collector_Scope as Scope, collector_SessionStartOptions as SessionStartOptions, collector_State as State };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { destination as DestinationWeb, elb as Elb, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, type SessionCallback, type SessionConfig, type SessionFunction, type SessionStorageConfig, type SessionWindowConfig, source as SourceWeb, type StorageValue, walker as Walker, collector as WebCollector, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, sessionStart, sessionStorage, sessionWindow, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Elb, Destination as Destination$1, SendHeaders, SendResponse, SendDataValue, Collector as Collector$1, StorageType, WalkerOS, MarketingParameters, Source as Source$1, Hooks, On } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get attribute value from element
|
|
5
|
+
* @param element - DOM element
|
|
6
|
+
* @param name - Attribute name
|
|
7
|
+
* @returns Trimmed attribute value or empty string
|
|
8
|
+
*/
|
|
9
|
+
declare function getAttribute(element: Element, name: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Split attribute string by separator (semicolon by default)
|
|
12
|
+
* Handles quoted values containing the separator
|
|
13
|
+
* @param str - String to split
|
|
14
|
+
* @param separator - Separator character (default: ';')
|
|
15
|
+
* @returns Array of attribute strings
|
|
16
|
+
*/
|
|
17
|
+
declare function splitAttribute(str: string, separator?: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Split key-value pair by first colon
|
|
20
|
+
* @param str - String in format "key:value"
|
|
21
|
+
* @returns Tuple of [key, value]
|
|
22
|
+
*/
|
|
23
|
+
declare function splitKeyVal(str: string): [string, string];
|
|
24
|
+
/**
|
|
25
|
+
* Parse inline configuration string into object
|
|
26
|
+
* Supports type conversion for boolean and numeric values
|
|
27
|
+
* @param str - Configuration string (e.g., "elb:track;run:false;port:3000")
|
|
28
|
+
* @returns Parsed configuration object
|
|
29
|
+
*/
|
|
30
|
+
declare function parseInlineConfig(str: string): Record<string, unknown>;
|
|
31
|
+
|
|
32
|
+
declare function getLanguage(navigatorRef: Navigator): string | undefined;
|
|
33
|
+
declare function getTimezone(): string | undefined;
|
|
34
|
+
declare function getScreenSize(windowRef: Window): string;
|
|
35
|
+
|
|
36
|
+
declare const elb$1: Elb.Fn<void>;
|
|
37
|
+
|
|
38
|
+
type TypesGeneric$1 = Destination$1.TypesGeneric;
|
|
39
|
+
interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
|
|
40
|
+
}
|
|
41
|
+
type Init$1 = Destination$1.Init;
|
|
42
|
+
type Config$2<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.Config<T>;
|
|
43
|
+
type PartialConfig$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PartialConfig<T>;
|
|
44
|
+
type InitFn$1<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.InitFn<T>;
|
|
45
|
+
type PushFn<T extends TypesGeneric$1 = Destination$1.Types> = Destination$1.PushFn<T>;
|
|
46
|
+
type PushEvent<Mapping = unknown> = Destination$1.PushEvent<Mapping>;
|
|
47
|
+
type PushEvents<Mapping = unknown> = Destination$1.PushEvents<Mapping>;
|
|
48
|
+
/**
|
|
49
|
+
* Web-specific environment requirements interface
|
|
50
|
+
*
|
|
51
|
+
* Extends the core Env interface with web-specific
|
|
52
|
+
* globals like window and document for browser destinations.
|
|
53
|
+
*/
|
|
54
|
+
interface Env extends Destination$1.BaseEnv {
|
|
55
|
+
/**
|
|
56
|
+
* Properties to be added to the global `window` object
|
|
57
|
+
*
|
|
58
|
+
* Used by web destinations that expect browser-specific
|
|
59
|
+
* global functions like analytics APIs.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* window: {
|
|
64
|
+
* gtag: () => {},
|
|
65
|
+
* fbq: () => {},
|
|
66
|
+
* dataLayer: []
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
window?: Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Properties to be added to the global `document` object
|
|
73
|
+
*
|
|
74
|
+
* Used by destinations that need DOM manipulation capabilities
|
|
75
|
+
* for script loading or element creation.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* document: {
|
|
80
|
+
* createElement: () => ({ src: '', async: false }),
|
|
81
|
+
* head: { appendChild: () => {} }
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
document?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type destination_Destination<T extends TypesGeneric$1 = Destination$1.Types> = Destination<T>;
|
|
89
|
+
type destination_Env = Env;
|
|
90
|
+
type destination_PushEvent<Mapping = unknown> = PushEvent<Mapping>;
|
|
91
|
+
type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
92
|
+
type destination_PushFn<T extends TypesGeneric$1 = Destination$1.Types> = PushFn<T>;
|
|
93
|
+
declare namespace destination {
|
|
94
|
+
export type { Config$2 as Config, destination_Destination as Destination, destination_Env as Env, Init$1 as Init, InitFn$1 as InitFn, PartialConfig$1 as PartialConfig, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, TypesGeneric$1 as TypesGeneric };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to get environment globals with fallbacks
|
|
99
|
+
*
|
|
100
|
+
* Returns window and document by default, with optional environment overrides.
|
|
101
|
+
*
|
|
102
|
+
* @param env - Optional environment overrides
|
|
103
|
+
* @returns Env with window/document defaults and any provided overrides
|
|
104
|
+
*/
|
|
105
|
+
declare function getEnv(env?: Env): {
|
|
106
|
+
window: Record<string, unknown> | (Window & typeof globalThis);
|
|
107
|
+
document: Record<string, unknown> | Document;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
declare function getHashWeb(str: string, length?: number): Promise<string>;
|
|
111
|
+
|
|
112
|
+
declare function isVisible(element: HTMLElement): boolean;
|
|
113
|
+
|
|
114
|
+
type SendWebTransport = 'fetch' | 'beacon' | 'xhr';
|
|
115
|
+
interface SendWebOptions {
|
|
116
|
+
headers?: SendHeaders;
|
|
117
|
+
transport?: SendWebTransport;
|
|
118
|
+
method?: string;
|
|
119
|
+
}
|
|
120
|
+
interface SendWebOptionsFetch extends SendWebOptions {
|
|
121
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
122
|
+
noCors?: boolean;
|
|
123
|
+
}
|
|
124
|
+
type SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch' ? SendWebOptionsFetch : SendWebOptions;
|
|
125
|
+
type SendWebReturn<T extends SendWebTransport> = T extends 'fetch' ? Promise<SendResponse> : SendResponse;
|
|
126
|
+
declare function sendWeb<T extends SendWebTransport>(url: string, data?: SendDataValue, options?: SendWebOptionsDynamic<T> & {
|
|
127
|
+
transport?: T;
|
|
128
|
+
}): SendWebReturn<T>;
|
|
129
|
+
declare function sendWebAsFetch(url: string, data?: SendDataValue, options?: SendWebOptionsFetch): Promise<SendResponse>;
|
|
130
|
+
declare function sendWebAsBeacon(url: string, data?: SendDataValue): SendResponse;
|
|
131
|
+
declare function sendWebAsXhr(url: string, data?: SendDataValue, options?: SendWebOptions): SendResponse;
|
|
132
|
+
|
|
133
|
+
interface SessionConfig extends SessionStorageConfig {
|
|
134
|
+
consent?: string | string[];
|
|
135
|
+
storage?: boolean;
|
|
136
|
+
cb?: SessionCallback | false;
|
|
137
|
+
collector?: Collector$1.Instance;
|
|
138
|
+
}
|
|
139
|
+
type SessionFunction = typeof sessionStorage | typeof sessionWindow;
|
|
140
|
+
type SessionCallback = (session: Collector$1.SessionData, collector: Collector$1.Instance | undefined, defaultCb: SessionCallback) => void;
|
|
141
|
+
declare function sessionStart(config?: SessionConfig): Collector$1.SessionData | void;
|
|
142
|
+
|
|
143
|
+
interface SessionStorageConfig extends SessionWindowConfig {
|
|
144
|
+
deviceKey?: string;
|
|
145
|
+
deviceStorage?: StorageType;
|
|
146
|
+
deviceAge?: number;
|
|
147
|
+
sessionKey?: string;
|
|
148
|
+
sessionStorage?: StorageType;
|
|
149
|
+
length?: number;
|
|
150
|
+
pulse?: boolean;
|
|
151
|
+
}
|
|
152
|
+
declare function sessionStorage(config?: SessionStorageConfig): Collector$1.SessionData;
|
|
153
|
+
|
|
154
|
+
interface SessionWindowConfig {
|
|
155
|
+
data?: WalkerOS.Properties;
|
|
156
|
+
domains?: string[];
|
|
157
|
+
isStart?: boolean;
|
|
158
|
+
parameters?: MarketingParameters;
|
|
159
|
+
referrer?: string;
|
|
160
|
+
url?: string;
|
|
161
|
+
}
|
|
162
|
+
declare function sessionWindow(config?: SessionWindowConfig): Collector$1.SessionData;
|
|
163
|
+
|
|
164
|
+
interface StorageValue {
|
|
165
|
+
e: number;
|
|
166
|
+
v: string;
|
|
167
|
+
}
|
|
168
|
+
declare function storageDelete(key: string, storage?: StorageType): void;
|
|
169
|
+
declare function storageRead(key: string, storage?: StorageType): WalkerOS.PropertyType;
|
|
170
|
+
declare function storageWrite(key: string, value: WalkerOS.PropertyType, maxAgeInMinutes?: number, storage?: StorageType, domain?: string): WalkerOS.PropertyType;
|
|
171
|
+
|
|
172
|
+
type TypesGeneric = Source$1.TypesGeneric;
|
|
173
|
+
interface Source<T extends TypesGeneric = Source$1.Types> extends Source$1.Instance<T> {
|
|
174
|
+
settings?: Source$1.Settings<T>;
|
|
175
|
+
mapping?: Source$1.Mapping<T>;
|
|
176
|
+
}
|
|
177
|
+
type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;
|
|
178
|
+
type Config$1<T extends TypesGeneric = Source$1.Types> = Source$1.Instance<T> & {
|
|
179
|
+
settings: Source$1.Settings<T>;
|
|
180
|
+
mapping?: Source$1.Mapping<T>;
|
|
181
|
+
};
|
|
182
|
+
type PartialConfig<T extends TypesGeneric = Source$1.Types> = Partial<Config$1<T>>;
|
|
183
|
+
type InitFn<T extends TypesGeneric = Source$1.Types> = (collector: Collector$1.Instance, config: Config$1<T>) => void | Promise<void>;
|
|
184
|
+
|
|
185
|
+
type source_Init = Init;
|
|
186
|
+
type source_InitFn<T extends TypesGeneric = Source$1.Types> = InitFn<T>;
|
|
187
|
+
type source_PartialConfig<T extends TypesGeneric = Source$1.Types> = PartialConfig<T>;
|
|
188
|
+
type source_Source<T extends TypesGeneric = Source$1.Types> = Source<T>;
|
|
189
|
+
type source_TypesGeneric = TypesGeneric;
|
|
190
|
+
declare namespace source {
|
|
191
|
+
export type { Config$1 as Config, source_Init as Init, source_InitFn as InitFn, source_PartialConfig as PartialConfig, source_Source as Source, source_TypesGeneric as TypesGeneric };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type PushResult = Elb.PushResult;
|
|
195
|
+
type Layer = Elb.Layer;
|
|
196
|
+
|
|
197
|
+
type elb_Layer = Layer;
|
|
198
|
+
type elb_PushResult = PushResult;
|
|
199
|
+
declare namespace elb {
|
|
200
|
+
export type { elb_Layer as Layer, elb_PushResult as PushResult };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
type Events = Event[];
|
|
204
|
+
interface Event {
|
|
205
|
+
entity: string;
|
|
206
|
+
action: string;
|
|
207
|
+
data?: WalkerOS.Properties;
|
|
208
|
+
context?: WalkerOS.OrderedProperties;
|
|
209
|
+
trigger?: Trigger;
|
|
210
|
+
nested: WalkerOS.Entities;
|
|
211
|
+
}
|
|
212
|
+
type KeyVal = [string, string];
|
|
213
|
+
type Attributes = Array<string>;
|
|
214
|
+
type Trigger = 'click' | 'custom' | 'hover' | 'load' | 'pulse' | 'scroll' | 'submit' | 'visible' | 'visibles' | 'wait' | string;
|
|
215
|
+
interface Filter {
|
|
216
|
+
[name: string]: boolean;
|
|
217
|
+
}
|
|
218
|
+
interface TriggersActionGroups {
|
|
219
|
+
[trigger: string]: TriggerActions;
|
|
220
|
+
}
|
|
221
|
+
type TriggerActions = Array<TriggerAction>;
|
|
222
|
+
interface TriggerAction {
|
|
223
|
+
trigger: string;
|
|
224
|
+
triggerParams?: string;
|
|
225
|
+
action: string;
|
|
226
|
+
actionParams?: string;
|
|
227
|
+
}
|
|
228
|
+
type ScrollElements = Array<[HTMLElement, number]>;
|
|
229
|
+
|
|
230
|
+
type walker_Attributes = Attributes;
|
|
231
|
+
type walker_Event = Event;
|
|
232
|
+
type walker_Events = Events;
|
|
233
|
+
type walker_Filter = Filter;
|
|
234
|
+
type walker_KeyVal = KeyVal;
|
|
235
|
+
type walker_ScrollElements = ScrollElements;
|
|
236
|
+
type walker_Trigger = Trigger;
|
|
237
|
+
type walker_TriggerActions = TriggerActions;
|
|
238
|
+
type walker_TriggersActionGroups = TriggersActionGroups;
|
|
239
|
+
declare namespace walker {
|
|
240
|
+
export type { walker_Attributes as Attributes, walker_Event as Event, walker_Events as Events, walker_Filter as Filter, walker_KeyVal as KeyVal, walker_ScrollElements as ScrollElements, walker_Trigger as Trigger, walker_TriggerActions as TriggerActions, walker_TriggersActionGroups as TriggersActionGroups };
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
declare global {
|
|
244
|
+
interface Window {
|
|
245
|
+
elbwalker: Collector;
|
|
246
|
+
walkerjs: Collector;
|
|
247
|
+
elbLayer: Layer;
|
|
248
|
+
dataLayer: WalkerOS.Events | unknown | unknown[];
|
|
249
|
+
elb: Elb.Fn<Promise<Elb.PushResult>>;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
interface Collector extends Omit<Collector$1.Instance, 'config'> {
|
|
253
|
+
config: Config & Collector$1.Config;
|
|
254
|
+
destinations: Destinations;
|
|
255
|
+
push: Elb.Fn<Promise<Elb.PushResult>>;
|
|
256
|
+
getAllEvents: (scope: Element, prefix: string) => Events;
|
|
257
|
+
getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;
|
|
258
|
+
getGlobals: () => WalkerOS.Properties;
|
|
259
|
+
sessionStart: (options?: SessionStartOptions) => void | Collector$1.SessionData;
|
|
260
|
+
_visibilityState?: {
|
|
261
|
+
observer: IntersectionObserver | undefined;
|
|
262
|
+
timers: WeakMap<HTMLElement, number>;
|
|
263
|
+
duration: number;
|
|
264
|
+
elementConfigs?: WeakMap<HTMLElement, {
|
|
265
|
+
multiple: boolean;
|
|
266
|
+
blocked: boolean;
|
|
267
|
+
}>;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
interface State {
|
|
271
|
+
config: Config;
|
|
272
|
+
destinations: Destinations;
|
|
273
|
+
}
|
|
274
|
+
interface Config {
|
|
275
|
+
dataLayer: boolean;
|
|
276
|
+
dataLayerConfig: Config$2;
|
|
277
|
+
elbLayer: Layer;
|
|
278
|
+
listeners: boolean;
|
|
279
|
+
pageview: boolean;
|
|
280
|
+
prefix: string;
|
|
281
|
+
run: boolean;
|
|
282
|
+
scope: Scope;
|
|
283
|
+
session: false | SessionConfig;
|
|
284
|
+
elb?: string;
|
|
285
|
+
name?: string;
|
|
286
|
+
}
|
|
287
|
+
interface InitConfig extends Partial<Config> {
|
|
288
|
+
consent?: WalkerOS.Consent;
|
|
289
|
+
custom?: WalkerOS.Properties;
|
|
290
|
+
destinations?: Destination$1.InitDestinations;
|
|
291
|
+
hooks?: Hooks.Functions;
|
|
292
|
+
on?: On.OnConfig;
|
|
293
|
+
tagging?: number;
|
|
294
|
+
user?: WalkerOS.User;
|
|
295
|
+
}
|
|
296
|
+
interface SessionStartOptions {
|
|
297
|
+
config?: SessionConfig;
|
|
298
|
+
data?: Partial<Collector$1.SessionData>;
|
|
299
|
+
}
|
|
300
|
+
interface Destinations {
|
|
301
|
+
[name: string]: Destination;
|
|
302
|
+
}
|
|
303
|
+
type Scope = Element | Document;
|
|
304
|
+
|
|
305
|
+
type collector_Collector = Collector;
|
|
306
|
+
type collector_Config = Config;
|
|
307
|
+
type collector_Destinations = Destinations;
|
|
308
|
+
type collector_InitConfig = InitConfig;
|
|
309
|
+
type collector_Scope = Scope;
|
|
310
|
+
type collector_SessionStartOptions = SessionStartOptions;
|
|
311
|
+
type collector_State = State;
|
|
312
|
+
declare namespace collector {
|
|
313
|
+
export type { collector_Collector as Collector, collector_Config as Config, collector_Destinations as Destinations, collector_InitConfig as InitConfig, collector_Scope as Scope, collector_SessionStartOptions as SessionStartOptions, collector_State as State };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { destination as DestinationWeb, elb as Elb, type SendWebOptions, type SendWebOptionsFetch, type SendWebReturn, type SendWebTransport, type SessionCallback, type SessionConfig, type SessionFunction, type SessionStorageConfig, type SessionWindowConfig, source as SourceWeb, type StorageValue, walker as Walker, collector as WebCollector, elb$1 as elb, getAttribute, getEnv, getHashWeb, getLanguage, getScreenSize, getTimezone, isVisible, parseInlineConfig, sendWeb, sendWebAsBeacon, sendWebAsFetch, sendWebAsXhr, sessionStart, sessionStorage, sessionWindow, splitAttribute, splitKeyVal, storageDelete, storageRead, storageWrite };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(s,{DestinationWeb:()=>N,Elb:()=>q,SourceWeb:()=>$,Walker:()=>R,WebCollector:()=>P,elb:()=>m,getAttribute:()=>a,getEnv:()=>w,getHashWeb:()=>h,getLanguage:()=>l,getScreenSize:()=>f,getTimezone:()=>g,isVisible:()=>S,parseInlineConfig:()=>d,sendWeb:()=>b,sendWebAsBeacon:()=>k,sendWebAsFetch:()=>v,sendWebAsXhr:()=>C,sessionStart:()=>x,sessionStorage:()=>T,sessionWindow:()=>L,splitAttribute:()=>c,splitKeyVal:()=>u,storageDelete:()=>A,storageRead:()=>j,storageWrite:()=>H}),module.exports=(e=s,((e,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of r(s))o.call(e,c)||c===i||t(e,c,{get:()=>s[c],enumerable:!(a=n(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=require("@walkeros/core");function a(e,t){return(e.getAttribute(t)||"").trim()}function c(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function u(e){const[t,n]=e.split(/:(.+)/,2);return[(0,i.trim)(t||""),(0,i.trim)(n||"")]}function d(e){const t={};return c(e).forEach(e=>{const[n,r]=u(e);n&&("true"===r?t[n]=!0:"false"===r?t[n]=!1:r&&/^\d+$/.test(r)?t[n]=parseInt(r,10):r&&/^\d+\.\d+$/.test(r)?t[n]=parseFloat(r):t[n]=r||!0)}),t}function l(e){return e.language}function g(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function f(e){return`${e.screen.width}x${e.screen.height}`}var m=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function w(e){return{window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e}}var p=require("@walkeros/core");async function h(e,t){return(await async function(e){const t=(0,p.isDefined)(window)&&window.crypto?window.crypto:void 0;if(!t||!t.subtle||!TextEncoder)return;const n=(new TextEncoder).encode(e),r=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)||"").slice(0,t)}function S(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const r=window.innerHeight,o=e.getBoundingClientRect(),s=o.height,i=o.y,a=i+s,c={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(s<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=r/2;if(i<0&&a<e)return!1;if(a>r&&i>e)return!1;n=document.elementFromPoint(c.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}var y=require("@walkeros/core");function b(e,t,n={transport:"fetch"}){switch(n.transport||"fetch"){case"beacon":return k(e,t);case"xhr":return C(e,t,n);default:return v(e,t,n)}}async function v(e,t,n={}){const r=(0,y.getHeaders)(n.headers),o=(0,y.transformData)(t);return(0,y.tryCatchAsync)(async()=>{const t=await fetch(e,{method:n.method||"POST",headers:r,keepalive:!0,credentials:n.credentials||"same-origin",mode:n.noCors?"no-cors":"cors",body:o}),s=n.noCors?"":await t.text();return{ok:t.ok,data:s,error:t.ok?void 0:t.statusText}},e=>({ok:!1,error:e.message}))()}function k(e,t){const n=(0,y.transformData)(t),r=navigator.sendBeacon(e,n);return{ok:r,error:r?void 0:"Failed to send beacon"}}function C(e,t,n={}){const r=(0,y.getHeaders)(n.headers),o=n.method||"POST",s=(0,y.transformData)(t);return(0,y.tryCatch)(()=>{const t=new XMLHttpRequest;t.open(o,e,!1);for(const e in r)t.setRequestHeader(e,r[e]);t.send(s);const n=t.status>=200&&t.status<300;return{ok:n,data:(0,y.tryCatch)(JSON.parse,()=>t.response)(t.response),error:n?void 0:`${t.status} ${t.statusText}`}},e=>({ok:!1,error:e.message}))()}var O=require("@walkeros/core");function x(e={}){const{cb:t,consent:n,collector:r,storage:o}=e;if(!n)return U((o?T:L)(e),r,t);{const o=function(e,t){let n;const r=(r,o)=>{if((0,O.isDefined)(n)&&n===r?.group)return;n=r?.group;let s=()=>L(e);if(e.consent){const t=((0,O.isArray)(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{});(0,O.getGrantedConsent)(t,o)&&(s=()=>T(e))}return U(s(),r,t)};return r}(e,t),s=((0,O.isArray)(n)?n:[n]).reduce((e,t)=>({...e,[t]:o}),{});r?r.command("on","consent",s):m("walker on","consent",s)}}function U(e,t,n){return!1===n?e:(n||(n=I),n(e,t,I))}var I=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):m("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):m({name:"session start",data:e})),e},W=require("@walkeros/core"),D=require("@walkeros/core");function A(e,t=D.Const.Utils.Storage.Session){switch(t){case D.Const.Utils.Storage.Cookie:H(e,"",0,t);break;case D.Const.Utils.Storage.Local:window.localStorage.removeItem(e);break;case D.Const.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}function j(e,t=D.Const.Utils.Storage.Session){function n(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let r,o;switch(t){case D.Const.Utils.Storage.Cookie:r=decodeURIComponent(document.cookie.split("; ").find(t=>t.startsWith(e+"="))?.split("=")[1]||"");break;case D.Const.Utils.Storage.Local:o=n(window.localStorage.getItem(e));break;case D.Const.Utils.Storage.Session:o=n(window.sessionStorage.getItem(e))}return o&&(r=o.v,0!=o.e&&o.e<Date.now()&&(A(e,t),r="")),(0,D.castValue)(r||"")}function H(e,t,n=30,r=D.Const.Utils.Storage.Session,o){const s={e:Date.now()+6e4*n,v:String(t)},i=JSON.stringify(s);switch(r){case D.Const.Utils.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case D.Const.Utils.Storage.Local:window.localStorage.setItem(e,i);break;case D.Const.Utils.Storage.Session:window.sessionStorage.setItem(e,i)}return j(e,r)}function T(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:s=30,sessionKey:i="elbSessionId",sessionStorage:a="local",pulse:c=!1}=e,u=L(e);let d=!1;const l=(0,W.tryCatch)((e,t,n)=>{let r=j(e,n);return r||(r=(0,W.getId)(8),H(e,r,1440*t,n)),String(r)})(r,s,o),g=(0,W.tryCatch)((e,r)=>{const o=JSON.parse(String(j(e,r)));return c||(o.isNew=!1,u.marketing&&(Object.assign(o,u),d=!0),d||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,d=!0):o.runs++),o},()=>{d=!0})(i,a)||{},f={id:(0,W.getId)(12),start:t,isNew:!0,count:1,runs:1},m=Object.assign(f,u,g,{device:l},{isStart:d,storage:!0,updated:t},e.data);return H(i,JSON.stringify(m),2*n,a),m}var E=require("@walkeros/core");function L(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),o=e.referrer||document.referrer,s=o&&new URL(o).hostname,i=(0,E.getMarketingParameters)(r,e.parameters);if(Object.keys(i).length&&(i.marketing||(i.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:(0,E.getId)(12),referrer:s},i,e.data):n}var N={},$={},q={},P={},R={};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/sendWeb.ts","../src/session/sessionStart.ts","../src/session/sessionStorage.ts","../src/storage.ts","../src/session/sessionWindow.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["export * from './attributes';\nexport * from './browser';\nexport * from './elb';\nexport * from './environment';\nexport * from './getHashWeb';\nexport * from './isVisible';\nexport * from './sendWeb';\nexport * from './session/';\nexport * from './storage';\n\n// Export web-specific types\nexport * from './types';\n","import { trim } from '@walkeros/core';\n\n/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n const reg = new RegExp(`(?:[^${separator}']+|'[^']*')+`, 'ig');\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by first colon\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [key, value] = str.split(/:(.+)/, 2);\n return [trim(key || ''), trim(value || '')];\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv(env?: Env) {\n return {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","export function isVisible(element: HTMLElement): boolean {\n // Check for hiding styles\n const style = getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n if (style.opacity && Number(style.opacity) < 0.1) return false;\n\n // Window positions\n let pointContainer;\n const windowHeight = window.innerHeight; // Height of the viewport\n\n // Element positions\n const elemRectRel = element.getBoundingClientRect(); // Get the elements relative to the viewport\n const elementHeight = elemRectRel.height; // Height of the element\n const elementTopRel = elemRectRel.y; // Relative distance from window top to element top\n const elementBottomRel = elementTopRel + elementHeight; // Relative distance from window to to element bottom\n const elemCenterRel = {\n // Relative position on viewport of the elements center\n x: elemRectRel.x + element.offsetWidth / 2,\n y: elemRectRel.y + element.offsetHeight / 2,\n };\n\n // Differentiate between small and large elements\n if (elementHeight <= windowHeight) {\n // Smaller than the viewport\n\n // Must have a width and height\n if (\n element.offsetWidth + elemRectRel.width === 0 ||\n element.offsetHeight + elemRectRel.height === 0\n )\n return false;\n\n if (elemCenterRel.x < 0) return false;\n if (\n elemCenterRel.x >\n (document.documentElement.clientWidth || window.innerWidth)\n )\n return false;\n if (elemCenterRel.y < 0) return false;\n if (\n elemCenterRel.y >\n (document.documentElement.clientHeight || window.innerHeight)\n )\n return false;\n\n // Select the element that is at the center of the target\n pointContainer = document.elementFromPoint(\n elemCenterRel.x,\n elemCenterRel.y,\n );\n } else {\n // Bigger than the viewport\n\n // that are considered visible if they fill half of the screen\n const viewportCenter = windowHeight / 2;\n\n // Check if upper part is above the viewports center\n if (elementTopRel < 0 && elementBottomRel < viewportCenter) return false;\n\n // Check if lower part is below the viewports center\n if (elementBottomRel > windowHeight && elementTopRel > viewportCenter)\n return false;\n\n // Select the element that is in the middle of the screen\n pointContainer = document.elementFromPoint(\n elemCenterRel.x,\n windowHeight / 2,\n );\n }\n\n // Check for potential overlays\n if (pointContainer) {\n do {\n if (pointContainer === element) return true; // should be visible\n } while ((pointContainer = pointContainer.parentElement));\n }\n\n return false;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n transformData,\n tryCatch,\n tryCatchAsync,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n}\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n\n return tryCatchAsync(\n async () => {\n const response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive: true,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n });\n\n const responseData = options.noCors ? '' : await response.text();\n\n return {\n ok: response.ok,\n data: responseData,\n error: response.ok ? undefined : response.statusText,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n const ok = navigator.sendBeacon(url, body);\n\n return {\n ok,\n error: ok ? undefined : 'Failed to send beacon',\n };\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n return tryCatch(\n () => {\n const xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n\n const ok = xhr.status >= 200 && xhr.status < 300;\n\n const parsedData = tryCatch(JSON.parse, () => xhr.response)(xhr.response);\n\n return {\n ok,\n data: parsedData,\n error: ok ? undefined : `${xhr.status} ${xhr.statusText}`,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n","import type { Collector, WalkerOS, On } from '@walkeros/core';\nimport type { SessionStorageConfig } from './';\nimport { sessionStorage, sessionWindow } from './';\nimport { elb as elbOrg } from '../elb';\nimport { getGrantedConsent, isArray, isDefined } from '@walkeros/core';\n\nexport interface SessionConfig extends SessionStorageConfig {\n consent?: string | string[];\n storage?: boolean;\n cb?: SessionCallback | false;\n collector?: Collector.Instance;\n}\n\nexport type SessionFunction = typeof sessionStorage | typeof sessionWindow;\nexport type SessionCallback = (\n session: Collector.SessionData,\n collector: Collector.Instance | undefined,\n defaultCb: SessionCallback,\n) => void;\n\nexport function sessionStart(\n config: SessionConfig = {},\n): Collector.SessionData | void {\n const { cb, consent, collector, storage } = config;\n const sessionFn: SessionFunction = storage ? sessionStorage : sessionWindow;\n\n // Consent\n if (consent) {\n const consentHandler = onConsentFn(config, cb);\n\n const consentConfig = (\n isArray(consent) ? consent : [consent]\n ).reduce<On.ConsentConfig>(\n (acc, key) => ({ ...acc, [key]: consentHandler }),\n {},\n );\n // Register consent handlers with the collector\n if (collector) {\n collector.command('on', 'consent', consentConfig);\n } else {\n // Fallback to elbLayer\n elbOrg('walker on', 'consent', consentConfig);\n }\n } else {\n // just do it\n return callFuncAndCb(sessionFn(config), collector, cb);\n }\n}\n\nfunction callFuncAndCb(\n session: Collector.SessionData,\n collector?: Collector.Instance,\n cb?: SessionCallback | false,\n) {\n if (cb === false) return session; // Callback is disabled\n if (!cb) cb = defaultCb; // Default callback if none is provided\n return cb(session, collector, defaultCb);\n}\n\nfunction onConsentFn(config: SessionConfig, cb?: SessionCallback | false) {\n // Track the last processed group to prevent duplicate processing\n let lastProcessedGroup: string | undefined;\n\n const func = (collector: Collector.Instance, consent: WalkerOS.Consent) => {\n // Skip if we've already processed this group\n if (\n isDefined(lastProcessedGroup) &&\n lastProcessedGroup === collector?.group\n )\n return;\n\n // Remember this group has been processed\n lastProcessedGroup = collector?.group;\n\n let sessionFn: SessionFunction = () => sessionWindow(config); // Window by default\n\n if (config.consent) {\n const consentKeys = (\n isArray(config.consent) ? config.consent : [config.consent]\n ).reduce<WalkerOS.Consent>((acc, key) => ({ ...acc, [key]: true }), {});\n\n if (getGrantedConsent(consentKeys, consent))\n // Use storage if consent is granted\n sessionFn = () => sessionStorage(config);\n }\n\n return callFuncAndCb(sessionFn(), collector, cb);\n };\n\n return func;\n}\n\nconst defaultCb: SessionCallback = (\n session,\n collector,\n): Collector.SessionData => {\n const user: WalkerOS.User = {};\n\n // User.session is the session ID\n if (session.id) user.session = session.id;\n\n // Set device ID only in storage mode\n if (session.storage && session.device) user.device = session.device;\n\n // Set user IDs\n if (collector) {\n collector.command('user', user);\n } else {\n // Fallback to elbLayer\n elbOrg('walker user', user);\n }\n\n if (session.isStart) {\n // Convert session start to an event object\n if (collector) {\n collector.push({\n name: 'session start',\n data: session,\n });\n } else {\n // Fallback to elbLayer\n elbOrg({\n name: 'session start',\n data: session,\n });\n }\n }\n\n return session;\n};\n","import type { Collector, WalkerOS } from '@walkeros/core';\nimport type { SessionWindowConfig } from '.';\nimport type { StorageType } from '@walkeros/core';\nimport { getId, tryCatch } from '@walkeros/core';\nimport { storageRead, storageWrite } from '../storage';\nimport { sessionWindow } from '.';\n\nexport interface SessionStorageConfig extends SessionWindowConfig {\n deviceKey?: string;\n deviceStorage?: StorageType;\n deviceAge?: number;\n sessionKey?: string;\n sessionStorage?: StorageType;\n length?: number; // Minutes after last update to consider session as expired (default: 30)\n pulse?: boolean;\n}\n\nexport function sessionStorage(\n config: SessionStorageConfig = {},\n): Collector.SessionData {\n const now = Date.now();\n const {\n length = 30, // Session length in minutes\n deviceKey = 'elbDeviceId',\n deviceStorage = 'local',\n deviceAge = 30, // Device ID age in days\n sessionKey = 'elbSessionId',\n sessionStorage = 'local',\n pulse = false, // Handle the counting\n } = config;\n const windowSession = sessionWindow(config); // Status based on window only\n let isStart = false;\n\n // Retrieve or create device ID\n const device = tryCatch((key: string, age: number, storage: StorageType) => {\n let id = storageRead(key, storage);\n if (!id) {\n id = getId(8); // Create a new device ID\n storageWrite(key, id, age * 1440, storage); // Write device ID to storage\n }\n return String(id);\n })(deviceKey, deviceAge, deviceStorage);\n\n // Retrieve or initialize session data\n const existingSession: Collector.SessionData =\n tryCatch(\n (key: string, storage?: StorageType) => {\n const session = JSON.parse(String(storageRead(key, storage)));\n\n // Only update session if it's not a pulse check\n if (pulse) return session;\n\n // Mark session as not new by default\n session.isNew = false;\n\n // Handle new marketing entry\n if (windowSession.marketing) {\n Object.assign(session, windowSession); // Overwrite existing session with marketing data\n isStart = true; // This is a session start\n }\n\n // Check if session is still active\n if (isStart || session.updated + length * 60000 < now) {\n // Session has expired\n delete session.id; // Unset session ID\n delete session.referrer; // Unset referrer\n session.start = now; // Set new session start\n session.count++; // Increase session count\n session.runs = 1; // Reset runs\n isStart = true; // It's a new session\n } else {\n // Session is still active\n session.runs++; // Increase number of runs\n }\n\n return session;\n },\n () => {\n // No existing session or something went wrong\n isStart = true; // Start a new session\n },\n )(sessionKey, sessionStorage) || {};\n\n // Default session data\n const defaultSession: Partial<Collector.SessionData> = {\n id: getId(12),\n start: now,\n isNew: true,\n count: 1,\n runs: 1,\n };\n\n // Merge session data\n const session = Object.assign(\n defaultSession, // Default session values\n windowSession, // Basic session data based on window\n existingSession, // (Updated) existing session\n { device }, // Device ID\n { isStart, storage: true, updated: now }, // Status of the session\n config.data, // Given data has the highest priority\n );\n\n // Write (updated) session to storage\n storageWrite(sessionKey, JSON.stringify(session), length * 2, sessionStorage);\n\n return session;\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n) {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage);\n break;\n case Const.Utils.Storage.Local:\n window.localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n window.sessionStorage.removeItem(key);\n break;\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n document.cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem(window.localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem(window.sessionStorage.getItem(key));\n break;\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage); // Remove item\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n document.cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n window.localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n window.sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n\n return storageRead(key, storage);\n}\n","import type { Collector, WalkerOS } from '@walkeros/core';\nimport {\n getId,\n getMarketingParameters,\n type MarketingParameters,\n} from '@walkeros/core';\n\nexport interface SessionWindowConfig {\n data?: WalkerOS.Properties;\n domains?: string[];\n isStart?: boolean;\n parameters?: MarketingParameters;\n referrer?: string;\n url?: string;\n}\n\nexport function sessionWindow(\n config: SessionWindowConfig = {},\n): Collector.SessionData {\n let isStart = config.isStart || false;\n const known = { isStart, storage: false };\n\n // If session has explicitly started, return known\n if (config.isStart === false) return known;\n\n // Entry type\n if (!isStart) {\n // Only focus on linked or direct navigation types\n // and ignore reloads and all others\n const [perf] = performance.getEntriesByType(\n 'navigation',\n ) as PerformanceNavigationTiming[];\n if (perf.type !== 'navigate') return known;\n }\n\n const url = new URL(config.url || window.location.href);\n const ref = config.referrer || document.referrer;\n const referrer = ref && new URL(ref).hostname;\n\n // Marketing\n const marketing = getMarketingParameters(url, config.parameters);\n if (Object.keys(marketing).length) {\n // Check for marketing parameters like UTM and add existing\n if (!marketing.marketing)\n // Flag as a marketing session without overwriting\n marketing.marketing = true;\n\n isStart = true;\n }\n\n // Referrer\n if (!isStart) {\n // Small chance of multiple unintended events for same users\n // https://en.wikipedia.org/wiki/HTTP_referer#Referrer_hiding\n // Use domains: [''] to disable direct or hidden referrer\n\n const domains = config.domains || [];\n domains.push(url.hostname);\n isStart = !domains.includes(referrer);\n }\n\n return isStart\n ? // It's a session start, moin\n Object.assign(\n {\n isStart,\n storage: false,\n start: Date.now(),\n id: getId(12),\n referrer,\n },\n marketing,\n config.data,\n )\n : // No session start\n known;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n} from '@walkeros/core';\nimport type { SessionConfig } from '../session';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\nimport type { On } from '@walkeros/core';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: Collector;\n elbLayer: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n sessionStart: (\n options?: SessionStartOptions,\n ) => void | CoreCollector.SessionData;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n session: false | SessionConfig;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n tagging?: number;\n user?: WalkerOS.User;\n}\n\nexport interface SessionStartOptions {\n config?: SessionConfig;\n data?: Partial<CoreCollector.SessionData>;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\n actionParams?: string;\n}\n\nexport type ScrollElements = Array<[HTMLElement, number]>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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MAAI,CAAC,SAAS;AAKZ,UAAM,UAAU,OAAO,WAAW,CAAC;AACnC,YAAQ,KAAK,IAAI,QAAQ;AACzB,cAAU,CAAC,QAAQ,SAAS,QAAQ;AAAA,EACtC;AAEA,SAAO;AAAA;AAAA,IAEH,OAAO;AAAA,MACL;AAAA,QACE;AAAA,QACA,SAAS;AAAA,QACT,OAAO,KAAK,IAAI;AAAA,QAChB,QAAI,oBAAM,EAAE;AAAA,QACZ;AAAA,MACF;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAAA;AAAA;AAAA,IAEA;AAAA;AACN;;;AC5EA;;;ACAA;;;ACAA;;;ACAA;;;ACAA;","names":["import_core","import_core","import_core","import_core","import_core","sessionStorage","session","import_core"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{trim as e}from"@walkeros/core";function t(e,t){return(e.getAttribute(t)||"").trim()}function n(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function r(t){const[n,r]=t.split(/:(.+)/,2);return[e(n||""),e(r||"")]}function o(e){const t={};return n(e).forEach(e=>{const[n,o]=r(e);n&&("true"===o?t[n]=!0:"false"===o?t[n]=!1:o&&/^\d+$/.test(o)?t[n]=parseInt(o,10):o&&/^\d+\.\d+$/.test(o)?t[n]=parseFloat(o):t[n]=o||!0)}),t}function s(e){return e.language}function i(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function a(e){return`${e.screen.width}x${e.screen.height}`}var c=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function u(e){return{window:"undefined"!=typeof window?window:globalThis.window,document:"undefined"!=typeof document?document:globalThis.document,...e}}import{isDefined as d}from"@walkeros/core";async function l(e,t){return(await async function(e){const t=d(window)&&window.crypto?window.crypto:void 0;if(!t||!t.subtle||!TextEncoder)return;const n=(new TextEncoder).encode(e),r=await t.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("")}(e)||"").slice(0,t)}function f(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const r=window.innerHeight,o=e.getBoundingClientRect(),s=o.height,i=o.y,a=i+s,c={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(s<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(c.x<0)return!1;if(c.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(c.y<0)return!1;if(c.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(c.x,c.y)}else{const e=r/2;if(i<0&&a<e)return!1;if(a>r&&i>e)return!1;n=document.elementFromPoint(c.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}import{getHeaders as m,transformData as g,tryCatch as w,tryCatchAsync as p}from"@walkeros/core";function S(e,t,n={transport:"fetch"}){switch(n.transport||"fetch"){case"beacon":return y(e,t);case"xhr":return k(e,t,n);default:return h(e,t,n)}}async function h(e,t,n={}){const r=m(n.headers),o=g(t);return p(async()=>{const t=await fetch(e,{method:n.method||"POST",headers:r,keepalive:!0,credentials:n.credentials||"same-origin",mode:n.noCors?"no-cors":"cors",body:o}),s=n.noCors?"":await t.text();return{ok:t.ok,data:s,error:t.ok?void 0:t.statusText}},e=>({ok:!1,error:e.message}))()}function y(e,t){const n=g(t),r=navigator.sendBeacon(e,n);return{ok:r,error:r?void 0:"Failed to send beacon"}}function k(e,t,n={}){const r=m(n.headers),o=n.method||"POST",s=g(t);return w(()=>{const t=new XMLHttpRequest;t.open(o,e,!1);for(const e in r)t.setRequestHeader(e,r[e]);t.send(s);const n=t.status>=200&&t.status<300;return{ok:n,data:w(JSON.parse,()=>t.response)(t.response),error:n?void 0:`${t.status} ${t.statusText}`}},e=>({ok:!1,error:e.message}))()}import{getGrantedConsent as b,isArray as v,isDefined as x}from"@walkeros/core";function U(e={}){const{cb:t,consent:n,collector:r,storage:o}=e;if(!n)return I((o?D:j)(e),r,t);{const o=function(e,t){let n;const r=(r,o)=>{if(x(n)&&n===r?.group)return;n=r?.group;let s=()=>j(e);if(e.consent){const t=(v(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{});b(t,o)&&(s=()=>D(e))}return I(s(),r,t)};return r}(e,t),s=(v(n)?n:[n]).reduce((e,t)=>({...e,[t]:o}),{});r?r.command("on","consent",s):c("walker on","consent",s)}}function I(e,t,n){return!1===n?e:(n||(n=O),n(e,t,O))}var O=(e,t)=>{const n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),t?t.command("user",n):c("walker user",n),e.isStart&&(t?t.push({name:"session start",data:e}):c({name:"session start",data:e})),e};import{getId as C,tryCatch as T}from"@walkeros/core";import{castValue as $,Const as E}from"@walkeros/core";function L(e,t=E.Utils.Storage.Session){switch(t){case E.Utils.Storage.Cookie:W(e,"",0,t);break;case E.Utils.Storage.Local:window.localStorage.removeItem(e);break;case E.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}function N(e,t=E.Utils.Storage.Session){function n(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let r,o;switch(t){case E.Utils.Storage.Cookie:r=decodeURIComponent(document.cookie.split("; ").find(t=>t.startsWith(e+"="))?.split("=")[1]||"");break;case E.Utils.Storage.Local:o=n(window.localStorage.getItem(e));break;case E.Utils.Storage.Session:o=n(window.sessionStorage.getItem(e))}return o&&(r=o.v,0!=o.e&&o.e<Date.now()&&(L(e,t),r="")),$(r||"")}function W(e,t,n=30,r=E.Utils.Storage.Session,o){const s={e:Date.now()+6e4*n,v:String(t)},i=JSON.stringify(s);switch(r){case E.Utils.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case E.Utils.Storage.Local:window.localStorage.setItem(e,i);break;case E.Utils.Storage.Session:window.sessionStorage.setItem(e,i)}return N(e,r)}function D(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:s=30,sessionKey:i="elbSessionId",sessionStorage:a="local",pulse:c=!1}=e,u=j(e);let d=!1;const l=T((e,t,n)=>{let r=N(e,n);return r||(r=C(8),W(e,r,1440*t,n)),String(r)})(r,s,o),f=T((e,r)=>{const o=JSON.parse(String(N(e,r)));return c||(o.isNew=!1,u.marketing&&(Object.assign(o,u),d=!0),d||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,d=!0):o.runs++),o},()=>{d=!0})(i,a)||{},m={id:C(12),start:t,isNew:!0,count:1,runs:1},g=Object.assign(m,u,f,{device:l},{isStart:d,storage:!0,updated:t},e.data);return W(i,JSON.stringify(g),2*n,a),g}import{getId as H,getMarketingParameters as R}from"@walkeros/core";function j(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),o=e.referrer||document.referrer,s=o&&new URL(o).hostname,i=R(r,e.parameters);if(Object.keys(i).length&&(i.marketing||(i.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:H(12),referrer:s},i,e.data):n}var J={},A={},F={},P={},B={};export{J as DestinationWeb,F as Elb,A as SourceWeb,B as Walker,P as WebCollector,c as elb,t as getAttribute,u as getEnv,l as getHashWeb,s as getLanguage,a as getScreenSize,i as getTimezone,f as isVisible,o as parseInlineConfig,S as sendWeb,y as sendWebAsBeacon,h as sendWebAsFetch,k as sendWebAsXhr,U as sessionStart,D as sessionStorage,j as sessionWindow,n as splitAttribute,r as splitKeyVal,L as storageDelete,N as storageRead,W as storageWrite};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/attributes.ts","../src/browser.ts","../src/elb.ts","../src/environment.ts","../src/getHashWeb.ts","../src/isVisible.ts","../src/sendWeb.ts","../src/session/sessionStart.ts","../src/session/sessionStorage.ts","../src/storage.ts","../src/session/sessionWindow.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts","../src/types/collector.ts","../src/types/walker.ts"],"sourcesContent":["import { trim } from '@walkeros/core';\n\n/**\n * Get attribute value from element\n * @param element - DOM element\n * @param name - Attribute name\n * @returns Trimmed attribute value or empty string\n */\nexport function getAttribute(element: Element, name: string): string {\n return (element.getAttribute(name) || '').trim();\n}\n\n/**\n * Split attribute string by separator (semicolon by default)\n * Handles quoted values containing the separator\n * @param str - String to split\n * @param separator - Separator character (default: ';')\n * @returns Array of attribute strings\n */\nexport function splitAttribute(str: string, separator = ';'): string[] {\n if (!str) return [];\n const reg = new RegExp(`(?:[^${separator}']+|'[^']*')+`, 'ig');\n return str.match(reg) || [];\n}\n\n/**\n * Split key-value pair by first colon\n * @param str - String in format \"key:value\"\n * @returns Tuple of [key, value]\n */\nexport function splitKeyVal(str: string): [string, string] {\n const [key, value] = str.split(/:(.+)/, 2);\n return [trim(key || ''), trim(value || '')];\n}\n\n/**\n * Parse inline configuration string into object\n * Supports type conversion for boolean and numeric values\n * @param str - Configuration string (e.g., \"elb:track;run:false;port:3000\")\n * @returns Parsed configuration object\n */\nexport function parseInlineConfig(str: string): Record<string, unknown> {\n const config: Record<string, unknown> = {};\n\n splitAttribute(str).forEach((pair) => {\n const [key, value] = splitKeyVal(pair);\n if (key) {\n // Type conversion\n if (value === 'true') {\n config[key] = true;\n } else if (value === 'false') {\n config[key] = false;\n } else if (value && /^\\d+$/.test(value)) {\n config[key] = parseInt(value, 10);\n } else if (value && /^\\d+\\.\\d+$/.test(value)) {\n config[key] = parseFloat(value);\n } else if (value) {\n config[key] = value;\n } else {\n // Key without value defaults to true\n config[key] = true;\n }\n }\n });\n\n return config;\n}\n","export function getLanguage(navigatorRef: Navigator): string | undefined {\n return navigatorRef.language;\n}\n\nexport function getTimezone(): string | undefined {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport function getScreenSize(windowRef: Window): string {\n return `${windowRef.screen.width}x${windowRef.screen.height}`;\n}\n","import type { Elb } from '@walkeros/core';\n\nexport const elb: Elb.Fn<void> = function () {\n const w = window as unknown as Record<string, unknown[]>;\n (w.elbLayer = w.elbLayer || []).push(arguments);\n};\n","import type { Env } from './types/destination';\n\n/**\n * Helper function to get environment globals with fallbacks\n *\n * Returns window and document by default, with optional environment overrides.\n *\n * @param env - Optional environment overrides\n * @returns Env with window/document defaults and any provided overrides\n */\nexport function getEnv(env?: Env) {\n return {\n window: typeof window !== 'undefined' ? window : globalThis.window,\n document: typeof document !== 'undefined' ? document : globalThis.document,\n ...env,\n };\n}\n","import { isDefined } from '@walkeros/core';\n\nasync function sha256(message: string): Promise<string | undefined> {\n const crypto: Crypto | undefined =\n isDefined(window) && window.crypto ? window.crypto : undefined;\n\n // Crypto API not available\n if (!crypto || !crypto.subtle || !TextEncoder) return;\n\n const msgBuffer = new TextEncoder().encode(message);\n const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const hashHex = hashArray\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n return hashHex;\n}\n\nexport async function getHashWeb(\n str: string,\n length?: number,\n): Promise<string> {\n return ((await sha256(str)) || '').slice(0, length);\n}\n","export function isVisible(element: HTMLElement): boolean {\n // Check for hiding styles\n const style = getComputedStyle(element);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n if (style.opacity && Number(style.opacity) < 0.1) return false;\n\n // Window positions\n let pointContainer;\n const windowHeight = window.innerHeight; // Height of the viewport\n\n // Element positions\n const elemRectRel = element.getBoundingClientRect(); // Get the elements relative to the viewport\n const elementHeight = elemRectRel.height; // Height of the element\n const elementTopRel = elemRectRel.y; // Relative distance from window top to element top\n const elementBottomRel = elementTopRel + elementHeight; // Relative distance from window to to element bottom\n const elemCenterRel = {\n // Relative position on viewport of the elements center\n x: elemRectRel.x + element.offsetWidth / 2,\n y: elemRectRel.y + element.offsetHeight / 2,\n };\n\n // Differentiate between small and large elements\n if (elementHeight <= windowHeight) {\n // Smaller than the viewport\n\n // Must have a width and height\n if (\n element.offsetWidth + elemRectRel.width === 0 ||\n element.offsetHeight + elemRectRel.height === 0\n )\n return false;\n\n if (elemCenterRel.x < 0) return false;\n if (\n elemCenterRel.x >\n (document.documentElement.clientWidth || window.innerWidth)\n )\n return false;\n if (elemCenterRel.y < 0) return false;\n if (\n elemCenterRel.y >\n (document.documentElement.clientHeight || window.innerHeight)\n )\n return false;\n\n // Select the element that is at the center of the target\n pointContainer = document.elementFromPoint(\n elemCenterRel.x,\n elemCenterRel.y,\n );\n } else {\n // Bigger than the viewport\n\n // that are considered visible if they fill half of the screen\n const viewportCenter = windowHeight / 2;\n\n // Check if upper part is above the viewports center\n if (elementTopRel < 0 && elementBottomRel < viewportCenter) return false;\n\n // Check if lower part is below the viewports center\n if (elementBottomRel > windowHeight && elementTopRel > viewportCenter)\n return false;\n\n // Select the element that is in the middle of the screen\n pointContainer = document.elementFromPoint(\n elemCenterRel.x,\n windowHeight / 2,\n );\n }\n\n // Check for potential overlays\n if (pointContainer) {\n do {\n if (pointContainer === element) return true; // should be visible\n } while ((pointContainer = pointContainer.parentElement));\n }\n\n return false;\n}\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport {\n getHeaders,\n transformData,\n tryCatch,\n tryCatchAsync,\n} from '@walkeros/core';\n\nexport type SendWebTransport = 'fetch' | 'beacon' | 'xhr';\n\nexport interface SendWebOptions {\n headers?: SendHeaders;\n transport?: SendWebTransport;\n method?: string;\n}\n\nexport interface SendWebOptionsFetch extends SendWebOptions {\n credentials?: 'omit' | 'same-origin' | 'include'; // Add credentials option\n noCors?: boolean; // Add noCors option for fetch transport\n}\n\ntype SendWebOptionsDynamic<T extends SendWebTransport> = T extends 'fetch'\n ? SendWebOptionsFetch\n : SendWebOptions;\n\nexport type SendWebReturn<T extends SendWebTransport> = T extends 'fetch'\n ? Promise<SendResponse>\n : SendResponse;\n\nexport function sendWeb<T extends SendWebTransport>(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsDynamic<T> & { transport?: T } = {\n transport: 'fetch' as T,\n },\n): SendWebReturn<T> {\n const transport = options.transport || 'fetch';\n\n switch (transport) {\n case 'beacon':\n return sendWebAsBeacon(url, data) as SendWebReturn<T>;\n case 'xhr':\n return sendWebAsXhr(url, data, options) as SendWebReturn<T>;\n case 'fetch':\n default:\n return sendWebAsFetch(url, data, options) as SendWebReturn<T>;\n }\n}\n\nexport async function sendWebAsFetch(\n url: string,\n data?: SendDataValue,\n options: SendWebOptionsFetch = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n\n return tryCatchAsync(\n async () => {\n const response = await fetch(url, {\n method: options.method || 'POST',\n headers,\n keepalive: true,\n credentials: options.credentials || 'same-origin',\n mode: options.noCors ? 'no-cors' : 'cors',\n body,\n });\n\n const responseData = options.noCors ? '' : await response.text();\n\n return {\n ok: response.ok,\n data: responseData,\n error: response.ok ? undefined : response.statusText,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n\nexport function sendWebAsBeacon(\n url: string,\n data?: SendDataValue,\n): SendResponse {\n const body = transformData(data);\n const ok = navigator.sendBeacon(url, body);\n\n return {\n ok,\n error: ok ? undefined : 'Failed to send beacon',\n };\n}\n\nexport function sendWebAsXhr(\n url: string,\n data?: SendDataValue,\n options: SendWebOptions = {},\n): SendResponse {\n const headers = getHeaders(options.headers);\n const method = options.method || 'POST';\n const body = transformData(data);\n\n return tryCatch(\n () => {\n const xhr = new XMLHttpRequest();\n xhr.open(method, url, false); // Synchronous request\n for (const header in headers) {\n xhr.setRequestHeader(header, headers[header]);\n }\n xhr.send(body);\n\n const ok = xhr.status >= 200 && xhr.status < 300;\n\n const parsedData = tryCatch(JSON.parse, () => xhr.response)(xhr.response);\n\n return {\n ok,\n data: parsedData,\n error: ok ? undefined : `${xhr.status} ${xhr.statusText}`,\n };\n },\n (error) => {\n return {\n ok: false,\n error: (error as Error).message,\n };\n },\n )();\n}\n","import type { Collector, WalkerOS, On } from '@walkeros/core';\nimport type { SessionStorageConfig } from './';\nimport { sessionStorage, sessionWindow } from './';\nimport { elb as elbOrg } from '../elb';\nimport { getGrantedConsent, isArray, isDefined } from '@walkeros/core';\n\nexport interface SessionConfig extends SessionStorageConfig {\n consent?: string | string[];\n storage?: boolean;\n cb?: SessionCallback | false;\n collector?: Collector.Instance;\n}\n\nexport type SessionFunction = typeof sessionStorage | typeof sessionWindow;\nexport type SessionCallback = (\n session: Collector.SessionData,\n collector: Collector.Instance | undefined,\n defaultCb: SessionCallback,\n) => void;\n\nexport function sessionStart(\n config: SessionConfig = {},\n): Collector.SessionData | void {\n const { cb, consent, collector, storage } = config;\n const sessionFn: SessionFunction = storage ? sessionStorage : sessionWindow;\n\n // Consent\n if (consent) {\n const consentHandler = onConsentFn(config, cb);\n\n const consentConfig = (\n isArray(consent) ? consent : [consent]\n ).reduce<On.ConsentConfig>(\n (acc, key) => ({ ...acc, [key]: consentHandler }),\n {},\n );\n // Register consent handlers with the collector\n if (collector) {\n collector.command('on', 'consent', consentConfig);\n } else {\n // Fallback to elbLayer\n elbOrg('walker on', 'consent', consentConfig);\n }\n } else {\n // just do it\n return callFuncAndCb(sessionFn(config), collector, cb);\n }\n}\n\nfunction callFuncAndCb(\n session: Collector.SessionData,\n collector?: Collector.Instance,\n cb?: SessionCallback | false,\n) {\n if (cb === false) return session; // Callback is disabled\n if (!cb) cb = defaultCb; // Default callback if none is provided\n return cb(session, collector, defaultCb);\n}\n\nfunction onConsentFn(config: SessionConfig, cb?: SessionCallback | false) {\n // Track the last processed group to prevent duplicate processing\n let lastProcessedGroup: string | undefined;\n\n const func = (collector: Collector.Instance, consent: WalkerOS.Consent) => {\n // Skip if we've already processed this group\n if (\n isDefined(lastProcessedGroup) &&\n lastProcessedGroup === collector?.group\n )\n return;\n\n // Remember this group has been processed\n lastProcessedGroup = collector?.group;\n\n let sessionFn: SessionFunction = () => sessionWindow(config); // Window by default\n\n if (config.consent) {\n const consentKeys = (\n isArray(config.consent) ? config.consent : [config.consent]\n ).reduce<WalkerOS.Consent>((acc, key) => ({ ...acc, [key]: true }), {});\n\n if (getGrantedConsent(consentKeys, consent))\n // Use storage if consent is granted\n sessionFn = () => sessionStorage(config);\n }\n\n return callFuncAndCb(sessionFn(), collector, cb);\n };\n\n return func;\n}\n\nconst defaultCb: SessionCallback = (\n session,\n collector,\n): Collector.SessionData => {\n const user: WalkerOS.User = {};\n\n // User.session is the session ID\n if (session.id) user.session = session.id;\n\n // Set device ID only in storage mode\n if (session.storage && session.device) user.device = session.device;\n\n // Set user IDs\n if (collector) {\n collector.command('user', user);\n } else {\n // Fallback to elbLayer\n elbOrg('walker user', user);\n }\n\n if (session.isStart) {\n // Convert session start to an event object\n if (collector) {\n collector.push({\n name: 'session start',\n data: session,\n });\n } else {\n // Fallback to elbLayer\n elbOrg({\n name: 'session start',\n data: session,\n });\n }\n }\n\n return session;\n};\n","import type { Collector, WalkerOS } from '@walkeros/core';\nimport type { SessionWindowConfig } from '.';\nimport type { StorageType } from '@walkeros/core';\nimport { getId, tryCatch } from '@walkeros/core';\nimport { storageRead, storageWrite } from '../storage';\nimport { sessionWindow } from '.';\n\nexport interface SessionStorageConfig extends SessionWindowConfig {\n deviceKey?: string;\n deviceStorage?: StorageType;\n deviceAge?: number;\n sessionKey?: string;\n sessionStorage?: StorageType;\n length?: number; // Minutes after last update to consider session as expired (default: 30)\n pulse?: boolean;\n}\n\nexport function sessionStorage(\n config: SessionStorageConfig = {},\n): Collector.SessionData {\n const now = Date.now();\n const {\n length = 30, // Session length in minutes\n deviceKey = 'elbDeviceId',\n deviceStorage = 'local',\n deviceAge = 30, // Device ID age in days\n sessionKey = 'elbSessionId',\n sessionStorage = 'local',\n pulse = false, // Handle the counting\n } = config;\n const windowSession = sessionWindow(config); // Status based on window only\n let isStart = false;\n\n // Retrieve or create device ID\n const device = tryCatch((key: string, age: number, storage: StorageType) => {\n let id = storageRead(key, storage);\n if (!id) {\n id = getId(8); // Create a new device ID\n storageWrite(key, id, age * 1440, storage); // Write device ID to storage\n }\n return String(id);\n })(deviceKey, deviceAge, deviceStorage);\n\n // Retrieve or initialize session data\n const existingSession: Collector.SessionData =\n tryCatch(\n (key: string, storage?: StorageType) => {\n const session = JSON.parse(String(storageRead(key, storage)));\n\n // Only update session if it's not a pulse check\n if (pulse) return session;\n\n // Mark session as not new by default\n session.isNew = false;\n\n // Handle new marketing entry\n if (windowSession.marketing) {\n Object.assign(session, windowSession); // Overwrite existing session with marketing data\n isStart = true; // This is a session start\n }\n\n // Check if session is still active\n if (isStart || session.updated + length * 60000 < now) {\n // Session has expired\n delete session.id; // Unset session ID\n delete session.referrer; // Unset referrer\n session.start = now; // Set new session start\n session.count++; // Increase session count\n session.runs = 1; // Reset runs\n isStart = true; // It's a new session\n } else {\n // Session is still active\n session.runs++; // Increase number of runs\n }\n\n return session;\n },\n () => {\n // No existing session or something went wrong\n isStart = true; // Start a new session\n },\n )(sessionKey, sessionStorage) || {};\n\n // Default session data\n const defaultSession: Partial<Collector.SessionData> = {\n id: getId(12),\n start: now,\n isNew: true,\n count: 1,\n runs: 1,\n };\n\n // Merge session data\n const session = Object.assign(\n defaultSession, // Default session values\n windowSession, // Basic session data based on window\n existingSession, // (Updated) existing session\n { device }, // Device ID\n { isStart, storage: true, updated: now }, // Status of the session\n config.data, // Given data has the highest priority\n );\n\n // Write (updated) session to storage\n storageWrite(sessionKey, JSON.stringify(session), length * 2, sessionStorage);\n\n return session;\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type { StorageType } from '@walkeros/core';\nimport { castValue, Const } from '@walkeros/core';\n\nexport interface StorageValue {\n e: number; // Expiration timestamp\n v: string; // Value\n}\n\nexport function storageDelete(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n) {\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n storageWrite(key, '', 0, storage);\n break;\n case Const.Utils.Storage.Local:\n window.localStorage.removeItem(key);\n break;\n case Const.Utils.Storage.Session:\n window.sessionStorage.removeItem(key);\n break;\n }\n}\n\nexport function storageRead(\n key: string,\n storage: StorageType = Const.Utils.Storage.Session,\n): WalkerOS.PropertyType {\n // Helper function for local and session storage to support expiration\n function parseItem(string: string | null): StorageValue {\n try {\n return JSON.parse(string || '');\n } catch (err) {\n let e = 1,\n v = '';\n\n // Remove expiration date\n if (string) {\n e = 0;\n v = string;\n }\n\n return { e, v };\n }\n }\n let value, item;\n\n switch (storage) {\n case Const.Utils.Storage.Cookie:\n value = decodeURIComponent(\n document.cookie\n .split('; ')\n .find((row) => row.startsWith(key + '='))\n ?.split('=')[1] || '',\n );\n break;\n case Const.Utils.Storage.Local:\n item = parseItem(window.localStorage.getItem(key));\n break;\n case Const.Utils.Storage.Session:\n item = parseItem(window.sessionStorage.getItem(key));\n break;\n }\n\n // Check if item is expired\n if (item) {\n value = item.v;\n\n if (item.e != 0 && item.e < Date.now()) {\n storageDelete(key, storage); // Remove item\n value = ''; // Conceal the outdated value\n }\n }\n\n return castValue(value || '');\n}\n\nexport function storageWrite(\n key: string,\n value: WalkerOS.PropertyType,\n maxAgeInMinutes = 30,\n storage: StorageType = Const.Utils.Storage.Session,\n domain?: string,\n): WalkerOS.PropertyType {\n const e = Date.now() + 1000 * 60 * maxAgeInMinutes;\n const item: StorageValue = { e, v: String(value) };\n const stringifiedItem = JSON.stringify(item);\n\n switch (storage) {\n case Const.Utils.Storage.Cookie: {\n value = typeof value === 'object' ? JSON.stringify(value) : value;\n let cookie = `${key}=${encodeURIComponent(value)}; max-age=${\n maxAgeInMinutes * 60\n }; path=/; SameSite=Lax; secure`;\n\n if (domain) cookie += '; domain=' + domain;\n\n document.cookie = cookie;\n break;\n }\n case Const.Utils.Storage.Local:\n window.localStorage.setItem(key, stringifiedItem);\n break;\n case Const.Utils.Storage.Session:\n window.sessionStorage.setItem(key, stringifiedItem);\n break;\n }\n\n return storageRead(key, storage);\n}\n","import type { Collector, WalkerOS } from '@walkeros/core';\nimport {\n getId,\n getMarketingParameters,\n type MarketingParameters,\n} from '@walkeros/core';\n\nexport interface SessionWindowConfig {\n data?: WalkerOS.Properties;\n domains?: string[];\n isStart?: boolean;\n parameters?: MarketingParameters;\n referrer?: string;\n url?: string;\n}\n\nexport function sessionWindow(\n config: SessionWindowConfig = {},\n): Collector.SessionData {\n let isStart = config.isStart || false;\n const known = { isStart, storage: false };\n\n // If session has explicitly started, return known\n if (config.isStart === false) return known;\n\n // Entry type\n if (!isStart) {\n // Only focus on linked or direct navigation types\n // and ignore reloads and all others\n const [perf] = performance.getEntriesByType(\n 'navigation',\n ) as PerformanceNavigationTiming[];\n if (perf.type !== 'navigate') return known;\n }\n\n const url = new URL(config.url || window.location.href);\n const ref = config.referrer || document.referrer;\n const referrer = ref && new URL(ref).hostname;\n\n // Marketing\n const marketing = getMarketingParameters(url, config.parameters);\n if (Object.keys(marketing).length) {\n // Check for marketing parameters like UTM and add existing\n if (!marketing.marketing)\n // Flag as a marketing session without overwriting\n marketing.marketing = true;\n\n isStart = true;\n }\n\n // Referrer\n if (!isStart) {\n // Small chance of multiple unintended events for same users\n // https://en.wikipedia.org/wiki/HTTP_referer#Referrer_hiding\n // Use domains: [''] to disable direct or hidden referrer\n\n const domains = config.domains || [];\n domains.push(url.hostname);\n isStart = !domains.includes(referrer);\n }\n\n return isStart\n ? // It's a session start, moin\n Object.assign(\n {\n isStart,\n storage: false,\n start: Date.now(),\n id: getId(12),\n referrer,\n },\n marketing,\n config.data,\n )\n : // No session start\n known;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Web-specific environment requirements interface\n *\n * Extends the core Env interface with web-specific\n * globals like window and document for browser destinations.\n */\nexport interface Env extends WalkerOSDestination.BaseEnv {\n /**\n * Properties to be added to the global `window` object\n *\n * Used by web destinations that expect browser-specific\n * global functions like analytics APIs.\n *\n * @example\n * ```typescript\n * window: {\n * gtag: () => {},\n * fbq: () => {},\n * dataLayer: []\n * }\n * ```\n */\n window?: Record<string, unknown>;\n\n /**\n * Properties to be added to the global `document` object\n *\n * Used by destinations that need DOM manipulation capabilities\n * for script loading or element creation.\n *\n * @example\n * ```typescript\n * document: {\n * createElement: () => ({ src: '', async: false }),\n * head: { appendChild: () => {} }\n * }\n * ```\n */\n document?: Record<string, unknown>;\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Collector, WalkerOS, Source as CoreSource } from '@walkeros/core';\n\nexport type TypesGeneric = CoreSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = CoreSource.Types>\n extends CoreSource.Instance<T> {\n settings?: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n}\n\nexport type Init = Partial<Omit<Source, 'init'>> & Pick<Source, 'type'>;\n\nexport type Config<T extends TypesGeneric = CoreSource.Types> =\n CoreSource.Instance<T> & {\n settings: CoreSource.Settings<T>;\n mapping?: CoreSource.Mapping<T>;\n };\n\nexport type PartialConfig<T extends TypesGeneric = CoreSource.Types> = Partial<\n Config<T>\n>;\n\nexport type InitFn<T extends TypesGeneric = CoreSource.Types> = (\n collector: Collector.Instance,\n config: Config<T>,\n) => void | Promise<void>;\n","import type { Elb } from '@walkeros/core';\n\n// Simple re-exports from core\nexport type PushResult = Elb.PushResult;\nexport type Layer = Elb.Layer;\n","import type {\n Collector as CoreCollector,\n Elb,\n Hooks,\n WalkerOS,\n Destination as WalkerOSDestination,\n} from '@walkeros/core';\nimport type { SessionConfig } from '../session';\nimport type { Destination, Config as DestConfig } from './destination';\nimport type { Layer } from './elb';\nimport type { Events, Trigger } from './walker';\nimport type { On } from '@walkeros/core';\n\ndeclare global {\n interface Window {\n elbwalker: Collector;\n walkerjs: Collector;\n elbLayer: Layer;\n dataLayer: WalkerOS.Events | unknown | unknown[];\n elb: Elb.Fn<Promise<Elb.PushResult>>;\n }\n}\n\nexport interface Collector extends Omit<CoreCollector.Instance, 'config'> {\n config: Config & CoreCollector.Config;\n destinations: Destinations;\n push: Elb.Fn<Promise<Elb.PushResult>>;\n getAllEvents: (scope: Element, prefix: string) => Events;\n getEvents: (target: Element, trigger: Trigger, prefix: string) => Events;\n getGlobals: () => WalkerOS.Properties;\n sessionStart: (\n options?: SessionStartOptions,\n ) => void | CoreCollector.SessionData;\n _visibilityState?: {\n observer: IntersectionObserver | undefined;\n timers: WeakMap<HTMLElement, number>;\n duration: number;\n elementConfigs?: WeakMap<\n HTMLElement,\n { multiple: boolean; blocked: boolean }\n >;\n };\n}\n\nexport interface State {\n config: Config;\n destinations: Destinations;\n}\n\nexport interface Config {\n dataLayer: boolean;\n dataLayerConfig: DestConfig;\n elbLayer: Layer;\n listeners: boolean;\n pageview: boolean;\n prefix: string;\n run: boolean;\n scope: Scope;\n session: false | SessionConfig;\n elb?: string;\n name?: string;\n}\n\nexport interface InitConfig extends Partial<Config> {\n consent?: WalkerOS.Consent;\n custom?: WalkerOS.Properties;\n destinations?: WalkerOSDestination.InitDestinations;\n hooks?: Hooks.Functions;\n on?: On.OnConfig;\n tagging?: number;\n user?: WalkerOS.User;\n}\n\nexport interface SessionStartOptions {\n config?: SessionConfig;\n data?: Partial<CoreCollector.SessionData>;\n}\n\nexport interface Destinations {\n [name: string]: Destination;\n}\n\nexport type Scope = Element | Document;\n","import type { WalkerOS } from '@walkeros/core';\n\nexport type Events = Event[];\n\nexport interface Event {\n entity: string;\n action: string;\n data?: WalkerOS.Properties;\n context?: WalkerOS.OrderedProperties;\n trigger?: Trigger;\n nested: WalkerOS.Entities;\n}\n\nexport type KeyVal = [string, string];\n\nexport type Attributes = Array<string>;\n\nexport type Trigger =\n | 'click'\n | 'custom'\n | 'hover'\n | 'load'\n | 'pulse'\n | 'scroll'\n | 'submit'\n | 'visible'\n | 'visibles'\n | 'wait'\n | string;\n\nexport interface Filter {\n [name: string]: boolean;\n}\n\nexport interface TriggersActionGroups {\n [trigger: string]: TriggerActions;\n}\n\nexport type TriggerActions = Array<TriggerAction>;\n\ninterface TriggerAction {\n trigger: string;\n triggerParams?: string;\n action: string;\n actionParams?: string;\n}\n\nexport type ScrollElements = Array<[HTMLElement, number]>;\n"],"mappings":";AAAA,SAAS,YAAY;AAQd,SAAS,aAAa,SAAkB,MAAsB;AACnE,UAAQ,QAAQ,aAAa,IAAI,KAAK,IAAI,KAAK;AACjD;AASO,SAAS,eAAe,KAAa,YAAY,KAAe;AACrE,MAAI,CAAC,IAAK,QAAO,CAAC;AAClB,QAAM,MAAM,IAAI,OAAO,QAAQ,SAAS,iBAAiB,IAAI;AAC7D,SAAO,IAAI,MAAM,GAAG,KAAK,CAAC;AAC5B;AAOO,SAAS,YAAY,KAA+B;AACzD,QAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,SAAS,CAAC;AACzC,SAAO,CAAC,KAAK,OAAO,EAAE,GAAG,KAAK,SA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AA;;;ACAA;","names":["isDefined","tryCatch","sessionStorage","tryCatch","session","getId"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/web-core",
|
|
3
|
+
"description": "Web-specific utilities 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
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup --silent",
|
|
21
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
22
|
+
"dev": "jest --watchAll --colors",
|
|
23
|
+
"lint": "tsc && eslint \"**/*.ts*\"",
|
|
24
|
+
"test": "jest",
|
|
25
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@walkeros/core": "0.0.0-next-20251219153324"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
32
|
+
"directory": "packages/web/core"
|
|
33
|
+
},
|
|
34
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
35
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"walker",
|
|
41
|
+
"walkerOS",
|
|
42
|
+
"web",
|
|
43
|
+
"browser",
|
|
44
|
+
"utilities"
|
|
45
|
+
],
|
|
46
|
+
"funding": [
|
|
47
|
+
{
|
|
48
|
+
"type": "GitHub Sponsors",
|
|
49
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|