Skip to content

Commit 31ad7af

Browse files
committed
Release v1.0.2
1 parent 67590ea commit 31ad7af

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [1.0.1] - 2025-12-04
9-
8+
## [1.0.2] - 2025-12-04
109

10+
Updated examples in the README
1111

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,21 @@ client = Klime::Client.new(
3131
write_key: 'your-write-key'
3232
)
3333

34-
# Track an event
35-
client.track('Button Clicked', {
36-
button_name: 'Sign up',
37-
plan: 'pro'
38-
})
39-
4034
# Identify a user
4135
client.identify('user_123', {
4236
4337
name: 'Stefan'
4438
})
4539

46-
# Group a user with an organization
47-
client.group('org_456', {
48-
name: 'Acme Inc',
49-
plan: 'enterprise'
40+
# Track an event
41+
client.track('Button Clicked', {
42+
button_name: 'Sign up',
43+
plan: 'pro'
5044
}, user_id: 'user_123')
5145

46+
# Associate a user with a group
47+
client.group('org_456', user_id: 'user_123')
48+
5249
# Shutdown gracefully
5350
client.shutdown
5451
```
@@ -74,16 +71,16 @@ Klime::Client.new(
7471

7572
#### `track(event_name, properties = nil, user_id: nil, group_id: nil, ip: nil)`
7673

77-
Track a user event.
74+
Track a user event. A `user_id` is required for events to be useful in Klime.
7875

7976
```ruby
80-
# Simple usage
77+
# Basic usage
8178
client.track('Button Clicked', {
8279
button_name: 'Sign up',
8380
plan: 'pro'
84-
})
81+
}, user_id: 'user_123')
8582

86-
# With user context and IP
83+
# With group context and IP
8784
client.track('Button Clicked', {
8885
button_name: 'Sign up',
8986
plan: 'pro'
@@ -103,20 +100,22 @@ client.identify('user_123', {
103100

104101
#### `group(group_id, traits = nil, user_id: nil, ip: nil)`
105102

106-
Associate a user with a group and set group traits.
103+
Register a group or associate a user with a group.
104+
105+
**Without `user_id`**: Register or update group metadata. Use this when you want to set or update properties on a group (e.g., company name, plan, industry).
107106

108107
```ruby
109-
# Simple usage
110108
client.group('org_456', {
111109
name: 'Acme Inc',
112-
plan: 'enterprise'
110+
plan: 'enterprise',
111+
industry: 'Technology'
113112
})
113+
```
114114

115-
# With user ID and IP
116-
client.group('org_456', {
117-
name: 'Acme Inc',
118-
plan: 'enterprise'
119-
}, user_id: 'user_123', ip: '192.168.1.1')
115+
**With `user_id`**: Associate a user with a group. Use this to link users to their organization. Keep it simple—no traits needed.
116+
117+
```ruby
118+
client.group('org_456', user_id: 'user_123')
120119
```
121120

122121
#### `flush`
@@ -234,12 +233,13 @@ class KlimeMiddleware
234233
def call(env)
235234
status, headers, response = @app.call(env)
236235

237-
# Track page views
238-
if env['REQUEST_METHOD'] == 'GET' && status == 200
236+
# Track page views for authenticated users
237+
user_id = env['rack.session']&.dig('user_id')
238+
if user_id && env['REQUEST_METHOD'] == 'GET' && status == 200
239239
@client.track('Page View', {
240240
path: env['PATH_INFO'],
241241
method: env['REQUEST_METHOD']
242-
}, ip: env['REMOTE_ADDR'])
242+
}, user_id: user_id, ip: env['REMOTE_ADDR'])
243243
end
244244

245245
[status, headers, response]

klime.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gem::Specification.new do |spec|
44
spec.name = "klime"
5-
spec.version = "1.0.1"
5+
spec.version = "1.0.2"
66
spec.authors = ["Klime"]
77
spec.email = ["[email protected]"]
88

lib/klime/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

33
module Klime
4-
VERSION = "1.0.1"
4+
VERSION = "1.0.2"
55
end
66

0 commit comments

Comments
 (0)