Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/hubspot integration #1123

Merged
merged 75 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f9b95de
object member support
Jul 7, 2023
094e458
wip
Jul 7, 2023
f82a04a
Merge branch 'main' into enhancement/support-object-members-and-organ…
Jul 10, 2023
3bf024c
organizations to new framework
Jul 11, 2023
7a12cb1
Merge branch 'main' into enhancement/support-object-members-and-organ…
Jul 11, 2023
c3f76cc
fixing @ imports in the backend folder
Jul 11, 2023
b2c6c4d
fixes
Jul 11, 2023
b1c6ce7
Merge branch 'main' into enhancement/support-object-members-and-organ…
Jul 11, 2023
2ab4231
bugfixes
Jul 11, 2023
50b95f2
handle webhooks in integration-stream-worker
Jul 11, 2023
b1843d7
wip - webhooks
Jul 11, 2023
52c216f
hubspot property mapping, incoming integrations contacts finalized
epipav Jul 12, 2023
a0164ab
update member organizations
Jul 12, 2023
08c433d
webhook retries
Jul 12, 2023
03e899c
logging fixed
epipav Jul 12, 2023
7a63e50
Merge branch 'enhancement/support-object-members-and-organizations-C-…
epipav Jul 12, 2023
00edb93
member service fix for the new findMember method
epipav Jul 12, 2023
08a018f
alter webhook creation logic wip
garrrikkotua Jul 12, 2023
f34b581
change webhooks creating logic
garrrikkotua Jul 13, 2023
5212de5
fix missing webhookId
garrrikkotua Jul 13, 2023
c138eb1
Merge branch 'main' into enhancement/support-object-members-and-organ…
garrrikkotua Jul 13, 2023
5fc0b5b
Fallback to organization names when sorting them
sausage-todd Jul 13, 2023
4074811
companies endpoint, throttler, mapper refactor
epipav Jul 13, 2023
bb69b00
Merge branch 'enhancement/support-object-members-and-organizations-C-…
epipav Jul 14, 2023
8a3594a
formatting
epipav Jul 14, 2023
ccf4269
Merge branch 'feature/hubspot-integration' of github.com:CrowdDotDev/…
epipav Jul 14, 2023
9009e69
Hubspot connect & settings (#1139)
gaspergrom Jul 19, 2023
5d1359b
Manual sync for members and organizations (#1146)
gaspergrom Jul 20, 2023
73fd150
integration sync service for outgoing integrations
epipav Jul 20, 2023
453fffb
Merge branch 'feature/hubspot-integration' of github.com:CrowdDotDev/…
epipav Jul 20, 2023
123b4e3
Merge branch 'main' into feature/hubspot-integration
epipav Jul 20, 2023
f4cd184
comment fix
epipav Jul 20, 2023
f7fd853
organizations manual sync endpoints and logic
epipav Jul 21, 2023
f38be73
build and deploy integration sync worker ci job for staging
epipav Jul 21, 2023
1104772
builder added for integration sync worker
epipav Jul 21, 2023
ec66f26
also setting default for member sourceId attribute
epipav Jul 21, 2023
573ffe3
integration settings overwrite fixed
epipav Jul 21, 2023
5a9319e
set hubspot id before getting crowd entity
epipav Jul 22, 2023
b96c5a7
hubpsot connect undefined settings fix
epipav Jul 22, 2023
343c44e
Fix organization sync
gaspergrom Jul 24, 2023
c5251e8
scale plan, serialization support in hubspot fields, org query now re…
epipav Jul 24, 2023
2481fb1
Merge branch 'feature/hubspot-integration' of github.com:CrowdDotDev/…
epipav Jul 24, 2023
be36d27
Add hubspot to scale plan (#1159)
gaspergrom Jul 24, 2023
2a26d06
support for http websites when deriving organization domain
epipav Jul 24, 2023
9aa2f85
permissions added to scale plan
epipav Jul 24, 2023
c068535
FE perms for scale plan
epipav Jul 24, 2023
05a42a5
linting, formatting
epipav Jul 24, 2023
70bc35d
formatting
epipav Jul 24, 2023
eded4f6
serialization for dates
epipav Jul 24, 2023
131d7c0
Organization hubspot identity
gaspergrom Jul 24, 2023
ad1c9ef
Fix feature flag
gaspergrom Jul 24, 2023
3d4276a
organization domain and url, date field fixes, displayName fix on update
epipav Jul 24, 2023
b510fa4
Fix org identity
gaspergrom Jul 24, 2023
6b36d17
Fix selects
gaspergrom Jul 24, 2023
140f8a9
Fix selects
gaspergrom Jul 24, 2023
5ebb4db
Merge branch 'main' into feature/hubspot-integration
epipav Jul 25, 2023
8e33d72
linter errors fixed
epipav Jul 25, 2023
d4f649e
Merge branch 'feature/hubspot-integration' of github.com:CrowdDotDev/…
epipav Jul 25, 2023
6818add
types package linting
epipav Jul 25, 2023
052f932
attributes record type to any
epipav Jul 25, 2023
1e347c8
more linting
epipav Jul 25, 2023
b6763bd
continue linting packages
epipav Jul 25, 2023
73ab618
prod ci for integration sync worker, more linting
epipav Jul 25, 2023
c94cb8a
linting data sink worker
epipav Jul 25, 2023
7e58d6e
integration run worker linting
epipav Jul 25, 2023
5345955
integration sync worker linting
epipav Jul 25, 2023
3b47fce
review points, formatting
epipav Jul 25, 2023
f6e0d00
prettier run on integration sync worker
epipav Jul 25, 2023
3e9c2dc
batch operations typings
epipav Jul 25, 2023
d91e687
deleting attributes cache when creating predefined attributes for int…
epipav Jul 25, 2023
87e73fb
hubspot integration frequency updated to 8 hours
epipav Jul 25, 2023
f569556
tests fixed
epipav Jul 25, 2023
448e20b
formatting
epipav Jul 25, 2023
1e0cb64
some comments cleaning and organization update bugfixes
epipav Jul 25, 2023
2e888f8
formatting
epipav Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/production-deploy-new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: Deploy search-sync-worker service?
required: true
type: boolean
deploy_integration_sync_worker:
description: Deploy integration-sync-worker service?
required: true
type: boolean

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down Expand Up @@ -41,6 +45,27 @@ jobs:
id: image
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT

build-and-push-integration-sync-worker:
runs-on: ubuntu-latest
if: ${{ inputs.deploy_integration_sync_worker }}
outputs:
image: ${{ steps.image.outputs.IMAGE }}
defaults:
run:
shell: bash
steps:
- name: Check out repository code
uses: actions/checkout@v2

- uses: ./.github/actions/build-docker-image
id: image-builder
with:
image: integration-sync-worker

- name: Set docker image output
id: image
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT

deploy-search-sync-worker:
needs: build-and-push-search-sync-worker
runs-on: ubuntu-latest
Expand All @@ -58,3 +83,21 @@ jobs:
service: search-sync-worker
image: ${{ needs.build-and-push-search-sync-worker.outputs.image }}
cluster: ${{ env.CROWD_CLUSTER }}

deploy-integration-sync-worker:
needs: build-and-push-integration-sync-worker
runs-on: ubuntu-latest
if: ${{ inputs.deploy_integration_sync_worker }}
defaults:
run:
shell: bash

steps:
- name: Check out repository code
uses: actions/checkout@v2

- uses: ./.github/actions/deploy-service
with:
service: integration-sync-worker
image: ${{ needs.build-and-push-integration-sync-worker.outputs.image }}
cluster: ${{ env.CROWD_CLUSTER }}
60 changes: 60 additions & 0 deletions .github/workflows/staging-deploy-integration-sync-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Staging Deploy Integration Sync Worker

on:
push:
branches:
- 'staging/**'
- 'staging-**'
paths:
- 'services/libs/**'
- 'services/apps/integration_sync_worker/**'

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
CROWD_CLUSTER: ${{ secrets.STAGING_CLUSTER_NAME }}
CROWD_ROLE_ARN: ${{ secrets.STAGING_CLUSTER_ROLE_ARN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SLACK_CHANNEL: deploys-staging
SLACK_WEBHOOK: ${{ secrets.STAGING_SLACK_CHANNEL_HOOK }}

jobs:
build-and-push:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.IMAGE }}
defaults:
run:
shell: bash

steps:
- name: Check out repository code
uses: actions/checkout@v2

- uses: ./.github/actions/build-docker-image
id: image-builder
with:
image: integration-sync-worker

- name: Set docker image output
id: image
run: echo "IMAGE=${{ steps.image-builder.outputs.image }}" >> $GITHUB_OUTPUT

deploy-integration-sync-worker:
needs: build-and-push
runs-on: ubuntu-latest
defaults:
run:
shell: bash

steps:
- name: Check out repository code
uses: actions/checkout@v2

- uses: ./.github/actions/deploy-service
with:
service: integration-sync-worker
image: ${{ needs.build-and-push.outputs.image }}
cluster: ${{ env.CROWD_CLUSTER }}
2 changes: 1 addition & 1 deletion backend/.env.dist.local
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CROWD_STACKEXCHANGE_KEY=
# Nango settings
CROWD_NANGO_URL=http://localhost:3003
CROWD_NANGO_SECRET_KEY=424242
CROWD_NANGO_INTEGRATIONS=reddit,linkedin,stackexchange
CROWD_NANGO_INTEGRATIONS=reddit,linkedin,stackexchange,hubspot

# Cohere settings
CROWD_COHERE_API_KEY=
Expand Down
5 changes: 5 additions & 0 deletions backend/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
"stackexchange": {
"key": "CROWD_STACKEXCHANGE_KEY"
},
"hubspot": {
"appId": "CROWD_HUBSPOT_APP_ID",
"clientId": "CROWD_HUBSPOT_CLIENT_ID",
"clientSecret": "CROWD_HUBSPOT_CLIENT_SECRET"
},
"nango": {
"url": "CROWD_NANGO_URL",
"secretKey": "CROWD_NANGO_SECRET_KEY"
Expand Down
9 changes: 9 additions & 0 deletions backend/src/api/integration/helpers/hubspotConnect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.tenantEdit)
const payload = await new IntegrationService(req).hubspotConnect()
await req.responseHandler.success(req, res, payload)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.tenantEdit)
const payload = await new IntegrationService(req).hubspotGetMappableFields()
await req.responseHandler.success(req, res, payload)
}
9 changes: 9 additions & 0 deletions backend/src/api/integration/helpers/hubspotOnboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.tenantEdit)
const payload = await new IntegrationService(req).hubspotOnboard(req.body)
await req.responseHandler.success(req, res, payload)
}
9 changes: 9 additions & 0 deletions backend/src/api/integration/helpers/hubspotStopSyncMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)
const payload = await new IntegrationService(req).hubspotStopSyncMember(req.body)
await req.responseHandler.success(req, res, payload)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)
const payload = await new IntegrationService(req).hubspotStopSyncOrganization(req.body)
await req.responseHandler.success(req, res, payload)
}
9 changes: 9 additions & 0 deletions backend/src/api/integration/helpers/hubspotSyncMember.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)
const payload = await new IntegrationService(req).hubspotSyncMember(req.body)
await req.responseHandler.success(req, res, payload)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.integrationEdit)
const payload = await new IntegrationService(req).hubspotSyncOrganization(req.body)
await req.responseHandler.success(req, res, payload)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Permissions from '../../../security/permissions'
import IntegrationService from '../../../services/integrationService'
import PermissionChecker from '../../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.tenantEdit)
const payload = await new IntegrationService(req).hubspotUpdateProperties()
await req.responseHandler.success(req, res, payload)
}
50 changes: 50 additions & 0 deletions backend/src/api/integration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import SegmentRepository from '../../database/repositories/segmentRepository'
import { authMiddleware } from '../../middlewares/authMiddleware'
import { safeWrap } from '../../middlewares/errorMiddleware'
import TenantService from '../../services/tenantService'
import { FeatureFlag } from '@/types/common'
import { featureFlagMiddleware } from '@/middlewares/featureFlagMiddleware'

