Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Replace segmnet with mixpanel to track events #126

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=fakemixpaneltoken
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
3 changes: 2 additions & 1 deletion 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 All @@ -34,7 +35,7 @@ pytz==2021.1
requests==2.26.0
sentry-sdk==1.3.1
six==1.15.0
slack-sdk==3.3.1
slack-sdk==3.31.0
sqlparse==0.4.2
toml==0.10.2
typing-extensions==3.7.4.3
Expand Down
Loading