From 774dda05aa316c46a155ba46a25433ccc8754c8e Mon Sep 17 00:00:00 2001 From: CatalinVoss Date: Tue, 15 Mar 2022 23:21:19 -0700 Subject: [PATCH 1/2] Handle IP address and country code more readily --- __init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 01c0427..cc7df48 100755 --- a/__init__.py +++ b/__init__.py @@ -2262,7 +2262,7 @@ def _transform_amplitude_profiles(self, amplitude_profile): profile = { "$token": self.token, "$distinct_id": amplitude_profile["user_id"], - "$ip": amplitude_profile["ip_address"], + "$ip": amplitude_profile["ip_address"] if "ip_address" in amplitude_profile else "0.0.0.0", "$properties": {**properties, **default_properties} } @@ -2285,8 +2285,8 @@ def _transform_amplitude_events(self, amplitude_event): "amplitude_id"], "$device_id": amplitude_event["device_id"], "time": int(event_dt.timestamp() * 1000), - "ip": amplitude_event["ip_address"], - "mp_country_code": amplitude_event["country"] + "ip": amplitude_event["ip_address"] if "ip_address" in amplitude_event else "0.0.0.0", + "mp_country_code": amplitude_event["country"] if "country" in amplitude_event else "Unknown" } default_properties = { From e506e5f37d2594609fa25def0938d8019f7dac16 Mon Sep 17 00:00:00 2001 From: CatalinVoss Date: Tue, 15 Mar 2022 23:21:26 -0700 Subject: [PATCH 2/2] Add some logging --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index cc7df48..a800027 100755 --- a/__init__.py +++ b/__init__.py @@ -2372,7 +2372,7 @@ def _transform_and_load_amplitude_data(self, extract_data_path): event.get("user_id") and event.get("amplitude_id")] unique_merge_events = self._dedupe_merge_events(merge_events) - + print("Importing %s" % filename) self.import_people(transformed_profiles) self.import_events(transformed_events, 0) self.import_events(unique_merge_events, 0)