Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Hubspot import feature#26

Open
Jaspreet-singh-1032 wants to merge 8 commits intoPostHog:mainfrom
Jaspreet-singh-1032:hubspot-import-feature
Open

Hubspot import feature#26
Jaspreet-singh-1032 wants to merge 8 commits intoPostHog:mainfrom
Jaspreet-singh-1032:hubspot-import-feature

Conversation

@Jaspreet-singh-1032
Copy link

@Jaspreet-singh-1032 Jaspreet-singh-1032 commented Mar 6, 2022

  • Enrich users on posthog with data from contacts on Hubspot.
  • Enrich user-specified group type with companies information.
  • Enrich user-specified group type with deals information.

Hey guys, let me know if you want me to make any changes.

plugin.json Outdated
"hint": "Group type that you want to enrich with hubspot companies",
"name": "Company Group Type",
"type": "string",
"default": null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if type is string let's give this a string default

Suggested change
"default": null,
"default": "",

plugin.json Outdated
"hint": "Group type that you want to enrich with hubspot deals",
"name": "Deal Group Type",
"type": "string",
"default": null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

index.js Outdated
global.hubspotAuth
}&properties=${properties.join(',')}`
}
const authResponse = await fetchWithRetry(requestUrl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: authResponse implies to me we're just testing auth, not fetching important data

index.js Outdated
}
if (res && res['results']) {
for (hubspotDeal of res['results']) {
exists = await storage.get(hubspotDeal['id'], false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exists = await storage.get(hubspotDeal['id'], false)
const exists = await storage.get(hubspotDeal['id'], false)

index.js Outdated
if (res && res['results']) {
for (hubspotDeal of res['results']) {
exists = await storage.get(hubspotDeal['id'], false)
if (!exists) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's flip this if around:

if (exists) {} else {}

much easier to read that way

index.js Outdated
}
}
let nextDealBatch
res['paging'] && res['paging']['next']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just use an if here

return []
}
let requestUrl = await storage.get(NEXT_COMPANY_BATCH_KEY)
const properties = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can live at the top-level instead of inside the function

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just because before doing anything I am checking a condition that whether should I run this function or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but there's no need to re-initialize this every time the function is called

Jaspreet-singh-1032 and others added 4 commits April 18, 2022 20:59
Co-authored-by: Yakko Majuri <38760734+yakkomajuri@users.noreply.github.com>
Co-authored-by: Yakko Majuri <38760734+yakkomajuri@users.noreply.github.com>
}

export async function setupPlugin({ config, global }) {
async function setupPlugin({ config, global }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing export? this should be here. all plugin functions should be exported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I have exported it below at the end along with the other exports.

const { resetMeta } = require('@posthog/plugin-scaffold/test/utils')
const { fetchAllCompanies, fetchAllDeals } = require('./index')

test('test skip fetching companies if company groupType not set', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these definitely don't test very much

Copy link
Contributor

@yakkomajuri yakkomajuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcushyett-ph this is shaping up - I wonder if someone should test this e2e? i.e. connect to Hubspot and try this out

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants