Skip to content

Commit

Permalink
chore: set lookback window to a constant of 30 mins
Browse files Browse the repository at this point in the history
  • Loading branch information
am6010 committed May 26, 2023
1 parent cff4b79 commit 2673402
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
"""
api_key = config["api_key"]
start_date = config["start_date"]
events_look_back_window = config.get("events_look_back_window", 0)
return [
Campaigns(api_key=api_key),
Events(api_key=api_key, start_date=start_date, events_look_back_window=events_look_back_window),
Events(api_key=api_key, start_date=start_date),
GlobalExclusions(api_key=api_key, start_date=start_date),
Lists(api_key=api_key),
Metrics(api_key=api_key),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
"examples": ["2017-01-25T00:00:00Z"],
"type": "string",
"format": "date-time"
},
"events_look_back_window": {
"title": "Events Look Back Window In Minutes",
"description": "Events data created in the past N minutes since your last sync ended is re-exported.",
"type": "integer",
"examples": [10, 20, 30, 60, 120],
"default": 0
}
},
"required": ["api_key", "start_date"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,12 @@ def path(self, **kwargs) -> str:

class Events(IncrementalKlaviyoStream):
"""Docs: https://developers.klaviyo.com/en/reference/metrics-timeline"""
def __init__(self, start_date:str, events_look_back_window: int, **kwargs):
super().__init__(start_date=start_date, **kwargs)
self.events_look_back_window = events_look_back_window

cursor_field = "timestamp"

@property
def look_back_window_in_seconds(self) -> Optional[int]:
return timedelta(minutes=self.events_look_back_window).seconds
return timedelta(minutes=30).seconds

def path(self, **kwargs) -> str:
return "metrics/timeline"
Expand Down

0 comments on commit 2673402

Please sign in to comment.