-
-
Couldn't load subscription status.
- Fork 255
Refine JSDoc / TypeScript types for plugins #324
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add https://getanalytics.io/resources/faq/#do-i-need-to-use-a-plugin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, maybe? Doesn't seem like this PR is getting any attention from the library maintainer so I'm not sure making any changes to it makes practical sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it seems like issues and PRs are increasing. I'm sure @DavidWells is just busy at the moment. Maybe it's time for a call for maintainers? 🤔 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,70 @@ | ||
| /** | ||
| * @callback PluginTrackFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @param {Object} arg.payload event data | ||
| * @param {string} arg.payload.event event name passed to track | ||
| * @param {Object.<string,Object>} arg.payload.properties event properties passed to track | ||
| * @return {void} | ||
| */ | ||
|
|
||
| /** | ||
| * @callback PluginPageFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @param {Object} arg.payload | ||
| * @param {string} arg.payload.event | ||
| * @param {PageData} arg.payload.properties | ||
| * @return {void} | ||
| */ | ||
|
|
||
| /** | ||
| * @callback PluginIdentifyFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @param {Object} arg.payload | ||
| * @param {string} arg.payload.userId | ||
| * @param {Object.<string,Object>} arg.payload.traits | ||
| * @return {void} | ||
| */ | ||
|
|
||
| /** | ||
| * @callback PluginInitializeFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @return boolean | ||
| */ | ||
|
|
||
| /** | ||
| * @callback PluginLoadedFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @param {Object} arg.payload | ||
| * @return boolean | ||
| */ | ||
|
|
||
| /** | ||
| * @callback PluginReadyFunction | ||
| * @param {Object} arg | ||
| * @param {Object} arg.config config from the plugin spec | ||
| * @param {AnalyticsInstance} arg.instance analytics instance | ||
| * @return void | ||
| */ | ||
|
|
||
| /** | ||
| * @typedef {Object} AnalyticsPlugin | ||
| * @property {string} name - Name of plugin | ||
| * @property {Object} [EVENTS] - exposed events of plugin | ||
| * @property {Object} [config] - Configuration of plugin | ||
| * @property {function} [initialize] - Load analytics scripts method | ||
| * @property {function} [page] - Page visit tracking method | ||
| * @property {function} [track] - Custom event tracking method | ||
| * @property {function} [identify] - User identify method | ||
| * @property {function} [loaded] - Function to determine if analytics script loaded | ||
| * @property {function} [ready] - Fire function when plugin ready | ||
| * @property {PluginPageFunction} [page] - Page visit tracking method | ||
| * @property {PluginTrackFunction} [track] - Custom event tracking method | ||
| * @property {PluginIdentifyFunction} [identify] - User identify method | ||
| * @property {PluginLoadedFunction} [loaded] - Function to determine if analytics script loaded | ||
| * @property {PluginReadyFunction} [ready] - Fire function when plugin ready | ||
|
Comment on lines
+65
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be one of these for every event named in |
||
| */ | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
This conflicted with the built-in type
Storageused forlocalStorage&sessionStorageso I took the liberty of renaming it while I was in here to fix the TypeScript error I got. Hopefully that's OK.