Merge pull request #163 from omnivore-app/dependabot/npm_and_yarn/intercom-client-3.1.4

Bump intercom-client from 2.11.2 to 3.1.4
This commit is contained in:
Jackson Harper 2022-03-01 11:58:15 -08:00 committed by GitHub
commit 6ac3f7f6c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 60 deletions

View file

@ -74,7 +74,7 @@
"graphql-middleware": "^6.0.10",
"graphql-shield": "^7.5.0",
"highlightjs": "^9.16.2",
"intercom-client": "^2.11.0",
"intercom-client": "^3.1.4",
"jsdom": "^16.4.0",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^2.0.3",

View file

@ -60,17 +60,13 @@ export class CreateIntercomAccount
const customAttributes: { source_user_id: string } = {
source_user_id: profile.user.sourceUserId,
}
await IntercomClient?.users.create({
await IntercomClient?.contacts.createUser({
email: profile.user.email,
user_id: profile.user.id,
externalId: profile.user.id,
name: profile.user.name,
avatar: {
image_url: profile.pictureUrl || null,
type: 'avatar',
},
custom_attributes: customAttributes,
created_at: Math.floor(new Date(profile.user.createdAt).getTime() / 1000),
signed_up_at: Math.floor(Date.now() / 1000),
avatar: profile.pictureUrl,
customAttributes: customAttributes,
signedUpAt: Math.floor(Date.now() / 1000),
})
}
}

View file

@ -126,7 +126,7 @@ export const createArticleResolver = authorized<
env: env.server.apiEnv,
},
})
createIntercomEvent('link-saved', uid)
await createIntercomEvent('link-saved', uid)
const articleSavingRequest = articleSavingRequestId
? (await models.articleSavingRequest.get(articleSavingRequestId)) ||
@ -507,7 +507,7 @@ export const getArticleResolver: ResolverFn<
env: env.server.apiEnv,
},
})
createIntercomEvent('get-article', claims.uid)
await createIntercomEvent('get-article', claims.uid)
const article = await models.userArticle.getByUserIdAndSlug(
claims.uid,
@ -555,7 +555,7 @@ export const getArticlesResolver = authorized<
env: env.server.apiEnv,
},
})
createIntercomEvent('search', claims.uid)
await createIntercomEvent('search', claims.uid)
const [userArticles, totalCount] = (await authTrx((tx) =>
models.userArticle.getPaginated(

View file

@ -20,7 +20,7 @@ export const createArticleSavingRequestResolver = authorized<
CreateArticleSavingRequestError,
MutationCreateArticleSavingRequestArgs
>(async (_, { input: { url } }, { models, claims }) => {
createIntercomEvent('link-save-request', claims.uid)
await createIntercomEvent('link-save-request', claims.uid)
const request = await createPageSaveRequest(claims.uid, url, models)
return {
articleSavingRequest: request,

View file

@ -21,7 +21,7 @@ export const savePageResolver = authorized<
models,
claims: { uid },
} = ctx
createIntercomEvent('link-saved', uid)
await createIntercomEvent('link-saved', uid)
const user = userDataToUser(await models.user.get(uid))
if (!user) {
@ -44,7 +44,7 @@ export const saveUrlResolver = authorized<
models,
claims: { uid },
} = ctx
createIntercomEvent('link-saved', uid)
await createIntercomEvent('link-saved', uid)
const user = userDataToUser(await models.user.get(uid))
if (!user) {
@ -63,7 +63,7 @@ export const saveFileResolver = authorized<
models,
claims: { uid },
} = ctx
createIntercomEvent('link-saved', uid)
await createIntercomEvent('link-saved', uid)
const user = userDataToUser(await models.user.get(uid))
if (!user) {

View file

@ -333,13 +333,11 @@ export function authRouter() {
if (env.server.apiEnv && !env.dev.isLocal && IntercomClient) {
if (newUser) {
createIntercomEvent('signed-up', user.id, function () {
redirect(res)
})
await createIntercomEvent('signed-up', user.id)
redirect(res)
} else {
createIntercomEvent('logged-in', user.id, function () {
redirect(res)
})
await createIntercomEvent('logged-in', user.id)
redirect(res)
}
} else {
redirect(res)

View file

@ -1,35 +1,23 @@
import * as Intercom from 'intercom-client'
import { Client } from 'intercom-client'
import { env } from '../env'
export const IntercomClient =
env.server.apiEnv && !env.dev.isLocal
? new Intercom.Client({
token: env.intercom.token,
? new Client({
tokenAuth: { token: env.intercom.token },
})
: null
IntercomClient?.useRequestOpts({
headers: {
'Intercom-Version': 1.4,
},
})
export function createIntercomEvent(
export async function createIntercomEvent(
eventName: string,
userId: string,
callback?: () => void
): void {
if (!callback) {
// eslint-disable-next-line @typescript-eslint/no-empty-function
callback = () => {}
userId: string
): Promise<void> {
if (!IntercomClient) {
return
}
if (!IntercomClient) return callback()
IntercomClient.events.create(
{
event_name: eventName,
user_id: userId,
created_at: Math.floor(Date.now() / 1000), // this is mandatory for events
},
callback
)
return IntercomClient.events.create({
eventName: eventName,
userId: userId,
createdAt: Math.floor(Date.now() / 1000), // this is mandatory for events
})
}

View file

@ -5623,6 +5623,13 @@ axios@^0.21.4:
dependencies:
follow-redirects "^1.14.0"
axios@^0.24.0:
version "0.24.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6"
integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==
dependencies:
follow-redirects "^1.14.4"
axios@^0.26.0:
version "0.26.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.0.tgz#9a318f1c69ec108f8cd5f3c3d390366635e13928"
@ -5818,11 +5825,6 @@ bl@^4.0.3, bl@^4.1.0:
inherits "^2.0.4"
readable-stream "^3.4.0"
bluebird@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
body-parser@1.19.0, body-parser@^1.18.3:
version "1.19.0"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
@ -8622,6 +8624,11 @@ follow-redirects@^1.14.0, follow-redirects@^1.14.8:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
follow-redirects@^1.14.4:
version "1.14.9"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==
for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
@ -9818,15 +9825,14 @@ inquirer@^8.0.0:
strip-ansi "^6.0.0"
through "^2.3.6"
intercom-client@^2.11.0:
version "2.11.2"
resolved "https://registry.yarnpkg.com/intercom-client/-/intercom-client-2.11.2.tgz#3511e97f4af238d754d522c2e95afbe05a871eed"
integrity sha512-liIAVaXMZeaLLibWGKYGVIKV4yY5ra5Q3AA1YOnL3hI+mWIpBSx8DIXSKVM5iWMPQhr2H7Ss9jWppnBv+ujaew==
intercom-client@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/intercom-client/-/intercom-client-3.1.4.tgz#369e57011b8b17abd2db29f74507cc219ec72dfb"
integrity sha512-v6fhLJt2hHsaIemSATnbBBmRIdwcUcBp1T4iL/B3dAmURwcxTQSQi03mgAHtlGD/lITLQN8S4/hkgq65ZBQzfQ==
dependencies:
bluebird "^3.7.2"
axios "^0.24.0"
htmlencode "^0.0.4"
lodash "^4.17.19"
request "^2.88.0"
lodash "^4.17.21"
internal-slot@^1.0.3:
version "1.0.3"