diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a26df6d2a..621db64129 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -359,6 +359,7 @@ workflows: only: - develop - TOP-1390 + - PM-191-2 # This is alternate dev env for parallel testing # Deprecate this workflow due to beta env shutdown # https://topcoder.atlassian.net/browse/CORE-251 diff --git a/Dockerfile b/Dockerfile index feb8d0a005..7691feebdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,8 +71,6 @@ ARG GSHEETS_API_KEY # Gig work referrals ARG SENDGRID_API_KEY -ARG GROWSURF_API_KEY -ARG GROWSURF_CAMPAIGN_ID ARG GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY # Optimizely @@ -141,8 +139,6 @@ ENV CONTENTFUL_EDU_PREVIEW_API_KEY=$CONTENTFUL_EDU_PREVIEW_API_KEY ENV RECRUITCRM_API_KEY=$RECRUITCRM_API_KEY ENV COMMUNITY_APP_URL=$COMMUNITY_APP_URL ENV SENDGRID_API_KEY=$SENDGRID_API_KEY -ENV GROWSURF_API_KEY=$GROWSURF_API_KEY -ENV GROWSURF_CAMPAIGN_ID=$GROWSURF_CAMPAIGN_ID ENV GSHEETS_API_KEY=$GSHEETS_API_KEY ENV GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY=$GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY diff --git a/build.sh b/build.sh index ae6656897a..a3650db356 100755 --- a/build.sh +++ b/build.sh @@ -50,8 +50,6 @@ docker build -t $TAG \ --build-arg CONTENTFUL_COMCAST_PREVIEW_API_KEY=$CONTENTFUL_COMCAST_PREVIEW_API_KEY \ --build-arg RECRUITCRM_API_KEY=$RECRUITCRM_API_KEY \ --build-arg SENDGRID_API_KEY=$SENDGRID_API_KEY \ - --build-arg GROWSURF_API_KEY=$GROWSURF_API_KEY \ - --build-arg GROWSURF_CAMPAIGN_ID=$GROWSURF_CAMPAIGN_ID \ --build-arg GSHEETS_API_KEY=$GSHEETS_API_KEY \ --build-arg OPTIMIZELY_SDK_KEY=$OPTIMIZELY_SDK_KEY \ --build-arg COMMUNITY_APP_URL=$COMMUNITY_APP_URL \ diff --git a/config/backup-default.js b/config/backup-default.js index f7d0e839b5..6c7c3507ef 100644 --- a/config/backup-default.js +++ b/config/backup-default.js @@ -257,7 +257,6 @@ module.exports = { }, RECRUITCRM_API_KEY: '', - GROWSURF_API_KEY: '', SENDGRID_API_KEY: '', JWT_AUTH: { SECRET: 'mysecret', @@ -266,13 +265,6 @@ module.exports = { }, CHAMELEON_VERIFICATION_SECRET: 'mysecret', }, - GROWSURF_CAMPAIGN_ID: '', - GROWSURF_COOKIE: '_tc_gigs_ref', - GROWSURF_COOKIE_SETTINGS: { - secure: true, - domain: '', - expires: 30, // days - }, GSHEETS_API_KEY: 'AIzaSyBRdKySN5JNCb2H6ZxJdTTvp3cWU51jiOQ', GOOGLE_SERVICE_ACCOUNT_EMAIL: 'communityappserviceacc@tc-sheets-to-contentful.iam.gserviceaccount.com', diff --git a/config/custom-environment-variables.js b/config/custom-environment-variables.js index 7a46f7a078..38d3c74933 100644 --- a/config/custom-environment-variables.js +++ b/config/custom-environment-variables.js @@ -99,11 +99,9 @@ module.exports = { }, RECRUITCRM_API_KEY: 'RECRUITCRM_API_KEY', - GROWSURF_API_KEY: 'GROWSURF_API_KEY', SENDGRID_API_KEY: 'SENDGRID_API_KEY', CHAMELEON_VERIFICATION_SECRET: 'CHAMELEON_VERIFICATION_SECRET', }, - GROWSURF_CAMPAIGN_ID: 'GROWSURF_CAMPAIGN_ID', AUTH_CONFIG: { AUTH0_URL: 'TC_M2M_AUTH0_URL', AUTH0_AUDIENCE: 'TC_M2M_AUDIENCE', diff --git a/config/default.js b/config/default.js index 37cf1664c7..2b6fc14ee3 100644 --- a/config/default.js +++ b/config/default.js @@ -258,7 +258,6 @@ module.exports = { }, RECRUITCRM_API_KEY: '', - GROWSURF_API_KEY: '', SENDGRID_API_KEY: '', JWT_AUTH: { SECRET: 'mysecret', @@ -267,13 +266,6 @@ module.exports = { }, CHAMELEON_VERIFICATION_SECRET: 'mysecret', }, - GROWSURF_CAMPAIGN_ID: '', - GROWSURF_COOKIE: '_tc_gigs_ref', - GROWSURF_COOKIE_SETTINGS: { - secure: true, - domain: '', - expires: 30, // days - }, GSHEETS_API_KEY: 'AIzaSyBRdKySN5JNCb2H6ZxJdTTvp3cWU51jiOQ', GOOGLE_SERVICE_ACCOUNT_EMAIL: 'communityappserviceacc@tc-sheets-to-contentful.iam.gserviceaccount.com', diff --git a/package-lock.json b/package-lock.json index eb8e5f2778..bd250b4344 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16760,8 +16760,8 @@ "dev": true }, "navigation-component": { - "version": "github:topcoder-platform/navigation-component#b44259da14c0452606cc5abe15f10eea7e31f0e5", - "from": "github:topcoder-platform/navigation-component#v1000.1.7", + "version": "github:topcoder-platform/navigation-component#27625999e94725fb31c226b8255a549849f1ebe4", + "from": "github:topcoder-platform/navigation-component#develop", "requires": { "classnames": "^2.2.6", "lodash": "^4.17.11", @@ -16772,9 +16772,9 @@ }, "dependencies": { "config": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/config/-/config-3.3.11.tgz", - "integrity": "sha512-Dhn63ZoWCW5EMg4P0Sl/XNsj/7RLiUIA1x1npCy+m2cRwRHzLnt3UtYtxRDMZW/6oOMdWhCzaGYkOcajGgrAOA==", + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/config/-/config-3.3.12.tgz", + "integrity": "sha512-Vmx389R/QVM3foxqBzXO8t2tUikYZP64Q6vQxGrsMpREeJc/aWRnPRERXWsYzOHAumx/AOoILWe6nU3ZJL+6Sw==", "requires": { "json5": "^2.2.3" } diff --git a/src/server/index.js b/src/server/index.js index d107dd1beb..393a72b9a7 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -28,7 +28,6 @@ import mailChimpRouter from './routes/mailchimp'; import mockDocuSignFactory from './__mocks__/docu-sign-mock'; import recruitCRMRouter from './routes/recruitCRM'; import mmLeaderboardRouter from './routes/mmLeaderboard'; -import growsurfRouter from './routes/growsurf'; import gSheetsRouter from './routes/gSheet'; import blogRouter from './routes/blog'; import feedsRouter from './routes/feeds'; @@ -247,7 +246,6 @@ async function onExpressJsSetup(server) { server.use('/api/mailchimp', mailChimpRouter); server.use('/api/recruit', recruitCRMRouter); server.use('/api/mml', mmLeaderboardRouter); - server.use('/api/growsurf', growsurfRouter); server.use('/api/gsheets', gSheetsRouter); server.use('/api/blog', blogRouter); server.use('/api/feeds', feedsRouter); diff --git a/src/server/routes/growsurf.js b/src/server/routes/growsurf.js deleted file mode 100644 index 298464e44e..0000000000 --- a/src/server/routes/growsurf.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * The routes related to Growsurf integration - */ - -import _ from 'lodash'; -import express from 'express'; -import { middleware } from 'tc-core-library-js'; -import config from 'config'; -import GrowsurfService from '../services/growsurf'; - -const cors = require('cors'); - -const authenticator = middleware.jwtAuthenticator; -const authenticatorOptions = _.pick(config.SECRET.JWT_AUTH, ['AUTH_SECRET', 'VALID_ISSUERS']); -const routes = express.Router(); - -// Enables CORS on those routes according config above -// ToDo configure CORS for set of our trusted domains -routes.use(cors()); -routes.options('*', cors()); - -routes.get('/participant/:emailOrId', (req, res) => new GrowsurfService().getParticipantController(req, res).then(res.send.bind(res))); -routes.get('/participants', (req, res) => new GrowsurfService().getParticipantsController(req, res).then(res.send.bind(res))); -routes.post('/participants', (req, res, next) => authenticator(authenticatorOptions)(req, res, next), (req, res) => new GrowsurfService().getOrCreateParticipantController(req, res).then(res.send.bind(res))); -routes.patch('/participant/:emailOrId', (req, res, next) => authenticator(authenticatorOptions)(req, res, next), (req, res) => new GrowsurfService().updateParticipantController(req, res).then(res.send.bind(res))); - -export default routes; diff --git a/src/server/services/growsurf.js b/src/server/services/growsurf.js deleted file mode 100644 index b9850e002c..0000000000 --- a/src/server/services/growsurf.js +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Server-side functions necessary for effective integration with growsurf - */ -import fetch from 'isomorphic-fetch'; -import config from 'config'; - -/** - * Auxiliary class that handles communication with growsurf - */ -export default class GrowsurfService { - /** - * Creates a new service instance. - * @param {String} baseUrl The base API endpoint. - */ - constructor(baseUrl = 'https://api.growsurf.com/v2') { - this.private = { - baseUrl, - apiKey: config.SECRET.GROWSURF_API_KEY, - authorization: `Bearer ${config.SECRET.GROWSURF_API_KEY}`, - }; - } - - /** - * Gets participant by email or id - * @return {Promise} - * @param {String} idOrEmail growsurf id or email - */ - async getParticipantByIdOREmail(idOrEmail) { - const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${idOrEmail}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: this.private.authorization, - }, - }); - if (response.status >= 300) { - return { - error: await response.json(), - code: response.status, - url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${idOrEmail}`, - }; - } - const data = await response.json(); - return data; - } - - /** - * Controller - Gets get participant by email or id - * @return {Promise} - * @param {Object} req the request. - * @param {Object} res the response. - */ - async getParticipantController(req, res) { - const { emailOrId } = req.params; - const growSurfData = await this.getParticipantByIdOREmail(emailOrId); - if (growSurfData.error) { - res.status(growSurfData.code); - } - return growSurfData; - } - - /** - * Controller - Gets get participants in the campaign - * @return {Promise} - * @param {Object} req the request. - * @param {Object} res the response. - */ - async getParticipantsController(req, res) { - const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participants`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: this.private.authorization, - }, - }); - if (response.status >= 300) { - res.status(response.status); - return { - error: await response.json(), - code: response.status, - url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participants`, - }; - } - const data = await response.json(); - return data; - } - - /** - * Add participant - * @return {Promise} - * @param {Object} body the request payload. - */ - async addParticipant(body) { - const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: this.private.authorization, - }, - body, - }); - if (response.status >= 300) { - return { - error: await response.json(), - code: response.status, - url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant`, - body, - }; - } - const data = await response.json(); - return data; - } - - /** - * Controller - Gets get participant by email or id - * if not exxists create it - * @return {Promise} - * @param {Object} req the request. - * @param {Object} res the response. - */ - async getOrCreateParticipantController(req, res) { - const { body } = req; - const result = await this.addParticipant(JSON.stringify({ - email: body.email, - firstName: body.firstName, - lastName: body.lastName, - metadata: { - tcHandle: body.tcHandle, - }, - })); - if (result.error) { - res.status(result.code); - } - return result; - } - - /** - * Update participant in growSurf - * @param {string} idOrEmail id or email - * @param {string} body payload - * @returns {Promise} - */ - async updateParticipant(idOrEmail, body) { - const response = await fetch(`${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${idOrEmail}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: this.private.authorization, - }, - body: JSON.stringify(body), - }); - if (response.status >= 300) { - return { - error: await response.json(), - code: response.status, - url: `${this.private.baseUrl}/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${idOrEmail}`, - body, - }; - } - const data = await response.json(); - return data; - } - - /** - * Controller - update participant in the system - * @param {Object} req request - * @param {Object} res respons - */ - async updateParticipantController(req, res) { - const { emailOrId } = req.params; - const updateGrowRes = await this.updateParticipant(emailOrId, req.body); - if (updateGrowRes.error) { - res.status(updateGrowRes.code); - } - return updateGrowRes; - } -} diff --git a/src/server/services/recruitCRM.js b/src/server/services/recruitCRM.js index 16edc366fe..87324ea2ba 100644 --- a/src/server/services/recruitCRM.js +++ b/src/server/services/recruitCRM.js @@ -7,7 +7,6 @@ import qs from 'qs'; import _ from 'lodash'; import { logger, services } from 'topcoder-react-lib'; import Joi from 'joi'; -import GrowsurfService from './growsurf'; import { sendEmailDirect } from './sendGrid'; // import GSheetService from './gSheet'; @@ -415,63 +414,10 @@ export default class RecruitCRMService { } let candidateSlug; let isNewCandidate = true; - let isReferred = false; - let referralCookie = req.cookies[config.GROWSURF_COOKIE]; - if (referralCookie) referralCookie = JSON.parse(referralCookie); - const tcHandle = _.findIndex(form.custom_fields, { field_id: 2 }); + const isReferred = false; let growRes; try { - // referral tracking via growsurf - if (referralCookie) { - const gs = new GrowsurfService(); - // check if candidate exists in growsurf - const existRes = await gs.getParticipantByIdOREmail(form.email); - if (existRes.id) { - // candidate exists in growsurf - // update candidate to set referrer only if it is not set already - if (!existRes.referrer) { - growRes = await gs.updateParticipant(form.email, { - referredBy: referralCookie.referralId, - referralStatus: 'CREDIT_PENDING', - metadata: { - gigID: id, - }, - }); - // add referral link to candidate profile in recruitCRM - if (!growRes.error) { - isReferred = true; - form.custom_fields.push({ - field_id: 6, value: `https://app.growsurf.com/dashboard/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${growRes.id}`, - }); - } else notifyKirilAndNick(growRes); - } - } else { - growRes = await gs.addParticipant(JSON.stringify({ - email: form.email, - referredBy: referralCookie.referralId, - referralStatus: 'CREDIT_PENDING', - firstName: form.first_name, - lastName: form.last_name, - metadata: { - gigId: id, - tcHandle: form.custom_fields[tcHandle].value, - }, - })); - // add referral link to candidate profile in recruitCRM - if (!growRes.error) { - isReferred = true; - form.custom_fields.push({ - field_id: 6, value: `https://app.growsurf.com/dashboard/campaign/${config.GROWSURF_CAMPAIGN_ID}/participant/${growRes.id}`, - }); - } else notifyKirilAndNick(growRes); - } - // finally, clear the cookie - res.cookie(config.GROWSURF_COOKIE, '', { - maxAge: 0, - overwrite: true, - }); - } - // Check if candidate exsits in the system? + // Check if candidate exists in the system? const candidateResponse = await fetch(`${this.private.baseUrl}/v1/candidates/search?email=${form.email}`, { method: 'GET', headers: { @@ -630,7 +576,6 @@ export default class RecruitCRMService { // form.email, // `https://app.recruitcrm.io/candidate/${candidateData.slug}`, // `https://topcoder.com/members/${form.custom_fields[tcHandle].value}`, - // `https://app.growsurf.com/dashboard/campaign/u9frbx/participant/${growRes.referrer.id}`, // `${growRes.referrer.firstName} ${growRes.referrer.lastName}`, // growRes.referrer.email, // `https://topcoder.com/members/${growRes.referrer.metadata.tcHandle}`, diff --git a/src/shared/components/Gigs/GigDetails/index.jsx b/src/shared/components/Gigs/GigDetails/index.jsx index b7bbd2a156..f6af7ac223 100644 --- a/src/shared/components/Gigs/GigDetails/index.jsx +++ b/src/shared/components/Gigs/GigDetails/index.jsx @@ -184,13 +184,4 @@ GigDetails.propTypes = { profile: PT.shape(), }; -function mapStateToProps(state) { - const { growSurf } = state; - return { - growSurf, - }; -} - -export default connect( - mapStateToProps, -)(GigDetails); +export default connect()(GigDetails); diff --git a/src/shared/containers/GigsPages/index.jsx b/src/shared/containers/GigsPages/index.jsx index bcb33d4a4e..5e5bd0431c 100644 --- a/src/shared/containers/GigsPages/index.jsx +++ b/src/shared/containers/GigsPages/index.jsx @@ -14,7 +14,6 @@ import { OptimizelyProvider, createInstance } from '@optimizely/react-sdk'; import { connect } from 'react-redux'; import _ from 'lodash'; import { v4 as uuidv4 } from 'uuid'; -import { getQuery } from 'utils/url'; import ChallengeTab from 'components/challenge-listing/ChallengeTab'; import './style.scss'; @@ -56,15 +55,6 @@ function GigsPagesContainer(props) { }); } } - // check for referral code in the URL and set it to cookie - if (isomorphy.isClientSide()) { - const query = getQuery(); - if (query.referralId) { - cookies.set(config.GROWSURF_COOKIE, JSON.stringify({ - referralId: query.referralId, - }), config.GROWSURF_COOKIE_SETTINGS); - } - } const { id, type } = match.params; const isApply = `${config.GIGS_PAGES_PATH}/${id}/apply` === match.url; const title = 'Find Freelance Work | Gigs | Topcoder';