fix: rename event module into analytics and clean (#482)
This commit is contained in:
@ -189,16 +189,6 @@ MediumSize.parameters = {
|
|||||||
// Small size
|
// Small size
|
||||||
export const SmallSize: Story = {
|
export const SmallSize: Story = {
|
||||||
render: getRenderWrapperForComponent(<ButtonContainer size="small" />),
|
render: getRenderWrapperForComponent(<ButtonContainer size="small" />),
|
||||||
play: async ({ canvasElement }) => {
|
|
||||||
const canvas = within(canvasElement);
|
|
||||||
|
|
||||||
expect(clickJestFn).toHaveBeenCalledTimes(0);
|
|
||||||
|
|
||||||
const button = canvas.getByTestId('primary-button-default');
|
|
||||||
await userEvent.click(button);
|
|
||||||
|
|
||||||
expect(clickJestFn).toHaveBeenCalledTimes(1);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
SmallSize.parameters = {
|
SmallSize.parameters = {
|
||||||
pseudo: {
|
pseudo: {
|
||||||
|
|||||||
@ -65,15 +65,6 @@ export const DefaultSecondary: Story = {
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
/>,
|
/>,
|
||||||
),
|
),
|
||||||
play: async ({ canvasElement }) => {
|
|
||||||
const canvas = within(canvasElement);
|
|
||||||
|
|
||||||
expect(clickJestFn).toHaveBeenCalledTimes(0);
|
|
||||||
const button = canvas.getByRole('button');
|
|
||||||
await userEvent.click(button);
|
|
||||||
|
|
||||||
expect(clickJestFn).toHaveBeenCalledTimes(1);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WithIconSecondary: Story = {
|
export const WithIconSecondary: Story = {
|
||||||
|
|||||||
@ -31,7 +31,6 @@
|
|||||||
"@casl/ability": "^6.5.0",
|
"@casl/ability": "^6.5.0",
|
||||||
"@casl/prisma": "^1.4.0",
|
"@casl/prisma": "^1.4.0",
|
||||||
"@nestjs/apollo": "^11.0.5",
|
"@nestjs/apollo": "^11.0.5",
|
||||||
"@nestjs/axios": "^3.0.0",
|
|
||||||
"@nestjs/common": "^9.0.0",
|
"@nestjs/common": "^9.0.0",
|
||||||
"@nestjs/config": "^2.3.2",
|
"@nestjs/config": "^2.3.2",
|
||||||
"@nestjs/core": "^9.0.0",
|
"@nestjs/core": "^9.0.0",
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { GraphQLError } from 'graphql';
|
|||||||
import { PrismaModule } from './database/prisma.module';
|
import { PrismaModule } from './database/prisma.module';
|
||||||
import { HealthModule } from './health/health.module';
|
import { HealthModule } from './health/health.module';
|
||||||
import { AbilityModule } from './ability/ability.module';
|
import { AbilityModule } from './ability/ability.module';
|
||||||
import { EventModule } from './core/analytics/event.module';
|
|
||||||
import GraphQLJSON from 'graphql-type-json';
|
import GraphQLJSON from 'graphql-type-json';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
@ -34,7 +33,6 @@ import GraphQLJSON from 'graphql-type-json';
|
|||||||
HealthModule,
|
HealthModule,
|
||||||
AbilityModule,
|
AbilityModule,
|
||||||
CoreModule,
|
CoreModule,
|
||||||
EventModule,
|
|
||||||
],
|
],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { ObjectType, Field } from '@nestjs/graphql';
|
import { ObjectType, Field } from '@nestjs/graphql';
|
||||||
|
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class Event {
|
export class Analytics {
|
||||||
@Field(() => Boolean, {
|
@Field(() => Boolean, {
|
||||||
description: 'Boolean that confirms query was dispatched',
|
description: 'Boolean that confirms query was dispatched',
|
||||||
})
|
})
|
||||||
8
server/src/core/analytics/analytics.module.ts
Normal file
8
server/src/core/analytics/analytics.module.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AnalyticsService } from './analytics.service';
|
||||||
|
import { AnalyticsResolver } from './analytics.resolver';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [AnalyticsResolver, AnalyticsService],
|
||||||
|
})
|
||||||
|
export class AnalyticsModule {}
|
||||||
19
server/src/core/analytics/analytics.resolver.spec.ts
Normal file
19
server/src/core/analytics/analytics.resolver.spec.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AnalyticsResolver } from './analytics.resolver';
|
||||||
|
import { AnalyticsService } from './analytics.service';
|
||||||
|
|
||||||
|
describe('AnalyticsResolver', () => {
|
||||||
|
let resolver: AnalyticsResolver;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [AnalyticsResolver, AnalyticsService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
resolver = module.get<AnalyticsResolver>(AnalyticsResolver);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(resolver).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { Resolver, Mutation, Args } from '@nestjs/graphql';
|
import { Resolver, Mutation, Args } from '@nestjs/graphql';
|
||||||
import { EventService } from './event.service';
|
import { AnalyticsService } from './analytics.service';
|
||||||
import { Event } from './event.entity';
|
import { Analytics } from './analytics.entity';
|
||||||
import { CreateEventInput } from './dto/create-event.input';
|
import { CreateAnalyticsInput } from './dto/create-analytics.input';
|
||||||
import { OptionalJwtAuthGuard } from 'src/guards/optional-jwt.auth.guard';
|
import { OptionalJwtAuthGuard } from 'src/guards/optional-jwt.auth.guard';
|
||||||
import { UseGuards } from '@nestjs/common';
|
import { UseGuards } from '@nestjs/common';
|
||||||
import { AuthWorkspace } from 'src/decorators/auth-workspace.decorator';
|
import { AuthWorkspace } from 'src/decorators/auth-workspace.decorator';
|
||||||
@ -9,16 +9,16 @@ import { User, Workspace } from '@prisma/client';
|
|||||||
import { AuthUser } from 'src/decorators/auth-user.decorator';
|
import { AuthUser } from 'src/decorators/auth-user.decorator';
|
||||||
|
|
||||||
@UseGuards(OptionalJwtAuthGuard)
|
@UseGuards(OptionalJwtAuthGuard)
|
||||||
@Resolver(() => Event)
|
@Resolver(() => Analytics)
|
||||||
export class EventResolver {
|
export class AnalyticsResolver {
|
||||||
constructor(private readonly eventService: EventService) {}
|
constructor(private readonly analyticsService: AnalyticsService) {}
|
||||||
|
|
||||||
@Mutation(() => Event)
|
@Mutation(() => Analytics)
|
||||||
createEvent(
|
createEvent(
|
||||||
@Args() createEventInput: CreateEventInput,
|
@Args() createEventInput: CreateAnalyticsInput,
|
||||||
@AuthWorkspace() workspace: Workspace | undefined,
|
@AuthWorkspace() workspace: Workspace | undefined,
|
||||||
@AuthUser() user: User | undefined,
|
@AuthUser() user: User | undefined,
|
||||||
) {
|
) {
|
||||||
return this.eventService.create(createEventInput, user, workspace);
|
return this.analyticsService.create(createEventInput, user, workspace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
18
server/src/core/analytics/analytics.service.spec.ts
Normal file
18
server/src/core/analytics/analytics.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AnalyticsService } from './analytics.service';
|
||||||
|
|
||||||
|
describe('AnalyticsService', () => {
|
||||||
|
let service: AnalyticsService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [AnalyticsService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<AnalyticsService>(AnalyticsService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -1,15 +1,21 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { CreateEventInput } from './dto/create-event.input';
|
|
||||||
import { HttpService } from '@nestjs/axios';
|
|
||||||
import { anonymize } from 'src/utils/anonymize';
|
|
||||||
import { User, Workspace } from '@prisma/client';
|
import { User, Workspace } from '@prisma/client';
|
||||||
|
import axios, { AxiosInstance } from 'axios';
|
||||||
|
import { CreateAnalyticsInput } from './dto/create-analytics.input';
|
||||||
|
import { anonymize } from 'src/utils/anonymize';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EventService {
|
export class AnalyticsService {
|
||||||
constructor(private readonly httpService: HttpService) {}
|
private readonly httpService: AxiosInstance;
|
||||||
|
|
||||||
create(
|
constructor() {
|
||||||
createEventInput: CreateEventInput,
|
this.httpService = axios.create({
|
||||||
|
baseURL: 'https://t.twenty.com/api/v1/s2s',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(
|
||||||
|
createEventInput: CreateAnalyticsInput,
|
||||||
user: User | undefined,
|
user: User | undefined,
|
||||||
workspace: Workspace | undefined,
|
workspace: Workspace | undefined,
|
||||||
) {
|
) {
|
||||||
@ -27,11 +33,9 @@ export class EventService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
this.httpService
|
try {
|
||||||
.post('https://t.twenty.com/api/v1/s2s/event?noToken', data)
|
await this.httpService.post('/event?noToken', data);
|
||||||
.subscribe({
|
} catch {}
|
||||||
error: () => null,
|
|
||||||
});
|
|
||||||
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ import GraphQLJSON from 'graphql-type-json';
|
|||||||
import { IsNotEmpty, IsString, IsObject } from 'class-validator';
|
import { IsNotEmpty, IsString, IsObject } from 'class-validator';
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export class CreateEventInput {
|
export class CreateAnalyticsInput {
|
||||||
@Field({ description: 'Type of the event' })
|
@Field({ description: 'Type of the event' })
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsString()
|
@IsString()
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { EventService } from './event.service';
|
|
||||||
import { EventResolver } from './event.resolver';
|
|
||||||
import { HttpModule } from '@nestjs/axios';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
providers: [EventResolver, EventService],
|
|
||||||
imports: [HttpModule],
|
|
||||||
})
|
|
||||||
export class EventModule {}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { EventResolver } from './event.resolver';
|
|
||||||
import { EventService } from './event.service';
|
|
||||||
import { HttpModule } from '@nestjs/axios';
|
|
||||||
|
|
||||||
describe('EventResolver', () => {
|
|
||||||
let resolver: EventResolver;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
imports: [HttpModule],
|
|
||||||
providers: [EventResolver, EventService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
resolver = module.get<EventResolver>(EventResolver);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(resolver).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { EventService } from './event.service';
|
|
||||||
import { HttpModule } from '@nestjs/axios';
|
|
||||||
|
|
||||||
describe('EventService', () => {
|
|
||||||
let service: EventService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
imports: [HttpModule],
|
|
||||||
providers: [EventService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<EventService>(EventService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -6,7 +6,7 @@ import { PersonModule } from './person/person.module';
|
|||||||
import { PipelineModule } from './pipeline/pipeline.module';
|
import { PipelineModule } from './pipeline/pipeline.module';
|
||||||
import { AuthModule } from './auth/auth.module';
|
import { AuthModule } from './auth/auth.module';
|
||||||
import { WorkspaceModule } from './workspace/workspace.module';
|
import { WorkspaceModule } from './workspace/workspace.module';
|
||||||
import { EventModule } from './analytics/event.module';
|
import { AnalyticsModule } from './analytics/analytics.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -17,7 +17,7 @@ import { EventModule } from './analytics/event.module';
|
|||||||
PersonModule,
|
PersonModule,
|
||||||
PipelineModule,
|
PipelineModule,
|
||||||
WorkspaceModule,
|
WorkspaceModule,
|
||||||
EventModule,
|
AnalyticsModule,
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
AuthModule,
|
AuthModule,
|
||||||
@ -27,7 +27,7 @@ import { EventModule } from './analytics/event.module';
|
|||||||
PersonModule,
|
PersonModule,
|
||||||
PipelineModule,
|
PipelineModule,
|
||||||
WorkspaceModule,
|
WorkspaceModule,
|
||||||
EventModule,
|
AnalyticsModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class CoreModule {}
|
export class CoreModule {}
|
||||||
|
|||||||
@ -1055,11 +1055,6 @@
|
|||||||
lodash.omit "4.5.0"
|
lodash.omit "4.5.0"
|
||||||
tslib "2.5.2"
|
tslib "2.5.2"
|
||||||
|
|
||||||
"@nestjs/axios@^3.0.0":
|
|
||||||
version "3.0.0"
|
|
||||||
resolved "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.0.tgz"
|
|
||||||
integrity sha512-ULdH03jDWkS5dy9X69XbUVbhC+0pVnrRcj7bIK/ytTZ76w7CgvTZDJqsIyisg3kNOiljRW/4NIjSf3j6YGvl+g==
|
|
||||||
|
|
||||||
"@nestjs/cli@^9.0.0":
|
"@nestjs/cli@^9.0.0":
|
||||||
version "9.5.0"
|
version "9.5.0"
|
||||||
resolved "https://registry.npmjs.org/@nestjs/cli/-/cli-9.5.0.tgz"
|
resolved "https://registry.npmjs.org/@nestjs/cli/-/cli-9.5.0.tgz"
|
||||||
|
|||||||
Reference in New Issue
Block a user