Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

take/skip type transformation

Blue Mouseaab5cac314fb
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index 66fbcfe79..65a81b08e 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -3972,18 +3972,12 @@ export class AnalyticsService {
})
}
- getSafeNumber(value: any, defaultValue: number): number {
- if (typeof value === 'undefined') {
+ getSafeNumber(value: number | undefined, defaultValue: number): number {
+ if (typeof value === 'undefined' || Number.isNaN(value)) {
return defaultValue
}
- const parsed = parseInt(value, 10)
-
- if (Number.isNaN(parsed)) {
- return defaultValue
- }
-
- return parsed
+ return value
}
processPageflow(pages: IPageflow[]) {
diff --git a/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts b/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts
index 97975629d..cca8eb630 100644
--- a/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts
@@ -1,4 +1,5 @@
import { PickType, ApiProperty } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { GetDataDto } from './getData.dto'
export class GetErrorsDto extends PickType(GetDataDto, [
@@ -9,8 +10,10 @@ export class GetErrorsDto extends PickType(GetDataDto, [
'filters',
'timezone',
] as const) {
+ @Type(() => Number)
take: number
+ @Type(() => Number)
skip: number
@ApiProperty({
diff --git a/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts b/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts
index 9673c2cfb..8cb25d48c 100644
--- a/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts
@@ -1,4 +1,5 @@
import { ApiProperty, PickType } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { IsNotEmpty, IsOptional, Matches } from 'class-validator'
import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'
import { PID_REGEX } from '../../common/constants'
@@ -58,9 +59,11 @@ export class GetProfileSessionsDto extends PickType(GetDataDto, [
@ApiProperty({ required: false, default: 30 })
@IsOptional()
+ @Type(() => Number)
take?: number
@ApiProperty({ required: false, default: 0 })
@IsOptional()
+ @Type(() => Number)
skip?: number
}
diff --git a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
index e786f7bc6..e78f72dcc 100644
--- a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
@@ -1,4 +1,5 @@
import { ApiProperty, PickType } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { IsOptional, IsIn } from 'class-validator'
import { GetDataDto } from './getData.dto'
@@ -12,10 +13,12 @@ export class GetProfilesDto extends PickType(GetDataDto, [
] as const) {
@ApiProperty({ required: false, default: 30 })
@IsOptional()
+ @Type(() => Number)
take?: number
@ApiProperty({ required: false, default: 0 })
@IsOptional()
+ @Type(() => Number)
skip?: number
@ApiProperty({
diff --git a/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts b/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts
index 2dfc5d23f..bf369cc7c 100644
--- a/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts
@@ -1,4 +1,5 @@
import { PickType } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { GetDataDto } from './getData.dto'
export class GetSessionsDto extends PickType(GetDataDto, [
@@ -9,7 +10,9 @@ export class GetSessionsDto extends PickType(GetDataDto, [
'filters',
'timezone',
] as const) {
+ @Type(() => Number)
take: number
+ @Type(() => Number)
skip: number
}
diff --git a/backend/apps/community/src/analytics/analytics.service.ts b/backend/apps/community/src/analytics/analytics.service.ts
index 837d110da..a55b60ccd 100644
--- a/backend/apps/community/src/analytics/analytics.service.ts
+++ b/backend/apps/community/src/analytics/analytics.service.ts
@@ -3557,18 +3557,12 @@ export class AnalyticsService {
})
}
- getSafeNumber(value: any, defaultValue: number): number {
- if (typeof value === 'undefined') {
+ getSafeNumber(value: number | undefined, defaultValue: number): number {
+ if (typeof value === 'undefined' || Number.isNaN(value)) {
return defaultValue
}
- const parsed = parseInt(value, 10)
-
- if (Number.isNaN(parsed)) {
- return defaultValue
- }
-
- return parsed
+ return value
}
processPageflow(pages: IPageflow[]) {
diff --git a/backend/apps/community/src/analytics/dto/get-errors.dto.ts b/backend/apps/community/src/analytics/dto/get-errors.dto.ts
index 97975629d..cca8eb630 100644
--- a/backend/apps/community/src/analytics/dto/get-errors.dto.ts
+++ b/backend/apps/community/src/analytics/dto/get-errors.dto.ts
@@ -1,4 +1,5 @@
import { PickType, ApiProperty } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { GetDataDto } from './getData.dto'
export class GetErrorsDto extends PickType(GetDataDto, [
@@ -9,8 +10,10 @@ export class GetErrorsDto extends PickType(GetDataDto, [
'filters',
'timezone',
] as const) {
+ @Type(() => Number)
take: number
+ @Type(() => Number)
skip: number
@ApiProperty({
diff --git a/backend/apps/community/src/analytics/dto/get-sessions.dto.ts b/backend/apps/community/src/analytics/dto/get-sessions.dto.ts
index 2dfc5d23f..bf369cc7c 100644
--- a/backend/apps/community/src/analytics/dto/get-sessions.dto.ts
+++ b/backend/apps/community/src/analytics/dto/get-sessions.dto.ts
@@ -1,4 +1,5 @@
import { PickType } from '@nestjs/swagger'
+import { Type } from 'class-transformer'
import { GetDataDto } from './getData.dto'
export class GetSessionsDto extends PickType(GetDataDto, [
@@ -9,7 +10,9 @@ export class GetSessionsDto extends PickType(GetDataDto, [
'filters',
'timezone',
] as const) {
+ @Type(() => Number)
take: number
+ @Type(() => Number)
skip: number
}