Skip to content

Comments

Add modifier for last_seen_on#1482

Merged
rowanseymour merged 1 commit intomainfrom
seen_modifier
Feb 3, 2026
Merged

Add modifier for last_seen_on#1482
rowanseymour merged 1 commit intomainfrom
seen_modifier

Conversation

@rowanseymour
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings February 3, 2026 16:25
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.51%. Comparing base (4c24884) to head (72d492a).

Files with missing lines Patch % Lines
flows/modifiers/seen.go 86.36% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1482      +/-   ##
==========================================
+ Coverage   69.48%   69.51%   +0.03%     
==========================================
  Files         303      305       +2     
  Lines       17982    18010      +28     
==========================================
+ Hits        12495    12520      +25     
- Misses       5057     5059       +2     
- Partials      430      431       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour rowanseymour merged commit f6d4ea2 into main Feb 3, 2026
15 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new "seen" modifier to track when a contact was last seen, along with a corresponding event type to notify when this value changes.

Changes:

  • Added Seen modifier that updates a contact's last_seen_on timestamp
  • Added ContactLastSeenChanged event that fires when the last seen timestamp is updated
  • Added test data and test assets to support the new functionality

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
flows/modifiers/seen.go Implements the Seen modifier with logic to update last_seen_on only when the new timestamp is later
flows/events/contact_last_seen_changed.go Defines the ContactLastSeenChanged event type
flows/modifiers/testdata/seen.json Test data for the Seen modifier
flows/modifiers/testdata/_assets.json Adds "Seen In 2026" group for testing
flows/events/base_test.go Adds test case for ContactLastSeenChanged event marshaling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// "uuid": "0197b335-6ded-79a4-95a6-3af85b57f108",
// "type": "contact_last_seen_changed",
// "created_on": "2006-01-02T15:04:05Z",
// "seen_on": "2026-02-03T15:04:05Z"
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON field name in the documentation should be "last_seen_on" instead of "seen_on" to match the struct field name. The struct field LastSeenOn with the json tag json:"last_seen_on" will serialize to "last_seen_on" in JSON, not "seen_on".

Suggested change
// "seen_on": "2026-02-03T15:04:05Z"
// "last_seen_on": "2026-02-03T15:04:05Z"

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +47
[
{
"description": "last seen changed event if changed",
"contact_before": {
"uuid": "5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f",
"name": "Bob",
"status": "active",
"created_on": "2018-06-20T11:40:30.123456789Z"
},
"modifier": {
"type": "seen",
"seen_on": "2026-02-03T11:40:30.123456789Z"
},
"contact_after": {
"uuid": "5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f",
"name": "Bob",
"status": "active",
"created_on": "2018-06-20T11:40:30.123456789Z",
"last_seen_on": "2026-02-03T11:40:30.123456789Z",
"groups": [
{
"uuid": "23d0f9a4-5bb8-4577-b518-d404caef8cf3",
"name": "Seen In 2026"
}
]
},
"events": [
{
"uuid": "01969b47-0583-76f8-ae7f-f8b243c49ff5",
"type": "contact_last_seen_changed",
"created_on": "2025-05-04T12:30:46.123456789Z",
"last_seen_on": "2026-02-03T11:40:30.123456789Z"
},
{
"uuid": "01969b47-0d53-76f8-bd38-d266ec8d3716",
"type": "contact_groups_changed",
"created_on": "2025-05-04T12:30:48.123456789Z",
"groups_added": [
{
"uuid": "23d0f9a4-5bb8-4577-b518-d404caef8cf3",
"name": "Seen In 2026"
}
]
}
]
}
] No newline at end of file
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test data should include additional test cases to cover edge cases. Looking at similar modifiers like language.json, there should be at least two test cases: one where the last_seen_on changes (already covered) and one where it doesn't change (e.g., when the new seen_on is equal to or before the current last_seen_on). This would test the condition on line 39 of flows/modifiers/seen.go where the modifier should return false and not create an event.

Copilot uses AI. Check for mistakes.
@rowanseymour rowanseymour deleted the seen_modifier branch February 3, 2026 16:28
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant