-
Notifications
You must be signed in to change notification settings - Fork 303
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
Adrienne / Rudderstack integration #9013
Adrienne / Rudderstack integration #9013
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
🚨 Lighthouse report for the changes in this PR:
Lighthouse ran with https://deriv-app-git-fork-adrienne-deriv-rudderstack-integration-hook.binary.sx/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work man 🚀
I think we can go with a simpler implementation, We basically just want to add types around RudderStack SDK 🤔 What do you think? 🤔
class RudderStack {
constructor() {
this.init();
}
init = () => {
// Abort if RudderStack key or url is not set in .env
if (!process.env.RUDDERSTACK_KEY || !process.env.RUDDERSTACK_URL) return;
rudderanalytics.load(process.env.RUDDERSTACK_KEY, process.env.RUDDERSTACK_URL);
};
identify = (user_id: string, payload: TEvents['identify']) => rudderanalytics.identify(user_id, payload);
track = <T extends keyof TEvents>(event: T, payload: TPayload[T]) => rudderanalytics.track(event, payload);
page = (name: string) => rudderanalytics.page('Deriv App', name);
reset = () => rudderanalytics.reset();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🚀
packages/core/src/index.html
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🚀
pageView() { | ||
const current_page = window.location.hostname + window.location.pathname; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageView() { | |
const current_page = window.location.hostname + window.location.pathname; | |
pageView(current_page: string) { |
@adrienne-deriv Let's make it prop instead of using window.
packages/shared/package-lock.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adrienne-deriv This file shouldn't be in the changes 👀
packages/shared/src/index.ts
Outdated
@@ -1,4 +1,5 @@ | |||
export * from './services'; | |||
export * from './utils/analytics'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adrienne-deriv I would still recommend creating a new package like @deriv/analytics
and move this implementation there instead of @deriv/shared
👀
cc: @yashim-deriv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. I think this would be a great thing to abstract out, as we will surely use it in multiple projects as we abstract out the projects.
current_page = ''; | ||
|
||
constructor() { | ||
const write_key = isProduction() ? process.env.RUDDERSTACK_PRODUCTION_KEY : process.env.RUDDERSTACK_STAGING_KEY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const write_key = isProduction() ? process.env.RUDDERSTACK_PRODUCTION_KEY : process.env.RUDDERSTACK_STAGING_KEY; | |
const write_key = process.env.RUDDERSTACK_KEY; |
This should be handled in the CI, We should expose the different environment variables there 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with our current circleci setup this is not possible.
what we can do is to decide based on the circle ci job name.
I believe @adrienne-deriv is implementing it now in that way.
track<EventType extends keyof RSEvents, EventPayload extends RSEvents[EventType]>( | ||
event_type: EventType, | ||
payload: EventPayload | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
track<EventType extends keyof RSEvents, EventPayload extends RSEvents[EventType]>( | |
event_type: EventType, | |
payload: EventPayload | |
) { | |
track<T extends keyof TEvents>(event: T, payload: TPayload[T]) { |
@adrienne-deriv Let's name things simpler 🙇🏻
error_message?: string; | ||
}; | ||
|
||
type TradeTypesFormAction = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adrienne-deriv Let's do some type improvements together when you are free if you like 🙇🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeaah I need some feedback on these types 😅
rudderstack.identifyEvent(user_id, { | ||
language: getLanguage().toLowerCase() || 'en', | ||
}); | ||
rudderstack.pageView(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to call pageView()
again? because It's being called inside identyfyEvent
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and correct me if I'm wrong, we are calling identyfyEvent
inside client-store
after user is logged in. so here when we call it again, it's not going to do anything because has_initialized
is already set to true , right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I've added rudderstack.reset()
when the user logs out, so this resets the state has_identified
to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'll remove the pageView call inside identifyEvent
, it should be called separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing. I agree with Farzin and Mark about abstracting these things in a separate package so It can be used across all of our projects.
packages/shared/package-lock.json
Outdated
@@ -0,0 +1,6373 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this package-lock and run npm run bootstrap:dev
in the root 🙏
…riv/deriv-app into rudderstack-integration-hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
…riv/deriv-app into rudderstack-integration-hook
9820005
} | ||
|
||
init() { | ||
const isProduction = process.env.CIRCLE_JOB === 'release_production'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please write it in a way to make sure CIRCLE_JOB is either production or staging otherwise you need to skip it.
lets say on test links or localhost, we need to exclude them, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
✨ PR has been merged by Paimon the Release Bot |
Changes:
rudderstack-store
from root storePlease provide a summary of the change.
Screenshots:
Please provide some screenshots of the change.