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!

submitting project name to the invitation email

Blue Mouse636c17ec0dde
diff --git a/src/project/dto/add-subscriber.dto.ts b/src/project/dto/add-subscriber.dto.ts
index 85b069f86..fcafa67f0 100644
--- a/src/project/dto/add-subscriber.dto.ts
+++ b/src/project/dto/add-subscriber.dto.ts
@@ -1,4 +1,4 @@
-import { Matches, IsEmail, IsNotEmpty, IsEnum } from 'class-validator'
+import { Matches, IsEmail, IsNotEmpty, IsEnum, IsString } from 'class-validator'
import { ReportFrequency } from '../enums'
export class AddSubscriberParamsDto {
@@ -6,6 +6,11 @@ export class AddSubscriberParamsDto {
readonly projectId: string
}
+export class AddSubscriberMetaParamsDTO {
+ @IsString()
+ readonly projectName: string
+}
+
export class AddSubscriberBodyDto {
@IsEmail()
readonly email: string
diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts
index 1fb621a8d..0e8881c4f 100644
--- a/src/project/project.controller.ts
+++ b/src/project/project.controller.ts
@@ -835,6 +835,7 @@ export class ProjectController {
return await this.projectService.addSubscriber({
userId,
projectId: params.projectId,
+ projectName: project.name,
email: body.email,
reportFrequency: body.reportFrequency,
origin: headers.origin,
diff --git a/src/project/project.service.ts b/src/project/project.service.ts
index 5a7e25f1d..96fa6c091 100644
--- a/src/project/project.service.ts
+++ b/src/project/project.service.ts
@@ -456,36 +456,33 @@ export class ProjectService {
const subscriber = await this.projectSubscriberRepository.save({ ...data })
await this.sendSubscriberInvite(
- data.userId,
- data.projectId,
- subscriber.id,
- data.email,
- data.origin,
+ data, subscriber.id,
)
return subscriber
}
async sendSubscriberInvite(
- userId: string,
- projectId: string,
+ data: AddSubscriberType,
subscriberId: string,
- email: string,
- origin: string,
) {
+ const {
+ userId, projectId, projectName, email, origin
+ } = data
+
const actionToken = await this.actionTokens.createActionToken(
userId,
ActionTokenType.ADDING_PROJECT_SUBSCRIBER,
`${projectId}:${subscriberId}`,
)
- const inviteLink = `${origin}/projects/${projectId}/subscribers/invite?token=${actionToken.id}`
+ const url = `${origin}/projects/${projectId}/subscribers/invite?token=${actionToken.id}`
await this.mailerService.sendEmail(
email,
LetterTemplate.ProjectSubscriberInvitation,
{
- inviteLink,
+ url, projectName,
},
)
}
diff --git a/src/project/types/add-subscriber.type.ts b/src/project/types/add-subscriber.type.ts
index f35dedaa6..0276e73d3 100644
--- a/src/project/types/add-subscriber.type.ts
+++ b/src/project/types/add-subscriber.type.ts
@@ -1,6 +1,6 @@
-import { AddSubscriberBodyDto, AddSubscriberParamsDto } from '../dto'
+import { AddSubscriberBodyDto, AddSubscriberParamsDto, AddSubscriberMetaParamsDTO } from '../dto'
-export type AddSubscriberType = { userId: string } & AddSubscriberParamsDto &
+export type AddSubscriberType = { userId: string } & AddSubscriberParamsDto & AddSubscriberMetaParamsDTO &
AddSubscriberBodyDto & {
origin: string
}