@crelora/mark 0.0.18 → 0.1.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 +38 -11
- package/dist/browser.es.js +618 -124
- package/dist/browser.es.js.map +1 -0
- package/dist/browser.umd.js +2 -1
- package/dist/browser.umd.js.map +1 -0
- package/dist/node.cjs +2 -1
- package/dist/node.cjs.map +1 -0
- package/dist/node.es.js +431 -66
- package/dist/node.es.js.map +1 -0
- package/dist/types/browser/BrowserStorage.d.ts +12 -0
- package/dist/types/browser/Mark.d.ts +18 -0
- package/dist/types/core/DeliveryQueue.d.ts +57 -0
- package/dist/types/core/HttpTransport.d.ts +6 -2
- package/dist/types/core/MarkCore.d.ts +46 -2
- package/dist/types/core/TransportError.d.ts +15 -0
- package/dist/types/core/adapters.d.ts +14 -1
- package/dist/types/node/StatelessStorage.d.ts +7 -0
- package/dist/types/node/index.d.ts +8 -0
- package/dist/types/types.d.ts +37 -0
- package/dist/web-vitals-CrnTllyu.js +221 -0
- package/dist/web-vitals-CrnTllyu.js.map +1 -0
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Mark is Crelora's lightweight attribution SDK for capturing user journeys, conversions, and consent across browsers and server-side runtimes. The npm package includes both browser and Node entry points so you can send consistent data from any surface.
|
|
4
4
|
|
|
5
|
+
Use it to feed **OneLence** with first‑party behavioral and conversion data so you can build **analytics**, **insights**, **signals**, and **decisions** on top of a unified event stream.
|
|
6
|
+
|
|
7
|
+
### API keys and documentation
|
|
8
|
+
|
|
9
|
+
- **Keys:** Publishable keys (`pk_…`) for browser and secret keys (`sk_…`) for server-side use are available in the OneLence dashboard: [API keys](https://onelence.com/dash/settings/api-keys).
|
|
10
|
+
- **Guides:** For integration patterns, alternative integration types (e.g. server-only, tag managers), and deeper technical documentation, see the [Integrations overview](https://onelence.com/docs/integrations/overview).
|
|
11
|
+
|
|
5
12
|
## Installation
|
|
6
13
|
|
|
7
14
|
```bash
|
|
@@ -90,10 +97,13 @@ The Node factory accepts optional custom storage or transport adapters so you ca
|
|
|
90
97
|
|
|
91
98
|
- `Mark.init(config)` / `createNodeMark(config)` – bootstraps the client with your publishable or secret key.
|
|
92
99
|
- `track(eventName, payload?)` – records custom events with arbitrary properties (numbers, strings, arrays, objects). Use `site_id` and `site_host` for per-event site overrides.
|
|
93
|
-
- `conversion(eventName, payload?)` – records conversion events
|
|
100
|
+
- `conversion(eventName, payload?)` – records conversion events (same endpoint path as track, with `is_conversion: true` for backend compatibility).
|
|
94
101
|
- `identify(userId, traits?)` – ties a known user identifier to previous anonymous activity. Recommended traits: `email`, `display_name`, `language`. Custom traits are also supported.
|
|
95
102
|
- `setConsent(status)` – enforces consent gating; pass `'granted'` or `'denied'`.
|
|
96
103
|
- `getVisitorId()` – returns the current pseudonymous visitor ID when available. On the browser, returns `undefined` until consent is granted when `require_consent` is set. Use it to send the ID to your backend (e.g. in a header or body) for server-side attribution when you don't have an authenticated user ID.
|
|
104
|
+
- `flush()` – flushes queued/persisted delivery items.
|
|
105
|
+
- `reset()` – clears user/session/attribution state and rotates visitor identity for logout flows.
|
|
106
|
+
- `getStats()` – returns runtime delivery stats `{ queued, sent, failed, dropped }`.
|
|
97
107
|
|
|
98
108
|
Reserved SDK fields (for example `event_name`, `user_id`, `consent_state`, and internal identity metadata) are sanitized from user payloads/traits and cannot override SDK-managed values.
|
|
99
109
|
|
|
@@ -133,10 +143,19 @@ All config options use snake_case. Stored event payloads and database columns ma
|
|
|
133
143
|
|
|
134
144
|
| Option | Type | Description |
|
|
135
145
|
| --- | --- | --- |
|
|
136
|
-
| `key` | `string` | Publishable (browser) or secret (server) key
|
|
146
|
+
| `key` | `string` | Publishable (browser) or secret (server) key from [OneLence API keys](https://onelence.com/dash/settings/api-keys). |
|
|
137
147
|
| `debug` | `boolean` | Enables verbose console logging to help with integration tests. |
|
|
148
|
+
| `before_send` | `(event) => event \| null` | Mutate/redact payloads before send, or return `null` to drop events. |
|
|
149
|
+
| `on_error` | `(error, event?) => void` | Hook for transport and queue failures. |
|
|
150
|
+
| `sample_rate` | `number` | Fraction (`0..1`) for `track` event sampling. `identify` and `conversion` are never sampled. |
|
|
151
|
+
| `honor_dnt` | `boolean` | When true, blocks tracking when browser DNT/GPC is enabled. |
|
|
152
|
+
| `session_timeout_ms` | `number` | Inactivity window for rotating `session_id` (default 30 minutes). |
|
|
153
|
+
| `request_timeout_ms` | `number` | HTTP timeout per request in milliseconds (default `10000`). |
|
|
154
|
+
| `rotate_visitor_on_consent_change` | `boolean` | Rotate `visitor_id` after denied -> granted transition. |
|
|
155
|
+
| `batching` | `{ enabled?: boolean, max_size?: number, flush_interval_ms?: number, endpoint_path?: string }` | Optional batch mode (`/events` by default). |
|
|
138
156
|
| `require_consent` | `boolean \| 'auto'` | `true` blocks tracking until consent is granted, `'auto'` requires stored granted consent and treats missing consent as denied, default `false` (`'auto'` recommended for production). |
|
|
139
|
-
| `
|
|
157
|
+
| `consent_source` | `{ type: 'tcf', purposes: number[] }` | Optional **IAB TCF v2** integration: the SDK listens for CMP updates and only allows tracking when the listed numeric purpose IDs are consented. Combine with `require_consent` and `setConsent` as your legal team requires. |
|
|
158
|
+
| `autocapture` | `{ pageview?: boolean, click?: boolean \| { selector?: string }, form_submit?: boolean, outbound_link?: boolean, scroll_depth?: boolean, web_vitals?: boolean }` | Auto-capture toggles for page views and optional interaction/perf signals. |
|
|
140
159
|
| `track_route_changes` | `boolean` | When `autocapture.pageview` is true, also emits on SPA route changes (pushState/replaceState/popstate); defaults to `true`. |
|
|
141
160
|
| `include_page_context` | `boolean` | When true (default), enriches events with `page`, `title`, `referrer`, `site` (full `url` is only sent if you pass it explicitly in payload). |
|
|
142
161
|
| `cross_domain` | `CrossDomainConfig` | Controls cookie domain, bridge URL, and allowlist for multi-domain attribution. |
|
|
@@ -152,13 +171,21 @@ Server runtimes can also pass `storage`, `storageDefaults`, or `transport` via `
|
|
|
152
171
|
|
|
153
172
|
## Consent & Privacy
|
|
154
173
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- In `'auto'` mode, missing consent is treated as denied until
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
174
|
+
These behaviors matter for **compliance-sensitive** setups (GDPR-style consent, CMPs, enterprise security reviews):
|
|
175
|
+
|
|
176
|
+
- **Consent gating:** Use `require_consent: true` or `'auto'` so events and `identify` only run after a positive consent signal. In `'auto'` mode, missing consent is treated as denied until `setConsent('granted')`.
|
|
177
|
+
- **TCF v2:** Set `consent_source: { type: 'tcf', purposes: [/* IAB purpose IDs */] }` so tracking follows your CMP’s current purpose consents (the SDK subscribes to CMP updates rather than relying on a one-time read).
|
|
178
|
+
- **Withdrawal:** `setConsent('denied')` stops tracking and clears stored attribution plus cookie-backed visitor identity where applicable.
|
|
179
|
+
- **Stricter identity hygiene:** Enable `rotate_visitor_on_consent_change` if you want a fresh `visitor_id` after a denied → granted transition.
|
|
180
|
+
- **DNT / GPC:** `honor_dnt: true` blocks tracking when the browser reports Do Not Track or Global Privacy Control.
|
|
181
|
+
- **Data minimization:** Use `before_send` to strip or redact fields before they leave the client; use `on_error` for observability without logging raw payloads.
|
|
182
|
+
- **Payloads cannot bypass consent** via event properties; reserved fields are sanitized.
|
|
183
|
+
- **Pre-consent attribution:** URL attribution is held in memory only until consent is granted, then persisted.
|
|
184
|
+
- **Cross-domain:** First-party iframe bridges keep identifiers under your control.
|
|
185
|
+
- **Delivery without long-lived local queues:** Failed sends can be retried from a browser outbox with a **48-hour TTL**; on tab hide / unload, pending items are flushed with **`sendBeacon`** where possible to improve delivery without weakening consent checks.
|
|
186
|
+
- **IP / geo:** IP is not read in the browser; it is taken server-side, hashed, and used for coarse geo only when allowed by consent and tenant settings.
|
|
187
|
+
|
|
188
|
+
For product-level privacy commitments and processor terms, rely on your OneLence agreement and [documentation](https://onelence.com/docs/integrations/overview); this README describes SDK behavior only.
|
|
162
189
|
|
|
163
190
|
## Visitor ID for server attribution
|
|
164
191
|
|
|
@@ -198,5 +225,5 @@ Mark.identify('user_123', {
|
|
|
198
225
|
|
|
199
226
|
## Support
|
|
200
227
|
|
|
201
|
-
Need help? Reach out through your
|
|
228
|
+
Need help? Reach out through your account team or file a ticket via the OneLence dashboard. Please include the SDK version, runtime (browser or Node), and any reproduction steps so we can assist quickly.
|
|
202
229
|
|