@compilacion/colleciones-clientos 1.0.12 → 2.0.1
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 +45 -83
- package/dist/collecionesClientos.iife.js +433 -345
- package/dist/collecionesClientos.iife.js.map +1 -1
- package/dist/index.cjs +433 -345
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +433 -344
- package/dist/index.mjs.map +1 -1
- package/docs/architecture.md +50 -0
- package/docs/concept.md +65 -0
- package/docs/dsl.md +92 -0
- package/docs/emitterAndTracker.md +63 -0
- package/docs/events.md +68 -0
- package/package.json +4 -3
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/utils/utils.js","../src/CollecionesBaseEvent.js","../src/CollecionesEmitter.js","../src/CollecionesTracker.js","../src/CollecionesWebTracker.js","../src/CollecionesEvent.js","../node_modules/uuid/dist/esm-browser/stringify.js","../node_modules/uuid/dist/esm-browser/rng.js","../node_modules/uuid/dist/esm-browser/native.js","../node_modules/uuid/dist/esm-browser/v4.js","../src/CollecionesSemanticEvent.js","../src/CollecionesSemanticCollectionEvent.js"],"sourcesContent":["// helper 'private' functions\n/**\n * Converts a snake_case string to camelCase.\n * Removes non-ASCII characters.\n * @param {string} str\n * @returns {string}\n */\nconst underscoreToCamelCase = function (str) {\n str = str.replace(/[^\\x00-\\x7F_]/g, '');\n return str\n .split('_')\n .map((word, index) => {\n if (index === 0) {\n return word;\n }\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join('');\n}\n\n/**\n * Formats adjectives by converting them to camelCase strings.\n * Accepts a single string or an array of strings.\n * @param {string|string[]|undefined} adjectiveParameter\n * @returns {string[]|undefined}\n */\nconst formatAdjectives = function (adjectiveParameter) {\n const errorMsg = new Error('Adjective must be a string, an array of strings, or undefined');\n if (typeof adjectiveParameter === 'undefined') {\n return undefined;\n }\n if (typeof adjectiveParameter === 'string') {\n return [underscoreToCamelCase(adjectiveParameter)];\n }\n if (Array.isArray(adjectiveParameter) && adjectiveParameter.every(item => typeof item === 'string')) {\n return adjectiveParameter.map(adjective => underscoreToCamelCase(adjective));\n }\n throw errorMsg;\n}\n\n/**\n * Converts an array of adjective strings to a dot-prefixed, dot-separated string.\n * Removes duplicates and sorts alphabetically.\n * @param {string[]} adjective\n * @returns {string|undefined}\n */\nconst stringifyAdjectives = function (adjective) {\n if (!Array.isArray(adjective) || adjective.length === 0) {\n return undefined;\n }\n const uniqueSorted = [...new Set(adjective)].sort();\n return '.' + uniqueSorted.join('.');\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\nexport {\n formatAdjectives,\n fromBase64,\n getBrowserContext,\n stringifyAdjectives,\n toBase64,\n underscoreToCamelCase\n};","import { toBase64 } from './utils/utils.js';\n\n/**\n * Base class representing a structured event with timestamp, identifiers, and data fields.\n */\nclass CollecionesBaseEvent {\n\n /**\n * Constructs a new event with default metadata and timestamps.\n */\n constructor() {\n this.eventName = '';\n this.data = {};\n this.data.meta = {\n eventFormat: 'CollecionesBaseEvent',\n eventFormatVersion: '1'\n };\n const now = new Date();\n this.data.timestamps = {};\n this.data.timestamps.clientDatetimeUtc = new Date().toISOString();\n if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.language) {\n this.data.timestamps.clientDatetimeLocal = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();\n this.data.timestamps.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n this.data.timestamps.timeZoneOffset = new Date().getTimezoneOffset()\n } else {\n this.data.timestamps.clientDatetimeLocal = new Date().toISOString();\n this.data.timestamps.timeZone = 'UTC';\n }\n }\n\n /**\n * Sets the event name.\n * @param {string} name\n */\n setEventName(name) {\n this.eventName = name;\n }\n\n /**\n * Returns the event name.\n * @returns {string}\n */\n getEventName() {\n return this.eventName;\n }\n\n /**\n * Gets the format of the event.\n * @returns {string}\n */\n getEventFormat() {\n let v = this.data?.meta?.eventFormat;\n return (typeof v !== 'undefined') ? v : '1';\n }\n\n /**\n * Gets the version of the event format.\n * @returns {string}\n */\n getEventFormatVersion() {\n let v = this.data?.meta?.eventFormatVersion;\n return (typeof v !== 'undefined') ? v : 'CollecionesBaseEvent';\n }\n\n /**\n * Replaces the entire data object.\n * @param {object} data\n */\n setData(data) {\n this.data = data;\n }\n\n /**\n * Adds a field to the event's custom fields section.\n * @param {string} name\n * @param {*} value\n */\n addAttribute(name, value) {\n return this.addField(name, value);\n }\n\n /**\n * Adds a key-value pair to the custom fields.\n * @param {string} name\n * @param {*} value\n */\n addField(name, value) {\n if (typeof this.data.fields !== 'object' || this.data.fields === null) {\n this.data.fields = {};\n }\n this.data.fields[name] = value;\n }\n\n /**\n * Sets the name of the tracker used to generate the event.\n * @param {string} name\n */\n setTracker(name) {\n this.data.tracker = name;\n }\n\n /**\n * Sets the name of the application that created the event.\n * @param {string} name\n */\n setAppName(name) {\n this.data.appName = name;\n }\n\n /**\n * Adds multiple identifiers from an object.\n * @param {object} param\n */\n convertParamIdentifiers(param) {\n if (typeof param === 'object' && param !== null && !Array.isArray(param)) {\n for (const [key, value] of Object.entries(param)) {\n this.addIdentifier(key, value);\n }\n }\n }\n\n /**\n * Adds a single identifier to the event.\n * @param {string} name\n * @param {*} value\n */\n addIdentifier(name, value) {\n if (typeof this.data.identifiers !== 'object' || this.data.identifiers === null) {\n this.data.identifiers = {};\n }\n this.data.identifiers[name] = value;\n }\n\n /**\n * Constructs the postable event object with metadata and encoded payload.\n * @returns {object}\n */\n getPostObject() {\n this.data.timestamps.sendDatetimeUtc = new Date().toISOString();\n this.data.timestamps.sendDatetimeLocal = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();\n return {\n eventname: this.getEventName(),\n eventFormat: this.getEventFormat(),\n eventFormatVersion: this.getEventFormatVersion(),\n payload: toBase64(this.getPayload())\n };\n }\n\n /**\n * Overrides or extends the timestamp fields of the event.\n * @param {object} dateTimeObject\n */\n overrideDatetime(dateTimeObject = {}) {\n for (const [key, value] of Object.entries(dateTimeObject)) {\n this.data.timestamps[key] = value;\n }\n }\n\n /**\n * Serializes the event data to a JSON string.\n * @returns {string}\n */\n getPayload() {\n return JSON.stringify(this.data);\n }\n\n}\n\nexport default CollecionesBaseEvent;","import CollecionesBaseEvent from './CollecionesBaseEvent.js';\n\n/**\n * Emitter class responsible for batching and sending events to a configured endpoint.\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 }\n\n /**\n * Starts the flush timer if a valid interval is set.\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 */\n startTimerIfStopped() {\n if (!this.timer) {\n this.startTimer();\n }\n }\n\n /**\n * Stops the active flush timer.\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 * @param {CollecionesBaseEvent} event\n */\n track(event) {\n if (!(event instanceof CollecionesBaseEvent)) {\n throw new Error('Event must be an instance of CollecionesBaseEvent');\n }\n this.trackAsync(event);\n }\n\n /**\n * Asynchronously adds an event and flushes if the buffer size is exceeded.\n * @param {CollecionesBaseEvent} event\n * @returns {Promise<void>}\n */\n async trackAsync(event) {\n if (!(event instanceof CollecionesBaseEvent)) {\n throw new Error('Event must be an instance of CollecionesBaseEvent');\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 the buffered events to the server and clears the buffer.\n * @returns {Promise<boolean|undefined>}\n */\n async flush() {\n if (this.buffer.length === 0) return;\n const eventsToSend = [...this.buffer];\n this.buffer = [];\n let postPayload = [];\n eventsToSend.forEach((e) => {\n postPayload.push( e.getPostObject() );\n });\n this.stopTimer();\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: JSON.stringify(postPayload)\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\nexport default CollecionesEmitter;","import CollecionesBaseEvent from './CollecionesBaseEvent.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 this.identifiers = {};\n }\n\n /**\n * Adds a global identifier to be included with every event.\n * @param {string} name - Identifier key.\n * @param {*} value - Identifier value.\n */\n addIdentifier(name, value) {\n this.identifiers[name] = value;\n }\n\n /**\n * Sends an event to all emitters after enriching it with identifiers and metadata.\n * @param {CollecionesBaseEvent} collecionesEvent - The event to be sent.\n * @throws {Error} If the input is not an instance of CollecionesBaseEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesBaseEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n for (const [key, value] of Object.entries(this.identifiers)) {\n collecionesEvent.addIdentifier(key, value);\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 CollecionesBaseEvent from './CollecionesBaseEvent.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 {CollecionesBaseEvent} collecionesEvent - The event object to track.\n * @throws {Error} If the event is not an instance of CollecionesBaseEvent.\n */\n track(collecionesEvent) {\n if (!(collecionesEvent instanceof CollecionesBaseEvent)) {\n throw new Error('Event must be of type CollecionesEvent');\n }\n collecionesEvent.addField('browserContext', getBrowserContext());\n super.track(collecionesEvent); \n }\n}\n\nexport default CollecionesWebTracker;","import CollecionesBaseEvent from './CollecionesBaseEvent.js';\n\n/**\n * Represents a semantic event with a name, data payload, and identifiers.\n * Extends CollecionesBaseEvent.\n */\nclass CollecionesEvent extends CollecionesBaseEvent {\n\n /**\n * Constructs a new CollecionesEvent instance.\n * @param {string} name - The name of the event.\n * @param {object} data - The main data payload of the event.\n * @param {object} identifiers - A set of identifiers to associate with the event.\n */\n constructor(name, data, identifiers) {\n super();\n this.setEventName(name);\n Object.assign(this.data, data);\n this.convertParamIdentifiers(identifiers);\n }\n\n}\n\nexport default CollecionesEvent;","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","let getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n if (!getRandomValues) {\n if (typeof crypto === 'undefined' || !crypto.getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n getRandomValues = crypto.getRandomValues.bind(crypto);\n }\n return getRandomValues(rnds8);\n}\n","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { v4 as uuidv4 } from 'uuid';\nimport {underscoreToCamelCase, formatAdjectives, stringifyAdjectives } from './utils/utils.js';\nimport CollecionesBaseEvent from './CollecionesBaseEvent.js';\n\n/**\n * Represents a structured semantic event with entity, action, and optional adjective.\n * Includes automatic naming and identifier mapping.\n * Extends CollecionesBaseEvent.\n */\nclass CollecionesSemanticEvent extends CollecionesBaseEvent {\n\n /**\n * Constructs a new semantic event.\n * @param {string} entity - The entity involved in the event.\n * @param {string} action - The action performed on the entity.\n * @param {string|string[]|undefined} adjective - Optional adjective(s) modifying the event.\n * @param {object} identifiers - Key-value pairs to be added as identifiers.\n */\n constructor(entity, action, adjective, identifiers) {\n super();\n this.entity = underscoreToCamelCase(entity);\n this.action = underscoreToCamelCase(action);\n this.adjective = formatAdjectives(adjective);\n let adjectiveString = stringifyAdjectives(this.adjective);\n this.eventName = `${this.entity}${(adjectiveString !== undefined) ? adjectiveString : ''}__${this.action}`;\n this.convertParamIdentifiers(identifiers);\n this.data.entityIdentifiers = {};\n this.data.attributes = {};\n this.data.clientEventId = uuidv4();\n this.data.meta = {\n eventFormat: 'CollecionesSemanticEvent',\n eventFormatVersion: '1'\n };\n }\n\n /**\n * This method is deprecated in semantic events and will throw if called.\n * @throws {Error}\n */\n setData() {\n throw new Error('setData deprecated in semantic events');\n }\n\n /**\n * Adds a key-value pair as an identifier for the semantic entity.\n * @param {string} key - The identifier name.\n * @param {string|number} value - The identifier value.\n * @throws Will throw if key is not a string or value is not a string or number.\n */\n addEntityIdentifier(key, value) {\n if (typeof key !== 'string') {\n throw new Error('Entity identifier key must be a string');\n }\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw new Error('Entity identifier value must be a string or number');\n }\n this.data.entityIdentifiers[key] = value;\n }\n\n}\n\nexport default CollecionesSemanticEvent;","import { underscoreToCamelCase, formatAdjectives, stringifyAdjectives } from './utils/utils.js';\nimport CollecionesSemanticEvent from './CollecionesSemanticEvent.js';\n\n/**\n * Represents a semantic event related to a collection of entities.\n * Extends CollecionesSemanticEvent and adds item-level detail and identifiers.\n */\nclass CollecionesSemanticCollectionEvent extends CollecionesSemanticEvent {\n\n /**\n * Constructs a new CollecionesSemanticCollectionEvent.\n * @param {string} itemEntity - The name of the item entity being acted on.\n * @param {string} action - The action performed.\n * @param {string|string[]|undefined} adjective - Optional adjective(s) describing the action.\n * @param {object} identifiers - Identifiers associated with the event.\n * @param {string} [collectionEntity] - Optional collection name, defaults to `${itemEntity}Collection`.\n */\n constructor(itemEntity, action, adjective, identifiers, collectionEntity) {\n if (typeof collectionEntity == 'undefined') {\n collectionEntity = `${itemEntity}Collection`;\n }\n super(collectionEntity, action, undefined, identifiers);\n this.data.meta = {\n eventFormat: 'CollecionesSemanticCollectionEvent',\n eventFormatVersion: '1'\n };\n this.adjective = formatAdjectives(adjective);\n let adjectiveString = stringifyAdjectives(this.adjective);\n itemEntity = underscoreToCamelCase(itemEntity);\n this.data.itemEntity = itemEntity;\n this.data.itemEventName = `${itemEntity}${(adjectiveString !== undefined) ? adjectiveString : ''}__${this.action}`;\n this.data.entityItemIdentifiers = {};\n }\n\n /**\n * Adds an identifier value (or values) for a specific entity item key.\n * @param {string} key - The identifier name.\n * @param {string|number|Array<string|number>} value - The identifier value(s).\n * @throws Will throw if key is not a string or value is of invalid type.\n */\n addEntityItemIdentifier(key, value) {\n if (typeof key !== 'string') {\n throw new Error('Entity identifier key must be a string');\n }\n if (typeof value !== 'string' && typeof value !== 'number' && !Array.isArray(value)) {\n throw new Error('Entity identifier value must be a string or number');\n }\n if (typeof this.data.entityItemIdentifiers[key] == 'undefined') {\n this.data.entityItemIdentifiers[key] = [];\n }\n if (Array.isArray(value)) {\n value.forEach((v) => {\n this.data.entityItemIdentifiers[key].push(v);\n });\n } else {\n this.data.entityItemIdentifiers[key].push(value);\n }\n }\n\n}\n\nexport default CollecionesSemanticCollectionEvent;"],"names":["uuidv4"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,UAAU,GAAG,EAAE;AAC7C,IAAI,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;AAC3C,IAAI,OAAO;AACX,SAAS,KAAK,CAAC,GAAG;AAClB,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK;AAC9B,YAAY,IAAI,KAAK,KAAK,CAAC,EAAE;AAC7B,gBAAgB,OAAO,IAAI;AAC3B;AACA,YAAY,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;AAC7E,SAAS;AACT,SAAS,IAAI,CAAC,EAAE,CAAC;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,UAAU,kBAAkB,EAAE;AACvD,IAAI,MAAM,QAAQ,GAAG,IAAI,KAAK,CAA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{"version":3,"file":"index.mjs","sources":["../src/utils/utils.js","../src/CollecionesEvent.js","../src/CollecionesEmitter.js","../src/CollecionesTracker.js","../src/CollecionesWebTracker.js","../src/collecionesDsl.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\nexport {\n fromBase64,\n getBrowserContext,\n toBase64,\n};","/**\n * Base class representing a structured event with timestamp, identifiers, and data fields.\n * This class is used to model events in a semantic and structured format for tracking purposes.\n */\nclass CollecionesEvent {\n\n /**\n * Constructs a new event with default 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 name:'', \n identifiers: []\n };\n this.context = {};\n this.references = {};\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 = 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 = 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(adjective);\n }\n\n /**\n * Adds or updates an identifier for the primary 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').\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 * @param {string} name - Identifier name.\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.actor.identifiers[name] = identifier;\n }\n\n /**\n * Adds contextual information to the event.\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 * Declares an entity referenced by this event.\n * @param {string} entity - The referenced entity name.\n */\n setRefence = function(entity) {\n if (typeof entity !== 'string') {\n throw new Error('Referenced entity must be a string');\n }\n if(this.references[entity] === undefined) {\n this.references[entity] = {identifiers: {}};\n }\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 */\n setRefenceIdentifier = function(entity, name, identifier) {\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);\n this.references[entity].identifiers[name] = identifier;\n }\n\n /**\n * Serializes the event to a plain object suitable for JSON.stringify().\n * @returns {object}\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 context: this.context,\n references: this.references,\n meta: this.meta\n };\n }\n\n /**\n * Recreates an instance of CollecionesEvent from a plain object.\n * @param {object} obj\n * @returns {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 || { name: '', identifiers: {} };\n instance.context = obj.context || {};\n instance.references = obj.references || {};\n instance.meta = obj.meta || {};\n return instance;\n }\n \n}\n\nexport default CollecionesEvent;","import { 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 }\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 let body = this.getBody();\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 getBody() {\n const eventsToSend = [...this.buffer];\n this.buffer = [];\n let postPayload = [];\n eventsToSend.forEach((e) => {\n postPayload.push( toBase64( JSON.stringify(e.toJSON())) );\n });\n return JSON.stringify(postPayload);\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 this.identifiers = {};\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 for (const [key, value] of Object.entries(this.identifiers)) {\n collecionesEvent.addIdentifier(key, value);\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;","/**\n * Colleciones DSL\n * ---------------\n * This module provides a fluent, human-readable DSL (domain-specific language) for constructing\n * structured tracking events based on CollecionesBaseEvent. Each step in the chain represents\n * a semantically meaningful piece of the event: the entity, the action, the actor, references, etc.\n *\n * Entry Point:\n * collecionesDsl.the('dark')\n *\n * Chaining:\n * - .and('...') : add additional adjectives\n * - ._('entity') : specify the entity being acted on\n * - .identified.by('field') : declare primary identifier for the subject\n * - .has.been('action') : declare what happened\n * - .by('actor') : describe the actor performing the action\n * - .identified.by('id') : add identifiers for the actor\n * - .with('key').set.to('val') : add contextual data fields\n * - .referring.to('entity') : describe referenced/related entities\n * - .identified.by('refId') : add identifiers for the reference\n * - .conform.to('SchemaName') : attach schema metadata\n * - .then.track.with(emitter) : finalize and emit the event\n *\n * Each function in the chain passes forward a scoped version of the CollecionesBaseEvent instance,\n * and enforces semantic constraints (e.g. `.as()` is required after `.by()`).\n *\n * Internal:\n * - Uses setRefence / setRefenceIdentifier for references\n * - Uses helpers.getEvent() for test access\n * - Uses instanceof CollecionesEmitter for validation\n *\n * This file is designed for internal use by developers building with the Colleciones tracking model.\n */\n\nimport CollecionesEvent from './CollecionesEvent.js';\nimport CollecionesEmitter from './CollecionesEmitter.js';\n\nlet init = (entity) => {\n return ((entity)=>{\n let eventInstance = new CollecionesEvent(); // Core event object\n eventInstance.setEntity(entity);\n\n let helpers = {\n getEvent: () => {\n return eventInstance;\n },\n };\n\n // DSL function groups\n let andEntity = () => {}; // .and(...) chaining after the()\n let setEntityAfterAnd = () => {}; // ._('entity') after .and\n let setEntityIdentifiers = () => {}; // .identified.by(...) for main subject\n let setAction = () => {}; // .has.been(...) for action\n let setActor = () => {}; // .by('actor')\n let setActorIdentifier = () => {}; // .identified.by(...) inside .by(...)\n let addContext = () => {}; // .with(...).set.to(...)\n let addReference = () => {}; // .referring.to(...)\n let getAddReference = () => {}; // .identified.by().as() inside .referring\n let addReferenceIdentifier = () => {}; // .and(...) after reference\n let conformingTo = () => {}; // .conform.to('SchemaName')\n let track = () => {}; // .then.track.with(emitter)\n\n // Adjective chaining: .and(...)._('entity')\n setEntityAfterAnd = (entity) => {\n eventInstance.addAdjective(eventInstance.entity);\n eventInstance.setEntity(entity);\n return {\n as: () => {\n return { helpers }\n },\n identified: {\n by: setEntityIdentifiers\n },\n has: { been: setAction },\n helpers\n };\n };\n\n // Identifier setup: .identified.by().as()\n setEntityIdentifiers = (name) => {\n eventInstance.setIdentifier(name, null);\n return {\n as: (value) => {\n eventInstance.setIdentifier(name, value);\n return {\n helpers,\n and: {\n by: setEntityIdentifiers\n },\n has: { been: setAction },\n }\n },\n helpers\n };\n };\n\n // Additional adjectives: .and('...')._()\n andEntity = (entity) => {\n eventInstance.addAdjective(eventInstance.entity);\n eventInstance.setEntity(entity);\n return {\n and: andEntity,\n _ : setEntityAfterAnd,\n helpers\n }\n };\n\n // Action: .has.been('...')\n setAction = (action) => {\n eventInstance.setAction(action);\n return {\n by: setActor,\n referring: { to: addReference },\n with: addContext,\n conform: {to: conformingTo},\n then: {track: {with: track}},\n helpers\n }\n };\n\n // Actor: .by('user')\n setActor = (name) => {\n eventInstance.setActor(name);\n return { \n identified: {\n by: setActorIdentifier\n },\n with: addContext,\n helpers\n }\n };\n\n // Actor identifier: .identified.by().as()\n setActorIdentifier = (name) => {\n return {\n as: (value) => {\n eventInstance.setActorIdentifier(name, value);\n return {\n helpers,\n and: setActorIdentifier,\n with: addContext,\n referring: { to: addReference },\n }\n },\n helpers\n }\n };\n\n // Contextual field: .with('key').set.to('value')\n addContext = (context) => {\n return {\n helpers,\n set: {\n to: (value) => {\n eventInstance.setContext(context, value);\n return {\n helpers,\n and: addContext,\n referring: { to: addReference },\n }\n }\n }\n }\n };\n\n // Reference: .referring.to('...')\n addReference = (entity) => {\n eventInstance.setRefence(entity);\n return {\n identified: {\n by: getAddReference(entity)\n },\n conform: {to: conformingTo},\n then: {track: {with: track}},\n helpers\n }\n };\n\n // Reference identifier setup: .identified.by().as()\n getAddReference = (entity) => {\n return (name) => {\n return {\n as: (value) => {\n eventInstance.setRefenceIdentifier(entity, name, value);\n return {\n helpers,\n and: addReferenceIdentifier,\n conform: {to: conformingTo},\n then: {track: {with: track}},\n }\n },\n helpers,\n };\n };\n };\n\n // Schema declaration: .conform.to('...')\n conformingTo = (name) => {\n eventInstance.setSchema(name);\n return { \n then: {track: {with: track}},\n helpers\n }\n };\n\n // Final dispatch: .then.track.with(emitter)\n track = (emitter) => {\n if(emitter instanceof CollecionesEmitter){\n emitter.track(eventInstance);\n }\n return {\n and: track,\n helpers,\n }\n };\n\n return {\n and: andEntity,\n _: setEntityAfterAnd,\n identified: {\n by: setEntityIdentifiers\n },\n has: { been: setAction},\n node: '_base',\n helpers\n }\n\n })(entity);\n}\n\nlet collecionesDsl = {\n the: init\n};\n\n\nexport default collecionesDsl;"],"names":[],"mappings":"AAAA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,QAAQ,GAAG,UAAU,GAAG,EAAE;AAChC,IAAI,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;AAC5E,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,KAAK,MAAM;AACX,QAAQ,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C/B,4BAA4B,OAAO;AACnC,4BAA4B,GAAG,EAAE,sBAAsB;AACvD,4BAA4B,OAAO,EAAE,CAAC,EAAE,EAAE,YAAY,CAAC;AACvD,4BAA4B,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACxD;AACA,qBAAqB;AACrB,oBAAoB,OAAO;AAC3B,iBAAiB;AACjB,aAAa;AACb,SAAS;;AAET;AACA,QAAQ,YAAY,GAAG,CAAC,IAAI,KAAK;AACjC,YAAY,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC;AACzC,YAAY,OAAO;AACnB,gBAAgB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC5C,gBAAgB;AAChB;AACA,SAAS;;AAET;AACA,QAAQ,KAAK,GAAG,CAAC,OAAO,KAAK;AAC7B,YAAY,GAAG,OAAO,YAAY,kBAAkB,CAAC;AACrD,gBAAgB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC;AAC5C;AACA,YAAY,OAAO;AACnB,gBAAgB,GAAG,EAAE,KAAK;AAC1B,gBAAgB,OAAO;AACvB;AACA,SAAS;;AAET,QAAQ,OAAO;AACf,YAAY,GAAG,EAAE,SAAS;AAC1B,YAAY,CAAC,EAAE,iBAAiB;AAChC,YAAY,UAAU,EAAE;AACxB,gBAAgB,EAAE,EAAE;AACpB,aAAa;AACb,YAAY,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC;AACnC,YAAY,IAAI,EAAE,OAAO;AACzB,YAAY;AACZ;;AAEA,KAAK,EAAE,MAAM,CAAC;AACd;;AAEG,IAAC,cAAc,GAAG;AACrB,IAAI,GAAG,EAAE;AACT;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Colleciones Tracker Architecture
|
|
5
|
+
|
|
6
|
+
The Colleciones tracking system is built around a modular, event-driven architecture designed for semantic expressiveness, schema validation, and cross-environment compatibility (browser/server).
|
|
7
|
+
|
|
8
|
+
## Components
|
|
9
|
+
|
|
10
|
+
### 1. Event Classes
|
|
11
|
+
At the heart of the system is the `CollecionesBaseEvent` class and its main derivative:
|
|
12
|
+
- `CollecionesEvent`: A structured event with entity, action, actor, identifiers, context, and references.
|
|
13
|
+
|
|
14
|
+
Each event can be serialized via `.toJSON()` and reconstructed with `.fromJSON()`.
|
|
15
|
+
|
|
16
|
+
### 2. Trackers
|
|
17
|
+
A tracker manages the enrichment and dispatching of events:
|
|
18
|
+
- `CollecionesTracker`: Adds global identifiers and routes events to one or more emitters.
|
|
19
|
+
- `CollecionesWebTracker`: Extends the base tracker by attaching browser context via `getBrowserContext()`.
|
|
20
|
+
|
|
21
|
+
Trackers ensure the event includes metadata such as `appName` and `trackerName`.
|
|
22
|
+
|
|
23
|
+
### 3. Emitter
|
|
24
|
+
`CollecionesEmitter` is responsible for batching, timing, and delivering events to a server endpoint:
|
|
25
|
+
- Events are buffered until `flushSize` is reached or `flushInterval` triggers a timed flush.
|
|
26
|
+
- The emitter serializes the buffered events and sends them via HTTP POST.
|
|
27
|
+
|
|
28
|
+
### 4. DSL (Domain-Specific Language)
|
|
29
|
+
The `collecionesDsl` provides a natural-language-inspired way to construct events declaratively:
|
|
30
|
+
```js
|
|
31
|
+
the('dark')._('button').has.been('clicked').then.track.with(emitter);
|
|
32
|
+
```
|
|
33
|
+
Each segment maps to semantic properties of the event object, with grammar rules enforced by the chain design.
|
|
34
|
+
|
|
35
|
+
### 5. Schema Validation
|
|
36
|
+
Events can declare a schema using `.conform.to('SchemaName')`. This allows for downstream validation and processing logic to be tailored based on expected structure.
|
|
37
|
+
|
|
38
|
+
## Serialization & Transport
|
|
39
|
+
All events implement a `toJSON()` method that produces a transportable payload. When combined with `fromJSON()`, the system supports full serialization/deserialization across boundaries.
|
|
40
|
+
|
|
41
|
+
## Testing
|
|
42
|
+
The system is thoroughly tested with unit tests per module (emitters, trackers, DSL, utils) and integration-style roundtrip tests (`toJSON()` ⇄ `fromJSON()`).
|
|
43
|
+
|
|
44
|
+
## Extensibility
|
|
45
|
+
- New event types can subclass `CollecionesBaseEvent`.
|
|
46
|
+
- New output mechanisms can subclass `CollecionesEmitter`.
|
|
47
|
+
- DSL chains can be extended with additional semantic layers (`.because(...)`, `.resultedIn(...)`, etc.).
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
This architecture enables a fluent, reliable, and extensible way to model and track interactions with clarity and precision.
|
package/docs/concept.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Concept: Why Colleciones?
|
|
5
|
+
|
|
6
|
+
Colleciones was born out of a need for structure, clarity, and meaning in how events are tracked across systems. In many legacy tracking setups, events were loosely defined, often ad hoc, with inconsistent naming and unpredictable attributes. This made it hard to understand relationships between events, reconstruct intent, or trust the semantics of what was recorded.
|
|
7
|
+
|
|
8
|
+
## The Problem
|
|
9
|
+
|
|
10
|
+
In traditional analytics, events might be named freely (`"UserClicked"`, `"submit_form"`, `"page_hit"`, `"clickedButton"`) and could contain any number of properties. There was no standard way to express:
|
|
11
|
+
|
|
12
|
+
- What was the **subject** of the event?
|
|
13
|
+
- What **action** occurred?
|
|
14
|
+
- Who **caused** it?
|
|
15
|
+
- What **other entities** were involved?
|
|
16
|
+
- Under what **conditions** did it happen?
|
|
17
|
+
|
|
18
|
+
Without this structure, it becomes impossible to map meaningful relationships, aggregate consistently across types, or validate the shape of event data.
|
|
19
|
+
|
|
20
|
+
## The Solution: Semantic Events
|
|
21
|
+
|
|
22
|
+
Colleciones brings structure by modeling each event as a **semantic sentence** about the system:
|
|
23
|
+
|
|
24
|
+
> “A user clicked the green button referring to campaign X, in the context of sourcePage=home, conforming to schema `UserInteractionEvent`.”
|
|
25
|
+
|
|
26
|
+
This sentence is built from explicit components:
|
|
27
|
+
|
|
28
|
+
- **Entity** (e.g., `button`, `email`, `property`)
|
|
29
|
+
- **Adjectives** that describe that entity (e.g., `green`, `featured`)
|
|
30
|
+
- **Action** (e.g., `clicked`, `submitted`, `viewed`)
|
|
31
|
+
- **Actor** who performed the action (e.g., `user`, `system`)
|
|
32
|
+
- **Identifiers** for both entity and actor
|
|
33
|
+
- **Context** (e.g., page, location, AB test)
|
|
34
|
+
- **References** to other entities
|
|
35
|
+
- **Schema name** for validation
|
|
36
|
+
|
|
37
|
+
Each piece is both human-expressive and machine-verifiable.
|
|
38
|
+
|
|
39
|
+
## Event Objects
|
|
40
|
+
|
|
41
|
+
Events are modeled in code via `CollecionesEvent`, which provides:
|
|
42
|
+
|
|
43
|
+
- Clean methods to set structured properties (`setEntity`, `setAction`, `setContext`, etc.)
|
|
44
|
+
- Validation boundaries (e.g., identifiers must be explicitly named and assigned)
|
|
45
|
+
- Schema-ready serialization via `.toJSON()` and rehydration via `.fromJSON()`
|
|
46
|
+
|
|
47
|
+
This results in events that are easy to inspect, serialize, validate, and reason about.
|
|
48
|
+
|
|
49
|
+
## Why It Matters
|
|
50
|
+
|
|
51
|
+
With Colleciones:
|
|
52
|
+
|
|
53
|
+
- You **don’t guess** what an event represents — you can read it like a statement.
|
|
54
|
+
- You **don’t hardcode** dozens of different event types — you reuse structure.
|
|
55
|
+
- You **don’t struggle** to join across data — relationships are explicit.
|
|
56
|
+
- You **don’t rely** on naming conventions — semantics are built-in.
|
|
57
|
+
|
|
58
|
+
Instead of just "tracking" things, you **model behavior** across domains — with clarity.
|
|
59
|
+
|
|
60
|
+
## Learn More
|
|
61
|
+
|
|
62
|
+
- 📚 [Architecture Overview](./architecture.md)
|
|
63
|
+
- ✍️ [DSL Syntax](./dsl.md)
|
|
64
|
+
- 🔄 [Emitters & Trackers](./emitterAndTracker.md)
|
|
65
|
+
- 📦 [Event Structure](./events.md)
|
package/docs/dsl.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Colleciones DSL
|
|
2
|
+
|
|
3
|
+
## What is this DSL?
|
|
4
|
+
|
|
5
|
+
The Colleciones DSL (domain-specific language) is a fluent, expressive syntax designed to describe structured events in a natural, sentence-like form. It was created to make event definition both human-readable and machine-consumable.
|
|
6
|
+
|
|
7
|
+
This DSL:
|
|
8
|
+
- models events semantically (e.g., entity, actor, action),
|
|
9
|
+
- enforces structure through grammar-aware chaining,
|
|
10
|
+
- supports validation through schema binding,
|
|
11
|
+
- and expresses event logic with minimal technical friction.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Basic Example
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
the('dark')
|
|
19
|
+
._('button')
|
|
20
|
+
.has.been('clicked')
|
|
21
|
+
.then.track.with(emitter);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Tracks: a dark button was clicked.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Parameters
|
|
29
|
+
|
|
30
|
+
Each part of the DSL has a semantic role. Here's what you can define:
|
|
31
|
+
|
|
32
|
+
- **Adjectives**: `.the('dark').and('green')`
|
|
33
|
+
Describes qualities of the entity (e.g., "dark", "green").
|
|
34
|
+
|
|
35
|
+
- **Entity**: `._('button')`
|
|
36
|
+
The subject of the event (what something happened to).
|
|
37
|
+
|
|
38
|
+
- **Primary Identifier**:
|
|
39
|
+
`.identified.by('email').as('john@example.com')`
|
|
40
|
+
Adds key information to identify the main entity.
|
|
41
|
+
|
|
42
|
+
- **Action**:
|
|
43
|
+
`.has.been('clicked')`
|
|
44
|
+
Describes what happened.
|
|
45
|
+
|
|
46
|
+
- **Actor**:
|
|
47
|
+
`.by('user').identified.by('userId').as('abc-123')`
|
|
48
|
+
Who caused the action, and how to identify them.
|
|
49
|
+
|
|
50
|
+
- **Context**:
|
|
51
|
+
`.with('sourcePage').set.to('homepage')`
|
|
52
|
+
Adds extra metadata about the event environment.
|
|
53
|
+
|
|
54
|
+
- **References**:
|
|
55
|
+
`.referring.to('property').identified.by('id').as('123')`
|
|
56
|
+
Links to related entities that are not the subject.
|
|
57
|
+
|
|
58
|
+
- **Schema binding**:
|
|
59
|
+
`.conform.to('UserInteractionEvent')`
|
|
60
|
+
Declares the expected event format for validation.
|
|
61
|
+
|
|
62
|
+
- **Execution**:
|
|
63
|
+
`.then.track.with(emitter)`
|
|
64
|
+
Finalizes and emits the event to a given destination.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Full DSL Chain
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
the('dark') // required
|
|
72
|
+
.and('green') // optional
|
|
73
|
+
._('button') // optional, required if 'and' precedes
|
|
74
|
+
.identified.by('email') // optional
|
|
75
|
+
.as('john@example.com') // required if .identified is used
|
|
76
|
+
.has.been('clicked') // required
|
|
77
|
+
.by('user') // optional
|
|
78
|
+
.identified.by('userId') // optional
|
|
79
|
+
.as('abc-123') // required if .identified is used
|
|
80
|
+
.with('sourcePage').set.to('homepage') // optional
|
|
81
|
+
.and('ctaLabel').set.to('register-now') // optional
|
|
82
|
+
.referring.to('property') // optional
|
|
83
|
+
.identified.by('id') // optional
|
|
84
|
+
.as('123') // required if .identified is used
|
|
85
|
+
.conform.to('UserInteractionEvent') // optional
|
|
86
|
+
.then.track.with(emitter) // required
|
|
87
|
+
.and(emitter); // optional
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each segment builds a part of the event. Invalid chains are rejected early, and required follow-ups are enforced based on the grammar rules you've defined.
|
|
91
|
+
|
|
92
|
+
Use this DSL to define events declaratively, naturally, and with full structural validation.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Emitters and Trackers
|
|
2
|
+
|
|
3
|
+
## What is an Emitter?
|
|
4
|
+
|
|
5
|
+
An **emitter** is responsible for collecting and sending event data to a target destination — typically a server endpoint. Emitters buffer events, optionally batch them, and flush them either based on time (`flushInterval`) or count (`flushSize`).
|
|
6
|
+
|
|
7
|
+
In this system, `CollecionesEmitter` is the core emitter class. It supports:
|
|
8
|
+
- Buffering events locally
|
|
9
|
+
- Periodic flushing
|
|
10
|
+
- Manual flushing
|
|
11
|
+
- Network transmission via `fetch`
|
|
12
|
+
|
|
13
|
+
## What is a Tracker?
|
|
14
|
+
|
|
15
|
+
A **tracker** orchestrates the enrichment and dispatching of events. It adds structural metadata such as:
|
|
16
|
+
- `trackerName`
|
|
17
|
+
- `appName`
|
|
18
|
+
- Global identifiers that apply to all events
|
|
19
|
+
|
|
20
|
+
The base implementation is `CollecionesTracker`, and it accepts one or more emitters as output channels.
|
|
21
|
+
|
|
22
|
+
### Tracker and Multiple Emitters
|
|
23
|
+
|
|
24
|
+
A tracker can be configured with multiple emitters like so:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const emitter1 = new CollecionesEmitter('/endpoint1');
|
|
28
|
+
const emitter2 = new CollecionesEmitter('/endpoint2');
|
|
29
|
+
const tracker = new CollecionesTracker([emitter1, emitter2], 'mainTracker', 'webApp');
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Every event tracked via this tracker will be routed to all configured emitters.
|
|
33
|
+
|
|
34
|
+
## What is the WebTracker?
|
|
35
|
+
|
|
36
|
+
`CollecionesWebTracker` extends the base tracker by injecting **browser-specific context** into the event automatically. This includes:
|
|
37
|
+
- Screen size
|
|
38
|
+
- Referrer
|
|
39
|
+
- User agent
|
|
40
|
+
- Language
|
|
41
|
+
- Timezone
|
|
42
|
+
|
|
43
|
+
It behaves exactly like `CollecionesTracker` but includes additional browser metadata.
|
|
44
|
+
|
|
45
|
+
## How Events Work With Trackers
|
|
46
|
+
|
|
47
|
+
Events created using `CollecionesEvent` or `CollecionesBaseEvent` are passed into a tracker like so:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const event = new CollecionesEvent();
|
|
51
|
+
event.setEntity('button');
|
|
52
|
+
event.setAction('click');
|
|
53
|
+
tracker.track(event);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
When `track()` is called:
|
|
57
|
+
1. The tracker attaches the tracker name, app name, and any global identifiers.
|
|
58
|
+
2. If using `CollecionesWebTracker`, browser context is added.
|
|
59
|
+
3. The event is forwarded to every configured emitter.
|
|
60
|
+
4. The emitter buffers or sends the event according to its flush logic.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
Together, emitters and trackers define a powerful, flexible event pipeline that separates *what* you want to track from *how* it is sent.
|
package/docs/events.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Events in the Colleciones System
|
|
2
|
+
|
|
3
|
+
## Why Events?
|
|
4
|
+
|
|
5
|
+
The core idea behind events in the Colleciones system is to describe **interactions** and **occurrences** in a way that is both **semantic** and **structured**. Every event aims to answer a simple, human-readable question:
|
|
6
|
+
|
|
7
|
+
> "What happened? To what? Who did it? When? Under what conditions?"
|
|
8
|
+
|
|
9
|
+
This framing leads to a standard model that balances flexibility with precision.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Semantic Structure
|
|
14
|
+
|
|
15
|
+
Each event is designed to be semantically expressive. The model encourages natural expression of what happened, while retaining a consistent internal structure for machine processing and schema validation.
|
|
16
|
+
|
|
17
|
+
Events consist of the following semantic elements:
|
|
18
|
+
|
|
19
|
+
- **Entity**: What is the subject of the event? (e.g., `"button"`, `"property"`)
|
|
20
|
+
- **Adjectives**: Which qualities describe the entity? (e.g., `"red"`, `"large"`, `"featured"`)
|
|
21
|
+
- **Action**: What happened to the entity? (e.g., `"clicked"`, `"submitted"`, `"viewed"`)
|
|
22
|
+
- **Primary Identifiers**: How can this specific entity instance be uniquely identified?
|
|
23
|
+
- **Actor**: Who or what triggered the event? (e.g., a user, system, or bot)
|
|
24
|
+
- **Actor Identifiers**: How is the actor uniquely represented?
|
|
25
|
+
- **Context**: What additional environment data is relevant? (e.g., sourcePage, deviceType)
|
|
26
|
+
- **References**: What other entities are involved indirectly? (e.g., campaign, product)
|
|
27
|
+
- **Schema**: What expected format should the event conform to?
|
|
28
|
+
|
|
29
|
+
Each of these attributes maps cleanly into properties of the event object, and every DSL path or tracking call ultimately contributes to setting these fields.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## The Event Class
|
|
34
|
+
|
|
35
|
+
Events are instantiated via the `CollecionesBaseEvent` or `CollecionesEvent` classes. These classes expose methods to define every semantic layer described above.
|
|
36
|
+
|
|
37
|
+
Key methods include:
|
|
38
|
+
- `.setEntity()`, `.addAdjective()`, `.setAction()`
|
|
39
|
+
- `.setIdentifier()`, `.setActor()`, `.setActorIdentifier()`
|
|
40
|
+
- `.setContext()`, `.setRefence()`, `.setRefenceIdentifier()`
|
|
41
|
+
- `.setSchema()`
|
|
42
|
+
- `.toJSON()` and `.fromJSON()` for transport and storage
|
|
43
|
+
|
|
44
|
+
Each event object is:
|
|
45
|
+
- **schema-ready** (via `.setSchema()` and `.conform.to(...)` in the DSL)
|
|
46
|
+
- **fully serializable** (via `.toJSON()`)
|
|
47
|
+
- **traceable** to its source and context (via `actor`, `context`, and `tracker` fields)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Purpose of this Design
|
|
52
|
+
|
|
53
|
+
This model was designed to:
|
|
54
|
+
- Create **consistent and meaningful** event structures
|
|
55
|
+
- Enable **semantic expressiveness** in DSL chaining
|
|
56
|
+
- Ensure **cross-system interoperability** via schema support
|
|
57
|
+
- Reduce ambiguity and guesswork in tracking implementations
|
|
58
|
+
- Promote **testable, introspectable** events
|
|
59
|
+
|
|
60
|
+
It enables a high degree of **data integrity** and **clarity** across the analytics pipeline.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## See also
|
|
65
|
+
|
|
66
|
+
- 📚 [Architecture Overview](./architecture.md) – for system-wide roles of emitters, trackers, and DSL
|
|
67
|
+
- ✍️ [DSL Syntax](./dsl.md) – for declarative event construction
|
|
68
|
+
- 🔄 [Emitters & Trackers](./emitterAndTracker.md) – for how events are dispatched
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilacion/colleciones-clientos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
},
|
|
21
21
|
"author": "Maxime Passenier",
|
|
22
22
|
"license": "ISC",
|
|
23
|
-
"description": "",
|
|
23
|
+
"description": "A semantic event tracking library with DSL support, schema validation, and structured emitters.",
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"docs"
|
|
26
27
|
],
|
|
27
28
|
"publishConfig": {
|
|
28
29
|
"access": "public"
|