@compilacion/colleciones-clientos 2.0.8 → 2.0.10
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 +57 -6
- package/dist/browser.gtm.js +834 -0
- package/dist/browser.gtm.js.map +1 -0
- package/dist/browser.gtm.min.js +2 -0
- package/dist/browser.gtm.min.js.map +1 -0
- package/docs/gtm/gtm-development.md +76 -0
- package/docs/gtm/readme.md +31 -0
- package/docs/gtm.md +31 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -100,19 +100,64 @@ collecionesDsl
|
|
|
100
100
|
|
|
101
101
|
### 4. Manually Create Events (Optional)
|
|
102
102
|
|
|
103
|
-
You can also build structured events directly via the event class:
|
|
103
|
+
You can also build structured events directly via the event class. Below are examples for all main options supported by the DSL:
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
106
|
import { CollecionesEvent } from './index.js';
|
|
107
107
|
|
|
108
108
|
const event = new CollecionesEvent();
|
|
109
|
-
|
|
110
|
-
event.
|
|
111
|
-
event.
|
|
112
|
-
|
|
109
|
+
// Entity and Adjectives
|
|
110
|
+
event.setEntity('button');
|
|
111
|
+
event.addAdjective('dark');
|
|
112
|
+
event.addAdjective('green');
|
|
113
|
+
|
|
114
|
+
// Entity Identifiers
|
|
115
|
+
event.setIdentifier('id', 'button12');
|
|
116
|
+
event.setIdentifier('externalReference', 'ext-123');
|
|
117
|
+
|
|
118
|
+
// Action
|
|
119
|
+
event.setAction('clicked');
|
|
120
|
+
|
|
121
|
+
// Actor and Actor Identifiers
|
|
122
|
+
event.setActor('user');
|
|
123
|
+
event.setActorIdentifier('usrId', 'abc-123');
|
|
124
|
+
event.setActorIdentifier('email', 'jef@email.com');
|
|
125
|
+
|
|
126
|
+
// Context
|
|
127
|
+
event.setContext('sourcePage', 'homepage');
|
|
128
|
+
event.setContext('ctaLabel', 'register-now');
|
|
129
|
+
|
|
130
|
+
// Collections
|
|
131
|
+
// Property collection
|
|
132
|
+
// Add first property item
|
|
133
|
+
const propertyKey1 = event.setCollectionItem('property');
|
|
134
|
+
event.setCollectionItemReference('property', propertyKey1, 'propertyId', '1');
|
|
135
|
+
event.setCollectionItemReference('property', propertyKey1, 'externalId', '12');
|
|
136
|
+
// Add second property item
|
|
137
|
+
const propertyKey2 = event.setCollectionItem('property');
|
|
138
|
+
event.setCollectionItemReference('property', propertyKey2, 'propertyId', '2');
|
|
139
|
+
event.setCollectionItemReference('property', propertyKey2, 'externalId', '13');
|
|
140
|
+
// Suggest collection
|
|
141
|
+
const suggestKey1 = event.setCollectionItem('suggest');
|
|
142
|
+
event.setCollectionItemReference('suggest', suggestKey1, 'suggestionId', '1');
|
|
143
|
+
const suggestKey2 = event.setCollectionItem('suggest');
|
|
144
|
+
event.setCollectionItemReference('suggest', suggestKey2, 'suggestionId', '2');
|
|
145
|
+
|
|
146
|
+
// References
|
|
147
|
+
// Reference to property entity
|
|
148
|
+
event.setRefence('property');
|
|
149
|
+
event.setRefenceIdentifier('property', 'id', '123');
|
|
150
|
+
|
|
151
|
+
// Schema
|
|
152
|
+
event.setSchema('UserInteractionEvent');
|
|
153
|
+
|
|
154
|
+
// Send the event
|
|
113
155
|
tracker.track(event);
|
|
114
156
|
```
|
|
115
157
|
|
|
158
|
+
This example covers all main options: entity, adjectives, identifiers, action, actor, actor identifiers, context, collections, references, and schema.
|
|
159
|
+
```
|
|
160
|
+
|
|
116
161
|
---
|
|
117
162
|
|
|
118
163
|
## Learn More
|
|
@@ -121,4 +166,10 @@ tracker.track(event);
|
|
|
121
166
|
- 🏗️ [Architecture](./docs/architecture.md)
|
|
122
167
|
- 🔄 [Emitters & Trackers](./docs/emitterAndTracker.md)
|
|
123
168
|
- ✍️ [DSL Syntax](./docs/dsl.md)
|
|
124
|
-
- 📦 [Event Structure](./docs/events.md)
|
|
169
|
+
- 📦 [Event Structure](./docs/events.md)
|
|
170
|
+
|
|
171
|
+
## one more thing
|
|
172
|
+
It is also available in gtm
|
|
173
|
+
This is a real real pain
|
|
174
|
+
All things gtm can be found here:
|
|
175
|
+
🤕 [Gtm](./docs/gtm/readme.md)
|
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// helper 'private' functions
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Encodes a string to Base64.
|
|
9
|
+
* Uses browser or Node.js method depending on environment.
|
|
10
|
+
* @param {string} str
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
const toBase64 = function (str) {
|
|
14
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
15
|
+
return window.btoa(unescape(encodeURIComponent(str)));
|
|
16
|
+
} else {
|
|
17
|
+
return Buffer.from(str, 'utf-8').toString('base64');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Collects browser-related context values like screen size, language, etc.
|
|
23
|
+
* Returns an empty object if not in browser environment.
|
|
24
|
+
* @returns {Object}
|
|
25
|
+
*/
|
|
26
|
+
const getBrowserContext = function() {
|
|
27
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
hasFocus: document.hasFocus(),
|
|
32
|
+
language: navigator.language,
|
|
33
|
+
platform: navigator.platform,
|
|
34
|
+
referrer: document.referrer,
|
|
35
|
+
screenHeight: window.screen.height,
|
|
36
|
+
screenWidth: window.screen.width,
|
|
37
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
38
|
+
url: window.location.href,
|
|
39
|
+
userAgent: navigator.userAgent,
|
|
40
|
+
viewportHeight: window.innerHeight,
|
|
41
|
+
viewportWidth: window.innerWidth,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const formatToCamelCase = function(input) {
|
|
46
|
+
return input
|
|
47
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
48
|
+
.trim()
|
|
49
|
+
.split(/\s+/)
|
|
50
|
+
.map((word, index) => {
|
|
51
|
+
if (index === 0) return word;
|
|
52
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
53
|
+
})
|
|
54
|
+
.join('');
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CollecionesEvent
|
|
59
|
+
* -----------------
|
|
60
|
+
* Base class representing a semantically structured event object.
|
|
61
|
+
* Each event models a specific interaction with an entity, optionally performed by an actor,
|
|
62
|
+
* and may reference related entities or include contextual metadata.
|
|
63
|
+
*
|
|
64
|
+
* Key features:
|
|
65
|
+
* - Captures structured semantics: entity, action, actor, context, references
|
|
66
|
+
* - Supports multiple identifiers for both the main entity and the actor
|
|
67
|
+
* - Allows origin tagging for cross-context or cross-application references
|
|
68
|
+
* - Supports referencing collections of entities or grouped data
|
|
69
|
+
* - Includes timestamps and tracker/app metadata for auditability
|
|
70
|
+
* - Fully serializable and deserializable via toJSON/fromJSON
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class CollecionesEvent {
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Constructs a new CollecionesEvent with default structure and timestamps.
|
|
78
|
+
* Initializes empty containers for semantic attributes such as:
|
|
79
|
+
* - entity: the subject of the event
|
|
80
|
+
* - adjectives: descriptors of the entity
|
|
81
|
+
* - identifiers: identifiers of the entity
|
|
82
|
+
* - action: what happened to the entity
|
|
83
|
+
* - actor: who or what triggered the event (with identifiers in actorIdentifiers)
|
|
84
|
+
* - context: environmental data related to the event
|
|
85
|
+
* - references: external entities involved, optionally scoped by origin
|
|
86
|
+
* - collections: groups of related entities
|
|
87
|
+
* - meta: tracking metadata and timestamps
|
|
88
|
+
*/
|
|
89
|
+
constructor() {
|
|
90
|
+
// initialize event properties
|
|
91
|
+
this.entity = '';
|
|
92
|
+
this.adjevtives = [];
|
|
93
|
+
this.identifiers = {};
|
|
94
|
+
this.action = '';
|
|
95
|
+
this.actor = {};
|
|
96
|
+
this.actorIdentifiers = {};
|
|
97
|
+
this.context = {};
|
|
98
|
+
this.references = {};
|
|
99
|
+
this.collections = {};
|
|
100
|
+
// set default values
|
|
101
|
+
this.meta = {
|
|
102
|
+
eventFormat: 'CollecionesEvent',
|
|
103
|
+
eventFormatVersion: '1'
|
|
104
|
+
};
|
|
105
|
+
this.meta.tracker = '';
|
|
106
|
+
this.meta.app = '';
|
|
107
|
+
this.meta.timestamps = {};
|
|
108
|
+
this.meta.timestamps.clientDatetimeUtc = new Date().toISOString();
|
|
109
|
+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.language) {
|
|
110
|
+
this.meta.timestamps.clientDatetimeLocal = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();
|
|
111
|
+
this.meta.timestamps.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
112
|
+
this.meta.timestamps.timeZoneOffset = new Date().getTimezoneOffset();
|
|
113
|
+
} else {
|
|
114
|
+
this.meta.timestamps.clientDatetimeLocal = new Date().toISOString();
|
|
115
|
+
this.meta.timestamps.timeZone = 'UTC';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns the declared event format.
|
|
121
|
+
* @returns {string} The format name (e.g. 'CollecionesEvent').
|
|
122
|
+
*/
|
|
123
|
+
getEventFormat() {
|
|
124
|
+
let v = this.meta?.eventFormat;
|
|
125
|
+
return (typeof v !== 'undefined') ? v : '1';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns the version of the event format.
|
|
130
|
+
* @returns {string} The format version string.
|
|
131
|
+
*/
|
|
132
|
+
getEventFormatVersion() {
|
|
133
|
+
let v = this?.meta?.eventFormatVersion;
|
|
134
|
+
return (typeof v !== 'undefined') ? v : 'CollecionesEvent';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Overrides or supplements the event's timestamp fields with custom values.
|
|
139
|
+
* @param {object} dateTimeObject - Key-value pairs to merge into the existing timestamp object.
|
|
140
|
+
*/
|
|
141
|
+
overrideDatetime(dateTimeObject = {}) {
|
|
142
|
+
for (const [key, value] of Object.entries(dateTimeObject)) {
|
|
143
|
+
this.meta.timestamps[key] = value;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Sets the name of the tracker responsible for generating this event.
|
|
149
|
+
* @param {string} name - Tracker name.
|
|
150
|
+
*/
|
|
151
|
+
setTracker(name) {
|
|
152
|
+
this.meta.tracker = name;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Sets the name of the application that generated the event.
|
|
157
|
+
* @param {string} name - Application name.
|
|
158
|
+
*/
|
|
159
|
+
setAppName(name) {
|
|
160
|
+
this.meta.appName = name;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Sets the expected schema name for this event.
|
|
165
|
+
* @param {string} schema - The name of the schema.
|
|
166
|
+
*/
|
|
167
|
+
setSchema(schema) {
|
|
168
|
+
if (typeof schema !== 'string') {
|
|
169
|
+
throw new Error('Schema must be a string');
|
|
170
|
+
}
|
|
171
|
+
this.meta.schema = schema;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Sets the entity (subject) of the event.
|
|
176
|
+
* @param {string} entity - The entity name.
|
|
177
|
+
*/
|
|
178
|
+
setEntity = function(entity) {
|
|
179
|
+
this.entity = formatToCamelCase(entity);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Defines the main action of the event (e.g., 'clicked').
|
|
184
|
+
* @param {string} action - The action string.
|
|
185
|
+
*/
|
|
186
|
+
setAction = function(action) {
|
|
187
|
+
this.action = formatToCamelCase(action);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Adds an adjective that describes the entity in more detail.
|
|
192
|
+
* @param {string} adjective - An adjective string.
|
|
193
|
+
*/
|
|
194
|
+
addAdjective = function(adjective) {
|
|
195
|
+
if (typeof adjective !== 'string') {
|
|
196
|
+
throw new Error('Adjective must be a string');
|
|
197
|
+
}
|
|
198
|
+
this.adjevtives.push(formatToCamelCase(adjective));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Adds or updates an identifier for the primary entity.
|
|
203
|
+
* Identifiers allow multiple keys to uniquely identify the entity.
|
|
204
|
+
* @param {string} name - The identifier key.
|
|
205
|
+
* @param {*} identifier - The identifier value.
|
|
206
|
+
*/
|
|
207
|
+
setIdentifier = function(name, identifier) {
|
|
208
|
+
if (typeof name !== 'string') {
|
|
209
|
+
throw new Error('Identifier name must be a string');
|
|
210
|
+
}
|
|
211
|
+
this.identifiers[name] = identifier;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Defines the name of the actor (who or what performed the action).
|
|
216
|
+
* @param {string} name - Actor name (e.g., 'user', 'system').
|
|
217
|
+
*/
|
|
218
|
+
setActor = function(name) {
|
|
219
|
+
if (typeof name !== 'string') {
|
|
220
|
+
throw new Error('Actor name must be a string');
|
|
221
|
+
}
|
|
222
|
+
this.actor.name = name;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Adds or updates an identifier for the actor.
|
|
227
|
+
* Supports multiple identifiers to uniquely identify the actor.
|
|
228
|
+
* @param {string} name - Identifier key.
|
|
229
|
+
* @param {*} identifier - Identifier value.
|
|
230
|
+
*/
|
|
231
|
+
setActorIdentifier = function(name, identifier) {
|
|
232
|
+
if (typeof name !== 'string') {
|
|
233
|
+
throw new Error('Actor Identifier name must be a string');
|
|
234
|
+
}
|
|
235
|
+
this.actorIdentifiers[name] = identifier;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Adds contextual information to the event.
|
|
240
|
+
* Context can include any additional environmental or situational data.
|
|
241
|
+
* @param {string} context - The key of the context field.
|
|
242
|
+
* @param {*} value - The value of the context field.
|
|
243
|
+
*/
|
|
244
|
+
setContext = function(context, value) {
|
|
245
|
+
if (typeof context !== 'string') {
|
|
246
|
+
throw new Error('Context must be a string');
|
|
247
|
+
}
|
|
248
|
+
this.context[context] = value;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Alias for `setReference` for compatibility.
|
|
253
|
+
* Declares an external entity referenced by this event.
|
|
254
|
+
* @param {string} entity - The referenced entity name.
|
|
255
|
+
* @param {string|null} origin - The origin application or context (optional).
|
|
256
|
+
*/
|
|
257
|
+
setRefence = function(entity, origin=null) {
|
|
258
|
+
return this.setReference(entity, origin);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Declares an entity referenced by this event.
|
|
263
|
+
* References may include multiple identifiers and an optional origin to scope the reference.
|
|
264
|
+
* @param {string} entity - The referenced entity name.
|
|
265
|
+
* @param {string|null} origin - The origin application or context (optional).
|
|
266
|
+
*/
|
|
267
|
+
setReference = function(entity, origin=null) {
|
|
268
|
+
if (typeof entity !== 'string') {
|
|
269
|
+
throw new Error('Referenced entity must be a string');
|
|
270
|
+
}
|
|
271
|
+
entity = formatToCamelCase(entity);
|
|
272
|
+
if (origin !== null) {
|
|
273
|
+
entity = `${origin}.${entity}`;
|
|
274
|
+
}
|
|
275
|
+
if(this.references[entity] === undefined) {
|
|
276
|
+
this.references[entity] = {
|
|
277
|
+
identifiers: {},
|
|
278
|
+
origin
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Adds or updates an identifier for a referenced entity.
|
|
285
|
+
* Ensures the reference is declared and sets the identifier under that reference.
|
|
286
|
+
* @param {string} entity - The referenced entity name.
|
|
287
|
+
* @param {string} name - The identifier key.
|
|
288
|
+
* @param {*} identifier - The identifier value.
|
|
289
|
+
* @param {string|null} origin - Optional origin context.
|
|
290
|
+
*/
|
|
291
|
+
setRefenceIdentifier = function(entity, name, identifier, origin=null) {
|
|
292
|
+
return this.setReferenceIdentifier(entity, name, identifier, origin);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Adds or updates an identifier for a referenced entity.
|
|
297
|
+
* @param {string} entity - The referenced entity name.
|
|
298
|
+
* @param {string} name - The identifier key.
|
|
299
|
+
* @param {*} identifier - The identifier value.
|
|
300
|
+
* @param {string|null} origin - Optional origin context.
|
|
301
|
+
*/
|
|
302
|
+
setReferenceIdentifier = function(entity, name, identifier, origin=null) {
|
|
303
|
+
if (typeof entity !== 'string') {
|
|
304
|
+
throw new Error('Referenced entity name must be a string');
|
|
305
|
+
}
|
|
306
|
+
if (typeof name !== 'string') {
|
|
307
|
+
throw new Error('Actor Identifier name must be a string');
|
|
308
|
+
}
|
|
309
|
+
this.setRefence(entity, origin);
|
|
310
|
+
entity = formatToCamelCase(entity);
|
|
311
|
+
if (origin !== null) {
|
|
312
|
+
entity = `${origin}.${entity}`;
|
|
313
|
+
}
|
|
314
|
+
this.references[entity].identifiers[name] = identifier;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Declares a collection of related entities for this event.
|
|
319
|
+
* Collections group multiple related items and may include identifiers and origin metadata.
|
|
320
|
+
* @param {string} entity - The collection name.
|
|
321
|
+
* @param {string|null} origin - Optional origin identifier (e.g. system name).
|
|
322
|
+
*/
|
|
323
|
+
setCollection = function(entity, origin=null) {
|
|
324
|
+
entity = formatToCamelCase(entity);
|
|
325
|
+
if (origin !== null) {
|
|
326
|
+
entity = `${origin}.${entity}`;
|
|
327
|
+
}
|
|
328
|
+
if(this.collections[entity] == undefined) {
|
|
329
|
+
this.collections[entity] = {
|
|
330
|
+
items: [],
|
|
331
|
+
identifiers: {},
|
|
332
|
+
origin
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Adds a new item to a collection and returns its index key.
|
|
339
|
+
* Items represent individual elements within the collection.
|
|
340
|
+
* @param {string} entity - The name of the collection.
|
|
341
|
+
* @returns {number} Index of the newly added item in the collection.
|
|
342
|
+
*/
|
|
343
|
+
setCollectionItem = function(entity, origin=null) {
|
|
344
|
+
entity = formatToCamelCase(entity);
|
|
345
|
+
if (origin !== null) {
|
|
346
|
+
entity = `${origin}.${entity}`;
|
|
347
|
+
}
|
|
348
|
+
this.setCollection(entity);
|
|
349
|
+
this.collections[entity].items.push({});
|
|
350
|
+
let itemKey = this.collections[entity].items.length - 1;
|
|
351
|
+
return itemKey;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Assigns a reference (identifier) to a specific item in a collection.
|
|
356
|
+
* Useful for tagging individual collection elements with identifiers.
|
|
357
|
+
* @param {string} entity - Collection name.
|
|
358
|
+
* @param {number} itemKey - The index of the item in the collection.
|
|
359
|
+
* @param {string} name - The identifier key.
|
|
360
|
+
* @param {*} identifier - The identifier value.
|
|
361
|
+
* @throws {Error} If the item does not exist at the given index.
|
|
362
|
+
*/
|
|
363
|
+
setCollectionItemReference = function(entity, itemKey, name, identifier, origin=null) {
|
|
364
|
+
entity = formatToCamelCase(entity);
|
|
365
|
+
if (origin !== null) {
|
|
366
|
+
entity = `${origin}.${entity}`;
|
|
367
|
+
}
|
|
368
|
+
this.setCollection(entity);
|
|
369
|
+
if(typeof this.collections[entity].items[itemKey] !== 'object') {
|
|
370
|
+
throw new Error('bad bad man, the collection key does not exists');
|
|
371
|
+
}
|
|
372
|
+
this.collections[entity].items[itemKey][name] = identifier;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Sets a static identifier that applies to the entire collection.
|
|
377
|
+
* These identifiers describe the collection as a whole.
|
|
378
|
+
* @param {string} entity - Collection name.
|
|
379
|
+
* @param {string} name - Identifier key.
|
|
380
|
+
* @param {*} identifier - Identifier value.
|
|
381
|
+
*/
|
|
382
|
+
setCollectionIdentifier = function(entity, name, identifier, origin=null) {
|
|
383
|
+
entity = formatToCamelCase(entity);
|
|
384
|
+
if (origin !== null) {
|
|
385
|
+
entity = `${origin}.${entity}`;
|
|
386
|
+
}
|
|
387
|
+
if(this.collections[entity] == undefined) {
|
|
388
|
+
this.collections[entity] = {};
|
|
389
|
+
}
|
|
390
|
+
this.collections[entity].identifiers[name] = identifier;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Serializes the event instance to a plain object suitable for transport or storage.
|
|
395
|
+
* The output includes all semantic fields and metadata.
|
|
396
|
+
* @returns {object} A plain JavaScript object representing the event.
|
|
397
|
+
*/
|
|
398
|
+
toJSON() {
|
|
399
|
+
return {
|
|
400
|
+
class: 'CollecionesEvent',
|
|
401
|
+
entity: this.entity,
|
|
402
|
+
adjectives: this.adjevtives,
|
|
403
|
+
identifiers: this.identifiers,
|
|
404
|
+
action: this.action,
|
|
405
|
+
actor: this.actor,
|
|
406
|
+
actorIdentifiers: this.actorIdentifiers,
|
|
407
|
+
actorIds: this.actorIds,
|
|
408
|
+
context: this.context,
|
|
409
|
+
references: this.references,
|
|
410
|
+
meta: this.meta,
|
|
411
|
+
collections: this.collections
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Recreates a CollecionesEvent instance from a plain object.
|
|
417
|
+
* Used when deserializing events from storage or network transport.
|
|
418
|
+
* @param {object} obj - The input object containing event data.
|
|
419
|
+
* @returns {CollecionesEvent} A rehydrated event instance.
|
|
420
|
+
* @throws {Error} If the class type is not 'CollecionesEvent'.
|
|
421
|
+
*/
|
|
422
|
+
static fromJSON(obj) {
|
|
423
|
+
if (!obj || obj.class !== 'CollecionesEvent') {
|
|
424
|
+
throw new Error('Invalid or missing event class type');
|
|
425
|
+
}
|
|
426
|
+
const instance = new CollecionesEvent();
|
|
427
|
+
instance.entity = obj.entity;
|
|
428
|
+
instance.adjevtives = obj.adjectives || [];
|
|
429
|
+
instance.identifiers = obj.identifiers || {};
|
|
430
|
+
instance.action = obj.action;
|
|
431
|
+
instance.actor = obj.actor;
|
|
432
|
+
instance.actorIdentifiers = obj.actorIdentifiers;
|
|
433
|
+
instance.actorIds = obj.actorIds;
|
|
434
|
+
instance.context = obj.context || {};
|
|
435
|
+
instance.references = obj.references || {};
|
|
436
|
+
instance.meta = obj.meta || {};
|
|
437
|
+
instance.collections = obj.collections || {};
|
|
438
|
+
return instance;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* CollecionesEmitter
|
|
445
|
+
* -------------------
|
|
446
|
+
* This class collects and sends event objects to a remote endpoint (e.g., an event collector API).
|
|
447
|
+
* It is used in both client- and server-side tracking scenarios, typically in combination with
|
|
448
|
+
* CollecionesEvent or subclasses like CollecionesBaseEvent.
|
|
449
|
+
*
|
|
450
|
+
* Behavior:
|
|
451
|
+
* - Events are buffered via `.track()` or `.trackAsync()`.
|
|
452
|
+
* - If the number of buffered events reaches `flushSize`, the buffer is automatically flushed.
|
|
453
|
+
* - If `flushInterval` is provided, the buffer is flushed at a fixed interval.
|
|
454
|
+
* - Flushing serializes each event using `.toJSON()`, encodes it with base64, and posts
|
|
455
|
+
* the resulting array to the configured endpoint.
|
|
456
|
+
*
|
|
457
|
+
* Example usage:
|
|
458
|
+
* const emitter = new CollecionesEmitter('/track', 5, 10000);
|
|
459
|
+
* emitter.track(new CollecionesEvent());
|
|
460
|
+
*
|
|
461
|
+
* Note:
|
|
462
|
+
* This class is stateful. To stop periodic flushing, call `.stopTimer()` when the emitter is no longer in use.
|
|
463
|
+
*/
|
|
464
|
+
class CollecionesEmitter {
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Initializes the emitter with buffering settings.
|
|
468
|
+
* @param {string} [endpoint='/collect'] - The URL to send events to.
|
|
469
|
+
* @param {number} [flushSize=10] - Number of events to buffer before flushing.
|
|
470
|
+
* @param {number|boolean} [flushInterval=false] - Time in ms to flush events periodically.
|
|
471
|
+
*/
|
|
472
|
+
constructor(endpoint = '/collect', flushSize = 10, flushInterval = false) {
|
|
473
|
+
this.endpoint = endpoint;
|
|
474
|
+
this.flushInterval = flushInterval;
|
|
475
|
+
this.flushSize = flushSize;
|
|
476
|
+
this.buffer = [];
|
|
477
|
+
this.timer = null;
|
|
478
|
+
this.lastPayload = null;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Starts the flush timer if a valid interval is set.
|
|
483
|
+
* @returns {void}
|
|
484
|
+
*/
|
|
485
|
+
startTimer() {
|
|
486
|
+
this.stopTimer();
|
|
487
|
+
if (typeof this.flushInterval == 'number' && this.flushInterval > 0) {
|
|
488
|
+
this.timer = setInterval(() => this.flush(), this.flushInterval);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Starts the flush timer only if not already running.
|
|
494
|
+
* @returns {void}
|
|
495
|
+
*/
|
|
496
|
+
startTimerIfStopped() {
|
|
497
|
+
if (!this.timer) {
|
|
498
|
+
this.startTimer();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Stops the active flush timer.
|
|
504
|
+
* @returns {void}
|
|
505
|
+
*/
|
|
506
|
+
stopTimer() {
|
|
507
|
+
if (this.timer) {
|
|
508
|
+
clearInterval(this.timer);
|
|
509
|
+
}
|
|
510
|
+
this.timer = null;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Adds an event to the buffer and flushes if threshold is reached.
|
|
515
|
+
* Validates that the event is an instance of CollecionesEvent to ensure correct event type.
|
|
516
|
+
* @param {CollecionesEvent} event - Event instance to be tracked.
|
|
517
|
+
* @throws {Error} Throws if event is not a CollecionesEvent instance.
|
|
518
|
+
* @returns {void}
|
|
519
|
+
*/
|
|
520
|
+
track(event) {
|
|
521
|
+
if (!(event instanceof CollecionesEvent)) {
|
|
522
|
+
throw new Error('Event must be an instance of CollecionesEvent');
|
|
523
|
+
}
|
|
524
|
+
this.trackAsync(event);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Asynchronously adds an event and flushes if the buffer size is exceeded.
|
|
529
|
+
* Validates that the event is an instance of CollecionesEvent to ensure correct event type.
|
|
530
|
+
* @param {CollecionesEvent} event - Event instance to be tracked asynchronously.
|
|
531
|
+
* @throws {Error} Throws if event is not a CollecionesEvent instance.
|
|
532
|
+
* @returns {Promise<void>} Resolves when event is added and flush triggered if needed.
|
|
533
|
+
*/
|
|
534
|
+
async trackAsync(event) {
|
|
535
|
+
if (!(event instanceof CollecionesEvent)) {
|
|
536
|
+
throw new Error('Event must be an instance of CollecionesEvent');
|
|
537
|
+
}
|
|
538
|
+
this.startTimerIfStopped();
|
|
539
|
+
this.buffer.push(event);
|
|
540
|
+
return (this.buffer.length >= this.flushSize) ? this.flush() : Promise.resolve();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Sends all buffered events in a single POST request to the server.
|
|
545
|
+
* Each event is serialized via `.toJSON()` and encoded as a base64 string.
|
|
546
|
+
* Response status is checked for HTTP success; errors are logged but not thrown.
|
|
547
|
+
*
|
|
548
|
+
* @returns {Promise<boolean|undefined>} Resolves true if flush was triggered, or undefined if buffer was empty.
|
|
549
|
+
*/
|
|
550
|
+
async flush() {
|
|
551
|
+
if (this.buffer.length === 0) return;
|
|
552
|
+
this.stopTimer();
|
|
553
|
+
const body = this.buildBody();
|
|
554
|
+
this.lastPayload = body;
|
|
555
|
+
this.buffer = [];
|
|
556
|
+
try {
|
|
557
|
+
const response = await fetch(this.endpoint, {
|
|
558
|
+
method: 'POST',
|
|
559
|
+
credentials: 'include',
|
|
560
|
+
headers: {
|
|
561
|
+
'Content-Type': 'application/json'
|
|
562
|
+
},
|
|
563
|
+
body
|
|
564
|
+
});
|
|
565
|
+
if (!response.ok) {
|
|
566
|
+
console.log(`Failed to send events: ${response.statusText}`);
|
|
567
|
+
}
|
|
568
|
+
return true;
|
|
569
|
+
} catch (error) {
|
|
570
|
+
console.log(`Network error sending events: ${error.message}`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Builds a POST-ready payload from the current buffer, without clearing it.
|
|
576
|
+
* @returns {string} JSON string of base64-encoded serialized events.
|
|
577
|
+
*/
|
|
578
|
+
buildBody() {
|
|
579
|
+
return JSON.stringify(this.buffer.map(e => toBase64(JSON.stringify(e.toJSON()))));
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Tracks events by enriching them with shared identifiers and routing through configured emitters.
|
|
586
|
+
*/
|
|
587
|
+
class CollecionesTracker {
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Constructs a new tracker instance.
|
|
591
|
+
* @param {Array} emitters - Array of emitter instances responsible for sending events.
|
|
592
|
+
* @param {string} trackerName - Name identifying this tracker.
|
|
593
|
+
* @param {string} appName - Name of the application generating events.
|
|
594
|
+
*/
|
|
595
|
+
constructor(emitters, trackerName, appName) {
|
|
596
|
+
this.emitters = emitters;
|
|
597
|
+
this.trackerName = trackerName;
|
|
598
|
+
this.appName = appName;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Sends an event to all emitters after enriching it with identifiers and metadata.
|
|
603
|
+
* @param {CollecionesEvent} collecionesEvent - The event to be sent.
|
|
604
|
+
* @throws {Error} If the input is not an instance of CollecionesEvent.
|
|
605
|
+
*/
|
|
606
|
+
track(collecionesEvent) {
|
|
607
|
+
if (!(collecionesEvent instanceof CollecionesEvent)) {
|
|
608
|
+
throw new Error('Event must be of type CollecionesEvent');
|
|
609
|
+
}
|
|
610
|
+
collecionesEvent.setTracker(this.trackerName);
|
|
611
|
+
collecionesEvent.setAppName(this.appName);
|
|
612
|
+
this.emitters.forEach(element => {
|
|
613
|
+
element.track(collecionesEvent, this.trackerName, this.appName);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Web-specific tracker that enriches events with browser context before sending them.
|
|
620
|
+
* Extends the base CollecionesTracker.
|
|
621
|
+
*/
|
|
622
|
+
class CollecionesWebTracker extends CollecionesTracker {
|
|
623
|
+
/**
|
|
624
|
+
* Creates a new instance of CollecionesWebTracker.
|
|
625
|
+
* @param {Array} emitters - A list of emitter instances used to send the event.
|
|
626
|
+
* @param {string} trackerName - The name of the tracker.
|
|
627
|
+
* @param {string} appName - The name of the application generating events.
|
|
628
|
+
*/
|
|
629
|
+
constructor(emitters, trackerName, appName) {
|
|
630
|
+
super(emitters, trackerName, appName);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Tracks an event, enriching it with browser context information.
|
|
635
|
+
* @param {CollecionesEvent} collecionesEvent - The event object to track.
|
|
636
|
+
* @throws {Error} If the event is not an instance of CollecionesEvent.
|
|
637
|
+
*/
|
|
638
|
+
track(collecionesEvent) {
|
|
639
|
+
if (!(collecionesEvent instanceof CollecionesEvent)) {
|
|
640
|
+
throw new Error('Event must be of type CollecionesEvent');
|
|
641
|
+
}
|
|
642
|
+
collecionesEvent.setContext('browserContext', getBrowserContext());
|
|
643
|
+
super.track(collecionesEvent);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
window.compilacionCollecionesClientosGtmQueue = window.compilacionCollecionesClientosGtmQueue || [];
|
|
648
|
+
window.compilacionCollecionesClientosGtm = (() => {
|
|
649
|
+
const utils = {
|
|
650
|
+
getByPath: (obj, path) => {
|
|
651
|
+
return path.split('.').reduce((acc, key) => (acc && acc[key] !== undefined) ? acc[key] : undefined, obj);
|
|
652
|
+
},
|
|
653
|
+
evalobjectParamater: (parameter, object) => {
|
|
654
|
+
if (typeof parameter === 'string' && parameter.startsWith('@')) {
|
|
655
|
+
const path = parameter.slice(1);
|
|
656
|
+
return utils.getByPath(object, path);
|
|
657
|
+
}
|
|
658
|
+
return parameter;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
let initialized = false;
|
|
662
|
+
const methods = {};
|
|
663
|
+
let emitter = null;
|
|
664
|
+
let tracker = null;
|
|
665
|
+
|
|
666
|
+
methods.setEmitter = (endpoint, flushSize, flushInterval) => {
|
|
667
|
+
if (emitter) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
emitter = new CollecionesEmitter(endpoint, flushSize, flushInterval);
|
|
671
|
+
initialized = (emitter && tracker);
|
|
672
|
+
return true;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
methods.setTracker = (trackerName, appName) => {
|
|
676
|
+
if (emitter === null) {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
if (tracker) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
tracker = new CollecionesWebTracker([emitter], trackerName, appName);
|
|
683
|
+
initialized = (emitter && tracker);
|
|
684
|
+
return true;
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
methods.tag = ( gtmEventData ) => {
|
|
688
|
+
let trackerConfig = gtmEventData?.trackerConfig;
|
|
689
|
+
if (!initialized && !trackerConfig) {
|
|
690
|
+
return false;
|
|
691
|
+
} else if (!initialized && trackerConfig) {
|
|
692
|
+
methods.setEmitter(trackerConfig.endpoint, trackerConfig.flushSize, trackerConfig.flushInterval);
|
|
693
|
+
methods.setTracker(trackerConfig.trackerName, trackerConfig.appName);
|
|
694
|
+
}
|
|
695
|
+
if (!initialized) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
const event = new CollecionesEvent();
|
|
699
|
+
// entity
|
|
700
|
+
if (!gtmEventData.entity) {
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
// action
|
|
704
|
+
event.setEntity(gtmEventData.entity);
|
|
705
|
+
if (!gtmEventData.action) {
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
708
|
+
event.setAction(gtmEventData.entity);
|
|
709
|
+
// adjectives
|
|
710
|
+
let adjectives = gtmEventData.adjectives;
|
|
711
|
+
if (Array.isArray(adjectives)) {
|
|
712
|
+
adjectives.forEach(adjective => {
|
|
713
|
+
if (adjective.adjective?.length > 0) {
|
|
714
|
+
event.addAdjective(adjective.adjective);
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
// identifiers
|
|
719
|
+
let identifiers = gtmEventData.identifiers;
|
|
720
|
+
if (Array.isArray(identifiers)) {
|
|
721
|
+
identifiers.forEach(identifier => {
|
|
722
|
+
if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
event.setIdentifier(identifier.name, identifier.value);
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
// contexts
|
|
729
|
+
let contexts = gtmEventData.contexts;
|
|
730
|
+
if (Array.isArray(contexts)) {
|
|
731
|
+
contexts.forEach(context => {
|
|
732
|
+
if (!context.key || context.key.length < 1 || !context.value || context.value.length < 1) {
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
event.setContext(context.key, context.value);
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
// actor
|
|
739
|
+
let actor = gtmEventData.actor;
|
|
740
|
+
let actorIdentifiers = gtmEventData.actorIdentifiers;
|
|
741
|
+
if (typeof actor === 'string' && actor.length > 0) {
|
|
742
|
+
event.setActor(actor);
|
|
743
|
+
// actorIdentifiers
|
|
744
|
+
if (Array.isArray(actorIdentifiers)) {
|
|
745
|
+
actorIdentifiers.forEach(identifier => {
|
|
746
|
+
if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
event.setActorIdentifier(identifier.name, identifier.value);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
// References
|
|
754
|
+
let references = gtmEventData.references;
|
|
755
|
+
if (Array.isArray(references)) {
|
|
756
|
+
references.forEach(ref => {
|
|
757
|
+
if (!ref.entity || !ref.identifierName || !ref.identifierValue) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
event.setReference(ref.entity, ref.identifierName, ref.identifierValue);
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
// collections
|
|
764
|
+
const collectionInterpreter = {
|
|
765
|
+
'compilacionCollecionesClientosGtmVariable_collectionConfig': (event, collectionVariable) => {
|
|
766
|
+
let array = collectionVariable.array;
|
|
767
|
+
if (!array || !Array.isArray(array) || array.length < 1) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
array.forEach(item => {
|
|
771
|
+
let entity = utils.evalobjectParamater(collectionVariable.entity, item);
|
|
772
|
+
let identifierName = utils.evalobjectParamater(collectionVariable.identifiername, item);
|
|
773
|
+
let identifierValue = utils.evalobjectParamater(collectionVariable.identifiervalue, item);
|
|
774
|
+
if (!entity || !identifierName || !identifierValue) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
let collectionKey = event.setCollectionItem(entity);
|
|
778
|
+
event.setCollectionItemReference(entity, collectionKey, identifierName, identifierValue);
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
let collections = gtmEventData.collections;
|
|
783
|
+
if (Array.isArray(collections)) {
|
|
784
|
+
collections.forEach(collection => {
|
|
785
|
+
let collectionVariable = collection.collectionVariable;
|
|
786
|
+
let type = collectionVariable.type;
|
|
787
|
+
if (typeof collectionInterpreter[type] === 'function') {
|
|
788
|
+
collectionInterpreter[type](event, collectionVariable);
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
//
|
|
793
|
+
emitter.track(event);
|
|
794
|
+
return true;
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
const flush = () => {
|
|
798
|
+
const q = window.compilacionCollecionesClientosGtmQueue;
|
|
799
|
+
let rest = [];
|
|
800
|
+
if (!q || !Array.isArray(q)) return;
|
|
801
|
+
while (q.length > 0) {
|
|
802
|
+
const args = q.shift();
|
|
803
|
+
if (!(typeof methods[args.method] === 'function')) {
|
|
804
|
+
continue
|
|
805
|
+
}
|
|
806
|
+
let result = methods[args.method].apply(null, args.arguments);
|
|
807
|
+
if (result === true) {
|
|
808
|
+
continue
|
|
809
|
+
}
|
|
810
|
+
rest.push(args);
|
|
811
|
+
}
|
|
812
|
+
window.compilacionCollecionesClientosGtmQueue = rest;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
const purgeEvents = async() => {
|
|
816
|
+
if (!emitter) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
return emitter.flush();
|
|
820
|
+
};
|
|
821
|
+
flush();
|
|
822
|
+
return {
|
|
823
|
+
flush,
|
|
824
|
+
purgeEvents
|
|
825
|
+
};
|
|
826
|
+
})();
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
/*
|
|
830
|
+
trackerConfig.endpoint
|
|
831
|
+
*/
|
|
832
|
+
|
|
833
|
+
})();
|
|
834
|
+
//# sourceMappingURL=browser.gtm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.gtm.js","sources":["../src/utils/utils.js","../src/CollecionesEvent.js","../src/CollecionesEmitter.js","../src/CollecionesTracker.js","../src/CollecionesWebTracker.js","../src/browser.gtm.js"],"sourcesContent":["// helper 'private' functions\n\n\n/**\n * Encodes a string to Base64.\n * Uses browser or Node.js method depending on environment.\n * @param {string} str\n * @returns {string}\n */\nconst toBase64 = function (str) {\n if (typeof window !== 'undefined' && typeof window.btoa === 'function') {\n return window.btoa(unescape(encodeURIComponent(str)));\n } else {\n return Buffer.from(str, 'utf-8').toString('base64');\n }\n}\n\n/**\n * Decodes a Base64 string to UTF-8.\n * Uses browser or Node.js method depending on environment.\n * @param {string} b64\n * @returns {string}\n */\nconst fromBase64 = function (b64) {\n if (typeof window !== 'undefined' && typeof window.atob === 'function') {\n return decodeURIComponent(escape(window.atob(b64)));\n } else {\n return Buffer.from(b64, 'base64').toString('utf-8');\n }\n}\n\n/**\n * Collects browser-related context values like screen size, language, etc.\n * Returns an empty object if not in browser environment.\n * @returns {Object}\n */\nconst getBrowserContext = function() {\n if (typeof window === 'undefined' || typeof navigator === 'undefined') {\n return {};\n }\n return {\n hasFocus: document.hasFocus(),\n language: navigator.language,\n platform: navigator.platform,\n referrer: document.referrer,\n screenHeight: window.screen.height,\n screenWidth: window.screen.width,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n url: window.location.href,\n userAgent: navigator.userAgent,\n viewportHeight: window.innerHeight,\n viewportWidth: window.innerWidth,\n };\n}\n\nconst formatToCamelCase = function(input) {\n return input\n .replace(/[^a-zA-Z0-9]+/g, ' ')\n .trim()\n .split(/\\s+/)\n .map((word, index) => {\n if (index === 0) return word;\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join('');\n}\n\nexport {\n fromBase64,\n formatToCamelCase,\n getBrowserContext,\n toBase64,\n};","/**\n * CollecionesEvent\n * -----------------\n * Base class representing a semantically structured event object.\n * Each event models a specific interaction with an entity, optionally performed by an actor,\n * and may reference related entities or include contextual metadata.\n *\n * Key features:\n * - Captures structured semantics: entity, action, actor, context, references\n * - Supports multiple identifiers for both the main entity and the actor\n * - Allows origin tagging for cross-context or cross-application references\n * - Supports referencing collections of entities or grouped data\n * - Includes timestamps and tracker/app metadata for auditability\n * - Fully serializable and deserializable via toJSON/fromJSON\n */\n\nimport {formatToCamelCase } from './utils/utils.js';\n\nclass CollecionesEvent {\n\n /**\n * Constructs a new CollecionesEvent with default structure and timestamps.\n * Initializes empty containers for semantic attributes such as:\n * - entity: the subject of the event\n * - adjectives: descriptors of the entity\n * - identifiers: identifiers of the entity\n * - action: what happened to the entity\n * - actor: who or what triggered the event (with identifiers in actorIdentifiers)\n * - context: environmental data related to the event\n * - references: external entities involved, optionally scoped by origin\n * - collections: groups of related entities\n * - meta: tracking metadata and timestamps\n */\n constructor() {\n // initialize event properties\n this.entity = '';\n this.adjevtives = [];\n this.identifiers = {};\n this.action = '';\n this.actor = {};\n this.actorIdentifiers = {};\n this.context = {};\n this.references = {};\n this.collections = {};\n // set default values\n this.meta = {\n eventFormat: 'CollecionesEvent',\n eventFormatVersion: '1'\n };\n this.meta.tracker = '';\n this.meta.app = '';\n this.meta.timestamps = {};\n this.meta.timestamps.clientDatetimeUtc = new Date().toISOString();\n if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.language) {\n this.meta.timestamps.clientDatetimeLocal = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();\n this.meta.timestamps.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n this.meta.timestamps.timeZoneOffset = new Date().getTimezoneOffset()\n } else {\n this.meta.timestamps.clientDatetimeLocal = new Date().toISOString();\n this.meta.timestamps.timeZone = 'UTC';\n }\n }\n\n /**\n * Returns the declared event format.\n * @returns {string} The format name (e.g. 'CollecionesEvent').\n */\n getEventFormat() {\n let v = this.meta?.eventFormat;\n return (typeof v !== 'undefined') ? v : '1';\n }\n\n /**\n * Returns the version of the event format.\n * @returns {string} The format version string.\n */\n getEventFormatVersion() {\n let v = this?.meta?.eventFormatVersion;\n return (typeof v !== 'undefined') ? v : 'CollecionesEvent';\n }\n\n /**\n * Overrides or supplements the event's timestamp fields with custom values.\n * @param {object} dateTimeObject - Key-value pairs to merge into the existing timestamp object.\n */\n overrideDatetime(dateTimeObject = {}) {\n for (const [key, value] of Object.entries(dateTimeObject)) {\n this.meta.timestamps[key] = value;\n }\n }\n\n /**\n * Sets the name of the tracker responsible for generating this event.\n * @param {string} name - Tracker name.\n */\n setTracker(name) {\n this.meta.tracker = name;\n }\n\n /**\n * Sets the name of the application that generated the event.\n * @param {string} name - Application name.\n */\n setAppName(name) {\n this.meta.appName = name;\n }\n\n /**\n * Sets the expected schema name for this event.\n * @param {string} schema - The name of the schema.\n */\n setSchema(schema) {\n if (typeof schema !== 'string') {\n throw new Error('Schema must be a string');\n }\n this.meta.schema = schema;\n }\n\n /**\n * Sets the entity (subject) of the event.\n * @param {string} entity - The entity name.\n */\n setEntity = function(entity) {\n this.entity = formatToCamelCase(entity);\n }\n \n /**\n * Defines the main action of the event (e.g., 'clicked').\n * @param {string} action - The action string.\n */\n setAction = function(action) {\n this.action = formatToCamelCase(action);\n }\n\n /**\n * Adds an adjective that describes the entity in more detail.\n * @param {string} adjective - An adjective string.\n */\n addAdjective = function(adjective) {\n if (typeof adjective !== 'string') {\n throw new Error('Adjective must be a string');\n }\n this.adjevtives.push(formatToCamelCase(adjective));\n }\n\n /**\n * Adds or updates an identifier for the primary entity.\n * Identifiers allow multiple keys to uniquely identify the entity.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n */\n setIdentifier = function(name, identifier) {\n if (typeof name !== 'string') {\n throw new Error('Identifier name must be a string');\n }\n this.identifiers[name] = identifier;\n }\n\n /**\n * Defines the name of the actor (who or what performed the action).\n * @param {string} name - Actor name (e.g., 'user', 'system').\n */\n setActor = function(name) {\n if (typeof name !== 'string') {\n throw new Error('Actor name must be a string');\n }\n this.actor.name = name;\n }\n\n /**\n * Adds or updates an identifier for the actor.\n * Supports multiple identifiers to uniquely identify the actor.\n * @param {string} name - Identifier key.\n * @param {*} identifier - Identifier value.\n */\n setActorIdentifier = function(name, identifier) {\n if (typeof name !== 'string') {\n throw new Error('Actor Identifier name must be a string');\n }\n this.actorIdentifiers[name] = identifier;\n }\n\n /**\n * Adds contextual information to the event.\n * Context can include any additional environmental or situational data.\n * @param {string} context - The key of the context field.\n * @param {*} value - The value of the context field.\n */\n setContext = function(context, value) {\n if (typeof context !== 'string') {\n throw new Error('Context must be a string');\n }\n this.context[context] = value;\n }\n\n /**\n * Alias for `setReference` for compatibility.\n * Declares an external entity referenced by this event.\n * @param {string} entity - The referenced entity name.\n * @param {string|null} origin - The origin application or context (optional).\n */\n setRefence = function(entity, origin=null) {\n return this.setReference(entity, origin);\n }\n\n /**\n * Declares an entity referenced by this event.\n * References may include multiple identifiers and an optional origin to scope the reference.\n * @param {string} entity - The referenced entity name.\n * @param {string|null} origin - The origin application or context (optional).\n */\n setReference = function(entity, origin=null) {\n if (typeof entity !== 'string') {\n throw new Error('Referenced entity must be a string');\n }\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.references[entity] === undefined) {\n this.references[entity] = {\n identifiers: {},\n origin\n };\n }\n }\n\n /**\n * Adds or updates an identifier for a referenced entity.\n * Ensures the reference is declared and sets the identifier under that reference.\n * @param {string} entity - The referenced entity name.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @param {string|null} origin - Optional origin context.\n */\n setRefenceIdentifier = function(entity, name, identifier, origin=null) {\n return this.setReferenceIdentifier(entity, name, identifier, origin);\n }\n\n /**\n * Adds or updates an identifier for a referenced entity.\n * @param {string} entity - The referenced entity name.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @param {string|null} origin - Optional origin context.\n */\n setReferenceIdentifier = function(entity, name, identifier, origin=null) {\n if (typeof entity !== 'string') {\n throw new Error('Referenced entity name must be a string');\n }\n if (typeof name !== 'string') {\n throw new Error('Actor Identifier name must be a string');\n }\n this.setRefence(entity, origin);\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.references[entity].identifiers[name] = identifier;\n }\n\n /**\n * Declares a collection of related entities for this event.\n * Collections group multiple related items and may include identifiers and origin metadata.\n * @param {string} entity - The collection name.\n * @param {string|null} origin - Optional origin identifier (e.g. system name).\n */\n setCollection = function(entity, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.collections[entity] == undefined) {\n this.collections[entity] = {\n items: [],\n identifiers: {},\n origin\n };\n }\n }\n\n /**\n * Adds a new item to a collection and returns its index key.\n * Items represent individual elements within the collection.\n * @param {string} entity - The name of the collection.\n * @returns {number} Index of the newly added item in the collection.\n */\n setCollectionItem = function(entity, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.setCollection(entity);\n this.collections[entity].items.push({});\n let itemKey = this.collections[entity].items.length - 1;\n return itemKey;\n }\n\n /**\n * Assigns a reference (identifier) to a specific item in a collection.\n * Useful for tagging individual collection elements with identifiers.\n * @param {string} entity - Collection name.\n * @param {number} itemKey - The index of the item in the collection.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @throws {Error} If the item does not exist at the given index.\n */\n setCollectionItemReference = function(entity, itemKey, name, identifier, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.setCollection(entity);\n if(typeof this.collections[entity].items[itemKey] !== 'object') {\n throw new Error('bad bad man, the collection key does not exists');\n }\n this.collections[entity].items[itemKey][name] = identifier;\n }\n \n /**\n * Sets a static identifier that applies to the entire collection.\n * These identifiers describe the collection as a whole.\n * @param {string} entity - Collection name.\n * @param {string} name - Identifier key.\n * @param {*} identifier - Identifier value.\n */\n setCollectionIdentifier = function(entity, name, identifier, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.collections[entity] == undefined) {\n this.collections[entity] = {};\n }\n this.collections[entity].identifiers[name] = identifier;\n }\n\n /**\n * Serializes the event instance to a plain object suitable for transport or storage.\n * The output includes all semantic fields and metadata.\n * @returns {object} A plain JavaScript object representing the event.\n */\n toJSON() {\n return {\n class: 'CollecionesEvent',\n entity: this.entity,\n adjectives: this.adjevtives,\n identifiers: this.identifiers,\n action: this.action,\n actor: this.actor,\n actorIdentifiers: this.actorIdentifiers,\n actorIds: this.actorIds,\n context: this.context,\n references: this.references,\n meta: this.meta,\n collections: this.collections\n };\n }\n\n /**\n * Recreates a CollecionesEvent instance from a plain object.\n * Used when deserializing events from storage or network transport.\n * @param {object} obj - The input object containing event data.\n * @returns {CollecionesEvent} A rehydrated event instance.\n * @throws {Error} If the class type is not 'CollecionesEvent'.\n */\n static fromJSON(obj) { \n if (!obj || obj.class !== 'CollecionesEvent') {\n throw new Error('Invalid or missing event class type'); \n } \n const instance = new CollecionesEvent();\n instance.entity = obj.entity;\n instance.adjevtives = obj.adjectives || [];\n instance.identifiers = obj.identifiers || {};\n instance.action = obj.action;\n instance.actor = obj.actor;\n instance.actorIdentifiers = obj.actorIdentifiers;\n instance.actorIds = obj.actorIds;\n instance.context = obj.context || {};\n instance.references = obj.references || {};\n instance.meta = obj.meta || {};\n instance.collections = obj.collections || {};\n return instance;\n }\n \n}\n\nexport default CollecionesEvent;","import { fromBase64, toBase64 } from './utils/utils.js';\nimport CollecionesEvent from './CollecionesEvent.js';\n\n/**\n * CollecionesEmitter\n * -------------------\n * This class collects and sends event objects to a remote endpoint (e.g., an event collector API).\n * It is used in both client- and server-side tracking scenarios, typically in combination with\n * CollecionesEvent or subclasses like CollecionesBaseEvent.\n *\n * Behavior:\n * - Events are buffered via `.track()` or `.trackAsync()`.\n * - If the number of buffered events reaches `flushSize`, the buffer is automatically flushed.\n * - If `flushInterval` is provided, the buffer is flushed at a fixed interval.\n * - Flushing serializes each event using `.toJSON()`, encodes it with base64, and posts\n * the resulting array to the configured endpoint.\n *\n * Example usage:\n * const emitter = new CollecionesEmitter('/track', 5, 10000);\n * emitter.track(new CollecionesEvent());\n *\n * Note:\n * This class is stateful. To stop periodic flushing, call `.stopTimer()` when the emitter is no longer in use.\n */\nclass CollecionesEmitter {\n\n /**\n * Initializes the emitter with buffering settings.\n * @param {string} [endpoint='/collect'] - The URL to send events to.\n * @param {number} [flushSize=10] - Number of events to buffer before flushing.\n * @param {number|boolean} [flushInterval=false] - Time in ms to flush events periodically.\n */\n constructor(endpoint = '/collect', flushSize = 10, flushInterval = false) {\n this.endpoint = endpoint;\n this.flushInterval = flushInterval;\n this.flushSize = flushSize;\n this.buffer = [];\n this.timer = null;\n this.lastPayload = null;\n }\n\n /**\n * Starts the flush timer if a valid interval is set.\n * @returns {void}\n */\n startTimer() {\n this.stopTimer();\n if (typeof this.flushInterval == 'number' && this.flushInterval > 0) {\n this.timer = setInterval(() => this.flush(), this.flushInterval);\n }\n }\n\n /**\n * Starts the flush timer only if not already running.\n * @returns {void}\n */\n startTimerIfStopped() {\n if (!this.timer) {\n this.startTimer();\n }\n }\n\n /**\n * Stops the active flush timer.\n * @returns {void}\n */\n stopTimer() {\n if (this.timer) {\n clearInterval(this.timer);\n }\n this.timer = null;\n }\n\n /**\n * Adds an event to the buffer and flushes if threshold is reached.\n * Validates that the event is an instance of CollecionesEvent to ensure correct event type.\n * @param {CollecionesEvent} event - Event instance to be tracked.\n * @throws {Error} Throws if event is not a CollecionesEvent instance.\n * @returns {void}\n */\n track(event) {\n if (!(event instanceof CollecionesEvent)) {\n throw new Error('Event must be an instance of CollecionesEvent');\n }\n this.trackAsync(event);\n }\n\n /**\n * Asynchronously adds an event and flushes if the buffer size is exceeded.\n * Validates that the event is an instance of CollecionesEvent to ensure correct event type.\n * @param {CollecionesEvent} event - Event instance to be tracked asynchronously.\n * @throws {Error} Throws if event is not a CollecionesEvent instance.\n * @returns {Promise<void>} Resolves when event is added and flush triggered if needed.\n */\n async trackAsync(event) {\n if (!(event instanceof CollecionesEvent)) {\n throw new Error('Event must be an instance of CollecionesEvent');\n }\n this.startTimerIfStopped();\n this.buffer.push(event);\n return (this.buffer.length >= this.flushSize) ? this.flush() : Promise.resolve();\n }\n\n /**\n * Sends all buffered events in a single POST request to the server.\n * Each event is serialized via `.toJSON()` and encoded as a base64 string.\n * Response status is checked for HTTP success; errors are logged but not thrown.\n *\n * @returns {Promise<boolean|undefined>} Resolves true if flush was triggered, or undefined if buffer was empty.\n */\n async flush() {\n if (this.buffer.length === 0) return;\n this.stopTimer();\n const body = this.buildBody();\n this.lastPayload = body;\n this.buffer = [];\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json'\n },\n body\n });\n if (!response.ok) {\n console.log(`Failed to send events: ${response.statusText}`);\n }\n return true;\n } catch (error) { \n console.log(`Network error sending events: ${error.message}`);\n } \n }\n\n /**\n * Builds a POST-ready payload from the current buffer, without clearing it.\n * @returns {string} JSON string of base64-encoded serialized events.\n */\n buildBody() {\n return JSON.stringify(this.buffer.map(e => toBase64(JSON.stringify(e.toJSON()))));\n }\n\n}\n\nexport default CollecionesEmitter;","import CollecionesEvent from './CollecionesEvent.js';\n\n/**\n * Tracks events by enriching them with shared identifiers and routing through configured emitters.\n */\nclass CollecionesTracker {\n\n /**\n * Constructs a new tracker instance.\n * @param {Array} emitters - Array of emitter instances responsible for sending events.\n * @param {string} trackerName - Name identifying this tracker.\n * @param {string} appName - Name of the application generating events.\n */\n constructor(emitters, trackerName, appName) {\n this.emitters = emitters;\n this.trackerName = trackerName;\n this.appName = appName;\n }\n\n /**\n * Sends an event to all emitters after enriching it with identifiers and metadata.\n * @param {CollecionesEvent} collecionesEvent - The event to be sent.\n * @throws {Error} If the input is not an instance of CollecionesEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n collecionesEvent.setTracker(this.trackerName);\n collecionesEvent.setAppName(this.appName); \n this.emitters.forEach(element => {\n element.track(collecionesEvent, this.trackerName, this.appName);\n });\n }\n}\n\nexport default CollecionesTracker;","import CollecionesEvent from './CollecionesEvent.js';\nimport CollecionesTracker from './CollecionesTracker.js';\nimport { getBrowserContext } from './utils/utils.js';\n\n/**\n * Web-specific tracker that enriches events with browser context before sending them.\n * Extends the base CollecionesTracker.\n */\nclass CollecionesWebTracker extends CollecionesTracker {\n /**\n * Creates a new instance of CollecionesWebTracker.\n * @param {Array} emitters - A list of emitter instances used to send the event.\n * @param {string} trackerName - The name of the tracker.\n * @param {string} appName - The name of the application generating events.\n */\n constructor(emitters, trackerName, appName) {\n super(emitters, trackerName, appName);\n }\n\n /**\n * Tracks an event, enriching it with browser context information.\n * @param {CollecionesEvent} collecionesEvent - The event object to track.\n * @throws {Error} If the event is not an instance of CollecionesEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n collecionesEvent.setContext('browserContext', getBrowserContext());\n super.track(collecionesEvent); \n }\n}\n\nexport default CollecionesWebTracker;","import CollecionesEmitter from './CollecionesEmitter.js';\nimport CollecionesWebTracker from './CollecionesWebTracker.js';\nimport CollecionesEvent from './CollecionesEvent.js';\n\n\nwindow.compilacionCollecionesClientosGtmQueue = window.compilacionCollecionesClientosGtmQueue || [];\nwindow.compilacionCollecionesClientosGtm = (() => {\n const utils = {\n getByPath: (obj, path) => {\n return path.split('.').reduce((acc, key) => (acc && acc[key] !== undefined) ? acc[key] : undefined, obj);\n },\n evalobjectParamater: (parameter, object) => {\n if (typeof parameter === 'string' && parameter.startsWith('@')) {\n const path = parameter.slice(1);\n return utils.getByPath(object, path);\n }\n return parameter;\n }\n };\n let initialized = false;\n const methods = {};\n let emitter = null;\n let tracker = null;\n\n methods.setEmitter = (endpoint, flushSize, flushInterval) => {\n if (emitter) {\n return;\n }\n emitter = new CollecionesEmitter(endpoint, flushSize, flushInterval);\n initialized = (emitter && tracker);\n return true;\n };\n\n methods.setTracker = (trackerName, appName) => {\n if (emitter === null) {\n return false;\n }\n if (tracker) {\n return;\n }\n tracker = new CollecionesWebTracker([emitter], trackerName, appName);\n initialized = (emitter && tracker);\n return true;\n };\n\n methods.tag = ( gtmEventData ) => {\n let trackerConfig = gtmEventData?.trackerConfig;\n if (!initialized && !trackerConfig) {\n return false;\n } else if (!initialized && trackerConfig) {\n methods.setEmitter(trackerConfig.endpoint, trackerConfig.flushSize, trackerConfig.flushInterval);\n methods.setTracker(trackerConfig.trackerName, trackerConfig.appName);\n }\n if (!initialized) {\n return false;\n }\n const event = new CollecionesEvent();\n // entity\n if (!gtmEventData.entity) {\n return false;\n }\n // action\n event.setEntity(gtmEventData.entity);\n if (!gtmEventData.action) {\n return false;\n }\n event.setAction(gtmEventData.entity);\n // adjectives \n let adjectives = gtmEventData.adjectives;\n if (Array.isArray(adjectives)) {\n adjectives.forEach(adjective => {\n if (adjective.adjective?.length > 0) {\n event.addAdjective(adjective.adjective);\n }\n });\n }\n // identifiers\n let identifiers = gtmEventData.identifiers;\n if (Array.isArray(identifiers)) {\n identifiers.forEach(identifier => {\n if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {\n return;\n }\n event.setIdentifier(identifier.name, identifier.value);\n });\n }\n // contexts\n let contexts = gtmEventData.contexts;\n if (Array.isArray(contexts)) {\n contexts.forEach(context => {\n if (!context.key || context.key.length < 1 || !context.value || context.value.length < 1) {\n return;\n }\n event.setContext(context.key, context.value);\n });\n }\n // actor\n let actor = gtmEventData.actor;\n let actorIdentifiers = gtmEventData.actorIdentifiers;\n if (typeof actor === 'string' && actor.length > 0) {\n event.setActor(actor);\n // actorIdentifiers\n if (Array.isArray(actorIdentifiers)) {\n actorIdentifiers.forEach(identifier => {\n if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {\n return;\n }\n event.setActorIdentifier(identifier.name, identifier.value);\n });\n }\n }\n // References\n let references = gtmEventData.references;\n if (Array.isArray(references)) {\n references.forEach(ref => {\n if (!ref.entity || !ref.identifierName || !ref.identifierValue) {\n return;\n }\n event.setReference(ref.entity, ref.identifierName, ref.identifierValue);\n });\n }\n // collections\n const collectionInterpreter = {\n 'compilacionCollecionesClientosGtmVariable_collectionConfig': (event, collectionVariable) => {\n let array = collectionVariable.array;\n if (!array || !Array.isArray(array) || array.length < 1) {\n return false;\n }\n array.forEach(item => {\n let entity = utils.evalobjectParamater(collectionVariable.entity, item);\n let identifierName = utils.evalobjectParamater(collectionVariable.identifiername, item);\n let identifierValue = utils.evalobjectParamater(collectionVariable.identifiervalue, item);\n if (!entity || !identifierName || !identifierValue) {\n return;\n }\n let collectionKey = event.setCollectionItem(entity);\n event.setCollectionItemReference(entity, collectionKey, identifierName, identifierValue);\n });\n }\n }\n let collections = gtmEventData.collections;\n if (Array.isArray(collections)) {\n collections.forEach(collection => {\n let collectionVariable = collection.collectionVariable;\n let type = collectionVariable.type;\n if (typeof collectionInterpreter[type] === 'function') {\n collectionInterpreter[type](event, collectionVariable);\n }\n });\n }\n // \n emitter.track(event);\n return true;\n };\n\n const flush = () => {\n const q = window.compilacionCollecionesClientosGtmQueue;\n let rest = [];\n if (!q || !Array.isArray(q)) return;\n while (q.length > 0) {\n const args = q.shift();\n if (!(typeof methods[args.method] === 'function')) {\n continue\n }\n let result = methods[args.method].apply(null, args.arguments);\n if (result === true) {\n continue\n }\n rest.push(args);\n }\n window.compilacionCollecionesClientosGtmQueue = rest;\n };\n\n const purgeEvents = async() => {\n if (!emitter) {\n return;\n }\n return emitter.flush();\n };\n flush();\n return {\n flush,\n purgeEvents\n };\n})();\n\n\n/*\ntrackerConfig.endpoint\n*/"],"names":[],"mappings":";;;EAAA;;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM,QAAQ,GAAG,UAAU,GAAG,EAAE;EAChC,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;EAC5E,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;EAC7D,KAAK,MAAM;EACX,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;EAC3D;EACA;;EAgBA;EACA;EACA;EACA;EACA;EACA,MAAM,iBAAiB,GAAG,WAAW;EACrC,IAAI,IAAI,OAAO,MAAM,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xD,GAAG;;EAEH,EAAE,MAAM,WAAW,GAAG,WAAW;EACjC,IAAI,IAAI,CAAC,OAAO,EAAE;EAClB,MAAM;EACN;EACA,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE;EAC1B,GAAG;EACH,EAAE,KAAK,EAAE;EACT,EAAE,OAAO;EACT,IAAI,KAAK;EACT,IAAI;EACJ,GAAG;EACH,CAAC,GAAG;;;EAGJ;EACA;EACA;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(){"use strict";const e=function(e){return e.replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join("")};class t{constructor(){this.entity="",this.adjevtives=[],this.identifiers={},this.action="",this.actor={},this.actorIdentifiers={},this.context={},this.references={},this.collections={},this.meta={eventFormat:"CollecionesEvent",eventFormatVersion:"1"},this.meta.tracker="",this.meta.app="",this.meta.timestamps={},this.meta.timestamps.clientDatetimeUtc=(new Date).toISOString(),"undefined"!=typeof window&&"undefined"!=typeof navigator&&navigator.language?(this.meta.timestamps.clientDatetimeLocal=new Date(Date.now()-6e4*(new Date).getTimezoneOffset()).toISOString(),this.meta.timestamps.timeZone=Intl.DateTimeFormat().resolvedOptions().timeZone,this.meta.timestamps.timeZoneOffset=(new Date).getTimezoneOffset()):(this.meta.timestamps.clientDatetimeLocal=(new Date).toISOString(),this.meta.timestamps.timeZone="UTC")}getEventFormat(){let e=this.meta?.eventFormat;return void 0!==e?e:"1"}getEventFormatVersion(){let e=this?.meta?.eventFormatVersion;return void 0!==e?e:"CollecionesEvent"}overrideDatetime(e={}){for(const[t,i]of Object.entries(e))this.meta.timestamps[t]=i}setTracker(e){this.meta.tracker=e}setAppName(e){this.meta.appName=e}setSchema(e){if("string"!=typeof e)throw new Error("Schema must be a string");this.meta.schema=e}setEntity=function(t){this.entity=e(t)};setAction=function(t){this.action=e(t)};addAdjective=function(t){if("string"!=typeof t)throw new Error("Adjective must be a string");this.adjevtives.push(e(t))};setIdentifier=function(e,t){if("string"!=typeof e)throw new Error("Identifier name must be a string");this.identifiers[e]=t};setActor=function(e){if("string"!=typeof e)throw new Error("Actor name must be a string");this.actor.name=e};setActorIdentifier=function(e,t){if("string"!=typeof e)throw new Error("Actor Identifier name must be a string");this.actorIdentifiers[e]=t};setContext=function(e,t){if("string"!=typeof e)throw new Error("Context must be a string");this.context[e]=t};setRefence=function(e,t=null){return this.setReference(e,t)};setReference=function(t,i=null){if("string"!=typeof t)throw new Error("Referenced entity must be a string");t=e(t),null!==i&&(t=`${i}.${t}`),void 0===this.references[t]&&(this.references[t]={identifiers:{},origin:i})};setRefenceIdentifier=function(e,t,i,n=null){return this.setReferenceIdentifier(e,t,i,n)};setReferenceIdentifier=function(t,i,n,r=null){if("string"!=typeof t)throw new Error("Referenced entity name must be a string");if("string"!=typeof i)throw new Error("Actor Identifier name must be a string");this.setRefence(t,r),t=e(t),null!==r&&(t=`${r}.${t}`),this.references[t].identifiers[i]=n};setCollection=function(t,i=null){t=e(t),null!==i&&(t=`${i}.${t}`),null==this.collections[t]&&(this.collections[t]={items:[],identifiers:{},origin:i})};setCollectionItem=function(t,i=null){return t=e(t),null!==i&&(t=`${i}.${t}`),this.setCollection(t),this.collections[t].items.push({}),this.collections[t].items.length-1};setCollectionItemReference=function(t,i,n,r,s=null){if(t=e(t),null!==s&&(t=`${s}.${t}`),this.setCollection(t),"object"!=typeof this.collections[t].items[i])throw new Error("bad bad man, the collection key does not exists");this.collections[t].items[i][n]=r};setCollectionIdentifier=function(t,i,n,r=null){t=e(t),null!==r&&(t=`${r}.${t}`),null==this.collections[t]&&(this.collections[t]={}),this.collections[t].identifiers[i]=n};toJSON(){return{class:"CollecionesEvent",entity:this.entity,adjectives:this.adjevtives,identifiers:this.identifiers,action:this.action,actor:this.actor,actorIdentifiers:this.actorIdentifiers,actorIds:this.actorIds,context:this.context,references:this.references,meta:this.meta,collections:this.collections}}static fromJSON(e){if(!e||"CollecionesEvent"!==e.class)throw new Error("Invalid or missing event class type");const i=new t;return i.entity=e.entity,i.adjevtives=e.adjectives||[],i.identifiers=e.identifiers||{},i.action=e.action,i.actor=e.actor,i.actorIdentifiers=e.actorIdentifiers,i.actorIds=e.actorIds,i.context=e.context||{},i.references=e.references||{},i.meta=e.meta||{},i.collections=e.collections||{},i}}class i{constructor(e="/collect",t=10,i=!1){this.endpoint=e,this.flushInterval=i,this.flushSize=t,this.buffer=[],this.timer=null,this.lastPayload=null}startTimer(){this.stopTimer(),"number"==typeof this.flushInterval&&this.flushInterval>0&&(this.timer=setInterval(()=>this.flush(),this.flushInterval))}startTimerIfStopped(){this.timer||this.startTimer()}stopTimer(){this.timer&&clearInterval(this.timer),this.timer=null}track(e){if(!(e instanceof t))throw new Error("Event must be an instance of CollecionesEvent");this.trackAsync(e)}async trackAsync(e){if(!(e instanceof t))throw new Error("Event must be an instance of CollecionesEvent");return this.startTimerIfStopped(),this.buffer.push(e),this.buffer.length>=this.flushSize?this.flush():Promise.resolve()}async flush(){if(0===this.buffer.length)return;this.stopTimer();const e=this.buildBody();this.lastPayload=e,this.buffer=[];try{const t=await fetch(this.endpoint,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:e});return t.ok||console.log(`Failed to send events: ${t.statusText}`),!0}catch(e){console.log(`Network error sending events: ${e.message}`)}}buildBody(){return JSON.stringify(this.buffer.map(e=>{return t=JSON.stringify(e.toJSON()),"undefined"!=typeof window&&"function"==typeof window.btoa?window.btoa(unescape(encodeURIComponent(t))):Buffer.from(t,"utf-8").toString("base64");var t}))}}class n{constructor(e,t,i){this.emitters=e,this.trackerName=t,this.appName=i}track(e){if(!(e instanceof t))throw new Error("Event must be of type CollecionesEvent");e.setTracker(this.trackerName),e.setAppName(this.appName),this.emitters.forEach(t=>{t.track(e,this.trackerName,this.appName)})}}class r extends n{constructor(e,t,i){super(e,t,i)}track(e){if(!(e instanceof t))throw new Error("Event must be of type CollecionesEvent");e.setContext("browserContext","undefined"==typeof window||"undefined"==typeof navigator?{}:{hasFocus:document.hasFocus(),language:navigator.language,platform:navigator.platform,referrer:document.referrer,screenHeight:window.screen.height,screenWidth:window.screen.width,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,url:window.location.href,userAgent:navigator.userAgent,viewportHeight:window.innerHeight,viewportWidth:window.innerWidth}),super.track(e)}}window.compilacionCollecionesClientosGtmQueue=window.compilacionCollecionesClientosGtmQueue||[],window.compilacionCollecionesClientosGtm=(()=>{const e={getByPath:(e,t)=>t.split(".").reduce((e,t)=>e&&void 0!==e[t]?e[t]:void 0,e),evalobjectParamater:(t,i)=>{if("string"==typeof t&&t.startsWith("@")){const n=t.slice(1);return e.getByPath(i,n)}return t}};let n=!1;const s={};let o=null,a=null;s.setEmitter=(e,t,r)=>{if(!o)return o=new i(e,t,r),n=o&&a,!0},s.setTracker=(e,t)=>null!==o&&(a?void 0:(a=new r([o],e,t),n=o&&a,!0)),s.tag=i=>{let r=i?.trackerConfig;if(!n&&!r)return!1;if(!n&&r&&(s.setEmitter(r.endpoint,r.flushSize,r.flushInterval),s.setTracker(r.trackerName,r.appName)),!n)return!1;const a=new t;if(!i.entity)return!1;if(a.setEntity(i.entity),!i.action)return!1;a.setAction(i.entity);let c=i.adjectives;Array.isArray(c)&&c.forEach(e=>{e.adjective?.length>0&&a.addAdjective(e.adjective)});let l=i.identifiers;Array.isArray(l)&&l.forEach(e=>{!e.name||e.name.length<1||!e.value||e.value.length<1||a.setIdentifier(e.name,e.value)});let f=i.contexts;Array.isArray(f)&&f.forEach(e=>{!e.key||e.key.length<1||!e.value||e.value.length<1||a.setContext(e.key,e.value)});let h=i.actor,m=i.actorIdentifiers;"string"==typeof h&&h.length>0&&(a.setActor(h),Array.isArray(m)&&m.forEach(e=>{!e.name||e.name.length<1||!e.value||e.value.length<1||a.setActorIdentifier(e.name,e.value)}));let u=i.references;Array.isArray(u)&&u.forEach(e=>{e.entity&&e.identifierName&&e.identifierValue&&a.setReference(e.entity,e.identifierName,e.identifierValue)});const d={compilacionCollecionesClientosGtmVariable_collectionConfig:(t,i)=>{let n=i.array;if(!n||!Array.isArray(n)||n.length<1)return!1;n.forEach(n=>{let r=e.evalobjectParamater(i.entity,n),s=e.evalobjectParamater(i.identifiername,n),o=e.evalobjectParamater(i.identifiervalue,n);if(!r||!s||!o)return;let a=t.setCollectionItem(r);t.setCollectionItemReference(r,a,s,o)})}};let p=i.collections;return Array.isArray(p)&&p.forEach(e=>{let t=e.collectionVariable,i=t.type;"function"==typeof d[i]&&d[i](a,t)}),o.track(a),!0};const c=()=>{const e=window.compilacionCollecionesClientosGtmQueue;let t=[];if(e&&Array.isArray(e)){for(;e.length>0;){const i=e.shift();if("function"!=typeof s[i.method])continue;!0!==s[i.method].apply(null,i.arguments)&&t.push(i)}window.compilacionCollecionesClientosGtmQueue=t}};return c(),{flush:c,purgeEvents:async()=>{if(o)return o.flush()}}})()}();
|
|
2
|
+
//# sourceMappingURL=browser.gtm.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.gtm.min.js","sources":["../src/utils/utils.js","../src/CollecionesEvent.js","../src/CollecionesEmitter.js","../src/CollecionesTracker.js","../src/CollecionesWebTracker.js","../src/browser.gtm.js"],"sourcesContent":["// helper 'private' functions\n\n\n/**\n * Encodes a string to Base64.\n * Uses browser or Node.js method depending on environment.\n * @param {string} str\n * @returns {string}\n */\nconst toBase64 = function (str) {\n if (typeof window !== 'undefined' && typeof window.btoa === 'function') {\n return window.btoa(unescape(encodeURIComponent(str)));\n } else {\n return Buffer.from(str, 'utf-8').toString('base64');\n }\n}\n\n/**\n * Decodes a Base64 string to UTF-8.\n * Uses browser or Node.js method depending on environment.\n * @param {string} b64\n * @returns {string}\n */\nconst fromBase64 = function (b64) {\n if (typeof window !== 'undefined' && typeof window.atob === 'function') {\n return decodeURIComponent(escape(window.atob(b64)));\n } else {\n return Buffer.from(b64, 'base64').toString('utf-8');\n }\n}\n\n/**\n * Collects browser-related context values like screen size, language, etc.\n * Returns an empty object if not in browser environment.\n * @returns {Object}\n */\nconst getBrowserContext = function() {\n if (typeof window === 'undefined' || typeof navigator === 'undefined') {\n return {};\n }\n return {\n hasFocus: document.hasFocus(),\n language: navigator.language,\n platform: navigator.platform,\n referrer: document.referrer,\n screenHeight: window.screen.height,\n screenWidth: window.screen.width,\n timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n url: window.location.href,\n userAgent: navigator.userAgent,\n viewportHeight: window.innerHeight,\n viewportWidth: window.innerWidth,\n };\n}\n\nconst formatToCamelCase = function(input) {\n return input\n .replace(/[^a-zA-Z0-9]+/g, ' ')\n .trim()\n .split(/\\s+/)\n .map((word, index) => {\n if (index === 0) return word;\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join('');\n}\n\nexport {\n fromBase64,\n formatToCamelCase,\n getBrowserContext,\n toBase64,\n};","/**\n * CollecionesEvent\n * -----------------\n * Base class representing a semantically structured event object.\n * Each event models a specific interaction with an entity, optionally performed by an actor,\n * and may reference related entities or include contextual metadata.\n *\n * Key features:\n * - Captures structured semantics: entity, action, actor, context, references\n * - Supports multiple identifiers for both the main entity and the actor\n * - Allows origin tagging for cross-context or cross-application references\n * - Supports referencing collections of entities or grouped data\n * - Includes timestamps and tracker/app metadata for auditability\n * - Fully serializable and deserializable via toJSON/fromJSON\n */\n\nimport {formatToCamelCase } from './utils/utils.js';\n\nclass CollecionesEvent {\n\n /**\n * Constructs a new CollecionesEvent with default structure and timestamps.\n * Initializes empty containers for semantic attributes such as:\n * - entity: the subject of the event\n * - adjectives: descriptors of the entity\n * - identifiers: identifiers of the entity\n * - action: what happened to the entity\n * - actor: who or what triggered the event (with identifiers in actorIdentifiers)\n * - context: environmental data related to the event\n * - references: external entities involved, optionally scoped by origin\n * - collections: groups of related entities\n * - meta: tracking metadata and timestamps\n */\n constructor() {\n // initialize event properties\n this.entity = '';\n this.adjevtives = [];\n this.identifiers = {};\n this.action = '';\n this.actor = {};\n this.actorIdentifiers = {};\n this.context = {};\n this.references = {};\n this.collections = {};\n // set default values\n this.meta = {\n eventFormat: 'CollecionesEvent',\n eventFormatVersion: '1'\n };\n this.meta.tracker = '';\n this.meta.app = '';\n this.meta.timestamps = {};\n this.meta.timestamps.clientDatetimeUtc = new Date().toISOString();\n if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.language) {\n this.meta.timestamps.clientDatetimeLocal = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();\n this.meta.timestamps.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n this.meta.timestamps.timeZoneOffset = new Date().getTimezoneOffset()\n } else {\n this.meta.timestamps.clientDatetimeLocal = new Date().toISOString();\n this.meta.timestamps.timeZone = 'UTC';\n }\n }\n\n /**\n * Returns the declared event format.\n * @returns {string} The format name (e.g. 'CollecionesEvent').\n */\n getEventFormat() {\n let v = this.meta?.eventFormat;\n return (typeof v !== 'undefined') ? v : '1';\n }\n\n /**\n * Returns the version of the event format.\n * @returns {string} The format version string.\n */\n getEventFormatVersion() {\n let v = this?.meta?.eventFormatVersion;\n return (typeof v !== 'undefined') ? v : 'CollecionesEvent';\n }\n\n /**\n * Overrides or supplements the event's timestamp fields with custom values.\n * @param {object} dateTimeObject - Key-value pairs to merge into the existing timestamp object.\n */\n overrideDatetime(dateTimeObject = {}) {\n for (const [key, value] of Object.entries(dateTimeObject)) {\n this.meta.timestamps[key] = value;\n }\n }\n\n /**\n * Sets the name of the tracker responsible for generating this event.\n * @param {string} name - Tracker name.\n */\n setTracker(name) {\n this.meta.tracker = name;\n }\n\n /**\n * Sets the name of the application that generated the event.\n * @param {string} name - Application name.\n */\n setAppName(name) {\n this.meta.appName = name;\n }\n\n /**\n * Sets the expected schema name for this event.\n * @param {string} schema - The name of the schema.\n */\n setSchema(schema) {\n if (typeof schema !== 'string') {\n throw new Error('Schema must be a string');\n }\n this.meta.schema = schema;\n }\n\n /**\n * Sets the entity (subject) of the event.\n * @param {string} entity - The entity name.\n */\n setEntity = function(entity) {\n this.entity = formatToCamelCase(entity);\n }\n \n /**\n * Defines the main action of the event (e.g., 'clicked').\n * @param {string} action - The action string.\n */\n setAction = function(action) {\n this.action = formatToCamelCase(action);\n }\n\n /**\n * Adds an adjective that describes the entity in more detail.\n * @param {string} adjective - An adjective string.\n */\n addAdjective = function(adjective) {\n if (typeof adjective !== 'string') {\n throw new Error('Adjective must be a string');\n }\n this.adjevtives.push(formatToCamelCase(adjective));\n }\n\n /**\n * Adds or updates an identifier for the primary entity.\n * Identifiers allow multiple keys to uniquely identify the entity.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n */\n setIdentifier = function(name, identifier) {\n if (typeof name !== 'string') {\n throw new Error('Identifier name must be a string');\n }\n this.identifiers[name] = identifier;\n }\n\n /**\n * Defines the name of the actor (who or what performed the action).\n * @param {string} name - Actor name (e.g., 'user', 'system').\n */\n setActor = function(name) {\n if (typeof name !== 'string') {\n throw new Error('Actor name must be a string');\n }\n this.actor.name = name;\n }\n\n /**\n * Adds or updates an identifier for the actor.\n * Supports multiple identifiers to uniquely identify the actor.\n * @param {string} name - Identifier key.\n * @param {*} identifier - Identifier value.\n */\n setActorIdentifier = function(name, identifier) {\n if (typeof name !== 'string') {\n throw new Error('Actor Identifier name must be a string');\n }\n this.actorIdentifiers[name] = identifier;\n }\n\n /**\n * Adds contextual information to the event.\n * Context can include any additional environmental or situational data.\n * @param {string} context - The key of the context field.\n * @param {*} value - The value of the context field.\n */\n setContext = function(context, value) {\n if (typeof context !== 'string') {\n throw new Error('Context must be a string');\n }\n this.context[context] = value;\n }\n\n /**\n * Alias for `setReference` for compatibility.\n * Declares an external entity referenced by this event.\n * @param {string} entity - The referenced entity name.\n * @param {string|null} origin - The origin application or context (optional).\n */\n setRefence = function(entity, origin=null) {\n return this.setReference(entity, origin);\n }\n\n /**\n * Declares an entity referenced by this event.\n * References may include multiple identifiers and an optional origin to scope the reference.\n * @param {string} entity - The referenced entity name.\n * @param {string|null} origin - The origin application or context (optional).\n */\n setReference = function(entity, origin=null) {\n if (typeof entity !== 'string') {\n throw new Error('Referenced entity must be a string');\n }\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.references[entity] === undefined) {\n this.references[entity] = {\n identifiers: {},\n origin\n };\n }\n }\n\n /**\n * Adds or updates an identifier for a referenced entity.\n * Ensures the reference is declared and sets the identifier under that reference.\n * @param {string} entity - The referenced entity name.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @param {string|null} origin - Optional origin context.\n */\n setRefenceIdentifier = function(entity, name, identifier, origin=null) {\n return this.setReferenceIdentifier(entity, name, identifier, origin);\n }\n\n /**\n * Adds or updates an identifier for a referenced entity.\n * @param {string} entity - The referenced entity name.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @param {string|null} origin - Optional origin context.\n */\n setReferenceIdentifier = function(entity, name, identifier, origin=null) {\n if (typeof entity !== 'string') {\n throw new Error('Referenced entity name must be a string');\n }\n if (typeof name !== 'string') {\n throw new Error('Actor Identifier name must be a string');\n }\n this.setRefence(entity, origin);\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.references[entity].identifiers[name] = identifier;\n }\n\n /**\n * Declares a collection of related entities for this event.\n * Collections group multiple related items and may include identifiers and origin metadata.\n * @param {string} entity - The collection name.\n * @param {string|null} origin - Optional origin identifier (e.g. system name).\n */\n setCollection = function(entity, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.collections[entity] == undefined) {\n this.collections[entity] = {\n items: [],\n identifiers: {},\n origin\n };\n }\n }\n\n /**\n * Adds a new item to a collection and returns its index key.\n * Items represent individual elements within the collection.\n * @param {string} entity - The name of the collection.\n * @returns {number} Index of the newly added item in the collection.\n */\n setCollectionItem = function(entity, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.setCollection(entity);\n this.collections[entity].items.push({});\n let itemKey = this.collections[entity].items.length - 1;\n return itemKey;\n }\n\n /**\n * Assigns a reference (identifier) to a specific item in a collection.\n * Useful for tagging individual collection elements with identifiers.\n * @param {string} entity - Collection name.\n * @param {number} itemKey - The index of the item in the collection.\n * @param {string} name - The identifier key.\n * @param {*} identifier - The identifier value.\n * @throws {Error} If the item does not exist at the given index.\n */\n setCollectionItemReference = function(entity, itemKey, name, identifier, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n this.setCollection(entity);\n if(typeof this.collections[entity].items[itemKey] !== 'object') {\n throw new Error('bad bad man, the collection key does not exists');\n }\n this.collections[entity].items[itemKey][name] = identifier;\n }\n \n /**\n * Sets a static identifier that applies to the entire collection.\n * These identifiers describe the collection as a whole.\n * @param {string} entity - Collection name.\n * @param {string} name - Identifier key.\n * @param {*} identifier - Identifier value.\n */\n setCollectionIdentifier = function(entity, name, identifier, origin=null) {\n entity = formatToCamelCase(entity);\n if (origin !== null) {\n entity = `${origin}.${entity}`;\n }\n if(this.collections[entity] == undefined) {\n this.collections[entity] = {};\n }\n this.collections[entity].identifiers[name] = identifier;\n }\n\n /**\n * Serializes the event instance to a plain object suitable for transport or storage.\n * The output includes all semantic fields and metadata.\n * @returns {object} A plain JavaScript object representing the event.\n */\n toJSON() {\n return {\n class: 'CollecionesEvent',\n entity: this.entity,\n adjectives: this.adjevtives,\n identifiers: this.identifiers,\n action: this.action,\n actor: this.actor,\n actorIdentifiers: this.actorIdentifiers,\n actorIds: this.actorIds,\n context: this.context,\n references: this.references,\n meta: this.meta,\n collections: this.collections\n };\n }\n\n /**\n * Recreates a CollecionesEvent instance from a plain object.\n * Used when deserializing events from storage or network transport.\n * @param {object} obj - The input object containing event data.\n * @returns {CollecionesEvent} A rehydrated event instance.\n * @throws {Error} If the class type is not 'CollecionesEvent'.\n */\n static fromJSON(obj) { \n if (!obj || obj.class !== 'CollecionesEvent') {\n throw new Error('Invalid or missing event class type'); \n } \n const instance = new CollecionesEvent();\n instance.entity = obj.entity;\n instance.adjevtives = obj.adjectives || [];\n instance.identifiers = obj.identifiers || {};\n instance.action = obj.action;\n instance.actor = obj.actor;\n instance.actorIdentifiers = obj.actorIdentifiers;\n instance.actorIds = obj.actorIds;\n instance.context = obj.context || {};\n instance.references = obj.references || {};\n instance.meta = obj.meta || {};\n instance.collections = obj.collections || {};\n return instance;\n }\n \n}\n\nexport default CollecionesEvent;","import { fromBase64, toBase64 } from './utils/utils.js';\nimport CollecionesEvent from './CollecionesEvent.js';\n\n/**\n * CollecionesEmitter\n * -------------------\n * This class collects and sends event objects to a remote endpoint (e.g., an event collector API).\n * It is used in both client- and server-side tracking scenarios, typically in combination with\n * CollecionesEvent or subclasses like CollecionesBaseEvent.\n *\n * Behavior:\n * - Events are buffered via `.track()` or `.trackAsync()`.\n * - If the number of buffered events reaches `flushSize`, the buffer is automatically flushed.\n * - If `flushInterval` is provided, the buffer is flushed at a fixed interval.\n * - Flushing serializes each event using `.toJSON()`, encodes it with base64, and posts\n * the resulting array to the configured endpoint.\n *\n * Example usage:\n * const emitter = new CollecionesEmitter('/track', 5, 10000);\n * emitter.track(new CollecionesEvent());\n *\n * Note:\n * This class is stateful. To stop periodic flushing, call `.stopTimer()` when the emitter is no longer in use.\n */\nclass CollecionesEmitter {\n\n /**\n * Initializes the emitter with buffering settings.\n * @param {string} [endpoint='/collect'] - The URL to send events to.\n * @param {number} [flushSize=10] - Number of events to buffer before flushing.\n * @param {number|boolean} [flushInterval=false] - Time in ms to flush events periodically.\n */\n constructor(endpoint = '/collect', flushSize = 10, flushInterval = false) {\n this.endpoint = endpoint;\n this.flushInterval = flushInterval;\n this.flushSize = flushSize;\n this.buffer = [];\n this.timer = null;\n this.lastPayload = null;\n }\n\n /**\n * Starts the flush timer if a valid interval is set.\n * @returns {void}\n */\n startTimer() {\n this.stopTimer();\n if (typeof this.flushInterval == 'number' && this.flushInterval > 0) {\n this.timer = setInterval(() => this.flush(), this.flushInterval);\n }\n }\n\n /**\n * Starts the flush timer only if not already running.\n * @returns {void}\n */\n startTimerIfStopped() {\n if (!this.timer) {\n this.startTimer();\n }\n }\n\n /**\n * Stops the active flush timer.\n * @returns {void}\n */\n stopTimer() {\n if (this.timer) {\n clearInterval(this.timer);\n }\n this.timer = null;\n }\n\n /**\n * Adds an event to the buffer and flushes if threshold is reached.\n * Validates that the event is an instance of CollecionesEvent to ensure correct event type.\n * @param {CollecionesEvent} event - Event instance to be tracked.\n * @throws {Error} Throws if event is not a CollecionesEvent instance.\n * @returns {void}\n */\n track(event) {\n if (!(event instanceof CollecionesEvent)) {\n throw new Error('Event must be an instance of CollecionesEvent');\n }\n this.trackAsync(event);\n }\n\n /**\n * Asynchronously adds an event and flushes if the buffer size is exceeded.\n * Validates that the event is an instance of CollecionesEvent to ensure correct event type.\n * @param {CollecionesEvent} event - Event instance to be tracked asynchronously.\n * @throws {Error} Throws if event is not a CollecionesEvent instance.\n * @returns {Promise<void>} Resolves when event is added and flush triggered if needed.\n */\n async trackAsync(event) {\n if (!(event instanceof CollecionesEvent)) {\n throw new Error('Event must be an instance of CollecionesEvent');\n }\n this.startTimerIfStopped();\n this.buffer.push(event);\n return (this.buffer.length >= this.flushSize) ? this.flush() : Promise.resolve();\n }\n\n /**\n * Sends all buffered events in a single POST request to the server.\n * Each event is serialized via `.toJSON()` and encoded as a base64 string.\n * Response status is checked for HTTP success; errors are logged but not thrown.\n *\n * @returns {Promise<boolean|undefined>} Resolves true if flush was triggered, or undefined if buffer was empty.\n */\n async flush() {\n if (this.buffer.length === 0) return;\n this.stopTimer();\n const body = this.buildBody();\n this.lastPayload = body;\n this.buffer = [];\n try {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json'\n },\n body\n });\n if (!response.ok) {\n console.log(`Failed to send events: ${response.statusText}`);\n }\n return true;\n } catch (error) { \n console.log(`Network error sending events: ${error.message}`);\n } \n }\n\n /**\n * Builds a POST-ready payload from the current buffer, without clearing it.\n * @returns {string} JSON string of base64-encoded serialized events.\n */\n buildBody() {\n return JSON.stringify(this.buffer.map(e => toBase64(JSON.stringify(e.toJSON()))));\n }\n\n}\n\nexport default CollecionesEmitter;","import CollecionesEvent from './CollecionesEvent.js';\n\n/**\n * Tracks events by enriching them with shared identifiers and routing through configured emitters.\n */\nclass CollecionesTracker {\n\n /**\n * Constructs a new tracker instance.\n * @param {Array} emitters - Array of emitter instances responsible for sending events.\n * @param {string} trackerName - Name identifying this tracker.\n * @param {string} appName - Name of the application generating events.\n */\n constructor(emitters, trackerName, appName) {\n this.emitters = emitters;\n this.trackerName = trackerName;\n this.appName = appName;\n }\n\n /**\n * Sends an event to all emitters after enriching it with identifiers and metadata.\n * @param {CollecionesEvent} collecionesEvent - The event to be sent.\n * @throws {Error} If the input is not an instance of CollecionesEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n collecionesEvent.setTracker(this.trackerName);\n collecionesEvent.setAppName(this.appName); \n this.emitters.forEach(element => {\n element.track(collecionesEvent, this.trackerName, this.appName);\n });\n }\n}\n\nexport default CollecionesTracker;","import CollecionesEvent from './CollecionesEvent.js';\nimport CollecionesTracker from './CollecionesTracker.js';\nimport { getBrowserContext } from './utils/utils.js';\n\n/**\n * Web-specific tracker that enriches events with browser context before sending them.\n * Extends the base CollecionesTracker.\n */\nclass CollecionesWebTracker extends CollecionesTracker {\n /**\n * Creates a new instance of CollecionesWebTracker.\n * @param {Array} emitters - A list of emitter instances used to send the event.\n * @param {string} trackerName - The name of the tracker.\n * @param {string} appName - The name of the application generating events.\n */\n constructor(emitters, trackerName, appName) {\n super(emitters, trackerName, appName);\n }\n\n /**\n * Tracks an event, enriching it with browser context information.\n * @param {CollecionesEvent} collecionesEvent - The event object to track.\n * @throws {Error} If the event is not an instance of CollecionesEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n collecionesEvent.setContext('browserContext', getBrowserContext());\n super.track(collecionesEvent); \n }\n}\n\nexport default CollecionesWebTracker;","import CollecionesEmitter from './CollecionesEmitter.js';\nimport CollecionesWebTracker from './CollecionesWebTracker.js';\nimport CollecionesEvent from './CollecionesEvent.js';\n\n\nwindow.compilacionCollecionesClientosGtmQueue = window.compilacionCollecionesClientosGtmQueue || [];\nwindow.compilacionCollecionesClientosGtm = (() => {\n const utils = {\n getByPath: (obj, path) => {\n return path.split('.').reduce((acc, key) => (acc && acc[key] !== undefined) ? acc[key] : undefined, obj);\n },\n evalobjectParamater: (parameter, object) => {\n if (typeof parameter === 'string' && parameter.startsWith('@')) {\n const path = parameter.slice(1);\n return utils.getByPath(object, path);\n }\n return parameter;\n }\n };\n let initialized = false;\n const methods = {};\n let emitter = null;\n let tracker = null;\n\n methods.setEmitter = (endpoint, flushSize, flushInterval) => {\n if (emitter) {\n return;\n }\n emitter = new CollecionesEmitter(endpoint, flushSize, flushInterval);\n initialized = (emitter && tracker);\n return true;\n };\n\n methods.setTracker = (trackerName, appName) => {\n if (emitter === null) {\n return false;\n }\n if (tracker) {\n return;\n }\n tracker = new CollecionesWebTracker([emitter], trackerName, appName);\n initialized = (emitter && tracker);\n return true;\n };\n\n methods.tag = ( gtmEventData ) => {\n let trackerConfig = gtmEventData?.trackerConfig;\n if (!initialized && !trackerConfig) {\n return false;\n } else if (!initialized && trackerConfig) {\n methods.setEmitter(trackerConfig.endpoint, trackerConfig.flushSize, trackerConfig.flushInterval);\n methods.setTracker(trackerConfig.trackerName, trackerConfig.appName);\n }\n if (!initialized) {\n return false;\n }\n const event = new CollecionesEvent();\n // entity\n if (!gtmEventData.entity) {\n return false;\n }\n // action\n event.setEntity(gtmEventData.entity);\n if (!gtmEventData.action) {\n return false;\n }\n event.setAction(gtmEventData.entity);\n // adjectives \n let adjectives = gtmEventData.adjectives;\n if (Array.isArray(adjectives)) {\n adjectives.forEach(adjective => {\n if (adjective.adjective?.length > 0) {\n event.addAdjective(adjective.adjective);\n }\n });\n }\n // identifiers\n let identifiers = gtmEventData.identifiers;\n if (Array.isArray(identifiers)) {\n identifiers.forEach(identifier => {\n if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {\n return;\n }\n event.setIdentifier(identifier.name, identifier.value);\n });\n }\n // contexts\n let contexts = gtmEventData.contexts;\n if (Array.isArray(contexts)) {\n contexts.forEach(context => {\n if (!context.key || context.key.length < 1 || !context.value || context.value.length < 1) {\n return;\n }\n event.setContext(context.key, context.value);\n });\n }\n // actor\n let actor = gtmEventData.actor;\n let actorIdentifiers = gtmEventData.actorIdentifiers;\n if (typeof actor === 'string' && actor.length > 0) {\n event.setActor(actor);\n // actorIdentifiers\n if (Array.isArray(actorIdentifiers)) {\n actorIdentifiers.forEach(identifier => {\n if (!identifier.name || identifier.name.length < 1 || !identifier.value || identifier.value.length < 1) {\n return;\n }\n event.setActorIdentifier(identifier.name, identifier.value);\n });\n }\n }\n // References\n let references = gtmEventData.references;\n if (Array.isArray(references)) {\n references.forEach(ref => {\n if (!ref.entity || !ref.identifierName || !ref.identifierValue) {\n return;\n }\n event.setReference(ref.entity, ref.identifierName, ref.identifierValue);\n });\n }\n // collections\n const collectionInterpreter = {\n 'compilacionCollecionesClientosGtmVariable_collectionConfig': (event, collectionVariable) => {\n let array = collectionVariable.array;\n if (!array || !Array.isArray(array) || array.length < 1) {\n return false;\n }\n array.forEach(item => {\n let entity = utils.evalobjectParamater(collectionVariable.entity, item);\n let identifierName = utils.evalobjectParamater(collectionVariable.identifiername, item);\n let identifierValue = utils.evalobjectParamater(collectionVariable.identifiervalue, item);\n if (!entity || !identifierName || !identifierValue) {\n return;\n }\n let collectionKey = event.setCollectionItem(entity);\n event.setCollectionItemReference(entity, collectionKey, identifierName, identifierValue);\n });\n }\n }\n let collections = gtmEventData.collections;\n if (Array.isArray(collections)) {\n collections.forEach(collection => {\n let collectionVariable = collection.collectionVariable;\n let type = collectionVariable.type;\n if (typeof collectionInterpreter[type] === 'function') {\n collectionInterpreter[type](event, collectionVariable);\n }\n });\n }\n // \n emitter.track(event);\n return true;\n };\n\n const flush = () => {\n const q = window.compilacionCollecionesClientosGtmQueue;\n let rest = [];\n if (!q || !Array.isArray(q)) return;\n while (q.length > 0) {\n const args = q.shift();\n if (!(typeof methods[args.method] === 'function')) {\n continue\n }\n let result = methods[args.method].apply(null, args.arguments);\n if (result === true) {\n continue\n }\n rest.push(args);\n }\n window.compilacionCollecionesClientosGtmQueue = rest;\n };\n\n const purgeEvents = async() => {\n if (!emitter) {\n return;\n }\n return emitter.flush();\n };\n flush();\n return {\n flush,\n purgeEvents\n };\n})();\n\n\n/*\ntrackerConfig.endpoint\n*/"],"names":["formatToCamelCase","input","replace","trim","split","map","word","index","charAt","toUpperCase","slice","toLowerCase","join","CollecionesEvent","constructor","this","entity","adjevtives","identifiers","action","actor","actorIdentifiers","context","references","collections","meta","eventFormat","eventFormatVersion","tracker","app","timestamps","clientDatetimeUtc","Date","toISOString","window","navigator","language","clientDatetimeLocal","now","getTimezoneOffset","timeZone","Intl","DateTimeFormat","resolvedOptions","timeZoneOffset","getEventFormat","v","getEventFormatVersion","overrideDatetime","dateTimeObject","key","value","Object","entries","setTracker","name","setAppName","appName","setSchema","schema","Error","setEntity","setAction","addAdjective","adjective","push","setIdentifier","identifier","setActor","setActorIdentifier","setContext","setRefence","origin","setReference","undefined","setRefenceIdentifier","setReferenceIdentifier","setCollection","items","setCollectionItem","length","setCollectionItemReference","itemKey","setCollectionIdentifier","toJSON","class","adjectives","actorIds","fromJSON","obj","instance","CollecionesEmitter","endpoint","flushSize","flushInterval","buffer","timer","lastPayload","startTimer","stopTimer","setInterval","flush","startTimerIfStopped","clearInterval","track","event","trackAsync","Promise","resolve","body","buildBody","response","fetch","method","credentials","headers","ok","console","log","statusText","error","message","JSON","stringify","e","toBase64","str","btoa","unescape","encodeURIComponent","Buffer","from","toString","CollecionesTracker","emitters","trackerName","collecionesEvent","forEach","element","CollecionesWebTracker","super","hasFocus","document","platform","referrer","screenHeight","screen","height","screenWidth","width","timezone","url","location","href","userAgent","viewportHeight","innerHeight","viewportWidth","innerWidth","compilacionCollecionesClientosGtmQueue","compilacionCollecionesClientosGtm","utils","getByPath","path","reduce","acc","evalobjectParamater","parameter","object","startsWith","initialized","methods","emitter","setEmitter","tag","gtmEventData","trackerConfig","Array","isArray","contexts","ref","identifierName","identifierValue","collectionInterpreter","compilacionCollecionesClientosGtmVariable_collectionConfig","collectionVariable","array","item","identifiername","identifiervalue","collectionKey","collection","type","q","rest","args","shift","apply","arguments","purgeEvents","async"],"mappings":"yBASA,MA8CMA,EAAoB,SAASC,GACjC,OAAOA,EACJC,QAAQ,iBAAkB,KAC1BC,OACAC,MAAM,OACNC,IAAI,CAACC,EAAMC,IACI,IAAVA,EAAoBD,EACjBA,EAAKE,OAAO,GAAGC,cAAgBH,EAAKI,MAAM,GAAGC,eAErDC,KAAK,GACV,EC/CA,MAAMC,EAeF,WAAAC,GAEIC,KAAKC,OAAS,GACdD,KAAKE,WAAa,GAClBF,KAAKG,YAAc,CAAE,EACrBH,KAAKI,OAAS,GACdJ,KAAKK,MAAQ,CAAE,EACfL,KAAKM,iBAAmB,CAAE,EAC1BN,KAAKO,QAAU,CAAE,EACjBP,KAAKQ,WAAa,CAAE,EACpBR,KAAKS,YAAc,CAAE,EAErBT,KAAKU,KAAO,CACRC,YAAa,mBACbC,mBAAoB,KAExBZ,KAAKU,KAAKG,QAAU,GACpBb,KAAKU,KAAKI,IAAM,GAChBd,KAAKU,KAAKK,WAAa,CAAE,EACzBf,KAAKU,KAAKK,WAAWC,mBAAoB,IAAIC,MAAOC,cAC9B,oBAAXC,QAA+C,oBAAdC,WAA6BA,UAAUC,UAC/ErB,KAAKU,KAAKK,WAAWO,oBAAsB,IAAIL,KAAKA,KAAKM,MAAyC,KAAjC,IAAIN,MAAOO,qBAA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OA,EAAQvE,SAOlB,EAlL0C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# GTM Development Guide
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
Google Tag Manager (GTM) development can be challenging due to its strict sandbox environment and CORS limitations. This guide explains how to set up a local development workflow for GTM integrations using a local proxy and HTTPS certificates.
|
|
5
|
+
|
|
6
|
+
## Setup Overview
|
|
7
|
+
- Use a local HTTPS proxy to serve your GTM-compatible JavaScript bundle.
|
|
8
|
+
- Generate and trust local SSL certificates for development.
|
|
9
|
+
- Update your hosts file to use a custom domain for local testing.
|
|
10
|
+
- Run your proxy server and build process in watch mode for rapid development.
|
|
11
|
+
|
|
12
|
+
## Local Development Steps
|
|
13
|
+
|
|
14
|
+
### 1. Install mkcert (for local HTTPS certificates)
|
|
15
|
+
Install mkcert to easily generate trusted SSL certificates for your local domain.
|
|
16
|
+
```bash
|
|
17
|
+
brew install mkcert
|
|
18
|
+
```
|
|
19
|
+
If you use Firefox, also run:
|
|
20
|
+
```bash
|
|
21
|
+
brew install nss # Needed for Firefox, optional otherwise
|
|
22
|
+
mkcert -install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. Generate Certificates
|
|
26
|
+
```bash
|
|
27
|
+
mkcert dit-is-een-test.imoscoop.be
|
|
28
|
+
```
|
|
29
|
+
This will create two files:
|
|
30
|
+
- `dit-is-een-test.imoscoop.be.pem` (certificate)
|
|
31
|
+
- `dit-is-een-test.imoscoop.be-key.pem` (private key)
|
|
32
|
+
|
|
33
|
+
### 3. Update Your Hosts File
|
|
34
|
+
Add your local domain to `/etc/hosts` so it points to localhost:
|
|
35
|
+
```bash
|
|
36
|
+
sudo nano /etc/hosts
|
|
37
|
+
```
|
|
38
|
+
Add this line:
|
|
39
|
+
```
|
|
40
|
+
127.0.0.1 dit-is-een-test.imoscoop.be
|
|
41
|
+
```
|
|
42
|
+
Save and exit (`Ctrl+O`, `Enter`, then `Ctrl+X`).
|
|
43
|
+
|
|
44
|
+
### 4. Set Up the Local Proxy Server
|
|
45
|
+
A local HTTPS proxy is required to bypass CORS and serve your GTM bundle as if it were hosted remotely. The proxy server is located at [`./test/gtm/gtm-proxy.js`](./test/gtm/gtm-proxy.js).
|
|
46
|
+
|
|
47
|
+
Update the certificate paths in the proxy script if needed:
|
|
48
|
+
```javascript
|
|
49
|
+
const options = {
|
|
50
|
+
key: fs.readFileSync('./dit-is-een-test.imoscoop.be-key.pem'),
|
|
51
|
+
cert: fs.readFileSync('./dit-is-een-test.imoscoop.be.pem'),
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 5. Build and Run the Proxy
|
|
56
|
+
Make sure your GTM bundle is built and available in the `dist` folder as `browser.gtm.js`.
|
|
57
|
+
|
|
58
|
+
To start the proxy and watch for changes:
|
|
59
|
+
```bash
|
|
60
|
+
npm run dev:gtm
|
|
61
|
+
```
|
|
62
|
+
This script will run Rollup in watch mode and start the proxy server.
|
|
63
|
+
|
|
64
|
+
### 6. Reference Your Local Bundle in GTM
|
|
65
|
+
In GTM, reference your local bundle using the custom domain:
|
|
66
|
+
```
|
|
67
|
+
https://dit-is-een-test.imoscoop.be/my-plugin.js
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Note:**
|
|
71
|
+
- You may get a browser warning about the self-signed certificate; proceed anyway for local development.
|
|
72
|
+
- Make sure the proxy server is running and the bundle exists in the `dist` folder.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
This setup allows you to develop and test GTM integrations locally with full HTTPS and CORS support, closely mimicking a production environment.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Google Tag Manager (GTM) integration: sandbox, architecture, and approach
|
|
2
|
+
|
|
3
|
+
## Introduction to GTM and the sandbox environment
|
|
4
|
+
Google Tag Manager (GTM) is a platform that allows you to easily manage scripts and tags on your website without directly editing the codebase. However, GTM provides a so-called "sandbox" environment for custom templates and scripts. This sandbox is extremely limited:
|
|
5
|
+
- Only pure ES5 JavaScript is allowed (no ES6, no arrow functions, no modern syntax).
|
|
6
|
+
- Many standard JavaScript methods and objects are unavailable or behave differently.
|
|
7
|
+
- You cannot import or dynamically load external modules.
|
|
8
|
+
- Some JavaScript features (such as the `arguments` object or array methods) do not work as in a normal browser.
|
|
9
|
+
|
|
10
|
+
## Why only a minimal bridge in GTM?
|
|
11
|
+
Due to these limitations, it is not feasible to run complex logic or modern libraries directly in GTM Custom Templates. Therefore, it is best practice to implement only a minimal bridge in GTM:
|
|
12
|
+
- The GTM code contains as little logic as possible.
|
|
13
|
+
- The GTM code acts as a relay to the browser window.
|
|
14
|
+
- All real logic and processing happens outside GTM, in a full-featured JavaScript environment.
|
|
15
|
+
|
|
16
|
+
## Architecture: queue bridge and injection
|
|
17
|
+
The chosen architecture consists of three parts:
|
|
18
|
+
1. **Queue in the browser window:**
|
|
19
|
+
- A queue array is created on the window object.
|
|
20
|
+
- This queue collects all commands and data from GTM.
|
|
21
|
+
2. **GTM bridge function:**
|
|
22
|
+
- In GTM, a function is placed that adds items to the queue (for example, using a simple for-loop over arguments).
|
|
23
|
+
- This bridge is intentionally kept as simple as possible to guarantee compatibility.
|
|
24
|
+
3. **InjectScript with compilacion:**
|
|
25
|
+
- The full compilacion library is loaded in the browser via an injectScript.
|
|
26
|
+
- This library reads the queue, processes the commands, and handles everything further.
|
|
27
|
+
|
|
28
|
+
**Summary:**
|
|
29
|
+
- GTM is only a bridge, not logic.
|
|
30
|
+
- The browser (with compilacion) does the real work.
|
|
31
|
+
- This approach ensures maximum compatibility and flexibility.
|
package/docs/gtm.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Google Tag Manager (GTM) integration: sandbox, architecture, and approach
|
|
2
|
+
|
|
3
|
+
## Introduction to GTM and the sandbox environment
|
|
4
|
+
Google Tag Manager (GTM) is a platform that allows you to easily manage scripts and tags on your website without directly editing the codebase. However, GTM provides a so-called "sandbox" environment for custom templates and scripts. This sandbox is extremely limited:
|
|
5
|
+
- Only pure ES5 JavaScript is allowed (no ES6, no arrow functions, no modern syntax).
|
|
6
|
+
- Many standard JavaScript methods and objects are unavailable or behave differently.
|
|
7
|
+
- You cannot import or dynamically load external modules.
|
|
8
|
+
- Some JavaScript features (such as the `arguments` object or array methods) do not work as in a normal browser.
|
|
9
|
+
|
|
10
|
+
## Why only a minimal bridge in GTM?
|
|
11
|
+
Due to these limitations, it is not feasible to run complex logic or modern libraries directly in GTM Custom Templates. Therefore, it is best practice to implement only a minimal bridge in GTM:
|
|
12
|
+
- The GTM code contains as little logic as possible.
|
|
13
|
+
- The GTM code acts as a relay to the browser window.
|
|
14
|
+
- All real logic and processing happens outside GTM, in a full-featured JavaScript environment.
|
|
15
|
+
|
|
16
|
+
## Architecture: queue bridge and injection
|
|
17
|
+
The chosen architecture consists of three parts:
|
|
18
|
+
1. **Queue in the browser window:**
|
|
19
|
+
- A queue array is created on the window object.
|
|
20
|
+
- This queue collects all commands and data from GTM.
|
|
21
|
+
2. **GTM bridge function:**
|
|
22
|
+
- In GTM, a function is placed that adds items to the queue (for example, using a simple for-loop over arguments).
|
|
23
|
+
- This bridge is intentionally kept as simple as possible to guarantee compatibility.
|
|
24
|
+
3. **InjectScript with compilacion:**
|
|
25
|
+
- The full compilacion library is loaded in the browser via an injectScript.
|
|
26
|
+
- This library reads the queue, processes the commands, and handles everything further.
|
|
27
|
+
|
|
28
|
+
**Summary:**
|
|
29
|
+
- GTM is only a bridge, not logic.
|
|
30
|
+
- The browser (with compilacion) does the real work.
|
|
31
|
+
- This approach ensures maximum compatibility and flexibility.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilacion/colleciones-clientos",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"watch:build": "rollup -c --watch",
|
|
17
17
|
"start:server": "node ./test/webclient/devServer.js",
|
|
18
18
|
"dev": "npm run build:package && npm run start:server",
|
|
19
|
+
"dev:gtm": "node ./test/gtm/gtm-proxy.js",
|
|
19
20
|
"prepublishOnly": "npm run build:package"
|
|
20
21
|
},
|
|
21
22
|
"author": "Maxime Passenier",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
37
38
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
38
39
|
"@rollup/plugin-terser": "^0.4.4",
|
|
40
|
+
"jsdom": "^26.1.0",
|
|
39
41
|
"rollup": "^4.40.0",
|
|
40
42
|
"vitest": "^3.1.2"
|
|
41
43
|
}
|