Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: remove plain and move to pylon

Daniel Hougaard8fdc438940dd
diff --git a/backend/package-lock.json b/backend/package-lock.json
index 2fba00120e..9d0a3c8c9f 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -49,7 +49,6 @@
"@sindresorhus/slugify": "1.1.0",
"@slack/oauth": "^3.0.1",
"@slack/web-api": "^7.3.4",
- "@team-plain/typescript-sdk": "^4.6.1",
"@ucast/mongo2js": "^1.3.4",
"ajv": "^8.12.0",
"argon2": "^0.31.2",
@@ -5678,14 +5677,6 @@
"uuid": "dist/bin/uuid"
}
},
- "node_modules/@graphql-typed-document-node/core": {
- "version": "3.2.0",
- "resolved": "https://registry.npmjs.org/@graphql-typed-document-node/core/-/core-3.2.0.tgz",
- "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==",
- "peerDependencies": {
- "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
- }
- },
"node_modules/@grpc/grpc-js": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.12.2.tgz",
@@ -9970,18 +9961,6 @@
"optional": true,
"peer": true
},
- "node_modules/@team-plain/typescript-sdk": {
- "version": "4.6.1",
- "resolved": "https://registry.npmjs.org/@team-plain/typescript-sdk/-/typescript-sdk-4.6.1.tgz",
- "integrity": "sha512-Uy9QJXu9U7bJb6WXL9sArGk7FXPpzdqBd6q8tAF1vexTm8fbTJRqcikTKxGtZmNADt+C2SapH3cApM4oHpO4lQ==",
- "dependencies": {
- "@graphql-typed-document-node/core": "^3.2.0",
- "ajv": "^8.12.0",
- "ajv-formats": "^2.1.1",
- "graphql": "^16.6.0",
- "zod": "3.22.4"
- }
- },
"node_modules/@techteamer/ocsp": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@techteamer/ocsp/-/ocsp-1.0.1.tgz",
@@ -15180,14 +15159,6 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true
},
- "node_modules/graphql": {
- "version": "16.9.0",
- "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz",
- "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==",
- "engines": {
- "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
- }
- },
"node_modules/gtoken": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz",
diff --git a/backend/package.json b/backend/package.json
index 0dafc475cb..a7321f67d2 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -157,7 +157,6 @@
"@sindresorhus/slugify": "1.1.0",
"@slack/oauth": "^3.0.1",
"@slack/web-api": "^7.3.4",
- "@team-plain/typescript-sdk": "^4.6.1",
"@ucast/mongo2js": "^1.3.4",
"ajv": "^8.12.0",
"argon2": "^0.31.2",
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts
index 66c5f3d98d..7bb95468a6 100644
--- a/backend/src/lib/config/env.ts
+++ b/backend/src/lib/config/env.ts
@@ -166,8 +166,7 @@ const envSchema = z
OTEL_COLLECTOR_BASIC_AUTH_PASSWORD: zpStr(z.string().optional()),
OTEL_EXPORT_TYPE: z.enum(["prometheus", "otlp"]).optional(),
- PLAIN_API_KEY: zpStr(z.string().optional()),
- PLAIN_WISH_LABEL_IDS: zpStr(z.string().optional()),
+ PYLON_API_KEY: zpStr(z.string().optional()),
DISABLE_AUDIT_LOG_GENERATION: zodStrBool.default("false"),
SSL_CLIENT_CERTIFICATE_HEADER_KEY: zpStr(z.string().optional()).default("x-ssl-client-cert"),
WORKFLOW_SLACK_CLIENT_ID: zpStr(z.string().optional()),
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 8dbae554f2..806b3575c0 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1242,7 +1242,8 @@ export const registerRoutes = async (
});
const userEngagementService = userEngagementServiceFactory({
- userDAL
+ userDAL,
+ orgDAL
});
const slackService = slackServiceFactory({
diff --git a/backend/src/server/routes/v1/user-engagement-router.ts b/backend/src/server/routes/v1/user-engagement-router.ts
index e3ce6532e1..1a13dbc6e2 100644
--- a/backend/src/server/routes/v1/user-engagement-router.ts
+++ b/backend/src/server/routes/v1/user-engagement-router.ts
@@ -21,7 +21,7 @@ export const registerUserEngagementRouter = async (server: FastifyZodProvider) =
},
onRequest: verifyAuth([AuthMode.JWT]),
handler: async (req) => {
- return server.services.userEngagement.createUserWish(req.permission.id, req.body.text);
+ return server.services.userEngagement.createUserWish(req.permission.id, req.permission.orgId, req.body.text);
}
});
};
diff --git a/backend/src/services/user-engagement/user-engagement-service.ts b/backend/src/services/user-engagement/user-engagement-service.ts
index 5d7b549299..b146729036 100644
--- a/backend/src/services/user-engagement/user-engagement-service.ts
+++ b/backend/src/services/user-engagement/user-engagement-service.ts
@@ -1,87 +1,44 @@
-import { PlainClient } from "@team-plain/typescript-sdk";
+import axios from "axios";
import { getConfig } from "@app/lib/config/env";
import { InternalServerError } from "@app/lib/errors";
+import { TOrgDALFactory } from "../org/org-dal";
import { TUserDALFactory } from "../user/user-dal";
type TUserEngagementServiceFactoryDep = {
userDAL: Pick<TUserDALFactory, "findById">;
+ orgDAL: Pick<TOrgDALFactory, "findById">;
};
export type TUserEngagementServiceFactory = ReturnType<typeof userEngagementServiceFactory>;
-export const userEngagementServiceFactory = ({ userDAL }: TUserEngagementServiceFactoryDep) => {
- const createUserWish = async (userId: string, text: string) => {
+export const userEngagementServiceFactory = ({ userDAL, orgDAL }: TUserEngagementServiceFactoryDep) => {
+ const createUserWish = async (userId: string, orgId: string, text: string) => {
const user = await userDAL.findById(userId);
+ const org = await orgDAL.findById(orgId);
const appCfg = getConfig();
- if (!appCfg.PLAIN_API_KEY) {
+ if (!appCfg.PYLON_API_KEY) {
throw new InternalServerError({
- message: "Plain is not configured."
+ message: "Pylon is not configured."
});
}
- const client = new PlainClient({
- apiKey: appCfg.PLAIN_API_KEY
- });
-
- const customerUpsertRes = await client.upsertCustomer({
- identifier: {
- emailAddress: user.email
- },
- onCreate: {
- fullName: `${user.firstName} ${user.lastName}`,
- shortName: user.firstName,
- email: {
- email: user.email as string,
- isVerified: user.isEmailVerified as boolean
- },
-
- externalId: user.id
- },
-
- onUpdate: {
- fullName: {
- value: `${user.firstName} ${user.lastName}`
- },
- shortName: {
- value: user.firstName
- },
- email: {
- email: user.email as string,
- isVerified: user.isEmailVerified as boolean
- },
- externalId: {
- value: user.id
- }
+ const request = axios.create({
+ baseURL: "https://api.usepylon.com",
+ headers: {
+ Authorization: `Bearer ${appCfg.PYLON_API_KEY}`
}
});
- if (customerUpsertRes.error) {
- throw new InternalServerError({ message: customerUpsertRes.error.message });
- }
-
- const createThreadRes = await client.createThread({
- title: "Wish",
- customerIdentifier: {
- externalId: customerUpsertRes.data.customer.externalId
- },
- components: [
- {
- componentText: {
- text
- }
- }
- ],
- labelTypeIds: appCfg.PLAIN_WISH_LABEL_IDS?.split(",")
+ await request.post("/issues", {
+ title: `New Wish From: ${user.firstName} ${user.lastName} (${org.name})`,
+ body_html: text,
+ requester_email: user.email,
+ requester_name: `${user.firstName} ${user.lastName} (${org.name})`,
+ tags: ["wish"]
});
-
- if (createThreadRes.error) {
- throw new InternalServerError({
- message: createThreadRes.error.message
- });
- }
};
return {
createUserWish