@compilacion/colleciones-clientos 1.0.12 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,114 +1,76 @@
1
- npm run dev:testclient
1
+ # Colleciones
2
2
 
3
- zever gezever
4
- # @compilacion/colleciones-clientos
5
-
6
- A minimal, semantic-aware tracking client for compiling and emitting structured event data, designed for clean integration with web applications.
3
+ **Colleciones** is a structured, semantic tracking framework that lets you describe and dispatch events with clarity and precision. It introduces a fluent event model that is both developer-friendly and analytics-ready.
7
4
 
8
5
  ---
9
6
 
10
- ## Why this package?
11
-
12
- This package provides a modular, semantically structured way to track events in a browser or Node.js context. It introduces an expressive abstraction over raw event logging, allowing you to:
13
-
14
- - Build meaningful tracking data using domain and semantic context
15
- - Manage event batching and network traffic efficiently
16
- - Decouple semantic structure from transport
17
- - Keep client-side tracking logic testable and declarative
18
-
19
- ### About "semantic" events
20
-
21
- We use a consistent structure: `entity`, `action`, and `adjective`. This allows us to describe events like:
7
+ ## Why Colleciones?
22
8
 
23
- - `"session" "start" "engaged"`
24
- - `"property" "display" "preview"`
9
+ Most tracking systems suffer from inconsistent event naming and arbitrary structure. Colleciones solves this by building events around a shared semantic structure — entity, action, actor, context, and references — modeled as natural-language chains or structured code.
25
10
 
26
- This semantic approach gives us flexibility and consistency across tracking implementations.
11
+ 📖 See [docs/concept.md](./docs/concept.md) for the full background.
27
12
 
28
13
  ---
29
14
 
30
- ## 🚀 Usage
15
+ ## How to Use It
31
16
 
32
- You can run the [manual runner](./test/manual-runner.js) to test locally:
33
- ```bash
34
- npm run manual-runner
35
- ```
17
+ ### 1. Create an Emitter
36
18
 
37
- ### Example
19
+ An emitter is responsible for collecting and sending events to a server.
38
20
 
39
21
  ```js
40
- import CollecionesEmitter from '../src/CollecionesEmitter.js';
41
- import CollecionesTracker from '../src/CollecionesTracker.js';
42
- import CollecionesSemanticCollectionEvent from '../src/CollecionesSemanticCollectionEvent.js';
43
-
44
- // Setup
45
- let emitter = new CollecionesEmitter('http://localhost:8080/collect', 3, 10);
46
- let tracker = new CollecionesTracker([emitter], 'myTracker', 'theWebsiteApp');
47
- tracker.addIdentifier('visitorId', '12');
48
-
49
- // Create semantic collection event
50
- let eC = new CollecionesSemanticCollectionEvent(
51
- 'property',
52
- 'display',
53
- 'preview'
54
- );
55
-
56
- eC.addEntityIdentifier('serpPage', 1234);
57
- eC.addAttribute('pageUrl', 'https://');
58
- eC.addEntityItemIdentifier('propertyId', 1);
59
- eC.addEntityItemIdentifier('propertyId', 2);
60
- eC.addEntityItemIdentifier('propertyId', 3);
61
- eC.addEntityItemIdentifier('propertyId', [4, 5, 6]);
62
-
63
- console.log(eC.getPayload());
64
- tracker.track(eC);
65
-
66
- // Send events
67
- emitter.flush();
68
- ```
22
+ import { CollecionesEmitter } from './index.js';
69
23
 
70
- ---
71
-
72
- ## 🛠 Branching model
24
+ const emitter = new CollecionesEmitter('/collect', 5, 10000);
25
+ ```
73
26
 
74
- This project uses a dual-branch setup:
27
+ ### 2. Create a Tracker
75
28
 
76
- - `uat`: the **staging branch**. All feature work should merge into this first.
77
- - `main`: the **release branch**, protected and only updated via pull requests from `uat`.
29
+ A tracker enriches and routes events to one or more emitters.
78
30
 
79
- ---
31
+ ```js
32
+ import { CollecionesTracker } from './index.js';
80
33
 
81
- ## ⚙️ CI/CD Setup
34
+ const tracker = new CollecionesTracker([emitter], 'myTracker', 'myApp');
35
+ ```
82
36
 
83
- We use GitHub Actions:
37
+ ### 3. Build Events with the DSL
84
38
 
85
- - PRs to `uat` and `main` trigger the `build-and-test` job.
86
- - Version tags (e.g. `v1.2.0`) trigger the `release` job.
39
+ You can construct events declaratively using a natural language-like DSL:
87
40
 
88
- Only PRs to `main` from `uat` should be used to promote code to production.
41
+ ```js
42
+ import collecionesDsl from './src/collecionesDsl.js';
89
43
 
90
- ---
44
+ collecionesDsl
45
+ .the('red')
46
+ ._('button')
47
+ .has.been('clicked')
48
+ .then.track.with(emitter);
49
+ ```
91
50
 
92
- ## 📦 Release process
51
+ 📘 See [docs/dsl.md](./docs/dsl.md) for full DSL documentation.
93
52
 
94
- To publish a new version:
53
+ ### 4. Manually Create Events (Optional)
95
54
 
96
- 1. Merge to `main` via PR from `uat`
97
- 2. Go to **GitHub → Releases → Draft a new release**
98
- 3. Create a tag (e.g. `v1.0.1`)
99
- 4. Target the `main` branch
100
- 5. Publish the release
55
+ You can also build structured events directly via the event class:
101
56
 
102
- GitHub Actions will:
103
- - Build the package
104
- - Publish to npm
57
+ ```js
58
+ import { CollecionesEvent } from './index.js';
105
59
 
106
- The package is published as:
60
+ const event = new CollecionesEvent();
61
+ event.setEntity('form');
62
+ event.setAction('submitted');
63
+ event.setIdentifier('formId', 'abc123');
107
64
 
65
+ tracker.track(event);
108
66
  ```
109
- @compilacion/colleciones-clientos
110
- ```
111
67
 
112
- If you encounter issues with scope or publishing, ensure your npm org is set up and the scope `@compilacion` is correctly authorized.
68
+ ---
69
+
70
+ ## Learn More
113
71
 
114
- ---
72
+ - 🧠 [Concept](./docs/concept.md)
73
+ - 🏗️ [Architecture](./docs/architecture.md)
74
+ - 🔄 [Emitters & Trackers](./docs/emitterAndTracker.md)
75
+ - ✍️ [DSL Syntax](./docs/dsl.md)
76
+ - 📦 [Event Structure](./docs/events.md)