export default (app) => {
app.post(`/tenant/:tenantId/integration/query`, safeWrap(require('./integrationQuery').default))
Expand Down Expand Up @@ -76,6 +78,54 @@ export default (app) => {
safeWrap(require('./helpers/discourseTestWebhook').default),
)

app.post(
'/tenant/:tenantId/hubspot-connect',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotConnect').default),
)

app.post(
'/tenant/:tenantId/hubspot-onboard',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotOnboard').default),
)

app.post(
'/tenant/:tenantId/hubspot-update-properties',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotUpdateProperties').default),
)

app.get(
'/tenant/:tenantId/hubspot-mappable-fields',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotGetMappableFields').default),
)

app.post(
'/tenant/:tenantId/hubspot-sync-member',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotSyncMember').default),
)

app.post(
'/tenant/:tenantId/hubspot-stop-sync-member',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotStopSyncMember').default),
)

app.post(
'/tenant/:tenantId/hubspot-sync-organization',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotSyncOrganization').default),
)

app.post(
'/tenant/:tenantId/hubspot-stop-sync-organization',
featureFlagMiddleware(FeatureFlag.HUBSPOT, 'hubspot.errors.notInPlan'),
safeWrap(require('./helpers/hubspotStopSyncOrganization').default),
)

// if (TWITTER_CONFIG.clientId) {
// /**
// * Using the passport.authenticate this endpoint forces a
Expand Down
2 changes: 1 addition & 1 deletion backend/src/bin/jobs/downgradeExpiredPlans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const job: CrowdJob = {
log.info('Downgrading expired non-trial plans')
const expiredNonTrialTenants = await dbOptions.database.sequelize.query(
`select t.id, t.name from tenants t
where (t.plan = ${Plans.values.growth} or t.plan = ${Plans.values.eagleEye}) and t."planSubscriptionEndsAt" is not null and t."planSubscriptionEndsAt" + interval '3 days' < now()`,
where (t.plan = ${Plans.values.growth} or t.plan = ${Plans.values.eagleEye} or t.plan = ${Plans.values.scale}) and t."planSubscriptionEndsAt" is not null and t."planSubscriptionEndsAt" + interval '3 days' < now()`,
)

for (const tenant of expiredNonTrialTenants[0]) {
Expand Down
Loading
Loading