Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ABSmartly"
version = "0.2.3"
version = "0.2.4"
description = "ABSmartly Python SDK lib"
readme = "README.md"
authors = [{ name = "ABSmartly", email = "info@ABSmartly.com" }]
Expand Down
4 changes: 2 additions & 2 deletions sdk/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,11 @@ def publish_async(self):
self.check_not_closed()
return self.flush()

def track(self, goal_name: str, properties: dict):
def track(self, goal_name: str, properties: dict, achieved_at: int = None):
self.check_not_closed()

achievement = GoalAchievement()
achievement.achievedAt = self.clock.millis()
achievement.achievedAt = achieved_at or self.clock.millis()
achievement.name = goal_name
if properties is None:
achievement.properties = None
Expand Down
17 changes: 17 additions & 0 deletions test/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,20 @@ def test_assignment_with_historical_exposed_at_timestamp(self):
exposure = context.exposures[0]
self.assertEqual(1713218400000, exposure.exposedAt)
context.close()

def test_achievement_with_historical_achieved_at_timestamp(self):
self.set_up()
config = ContextConfig()
config.units = self.units
context = self.create_test_context(config, self.data_future_ready)
self.assertEqual(True, context.is_ready())
self.assertEqual(False, context.is_failed())

context.track(
"goal_test_historical_timestamp",
properties = {},
achieved_at = 1713218400000
)
achievement = context.achievements[0]
self.assertEqual(1713218400000, achievement.achievedAt)
context.close()