-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix: type issues #1663
fix: type issues #1663
Conversation
WalkthroughThe updates across various packages primarily focus on enhancing flexibility and simplification in the analytics framework. Key adjustments include reorganizing imports and simplifying type exports in the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (7)
- packages/analytics-js-common/src/types/Consent.ts (1 hunks)
- packages/analytics-js/src/components/preloadBuffer/types.ts (1 hunks)
- packages/analytics-js/src/components/utilities/consent.ts (1 hunks)
- packages/analytics-js/src/index.ts (2 hunks)
- packages/analytics-js/src/types/rudderanalytics.d.ts (1 hunks)
- packages/loading-scripts/src/types/rudderanalytics.d.ts (1 hunks)
- packages/sanity-suite/src/types/rudderanalytics.d.ts (1 hunks)
Additional comments: 7
packages/analytics-js/src/components/preloadBuffer/types.ts (1)
- 4-4: The update to
RudderAnalyticsPreloader
to accept any type of arguments (...args: any[]
) increases the SDK's flexibility. However, consider using more specific types or generics to maintain type safety where possible.packages/analytics-js/src/types/rudderanalytics.d.ts (1)
- 10-10: The update to the
rudderanalytics
property in the globalWindow
interface to supportRudderAnalytics
,RudderAnalyticsPreloader
, orundefined
enhances the SDK's robustness and flexibility. This is a positive change.packages/loading-scripts/src/types/rudderanalytics.d.ts (1)
- 10-10: The consistent update across packages to allow the
rudderanalytics
property in theWindow
interface to beRudderAnalytics
,RudderAnalyticsPreloader
, orundefined
is commendable. This enhances the SDK's flexibility and robustness.packages/sanity-suite/src/types/rudderanalytics.d.ts (1)
- 10-10: The update to the
rudderanalytics
property in the globalWindow
interface across different packages, including the sanity-suite, ensures consistency and enhances the SDK's usability. Good job on maintaining coherent type definitions.packages/analytics-js-common/src/types/Consent.ts (1)
- 34-35: Making the
enabled
andprovider
fields optional in theConsentManagementOptions
type enhances flexibility in consent management configurations. This is a positive change that improves the SDK's usability.packages/analytics-js/src/index.ts (1)
- 2-2: The changes in this file, including the reorganization of imports, removal of
PreloadedEventCall
, and update to therudderanalytics
global interface, contribute to a cleaner and more intuitive SDK interface. These modifications align well with the PR's objectives.Also applies to: 25-25, 29-29
packages/analytics-js/src/components/utilities/consent.ts (1)
- 101-102: The updates to the
getConsentManagerInfo
function, including handling theprovider
property as potentiallyundefined
and the conditional assignment ofconsentManagerPluginName
, improve the robustness and flexibility of the consent management logic. These changes are well-aligned with the PR's objectives.
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1663 +/- ##
========================================
Coverage 53.89% 53.89%
========================================
Files 461 461
Lines 15588 15588
Branches 3105 3096 -9
========================================
Hits 8401 8401
- Misses 5833 5892 +59
+ Partials 1354 1295 -59 ☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (2)
- packages/analytics-js/src/index.ts (2 hunks)
- packages/loading-scripts/src/index.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/analytics-js/src/index.ts
Additional comments: 4
packages/loading-scripts/src/index.ts (4)
- 18-24: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [21-42]
The method assignment within the loop uses an immediately invoked function expression (IIFE) to create a closure around the
methodName
. This is a valid approach to ensure that each method has its own scope. However, consider using ES6 arrow functions for a cleaner syntax and better readability.- (window.rudderanalytics as unknown as RudderAnalyticsPreloader)[method] = (methodName => - function () { - (window.rudderanalytics as unknown as PreloadedEventCall[]).push( - [methodName].concat(Array.prototype.slice.call(arguments) as PreloadedEventCall), - ); - })(method); + (window.rudderanalytics as unknown as RudderAnalyticsPreloader)[method] = ((methodName) => + (...args) => { + (window.rudderanalytics as unknown as PreloadedEventCall[]).push([methodName, ...args]); + } + )(method);
- 18-24: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [21-42]
The use of
Array.prototype.slice.call(arguments)
to convertarguments
to an array is correct but can be simplified with the spread syntax in the context of an arrow function, as suggested in the previous comment.
- 18-24: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [21-42]
The dynamic import feature detection using
new Function('return import("")')
is a clever way to determine if the environment supports modern JavaScript features. However, ensure that this feature detection is necessary for the SDK's target environments and that it aligns with the overall strategy for supporting different JavaScript versions.
- 18-24: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [21-42]
The polyfill loading logic for
Promise
andglobalThis
is important for ensuring compatibility with older browsers. However, consider if there's a more efficient way to include these polyfills, such as through a build step that automatically includes necessary polyfills based on the target environments. This could potentially reduce the need for runtime checks and improve the loading performance.
Quality Gate passedIssues Measures |
size-limit report 📦
|
PR Description
RudderAnalyticsPreloader
typewindow.rudderanalytics
type to supportundefined
and removedPreloadedEventCall[]
.Linear task (optional)
https://linear.app/rudderstack/issue/SDK-1400/fix-gcm-typescript-support-issues
Cross Browser Tests
Please confirm you have tested for the following browsers:
Sanity Suite
Security
Summary by CodeRabbit
New Features
enabled
andprovider
fields optional.Refactor
rudderanalytics
property to supportRudderAnalytics
,RudderAnalyticsPreloader
, orundefined
, ensuring consistency across the platform.window.rudderanalytics
to ensure type safety in method assignments and event call handling.