Skip to content

Commit

Permalink
feat: Replace segmnet with mixpanel to track events
Browse files Browse the repository at this point in the history
  • Loading branch information
prabs222 committed Aug 16, 2024
1 parent f63c887 commit e4843ed
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
SLACK_APP_ID: ${{ secrets.SLACK_APP_ID }}
SLACK_SERVICE_BASE_URL: ${{ secrets.SLACK_SERVICE_BASE_URL }}
FYLEHQ_SLACK_URL: 'fakefylehqurl'
FYLE_SLACK_APP_SEGMENT_KEY: ${{ secrets.FYLE_SLACK_APP_SEGMENT_KEY }}
FYLE_SLACK_APP_MIXPANEL_TOKEN: ${{ secrets.FYLE_SLACK_APP_MIXPANEL_TOKEN }}
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
SLACK_APP_ID: ${{ secrets.SLACK_APP_ID }}
SLACK_SERVICE_BASE_URL: ${{ secrets.SLACK_SERVICE_BASE_URL }}
FYLEHQ_SLACK_URL: 'fakefylehqurl'
FYLE_SLACK_APP_SEGMENT_KEY: ${{ secrets.FYLE_SLACK_APP_SEGMENT_KEY }}
FYLE_SLACK_APP_MIXPANEL_TOKEN: ${{ secrets.FYLE_SLACK_APP_MIXPANEL_TOKEN }}
ALLOWED_HOSTS: ${{ secrets.ALLOWED_HOSTS }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USER: ${{ secrets.DB_USER }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
SLACK_APP_ID=fakeslackappid
SLACK_SERVICE_BASE_URL=akeslackservicebaseurl
FYLEHQ_SLACK_URL=fakefylehqurl
FYLE_SLACK_APP_SEGMENT_KEY=fakesegmentkey
FYLE_SLACK_APP_MIXPANEL_TOKEN=fakesegmentkey
ALLOWED_HOSTS=fakeallowedhosts
DB_NAME=database
DB_USER=slack_user
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
SLACK_APP_ID: ${SLACK_APP_ID}
SLACK_SERVICE_BASE_URL: ${SLACK_SERVICE_BASE_URL}
FYLEHQ_SLACK_URL: 'fakefylehqurl'
FYLE_SLACK_APP_SEGMENT_KEY: ${FYLE_SLACK_APP_SEGMENT_KEY}
FYLE_SLACK_APP_MIXPANEL_TOKEN: ${FYLE_SLACK_APP_MIXPANEL_TOKEN}
DB_NAME: slack_db
DB_USER: postgres
DB_PASSWORD: postgres
Expand Down
10 changes: 6 additions & 4 deletions fyle_slack_app/tracking.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import analytics
from mixpanel import Mixpanel

from django.conf import settings

FYLE_SLACK_APP_MIXPANEL_TOKEN = settings.FYLE_SLACK_APP_MIXPANEL_TOKEN

mixpanel_client = Mixpanel(FYLE_SLACK_APP_MIXPANEL_TOKEN)

analytics.write_key = settings.FYLE_SLACK_APP_SEGMENT_KEY

def identify_user(user_email) -> bool:
analytics.identify(user_email, {})
mixpanel_client.people_set(user_email, {})
return True


def track_event(user_email, event_name, event_data) -> bool:
analytics.track(user_email, event_name, event_data)
mixpanel_client.track(user_email, event_name, event_data)
return True
2 changes: 1 addition & 1 deletion fyle_slack_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
FYLE_ACCOUNTS_URL = os.environ['FYLE_ACCOUNTS_URL']
FYLE_CLIENT_ID = os.environ['FYLE_CLIENT_ID']
FYLE_CLIENT_SECRET = os.environ['FYLE_CLIENT_SECRET']
FYLE_SLACK_APP_SEGMENT_KEY = os.environ['FYLE_SLACK_APP_SEGMENT_KEY']
FYLE_SLACK_APP_MIXPANEL_TOKEN = os.environ['FYLE_SLACK_APP_MIXPANEL_TOKEN']
FYLE_BRANCHIO_BASE_URI = os.environ['FYLE_BRANCHIO_BASE_URI']

# Slack Settings
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ iniconfig==1.1.1
isort==5.7.0
lazy-object-proxy==1.5.1
mccabe==0.6.1
mixpanel==4.10.1
mock==4.0.3
multidict==5.1.0
natsort==7.1.1
Expand Down

0 comments on commit e4843ed

Please sign in to comment.