This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API_URL = 'https://app.posthog.com/'; | |
const corsHeaders = { | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Methods': 'GET,HEAD,POST,OPTIONS', | |
'Access-Control-Max-Age': '86400', | |
}; | |
const ORIGIN = new URL(API_URL).origin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__LONG_SCALE__ = float(0xFFFFFFFFFFFFFFF) | |
import hashlib | |
import secrets | |
def hash(identifier): | |
hash_key = f"test.{identifier}.{secrets.token_hex(32)}" | |
hash_val = int(hashlib.sha1(hash_key.encode("utf-8")).hexdigest()[:15], 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In your time-sensitive process | |
tracker = Mixpanel::Tracker.new(YOUR_POSTHOG_TOKEN) do |type, message| | |
@queue.set('mixpanel_queue', [ type, message ].to_json) | |
end | |
# Track just like you would in any other situation | |
tracker.track(user_id, 'Sent Message') | |
tracker.people.increment(user_id, { | |
'Messages Sent' => 1 | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mixpanel import Mixpanel, Consumer, MixpanelException | |
class PostHogConsumer(Consumer): | |
_posthog_endpoints = { | |
'events': 'https://t.posthog.com/capture', | |
'people': 'https://t.posthog.com/engage', | |
'groups': 'https://t.posthog.com/groups', | |
'imports': 'https://t.posthog.com/import' | |
} | |
_posthog_api_key = '<posthog_key>' |