hangarx 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/README.md +152 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9daa2494e5b9047d2cb0bb663bbc3cb605b611d688ffcbc1c79ff6298b856533
|
4
|
+
data.tar.gz: 9b65fbec9f2f49bbe2ee2e4c265859d76290696d9c2414763ff04df8ba0864a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51d46059ab58b45af48689f3d95836730612189743a7e79ce67501ef43b21e6c7e1f8488874c0a9b64e610d9dd8a0032005ca6b4ce58aa5f29386b79d3fb475a
|
7
|
+
data.tar.gz: 177c3f139635cfb39869d642b84fa0e6d7dbf94e843ec951149e1c875fc33b6571f592590031a085137bbf90e01dbe3897912f116b0db68cea0afea1d62f26f0
|
data/README.md
CHANGED
@@ -81,7 +81,158 @@ hangarx.page(
|
|
81
81
|
)
|
82
82
|
```
|
83
83
|
|
84
|
-
### 3.
|
84
|
+
### 3. Multi-Tenancy Tracking
|
85
|
+
|
86
|
+
Track analytics across Organizations, Teams, Client Accounts, and Projects by adding context to your events.
|
87
|
+
|
88
|
+
#### Hierarchy Structure
|
89
|
+
|
90
|
+
```
|
91
|
+
Organizations (Partners/Agencies)
|
92
|
+
↓
|
93
|
+
Teams (Collaboration Units)
|
94
|
+
↓
|
95
|
+
Client Accounts (Business Entities)
|
96
|
+
↓
|
97
|
+
Projects (Websites/Apps)
|
98
|
+
↓
|
99
|
+
Events (User Actions)
|
100
|
+
```
|
101
|
+
|
102
|
+
#### Adding Multi-Tenancy Context
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
# Track event with full context
|
106
|
+
hangarx.track(
|
107
|
+
user_id: 'user-123',
|
108
|
+
event: 'api_request',
|
109
|
+
properties: {
|
110
|
+
endpoint: '/api/users',
|
111
|
+
method: 'POST',
|
112
|
+
response_time: 145,
|
113
|
+
|
114
|
+
# Multi-tenancy context
|
115
|
+
organization_id: 'org_marketing_agency',
|
116
|
+
team_id: 'team_client_services',
|
117
|
+
client_account_id: 'client_acme_corp',
|
118
|
+
project_id: 'proj_acme_website'
|
119
|
+
}
|
120
|
+
)
|
121
|
+
|
122
|
+
# Identify user with context
|
123
|
+
hangarx.identify(
|
124
|
+
user_id: 'user-123',
|
125
|
+
traits: {
|
126
|
+
email: 'user@example.com',
|
127
|
+
name: 'John Doe',
|
128
|
+
|
129
|
+
# Multi-tenancy context
|
130
|
+
organization_id: 'org_marketing_agency',
|
131
|
+
team_id: 'team_client_services',
|
132
|
+
role: 'admin'
|
133
|
+
}
|
134
|
+
)
|
135
|
+
```
|
136
|
+
|
137
|
+
#### Use Cases
|
138
|
+
|
139
|
+
**Partner Agency Managing Multiple Clients:**
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
AGENCY_CONTEXT = {
|
143
|
+
organization_id: 'org_marketing_agency',
|
144
|
+
team_id: 'team_client_services'
|
145
|
+
}
|
146
|
+
|
147
|
+
# Client 1: E-commerce Store
|
148
|
+
hangarx.track(
|
149
|
+
user_id: 'user-123',
|
150
|
+
event: 'product_viewed',
|
151
|
+
properties: {
|
152
|
+
product_id: 'prod_456',
|
153
|
+
**AGENCY_CONTEXT,
|
154
|
+
client_account_id: 'client_ecommerce',
|
155
|
+
project_id: 'proj_store_website'
|
156
|
+
}
|
157
|
+
)
|
158
|
+
|
159
|
+
# Client 2: SaaS Company
|
160
|
+
hangarx.track(
|
161
|
+
user_id: 'user-789',
|
162
|
+
event: 'signup_completed',
|
163
|
+
properties: {
|
164
|
+
plan: 'pro',
|
165
|
+
**AGENCY_CONTEXT,
|
166
|
+
client_account_id: 'client_saas',
|
167
|
+
project_id: 'proj_saas_app'
|
168
|
+
}
|
169
|
+
)
|
170
|
+
```
|
171
|
+
|
172
|
+
**Consultant Managing Client Projects:**
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
CONSULTANT_CONTEXT = {
|
176
|
+
team_id: 'team_john_consulting',
|
177
|
+
consultant_id: 'user_john'
|
178
|
+
}
|
179
|
+
|
180
|
+
# Client A: Restaurant
|
181
|
+
hangarx.track(
|
182
|
+
user_id: 'visitor-123',
|
183
|
+
event: 'reservation_made',
|
184
|
+
properties: {
|
185
|
+
date: '2025-10-15',
|
186
|
+
party_size: 4,
|
187
|
+
**CONSULTANT_CONTEXT,
|
188
|
+
client_account_id: 'client_restaurant',
|
189
|
+
project_id: 'proj_restaurant_site'
|
190
|
+
}
|
191
|
+
)
|
192
|
+
```
|
193
|
+
|
194
|
+
#### Helper Module
|
195
|
+
|
196
|
+
Create a reusable context module:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
module AnalyticsContext
|
200
|
+
def self.build(org_id: nil, team_id: nil, client_id: nil, project_id: nil)
|
201
|
+
{}.tap do |ctx|
|
202
|
+
ctx[:organization_id] = org_id if org_id
|
203
|
+
ctx[:team_id] = team_id if team_id
|
204
|
+
ctx[:client_account_id] = client_id if client_id
|
205
|
+
ctx[:project_id] = project_id if project_id
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.track(user_id:, event:, properties: {}, **context_params)
|
210
|
+
context = build(**context_params)
|
211
|
+
HangarX.track(
|
212
|
+
user_id: user_id,
|
213
|
+
event: event,
|
214
|
+
properties: properties.merge(context)
|
215
|
+
)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# Usage
|
220
|
+
AnalyticsContext.track(
|
221
|
+
user_id: 'user-123',
|
222
|
+
event: 'button_clicked',
|
223
|
+
properties: { button: 'signup' },
|
224
|
+
org_id: 'org_abc',
|
225
|
+
team_id: 'team_xyz',
|
226
|
+
client_id: 'client_def',
|
227
|
+
project_id: 'proj_ghi'
|
228
|
+
)
|
229
|
+
```
|
230
|
+
|
231
|
+
For complete multi-tenancy documentation, see [SDK_MULTI_TENANCY_TRACKING.md](../../SDK_MULTI_TENANCY_TRACKING.md)
|
232
|
+
|
233
|
+
---
|
234
|
+
|
235
|
+
### 4. Use Growth OS Features
|
85
236
|
|
86
237
|
```ruby
|
87
238
|
# Ask analytics questions
|