mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-20 14:39:09 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
003c9b176c | ||
|
|
1e5fe59d9c | ||
|
|
1a2b9617fe | ||
|
|
9bc42a4af0 | ||
|
|
9ae14ab04a | ||
|
|
5e8dea7255 | ||
|
|
80d7ac6ff9 |
@@ -5466,28 +5466,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/customers/logs-dashboard": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "CustomersController_getCustomerMixPanelLogsDashboard",
|
|
||||||
"parameters": [],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Customers"
|
|
||||||
],
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/open-data/sharing-ocean-data": {
|
"/open-data/sharing-ocean-data": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "OpenDataController_createUser",
|
"operationId": "OpenDataController_createUser",
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ charts:
|
|||||||
- name: maestro.tr_factory_url
|
- name: maestro.tr_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.dadosfera.ai
|
||||||
- name: maestro.open_customer_id
|
- name: maestro.open_customer_id
|
||||||
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
value: f239718a-a271-4ef9-ae7e-02a2f0f3aa6e
|
||||||
- name: maestro.open_group_id
|
- name: maestro.open_group_id
|
||||||
value: c0afdcce-c5be-40d0-9d1d-2d271121f14a
|
value: 401573bb-334f-44b2-b30e-88d4cea31ae9
|
||||||
- name: replicaCount
|
- name: replicaCount
|
||||||
value: 2
|
value: 2
|
||||||
|
|||||||
+3
-3
@@ -9,11 +9,11 @@ charts:
|
|||||||
- name: hostname
|
- name: hostname
|
||||||
value: maestro.stg.dadosfera.ai
|
value: maestro.stg.dadosfera.ai
|
||||||
- name: maestro.pi_factory_url
|
- name: maestro.pi_factory_url
|
||||||
value: pi-factory.dadosfera.ai
|
value: pi-factory.stg.dadosfera.ai
|
||||||
- name: maestro.in_factory_url
|
- name: maestro.in_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.stg.dadosfera.ai
|
||||||
- name: maestro.tr_factory_url
|
- name: maestro.tr_factory_url
|
||||||
value: in-factory.dadosfera.ai
|
value: in-factory.stg.dadosfera.ai
|
||||||
- name: maestro.open_customer_id
|
- name: maestro.open_customer_id
|
||||||
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
value: b3e3dfe5-b992-4586-a73c-c0b0c00f615d
|
||||||
- name: maestro.open_group_id
|
- name: maestro.open_group_id
|
||||||
|
|||||||
Generated
-1
@@ -8707,7 +8707,6 @@
|
|||||||
"version": "1.4.5-lts.1",
|
"version": "1.4.5-lts.1",
|
||||||
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz",
|
"resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz",
|
||||||
"integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==",
|
"integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"append-field": "^1.0.0",
|
"append-field": "^1.0.0",
|
||||||
"busboy": "^1.0.0",
|
"busboy": "^1.0.0",
|
||||||
|
|||||||
@@ -121,7 +121,6 @@ export class AuthenticationGuard
|
|||||||
customer_id: accessTokenPayload.customer_id,
|
customer_id: accessTokenPayload.customer_id,
|
||||||
customer_name: accessTokenPayload.customer_name,
|
customer_name: accessTokenPayload.customer_name,
|
||||||
customer_tier: accessTokenPayload.customer_tier,
|
customer_tier: accessTokenPayload.customer_tier,
|
||||||
customer_modules: accessTokenPayload.customer_modules,
|
|
||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
};
|
};
|
||||||
// TODO: for backwards compatibility. remove in the future
|
// TODO: for backwards compatibility. remove in the future
|
||||||
|
|||||||
@@ -609,12 +609,6 @@ export interface DadosferaModule {
|
|||||||
key: string;
|
key: string;
|
||||||
permissionSeqId: number;
|
permissionSeqId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DADOSFERA_MODULES_KEYS = {
|
|
||||||
LOG_DASHBOARD: 'logs-dashboard',
|
|
||||||
ACCESS_DASHBOARD: 'access-dashboard'
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
export const DADOSFERA_MODULES: Array<DadosferaModule> = [
|
||||||
{
|
{
|
||||||
name: 'Intelligence Module',
|
name: 'Intelligence Module',
|
||||||
|
|||||||
@@ -25,14 +25,6 @@ export function RequireSomePermission(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RequireModule(
|
|
||||||
key: string
|
|
||||||
) {
|
|
||||||
return createAuthenticatedDecorator((_, user: RequestUser) =>
|
|
||||||
user.customer_modules.some(module => module === key),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AuthenticateCondition(func: AuthenticationFunction) {
|
export function AuthenticateCondition(func: AuthenticationFunction) {
|
||||||
return createAuthenticatedDecorator(func);
|
return createAuthenticatedDecorator(func);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export interface RequestUser {
|
|||||||
customer_name: string;
|
customer_name: string;
|
||||||
customer_tier: string;
|
customer_tier: string;
|
||||||
access_token: string;
|
access_token: string;
|
||||||
customer_modules: string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
export const User: (options?: { required?: boolean }) => ParameterDecorator =
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ import {
|
|||||||
UseFilters,
|
UseFilters,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger';
|
||||||
import { DADOSFERA_MODULES_KEYS, PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
|
||||||
import {
|
import {
|
||||||
Authenticated,
|
Authenticated,
|
||||||
RequireAllPermissions,
|
RequireAllPermissions,
|
||||||
RequireModule,
|
|
||||||
} from 'src/decorators/authentication.decorator';
|
} from 'src/decorators/authentication.decorator';
|
||||||
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
|
||||||
import { CustomersService } from './customers.service';
|
import { CustomersService } from './customers.service';
|
||||||
@@ -92,36 +91,4 @@ export class CustomersController {
|
|||||||
const metadata = PackTheMetadata(user);
|
const metadata = PackTheMetadata(user);
|
||||||
return this.customersService.getMonitoringDashboardUrl(metadata);
|
return this.customersService.getMonitoringDashboardUrl(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('logs-dashboard')
|
|
||||||
@Authenticated()
|
|
||||||
@RequireAllPermissions(
|
|
||||||
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
|
||||||
)
|
|
||||||
@RequireModule(DADOSFERA_MODULES_KEYS.LOG_DASHBOARD)
|
|
||||||
async getCustomerMixPanelLogsDashboard(
|
|
||||||
@User() user: RequestUser,
|
|
||||||
): Promise<{ url: string }> {
|
|
||||||
this.logger.info('getLogsDashboardUrl');
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
const result = await this.customersService.getLogsDashboardUrl(metadata);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get('access-dashboard')
|
|
||||||
@Authenticated()
|
|
||||||
@RequireAllPermissions(
|
|
||||||
PERMISSIONS_GROUPS.USERS.permissions.ADMIN,
|
|
||||||
)
|
|
||||||
@RequireModule(DADOSFERA_MODULES_KEYS.ACCESS_DASHBOARD)
|
|
||||||
async getAccessDashboard(
|
|
||||||
@User() user: RequestUser,
|
|
||||||
): Promise<{ url: string }> {
|
|
||||||
this.logger.info('getAccessDashboard');
|
|
||||||
const metadata = PackTheMetadata(user);
|
|
||||||
|
|
||||||
const result = await this.customersService.getAccessDashboardUrl(user.customer_name, metadata);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
ForbiddenException,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
|
|
||||||
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
import { firstValueFrom, lastValueFrom } from 'rxjs';
|
||||||
@@ -157,50 +156,4 @@ export class CustomersService implements OnModuleInit {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
async getLogsDashboardUrl(metadata: Metadata) {
|
|
||||||
logger.info('CustomersService - getMixPanelLogsDashboardUrl');
|
|
||||||
|
|
||||||
const res = await lastValueFrom(
|
|
||||||
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
|
||||||
{
|
|
||||||
dashboard_id: '103',
|
|
||||||
exp: '15m',
|
|
||||||
metabase_customer_name: 'dadosferatech',
|
|
||||||
},
|
|
||||||
metadata,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
logger.info('Done');
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAccessDashboardUrl(customerName: string, metadata: Metadata) {
|
|
||||||
/*
|
|
||||||
* TODO(Refactor): dar um jeito de exibir o dash da sbm diferente dos outros customer
|
|
||||||
* pois o signicado de department para sbm significa as instituições do usuários
|
|
||||||
*/
|
|
||||||
if (customerName !== 'sbmoffshorecom') {
|
|
||||||
throw new ForbiddenException();
|
|
||||||
}
|
|
||||||
logger.info('CustomersService - getAccessDashboardUrl');
|
|
||||||
|
|
||||||
const res = await this.getDashboardUrl('105', metadata);
|
|
||||||
logger.info('Done');
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getDashboardUrl(dashboardId: string, metadata: Metadata) {
|
|
||||||
return await lastValueFrom(
|
|
||||||
this.pipelineReadService.PipelineV2GetDashboardUrl(
|
|
||||||
{
|
|
||||||
dashboard_id: dashboardId,
|
|
||||||
exp: '15m',
|
|
||||||
metabase_customer_name: 'dadosferatech',
|
|
||||||
},
|
|
||||||
metadata
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
import { Body, Controller, Inject, Param, Post, Req } from '@nestjs/common';
|
||||||
import { init } from 'mixpanel';
|
import { init } from 'mixpanel';
|
||||||
import { Authenticated } from 'src/decorators/authentication.decorator';
|
import { Authenticated } from 'src/decorators/authentication.decorator';
|
||||||
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
|
||||||
@@ -13,7 +13,12 @@ export class MixpanelController {
|
|||||||
private readonly mixpanelToken: string,
|
private readonly mixpanelToken: string,
|
||||||
) {}
|
) {}
|
||||||
@Post(':id')
|
@Post(':id')
|
||||||
async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) {
|
async trackEvent(
|
||||||
|
@Param('id') id,
|
||||||
|
@Body() body,
|
||||||
|
@User() user: RequestUser,
|
||||||
|
@Req() request
|
||||||
|
) {
|
||||||
delete body.info;
|
delete body.info;
|
||||||
const mixpanel = init(this.mixpanelToken);
|
const mixpanel = init(this.mixpanelToken);
|
||||||
|
|
||||||
@@ -66,13 +71,16 @@ export class MixpanelController {
|
|||||||
$email: user.username.includes('@')
|
$email: user.username.includes('@')
|
||||||
? user.username
|
? user.username
|
||||||
: user.username + '@dadosfera.ai',
|
: user.username + '@dadosfera.ai',
|
||||||
customer_name: user.customer_name,
|
customer_name: user.customer_name
|
||||||
});
|
});
|
||||||
|
|
||||||
await mixpanel.track(id, {
|
await mixpanel.track(id, {
|
||||||
distinct_id: user.username,
|
distinct_id: user.username,
|
||||||
customer: user.customer_name,
|
customer: user.customer_name,
|
||||||
env: process.env.ENV,
|
env: process.env.ENV,
|
||||||
|
$ip: request.ip,
|
||||||
|
$os: request.headers['sec-ch-ua-platform'] || '',
|
||||||
|
$browser: request.headers['user-agent'],
|
||||||
...body,
|
...body,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user