Skip to content

Commit 52e4105

Browse files
authored
Merge pull request #2 from Hatuna/main
Added uid/cid logic to measurement protocol
2 parents ecc1b3a + 0956451 commit 52e4105

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

megalist_dataflow/uploaders/google_analytics/google_analytics_measurement_protocol.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import apache_beam as beam
2121
import requests
22+
import re
2223

2324
from uploaders import utils
2425
from models.execution import DestinationType, Batch
@@ -46,13 +47,14 @@ def process(self, batch: Batch, **kwargs):
4647
"ni": execution.destination.destination_metadata[1],
4748
"t": "event",
4849
"ds": "mp - megalista",
49-
"cid": row['client_id'],
50+
**{'cid': row[key] for key in row.keys() if key.startswith("client_id")},
51+
**{'uid': row[key] for key in row.keys() if key.startswith("user_id")},
5052
"ea": row['event_action'],
5153
"ec": row['event_category'],
5254
"ev": row.get('event_value'),
5355
"el": row.get('event_label'),
5456
"ua": self.UA,
55-
**{key: row[key] for key in list(filter(lambda key: key.startswith("cd"), row.keys()))}
57+
**{key: row[key] for key in row.keys() if re.match('c[dm]\d+',key)}
5658
} for row in rows]
5759

5860
encoded = [self._format_hit(payload) for payload in payloads]

0 commit comments

Comments
 (0)