From 3246ccda2f068240e2166a0e0c6d2996cff44db9 Mon Sep 17 00:00:00 2001 From: Kamil Grzaba Date: Thu, 11 Jul 2024 10:28:07 +0200 Subject: [PATCH] infered return types --- package-lock.json | 4 +- package.json | 2 +- .../content-tracking.service.ts | 58 +++++++------- .../cookie-management.service.ts | 80 +++++++++++-------- .../custom-dimensions.service.ts | 24 +++--- .../custom-event/custom-events.service.ts | 2 +- .../services/data-layer/data-layer.service.ts | 2 +- .../download-and-outlink.service.ts | 76 ++++++++++-------- .../services/e-commerce/e-commerce.service.ts | 10 +-- .../goal-conversions.service.ts | 2 +- .../services/page-views/page-views.service.ts | 2 +- .../site-search/site-search.service.ts | 9 +-- .../user-management.service.ts | 16 ++-- 13 files changed, 152 insertions(+), 135 deletions(-) diff --git a/package-lock.json b/package-lock.json index 34beabb..53bac01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@piwikpro/ngx-piwik-pro-project", - "version": "1.1.1", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@piwikpro/ngx-piwik-pro-project", - "version": "1.1.1", + "version": "2.0.0", "license": "MIT", "dependencies": { "@angular/animations": "^18.0.0", diff --git a/package.json b/package.json index 584c767..24d8b7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@piwikpro/ngx-piwik-pro-project", - "version": "1.1.1", + "version": "2.0.0", "scripts": { "ng": "ng", "start": "ng serve", diff --git a/projects/ngx-piwik-pro/src/lib/services/content-tracking/content-tracking.service.ts b/projects/ngx-piwik-pro/src/lib/services/content-tracking/content-tracking.service.ts index 1bd7081..316635e 100644 --- a/projects/ngx-piwik-pro/src/lib/services/content-tracking/content-tracking.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/content-tracking/content-tracking.service.ts @@ -4,34 +4,34 @@ import { Injectable } from '@angular/core'; type IContentTracking = typeof ContentTracking; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class ContentTrackingService { - trackAllContentImpressions(...params: Parameters) { - ContentTracking.trackAllContentImpressions(...params); - } - - trackVisibleContentImpressions(...params: Parameters) { - ContentTracking.trackVisibleContentImpressions(...params); - } - - trackContentImpressionsWithinNode(...params: Parameters) { - ContentTracking.trackContentImpressionsWithinNode(...params); - } - - trackContentImpression(...params: Parameters) { - ContentTracking.trackContentImpression(...params); - } - - logAllContentBlocksOnPage(...params: Parameters): void { - ContentTracking.logAllContentBlocksOnPage(...params); - } - - trackContentInteractionNode(...params: Parameters) { - ContentTracking.trackContentInteractionNode(...params); - } - - trackContentInteraction(...params: Parameters) { - ContentTracking.trackContentInteraction(...params); - } -} + trackAllContentImpressions(...params: Parameters): ReturnType { + return ContentTracking.trackAllContentImpressions(...params); + } + + trackVisibleContentImpressions(...params: Parameters): ReturnType { + return ContentTracking.trackVisibleContentImpressions(...params); + } + + trackContentImpressionsWithinNode(...params: Parameters): ReturnType { + return ContentTracking.trackContentImpressionsWithinNode(...params); + } + + trackContentImpression(...params: Parameters): ReturnType { + return ContentTracking.trackContentImpression(...params); + } + + logAllContentBlocksOnPage(...params: Parameters): ReturnType { + return ContentTracking.logAllContentBlocksOnPage(...params); + } + + trackContentInteractionNode(...params: Parameters): ReturnType { + return ContentTracking.trackContentInteractionNode(...params); + } + + trackContentInteraction(...params: Parameters): ReturnType { + return ContentTracking.trackContentInteraction(...params); + } +} \ No newline at end of file diff --git a/projects/ngx-piwik-pro/src/lib/services/cookie-management/cookie-management.service.ts b/projects/ngx-piwik-pro/src/lib/services/cookie-management/cookie-management.service.ts index c988466..e50442b 100644 --- a/projects/ngx-piwik-pro/src/lib/services/cookie-management/cookie-management.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/cookie-management/cookie-management.service.ts @@ -4,40 +4,50 @@ import { Injectable } from '@angular/core'; type ICookieManagement = typeof CookieManagement; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class CookieManagementService { - disableCookies(...params: Parameters) { - CookieManagement.disableCookies(...params); - } - enableCookies(...params: Parameters) { - CookieManagement.enableCookies(...params); - } - deleteCookies(...params: Parameters) { - CookieManagement.deleteCookies(...params); - } - hasCookies(...params: Parameters): Promise { - return CookieManagement.hasCookies(...params); - } - setCookieNamePrefix(...params: Parameters) { - CookieManagement.setCookieNamePrefix(...params); - } - setCookieDomain(...params: Parameters) { - CookieManagement.setCookieDomain(...params); - } - setCookiePath(...params: Parameters) { - CookieManagement.setCookiePath(...params); - } - setSecureCookie(...params: Parameters) { - CookieManagement.setSecureCookie(...params); - } - setVisitorCookieTimeout(...params: Parameters) { - CookieManagement.setVisitorCookieTimeout(...params); - } - setSessionCookieTimeout(...params: Parameters) { - CookieManagement.setSessionCookieTimeout(...params); - } - setVisitorIdCookie(...params: Parameters) { - CookieManagement.setVisitorIdCookie(...params); - } -} + disableCookies(...params: Parameters): ReturnType { + return CookieManagement.disableCookies(...params); + } + + enableCookies(...params: Parameters): ReturnType { + return CookieManagement.enableCookies(...params); + } + + deleteCookies(...params: Parameters): ReturnType { + return CookieManagement.deleteCookies(...params); + } + + hasCookies(...params: Parameters): ReturnType { + return CookieManagement.hasCookies(...params); + } + + setCookieNamePrefix(...params: Parameters): ReturnType { + return CookieManagement.setCookieNamePrefix(...params); + } + + setCookieDomain(...params: Parameters): ReturnType { + return CookieManagement.setCookieDomain(...params); + } + + setCookiePath(...params: Parameters): ReturnType { + return CookieManagement.setCookiePath(...params); + } + + setSecureCookie(...params: Parameters): ReturnType { + return CookieManagement.setSecureCookie(...params); + } + + setVisitorCookieTimeout(...params: Parameters): ReturnType { + return CookieManagement.setVisitorCookieTimeout(...params); + } + + setSessionCookieTimeout(...params: Parameters): ReturnType { + return CookieManagement.setSessionCookieTimeout(...params); + } + + setVisitorIdCookie(...params: Parameters): ReturnType { + return CookieManagement.setVisitorIdCookie(...params); + } +} \ No newline at end of file diff --git a/projects/ngx-piwik-pro/src/lib/services/custom-dimensions/custom-dimensions.service.ts b/projects/ngx-piwik-pro/src/lib/services/custom-dimensions/custom-dimensions.service.ts index 5b8f31b..b1ab867 100644 --- a/projects/ngx-piwik-pro/src/lib/services/custom-dimensions/custom-dimensions.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/custom-dimensions/custom-dimensions.service.ts @@ -4,18 +4,18 @@ import { Injectable } from '@angular/core'; type ICustomDimensions = typeof CustomDimensions; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class CustomDimensionsService { - getCustomDimensionValue(...params: Parameters): Promise { - return CustomDimensions.getCustomDimensionValue(...params); - } - - setCustomDimensionValue(...params: Parameters) { - CustomDimensions.setCustomDimensionValue(...params); - } + getCustomDimensionValue(...params: Parameters): ReturnType { + return CustomDimensions.getCustomDimensionValue(...params); + } + + setCustomDimensionValue(...params: Parameters): ReturnType { + return CustomDimensions.setCustomDimensionValue(...params); + } - deleteCustomDimension(...params: Parameters) { - CustomDimensions.deleteCustomDimension(...params); - } -} + deleteCustomDimension(...params: Parameters): ReturnType { + return CustomDimensions.deleteCustomDimension(...params); + } +} \ No newline at end of file diff --git a/projects/ngx-piwik-pro/src/lib/services/custom-event/custom-events.service.ts b/projects/ngx-piwik-pro/src/lib/services/custom-event/custom-events.service.ts index f54a168..d6d10b4 100644 --- a/projects/ngx-piwik-pro/src/lib/services/custom-event/custom-events.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/custom-event/custom-events.service.ts @@ -7,7 +7,7 @@ type ICustomEvent = typeof CustomEvent; providedIn: 'root' }) export class CustomEventsService { - trackEvent(...params: Parameters) { + trackEvent(...params: Parameters): ReturnType { CustomEvent.trackEvent(...params) } } diff --git a/projects/ngx-piwik-pro/src/lib/services/data-layer/data-layer.service.ts b/projects/ngx-piwik-pro/src/lib/services/data-layer/data-layer.service.ts index ced6aeb..9d62f28 100644 --- a/projects/ngx-piwik-pro/src/lib/services/data-layer/data-layer.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/data-layer/data-layer.service.ts @@ -7,7 +7,7 @@ type IDataLayer = typeof DataLayer; providedIn: 'root' }) export class DataLayerService { - push(...params: Parameters) { + push(...params: Parameters): ReturnType { return DataLayer.push(...params); } } diff --git a/projects/ngx-piwik-pro/src/lib/services/download-and-outlink/download-and-outlink.service.ts b/projects/ngx-piwik-pro/src/lib/services/download-and-outlink/download-and-outlink.service.ts index 29e0642..042cb30 100644 --- a/projects/ngx-piwik-pro/src/lib/services/download-and-outlink/download-and-outlink.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/download-and-outlink/download-and-outlink.service.ts @@ -1,41 +1,49 @@ -import { Dimensions, DownloadAndOutlink } from '@piwikpro/tracking-base-library' - +import { DownloadAndOutlink } from '@piwikpro/tracking-base-library' import { Injectable } from '@angular/core'; type IDownloadAndOutlink = typeof DownloadAndOutlink; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class DownloadAndOutlinkService { - trackLink(...params: Parameters) { - DownloadAndOutlink.trackLink(...params); - } - enableLinkTracking(...params: Parameters) { - DownloadAndOutlink.enableLinkTracking(...params); - } - setLinkClasses(...params: Parameters) { - DownloadAndOutlink.setLinkClasses(...params); - } - setDownloadClasses(...params: Parameters) { - DownloadAndOutlink.setDownloadClasses(...params); - } - setDownloadExtensions(...params: Parameters) { - DownloadAndOutlink.setDownloadExtensions(...params); - } - addDownloadExtensions(...params: Parameters) { - DownloadAndOutlink.addDownloadExtensions(...params); - } - removeDownloadExtensions(...params: Parameters) { - DownloadAndOutlink.removeDownloadExtensions(...params); - } - setLinkTrackingTimer(...params: Parameters) { - DownloadAndOutlink.setLinkTrackingTimer(...params); - } - getLinkTrackingTimer(...params: Parameters) { - return DownloadAndOutlink.getLinkTrackingTimer(...params); - } - setIgnoreClasses(...params: Parameters) { - DownloadAndOutlink.setIgnoreClasses(...params); - } -} + trackLink(...params: Parameters): ReturnType { + return DownloadAndOutlink.trackLink(...params); + } + + enableLinkTracking(...params: Parameters): ReturnType { + return DownloadAndOutlink.enableLinkTracking(...params); + } + + setLinkClasses(...params: Parameters): ReturnType { + return DownloadAndOutlink.setLinkClasses(...params); + } + + setDownloadClasses(...params: Parameters): ReturnType { + return DownloadAndOutlink.setDownloadClasses(...params); + } + + setDownloadExtensions(...params: Parameters): ReturnType { + return DownloadAndOutlink.setDownloadExtensions(...params); + } + + addDownloadExtensions(...params: Parameters): ReturnType { + return DownloadAndOutlink.addDownloadExtensions(...params); + } + + removeDownloadExtensions(...params: Parameters): ReturnType { + return DownloadAndOutlink.removeDownloadExtensions(...params); + } + + setLinkTrackingTimer(...params: Parameters): ReturnType { + return DownloadAndOutlink.setLinkTrackingTimer(...params); + } + + getLinkTrackingTimer(...params: Parameters): ReturnType { + return DownloadAndOutlink.getLinkTrackingTimer(...params); + } + + setIgnoreClasses(...params: Parameters): ReturnType { + return DownloadAndOutlink.setIgnoreClasses(...params); + } +} \ No newline at end of file diff --git a/projects/ngx-piwik-pro/src/lib/services/e-commerce/e-commerce.service.ts b/projects/ngx-piwik-pro/src/lib/services/e-commerce/e-commerce.service.ts index 99035c3..aa57e98 100644 --- a/projects/ngx-piwik-pro/src/lib/services/e-commerce/e-commerce.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/e-commerce/e-commerce.service.ts @@ -35,7 +35,7 @@ export class ECommerceService { ]) } - ecommerceAddToCart(...params: Parameters) { + ecommerceAddToCart(...params: Parameters): ReturnType { eCommerce.ecommerceAddToCart(...params) } @@ -49,7 +49,7 @@ export class ECommerceService { ]) } - ecommerceRemoveFromCart(...params: Parameters) { + ecommerceRemoveFromCart(...params: Parameters): ReturnType { eCommerce.ecommerceRemoveFromCart(...params) } @@ -103,7 +103,7 @@ export class ECommerceService { ]); } - ecommerceOrder(...params: Parameters) { + ecommerceOrder(...params: Parameters): ReturnType { eCommerce.ecommerceOrder(...params) } @@ -117,7 +117,7 @@ export class ECommerceService { ]); } - ecommerceCartUpdate(...params: Parameters) { + ecommerceCartUpdate(...params: Parameters): ReturnType { eCommerce.ecommerceCartUpdate(...params) } @@ -134,7 +134,7 @@ export class ECommerceService { ]); } - ecommerceProductDetailView(...params: Parameters) { + ecommerceProductDetailView(...params: Parameters): ReturnType { eCommerce.ecommerceProductDetailView(...params) } } diff --git a/projects/ngx-piwik-pro/src/lib/services/goal-conversions/goal-conversions.service.ts b/projects/ngx-piwik-pro/src/lib/services/goal-conversions/goal-conversions.service.ts index dba5dcc..c110b37 100644 --- a/projects/ngx-piwik-pro/src/lib/services/goal-conversions/goal-conversions.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/goal-conversions/goal-conversions.service.ts @@ -7,7 +7,7 @@ type IGoalConversions = typeof GoalConversions; providedIn: 'root' }) export class GoalConversionsService { - trackGoal( ...params: Parameters) { + trackGoal( ...params: Parameters): ReturnType { GoalConversions.trackGoal(...params) } } diff --git a/projects/ngx-piwik-pro/src/lib/services/page-views/page-views.service.ts b/projects/ngx-piwik-pro/src/lib/services/page-views/page-views.service.ts index 532da1b..c5dce0b 100644 --- a/projects/ngx-piwik-pro/src/lib/services/page-views/page-views.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/page-views/page-views.service.ts @@ -7,7 +7,7 @@ type IPageViews = typeof PageViews providedIn: 'root' }) export class PageViewsService { - trackPageView(...params: Parameters) { + trackPageView(...params: Parameters): ReturnType { PageViews.trackPageView(...params) } } diff --git a/projects/ngx-piwik-pro/src/lib/services/site-search/site-search.service.ts b/projects/ngx-piwik-pro/src/lib/services/site-search/site-search.service.ts index 61a6d3f..45f11a4 100644 --- a/projects/ngx-piwik-pro/src/lib/services/site-search/site-search.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/site-search/site-search.service.ts @@ -1,6 +1,5 @@ -import { Dimensions, SiteSearch } from '@piwikpro/tracking-base-library' - import { Injectable } from '@angular/core'; +import { SiteSearch } from '@piwikpro/tracking-base-library' type ISiteSearch = typeof SiteSearch; @@ -8,7 +7,7 @@ type ISiteSearch = typeof SiteSearch; providedIn: 'root' }) export class SiteSearchService { - trackSiteSearch(...params: Parameters) { - SiteSearch.trackSiteSearch(...params) + trackSiteSearch(...params: Parameters): ReturnType { + return SiteSearch.trackSiteSearch(...params) } -} +} \ No newline at end of file diff --git a/projects/ngx-piwik-pro/src/lib/services/user-management/user-management.service.ts b/projects/ngx-piwik-pro/src/lib/services/user-management/user-management.service.ts index f49569b..79e8368 100644 --- a/projects/ngx-piwik-pro/src/lib/services/user-management/user-management.service.ts +++ b/projects/ngx-piwik-pro/src/lib/services/user-management/user-management.service.ts @@ -7,23 +7,23 @@ type IUserManagement = typeof UserManagement providedIn: 'root' }) export class UserManagementService { - getUserId(...params: Parameters): Promise { + getUserId(...params: Parameters): ReturnType { return UserManagement.getUserId(...params) } - setUserId(...params: Parameters): void { - UserManagement.setUserId(...params) + setUserId(...params: Parameters): ReturnType { + return UserManagement.setUserId(...params) } - resetUserId(...params: Parameters): void { - UserManagement.resetUserId(...params) + resetUserId(...params: Parameters): ReturnType { + return UserManagement.resetUserId(...params) } - getVisitorId(...params: Parameters): Promise { + getVisitorId(...params: Parameters): ReturnType { return UserManagement.getVisitorId(...params) } - getVisitorInfo(...params: Parameters): Promise { + getVisitorInfo(...params: Parameters): ReturnType { return UserManagement.getVisitorInfo(...params) } -} +} \ No newline at end of file