import tracker

from tracker import AnalyticService


class PublisherAnalyticsService(AnalyticService):
    def __init__(self):
        self.cluster_id = None
        self.publisher = None

    def get_cluster_id(self):
        if self.cluster_id:
            return self.cluster_id

        from clusters.models import Cluster
        cluster_uuid = Cluster.load().uuid.hex
        self.cluster_id = cluster_uuid
        return self.cluster_id

    def record_event(self, event):
        self.publisher.publish(
            self.cluster_id,  # Add to data
            data=event.serialize(dumps=True),
        )

@@ -1,22 +1,24 @@
 import 
-tracker
+analytics
 %0A%0Afrom t
@@ -179,20 +179,76 @@
 isher = 
-None
+analytics%0A        # Set key%0A        analytics.write_key = ''
 %0A%0A    de
@@ -555,23 +555,21 @@
 blisher.
-publish
+track
 (%0A      

Update publisher