core-outline 1.1.22 → 1.1.24

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,31 +1,55 @@
1
1
  # Core&Outline React Component
2
2
 
3
- A React component for integrating Core&Outline session recording and event tracking into your web application.
3
+ A React component for automatically tracking user activity — page views, clicks, session duration, SPA navigation, and session recordings and streaming events to your Core&Outline analytics warehouse.
4
4
 
5
5
  ## Installation
6
6
 
7
- Install the package using npm:
8
-
9
7
  ```sh
10
8
  npm install core-outline
11
9
  ```
12
10
 
13
- or using yarn:
14
-
15
11
  ```sh
16
12
  yarn add core-outline
17
13
  ```
18
14
 
15
+ ## Prerequisites
16
+
17
+ Before adding the component to your app, create an SDK data source through the Hermes API to obtain your credentials. This requires your Firebase authentication token.
18
+
19
19
  ```sh
20
+ curl -X POST https://atlas-orchestrator.atlas.coreoutline.com/api/ingest/sdk-sources \
21
+ -H "Authorization: Bearer <your-firebase-token>" \
22
+ -H "Content-Type: application/json" \
23
+ -d '{"name": "My Website"}'
24
+ ```
25
+
26
+ The response contains your `data_source_id`, `data_source_secret`, and `warehouse_id`. **The secret is shown once — store it securely.**
27
+
28
+ ```json
29
+ {
30
+ "data_source_id": "3f4a1c2d-...",
31
+ "data_source_secret": "aB3xK9mZqR...",
32
+ "warehouse_id": "cad1acc0-...",
33
+ "name": "My Website"
34
+ }
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Wrap your app's root component with `<CoreOutline>`. All tracking is automatic from that point — no additional configuration is needed.
40
+
41
+ ```jsx
20
42
  import React from 'react';
21
- import CoreOutline from 'core-outline';
43
+ import { CoreOutline } from 'core-outline';
22
44
 
23
45
  function App() {
24
46
  return (
25
47
  <CoreOutline
26
- data_source_id={{ YOUR_DATA_SOURCE_ID }}
27
- data_source_secret={{ YOUR_DATA_SOURCE_SECRET }}>
28
- {/* Your app components */}
48
+ warehouse_id="cad1acc0-..."
49
+ data_source_id="3f4a1c2d-..."
50
+ data_source_secret="aB3xK9mZqR..."
51
+ >
52
+ {/* Your app */}
29
53
  </CoreOutline>
30
54
  );
31
55
  }
@@ -33,20 +57,70 @@ function App() {
33
57
  export default App;
34
58
  ```
35
59
 
36
- To flag items clicked or purchased:
60
+ ### Props
37
61
 
38
- ```sh
39
- import { flag_item_clicked, flag_item_purchased } from 'core-outline;
40
- ```
62
+ | Prop | Type | Required | Description |
63
+ |------|------|----------|-------------|
64
+ | `warehouse_id` | `string` | Yes | Your tenant warehouse UUID (returned from the SDK source creation call) |
65
+ | `data_source_id` | `string` | Yes | The UUID of your SDK data source |
66
+ | `data_source_secret` | `string` | Yes | The secret generated at data source creation |
41
67
 
42
- To flag items clicked:
68
+ ## What Gets Tracked Automatically
43
69
 
44
- ```sh
45
- flag_item_clicked('ITEM_ID');
70
+ | Event | Description |
71
+ |-------|-------------|
72
+ | `session_start` | Fires when the component mounts; captures browser, OS, device type, UTM params, referrer |
73
+ | `pageview` | Fires on mount and on every SPA navigation (pushState / popstate) |
74
+ | `item_clicked` | Fires on every click; captures element tag, id, class, and inner text |
75
+ | `session_end` | Fires on tab close or visibility change; includes session duration and pageview count |
76
+ | Session recording | rrweb-powered DOM recording uploaded at session end |
77
+
78
+ All events include: `anonymous_id` (persistent across sessions), `session_id` (per tab), UTM parameters, page URL, page path, device type, OS, and browser name.
79
+
80
+ ## Manual Event Tracking
81
+
82
+ For commerce events, call the exported helpers from anywhere in your app — no props required.
83
+
84
+ ```js
85
+ import { flag_item_clicked, flag_item_purchased } from 'core-outline';
86
+
87
+ // Track a product click
88
+ flag_item_clicked('sku-123');
89
+
90
+ // Track a purchase (price is optional, maps to value_num in ClickHouse)
91
+ flag_item_purchased('sku-123', 49.99);
46
92
  ```
47
93
 
48
- To flag items purchased:
94
+ ## Data Pipeline
49
95
 
50
- ```sh
51
- flag_item_purchased('ITEM_ID');
96
+ Events flow through the following pipeline:
97
+
98
+ ```
99
+ Browser → POST /api/ingest/events → RabbitMQ ({warehouse_id}.analytics.events)
100
+ → Consumer worker → ClickHouse atlas_analytics
52
101
  ```
102
+
103
+ The ClickHouse tables populated are:
104
+
105
+ | Table | Populated by |
106
+ |-------|-------------|
107
+ | `fact_event` | All events except session start/end |
108
+ | `fact_session` | `session_start` and `session_end` events |
109
+ | `fact_pageview` | `pageview` events |
110
+ | `stg_events_sdk_event` | All events (raw staging) |
111
+ | `stg_rrweb_event` | Session recording chunks |
112
+
113
+ These tables are queried by the [atlas-analytics](https://analytics.atlas.coreoutline.com) API under `/metrics/saas/traffic`, `/metrics/saas/engagement`, and related endpoints.
114
+
115
+ ## Anonymous vs Session Identity
116
+
117
+ - **`anonymous_id`** — a UUID stored in `localStorage`; persists across browser sessions, used to stitch cross-session user journeys.
118
+ - **`session_id`** — a UUID stored in `sessionStorage`; reset on each new tab or browser close, matching the standard session definition.
119
+
120
+ ## Service URLs
121
+
122
+ | Service | URL |
123
+ |---------|-----|
124
+ | Hermes API (credential management) | `https://atlas-orchestrator.atlas.coreoutline.com` |
125
+ | Maia (data engineering / pipelines) | `https://data-engineering.atlas.coreoutline.com` |
126
+ | Atlas Analytics API | `https://analytics.atlas.coreoutline.com` |