-
Notifications
You must be signed in to change notification settings - Fork 5
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
Create a simple event tracking package #472
base: dev
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #472 +/- ##
=======================================
Coverage 22.38% 22.38%
=======================================
Files 132 132
Lines 5521 5521
Branches 241 241
=======================================
Hits 1236 1236
Misses 4285 4285
|
5b20b24
to
cd7e962
Compare
Is there an issue to link here? |
There was but I'm struggling to find it. I think I left it in "draft" and possibly lost it. |
EDIT: Feel like I answered my own question looking at how these things are linked. One issue per PR seems to be the only real logical choice. |
c92b553
to
87dcb52
Compare
87dcb52
to
737d3fb
Compare
You can link multiple issues to one PR if needed ...sometimes a PR will close multiple open issues. |
@camerow are you using GH notifications? They can be super helpful. I keep a tab pinned with my notifications always open. |
} | ||
// TODO: replace ledger_nativesegwit_add_nonwitnessutxo with this method call. | ||
// TODO: replace ledger_nativesegwit_skip_add_nonwitnessutxo with this method call. | ||
public async trackLedgerNativesegwitAddNonwitnessUtxo(properties: { |
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.
public async trackLedgerNativesegwitAddNonwitnessUtxo(properties: { | |
public async trackLedgerNativeSegwitAddNonWitnessUtxo(properties: { |
|
||
// TODO: replace view_transaction_confirmation with this method call. | ||
public async trackViewTransactionConfirmation(properties: { symbol: string }) { | ||
return this.track('Transaction Confirmation Viewed', properties); |
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.
Not sure about the naming pattern change here? @markmhendrickson is this change ok? I know we coordinated the snake_case
for naming quite awhile ago.
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.
I'm cool with updating the naming pattern. Let's just be sure to alias old names to the new ones if we update them, so we can continue reporting consistently.
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.
Mentioned on slack, but would push back against this change. What's superior about this naming scheme that warrants the effort of doing the aliasing for 100s of events? Per Mixpanel docs
Generally, adopting snake_case for your event and property names tend to be more robust, especially if you plan to export your Mixpanel data to downstream processes such as data warehouses.
If we ever want to programmatically do anything with this data, we have to start escaping spaces in the ids etc, it's a limiting decision.
I see parallels here with how we're moving to ids for our localisation. sentences !== programatic identifiers.
'defaultProperties' | 'defaultTraits' | ||
>; | ||
|
||
export class AnalyticsClient<T extends GenericAnalyticsClient> { |
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 the choice here to use a class over a function? We just refactored our api clients away from using classes.
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.
I would like to store a reference to options
and creating a class seemed to be the best way. WHat is the disadvantage of a class over a function?
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.
Nothing inherently wrong using a class
here, and think it's okay for a package like this, but I think Fara's mentioning because we typically favour a more functional approach. Classes often lead to inheritance over composition, mutative methods over pure functions etc. Use of classes in Javascript is a hotly debated topic.
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.
Yep, was just questioning based on Kyran's feedback here. Some suggest to avoid classes in JS if possible, so was just curious about your choice.
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 @camerow 👍
This code LGTM so good to merge, especially as the package is not yet consumed.
I like the readability of the uppercase events better but I'm not sure if we need snake_case
for some reason
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.
Great start @camerow
const configureAnalyticsClient = ({ | ||
writeKey, | ||
defaultProperties, | ||
client, | ||
}: AnalyticsClientConfig) => { | ||
const nativeClient = | ||
client ?? | ||
createClient({ | ||
writeKey, | ||
}); | ||
|
||
analyticsClient = new AnalyticsClient(nativeClient, { defaultProperties }); | ||
|
||
return analyticsClient; | ||
}; | ||
|
||
export { analyticsClient, configureAnalyticsClient }; |
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 configureAnalyticsClient = ({ | |
writeKey, | |
defaultProperties, | |
client, | |
}: AnalyticsClientConfig) => { | |
const nativeClient = | |
client ?? | |
createClient({ | |
writeKey, | |
}); | |
analyticsClient = new AnalyticsClient(nativeClient, { defaultProperties }); | |
return analyticsClient; | |
}; | |
export { analyticsClient, configureAnalyticsClient }; | |
export function configureAnalyticsClient ({ | |
writeKey, | |
defaultProperties, | |
client, | |
}: AnalyticsClientConfig) { | |
const nativeClient = | |
client ?? | |
createClient({ | |
writeKey, | |
}); | |
analyticsClient = new AnalyticsClient(nativeClient, { defaultProperties }); | |
return analyticsClient; | |
} |
Convention used elsewhere is to use function declarations
export type JsonValue = boolean | number | string | null | JsonList | JsonMap | undefined; | ||
|
||
export interface JsonMap { | ||
[key: string]: JsonValue; | ||
[index: number]: JsonValue; | ||
} | ||
|
||
export type JsonList = JsonValue[]; |
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.
Seems like a candidate for utils pkg
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.
Great work!
@@ -0,0 +1 @@ | |||
nodejs 20.12.2 |
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.
As we already have .prototools, i would suggest not using more dot files to keep a version of tools.
Overview
Assumptions
Future steps
I decided to just create the package and not include it anywhere for now. This is just to scope out the work such that we can identify more clearly when we added this to the respective applications, update stakeholders on name changes, etc.