@vrplatform/log 2.0.42 → 2.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main/baselog.d.ts +19 -0
- package/build/main/baselog.js +137 -0
- package/build/main/baselog.js.map +1 -0
- package/build/main/color.d.ts +54 -0
- package/build/main/color.js +371 -0
- package/build/main/color.js.map +1 -0
- package/build/main/common.d.ts +29 -0
- package/build/main/common.js +86 -0
- package/build/main/common.js.map +1 -0
- package/build/main/index.spec.d.ts +0 -0
- package/build/main/index.spec.js +2 -0
- package/build/main/index.spec.js.map +1 -0
- package/build/main/log/baselog.d.ts +2 -1
- package/build/main/log/baselog.js +6 -3
- package/build/main/log/baselog.js.map +1 -1
- package/build/main/log/common.d.ts +1 -0
- package/build/main/log/common.js +10 -0
- package/build/main/log/common.js.map +1 -1
- package/build/main/log/index.d.ts +2 -1
- package/build/main/log/index.js +4 -1
- package/build/main/log/index.js.map +1 -1
- package/build/main/log/type.d.ts +1 -0
- package/build/main/log/type.js +2 -1
- package/build/main/log/type.js.map +1 -1
- package/build/main/type.d.ts +39 -0
- package/build/main/{tracking/eventTypes.js → type.js} +1 -1
- package/build/main/type.js.map +1 -0
- package/build/module/baselog.d.ts +19 -0
- package/build/module/baselog.js +120 -0
- package/build/module/baselog.js.map +1 -0
- package/build/module/color.d.ts +54 -0
- package/build/module/color.js +375 -0
- package/build/module/color.js.map +1 -0
- package/build/module/common.d.ts +29 -0
- package/build/module/common.js +80 -0
- package/build/module/common.js.map +1 -0
- package/build/module/index.spec.d.ts +0 -0
- package/build/module/index.spec.js +2 -0
- package/build/module/index.spec.js.map +1 -0
- package/build/module/log/baselog.d.ts +2 -1
- package/build/module/log/baselog.js +6 -3
- package/build/module/log/baselog.js.map +1 -1
- package/build/module/log/common.d.ts +1 -0
- package/build/module/log/common.js +10 -1
- package/build/module/log/common.js.map +1 -1
- package/build/module/log/index.d.ts +2 -1
- package/build/module/log/index.js +5 -2
- package/build/module/log/index.js.map +1 -1
- package/build/module/log/type.d.ts +1 -0
- package/build/module/log/type.js +1 -0
- package/build/module/log/type.js.map +1 -1
- package/build/module/type.d.ts +39 -0
- package/build/module/type.js +2 -0
- package/build/module/type.js.map +1 -0
- package/package.json +1 -1
- package/src/log/baselog.ts +8 -2
- package/src/log/common.ts +16 -1
- package/src/log/index.ts +11 -1
- package/src/log/type.ts +1 -0
- package/build/main/tracking/_intercom.d.ts +0 -109
- package/build/main/tracking/_intercom.js +0 -139
- package/build/main/tracking/_intercom.js.map +0 -1
- package/build/main/tracking/eventTypes.d.ts +0 -16
- package/build/main/tracking/eventTypes.js.map +0 -1
- package/build/main/tracking/intercom.d.ts +0 -109
- package/build/main/tracking/intercom.js +0 -139
- package/build/main/tracking/intercom.js.map +0 -1
- package/build/module/tracking/_intercom.d.ts +0 -109
- package/build/module/tracking/_intercom.js +0 -136
- package/build/module/tracking/_intercom.js.map +0 -1
- package/build/module/tracking/eventTypes.d.ts +0 -16
- package/build/module/tracking/eventTypes.js +0 -2
- package/build/module/tracking/eventTypes.js.map +0 -1
- package/build/module/tracking/intercom.d.ts +0 -109
- package/build/module/tracking/intercom.js +0 -136
- package/build/module/tracking/intercom.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createBaseLog } from './baselog';
|
|
2
|
-
import { getCorrelationId, getEnvironment, requestToContext } from './common';
|
|
2
|
+
import { getCorrelationId, getEnvironment, getSessionId, requestToContext, } from './common';
|
|
3
3
|
import { AXIOM_AUTH_TOKEN_ENV, AXIOM_DATASET_ENV, AXIOM_ORG_ID_ENV, LOG_ENV, TASK_QUEUE_HEADER, WORKFLOW_ID_HEADER, } from './type';
|
|
4
4
|
export * from './common';
|
|
5
5
|
export * from './baselog';
|
|
6
6
|
export * from './type';
|
|
7
|
-
export function useLog({ environment: _environment, name, request, body, env, correlationId: cid, version, executionContext, logRequest, consoleLog: _consoleLog, dataset: _dataset, context: initialContext = {}, }) {
|
|
7
|
+
export function useLog({ environment: _environment, name, request, body, env, correlationId: cid, sessionId: sid, version, executionContext, logRequest, consoleLog: _consoleLog, dataset: _dataset, context: initialContext = {}, }) {
|
|
8
8
|
const environment = _environment || getEnvironment(env);
|
|
9
9
|
// const colorLogs = env?.[LOG_ENV] === '*' || ;
|
|
10
10
|
const correlationId = cid || getCorrelationId(request); //const logger = nodeColorLog;
|
|
11
|
+
const sessionId = sid || getSessionId(request);
|
|
11
12
|
const axiomToken = env?.[AXIOM_AUTH_TOKEN_ENV];
|
|
12
13
|
const isNodeJsCompat = typeof process !== 'undefined';
|
|
13
14
|
const isDev = environment === 'development';
|
|
@@ -28,10 +29,12 @@ export function useLog({ environment: _environment, name, request, body, env, co
|
|
|
28
29
|
app: name || 'default',
|
|
29
30
|
version: version || 'default',
|
|
30
31
|
correlationId,
|
|
32
|
+
sessionId,
|
|
31
33
|
context: {
|
|
32
34
|
...initialContext,
|
|
33
35
|
rootCorrelationId: correlationId,
|
|
34
36
|
correlationId,
|
|
37
|
+
sessionId,
|
|
35
38
|
taskQueue: request?.headers?.get(TASK_QUEUE_HEADER) || undefined,
|
|
36
39
|
workflowId: request?.headers?.get(WORKFLOW_ID_HEADER) || undefined,
|
|
37
40
|
child: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["log/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EAGP,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,QAA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E;wBACR,IAAI,EAAE,IAAI;6BACP,KAAK,EAAE;6BACP,IAAI,EAAE;6BACN,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;wBACzB,QAAQ,EAAE,IAAI;wBACd,MAAM,EAAE,IAAI,CAAC,MAAM;wBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;wBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;qBACtB;iBACF,CAAC,CAAC;gBAEH,OAAO,IAAI,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,sCAAsC;gBACtC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE;oBAC1B,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAC;gBAEH,OAAO,IAAI,QAAQ,CACjB,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EACrE;oBACE,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;iBACtB,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,MAAM,KAAK,EAAE,KAAK,EAAE,CAAC;QAErB,OAAO,QAAS,CAAC;IACnB,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -2,6 +2,7 @@ export declare const CONNECTION_ID_HEADER = "X-Connection-ID";
|
|
|
2
2
|
export declare const WORKFLOW_ID_HEADER = "X-Workflow-ID";
|
|
3
3
|
export declare const TASK_QUEUE_HEADER = "X-Task-Queue";
|
|
4
4
|
export declare const CORRELATION_ID_HEADER = "X-Correlation-ID";
|
|
5
|
+
export declare const SESSION_ID_HEADER = "X-Session-ID";
|
|
5
6
|
export declare const VERIFICATION_HEADER = "X-Verification-Key";
|
|
6
7
|
export declare const AXIOM_AUTH_TOKEN_ENV = "AXIOM_AUTH_TOKEN";
|
|
7
8
|
export declare const AXIOM_ORG_ID_ENV = "AXIOM_ORG_ID";
|
package/build/module/log/type.js
CHANGED
|
@@ -3,6 +3,7 @@ export const CONNECTION_ID_HEADER = 'X-Connection-ID';
|
|
|
3
3
|
export const WORKFLOW_ID_HEADER = 'X-Workflow-ID';
|
|
4
4
|
export const TASK_QUEUE_HEADER = 'X-Task-Queue';
|
|
5
5
|
export const CORRELATION_ID_HEADER = 'X-Correlation-ID';
|
|
6
|
+
export const SESSION_ID_HEADER = 'X-Session-ID';
|
|
6
7
|
export const VERIFICATION_HEADER = 'X-Verification-Key';
|
|
7
8
|
// Env
|
|
8
9
|
export const AXIOM_AUTH_TOKEN_ENV = 'AXIOM_AUTH_TOKEN';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"src/","sources":["log/type.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AACxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,MAAM;AACN,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"src/","sources":["log/type.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAChD,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,MAAM;AACN,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AACjD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type LogFn = (message: any, additionalContext?: Record<string, any>) => void;
|
|
2
|
+
export type LogFns = {
|
|
3
|
+
error: LogFn;
|
|
4
|
+
info: LogFn;
|
|
5
|
+
debug: LogFn;
|
|
6
|
+
warn: LogFn;
|
|
7
|
+
};
|
|
8
|
+
export type Log = LogFns & {
|
|
9
|
+
child: (data: ChildLogOptions) => Log;
|
|
10
|
+
addContext: (data: Record<string, any>) => void;
|
|
11
|
+
};
|
|
12
|
+
export type ChildLogOptions = {
|
|
13
|
+
correlationId?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
request?: any;
|
|
16
|
+
context?: Record<string, any>;
|
|
17
|
+
};
|
|
18
|
+
type Res = Response | {
|
|
19
|
+
status: number;
|
|
20
|
+
statusText?: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
body?: any;
|
|
23
|
+
response?: Response;
|
|
24
|
+
};
|
|
25
|
+
export type BaseLog = Log & {
|
|
26
|
+
flush(): Promise<void> | void;
|
|
27
|
+
};
|
|
28
|
+
export type WorkerLog = BaseLog & {
|
|
29
|
+
respond(response: Res | Promise<Res> | (() => Res | Promise<Res>)): Promise<Response>;
|
|
30
|
+
};
|
|
31
|
+
export type RequestLike = {
|
|
32
|
+
headers: {
|
|
33
|
+
get: (key: string) => string | null;
|
|
34
|
+
};
|
|
35
|
+
method: string;
|
|
36
|
+
url: string;
|
|
37
|
+
json: () => Promise<any>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"src/","sources":["type.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
package/src/log/baselog.ts
CHANGED
|
@@ -35,9 +35,11 @@ export function createBaseLog(
|
|
|
35
35
|
context,
|
|
36
36
|
type,
|
|
37
37
|
correlationId,
|
|
38
|
+
sessionId,
|
|
38
39
|
executionContext,
|
|
39
40
|
}: {
|
|
40
41
|
correlationId?: string;
|
|
42
|
+
sessionId?: string;
|
|
41
43
|
environment?: 'development' | 'production';
|
|
42
44
|
type?: 'worker' | 'durableObject';
|
|
43
45
|
workerId?: string;
|
|
@@ -85,6 +87,8 @@ export function createBaseLog(
|
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
|
|
90
|
+
const sid = sessionId || crypto.randomUUID().substring(0, 13);
|
|
91
|
+
|
|
88
92
|
function createBaseLog(arg: ChildLogOptions = {}): Log {
|
|
89
93
|
const childContext = arg.context || {};
|
|
90
94
|
if (arg.request) {
|
|
@@ -106,6 +110,7 @@ export function createBaseLog(
|
|
|
106
110
|
...childContext,
|
|
107
111
|
...additionalContext,
|
|
108
112
|
correlationId: cid,
|
|
113
|
+
sessionId: sid,
|
|
109
114
|
});
|
|
110
115
|
if (consoleLog) {
|
|
111
116
|
const name = arg.name ? `${app}/${arg.name}` : app;
|
|
@@ -119,7 +124,8 @@ export function createBaseLog(
|
|
|
119
124
|
|
|
120
125
|
error = message instanceof Error ? message : error;
|
|
121
126
|
message = message instanceof Error ? message.message : message;
|
|
122
|
-
const
|
|
127
|
+
const s = [sid, cid].filter(Boolean).join('/');
|
|
128
|
+
const formatted = `[${lev}] [${name}]${s ? ` [${s}]` : ''} ${message}`;
|
|
123
129
|
if (typeof consoleLog === 'function')
|
|
124
130
|
consoleLog({
|
|
125
131
|
formatted,
|
|
@@ -141,7 +147,7 @@ export function createBaseLog(
|
|
|
141
147
|
.reset()
|
|
142
148
|
.color('blue')
|
|
143
149
|
.bold()
|
|
144
|
-
.append(
|
|
150
|
+
.append(s ? `[${s}] ` : '')
|
|
145
151
|
.reset()
|
|
146
152
|
.append(message)
|
|
147
153
|
.log();
|
package/src/log/common.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CORRELATION_ID_HEADER,
|
|
3
|
+
type RequestLike,
|
|
4
|
+
SESSION_ID_HEADER,
|
|
5
|
+
} from './type';
|
|
2
6
|
|
|
3
7
|
export const requestHeadersToCapture = ['user-agent'];
|
|
4
8
|
|
|
@@ -18,6 +22,17 @@ export function getCorrelationId(request?: RequestLike) {
|
|
|
18
22
|
);
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
export function getSessionId(request?: RequestLike) {
|
|
26
|
+
if (!request?.headers) return undefined;
|
|
27
|
+
return (
|
|
28
|
+
request.headers.get(SESSION_ID_HEADER) ||
|
|
29
|
+
request.headers.get('fi-session-id') ||
|
|
30
|
+
request.headers.get('x-session-id') ||
|
|
31
|
+
request.headers.get('session-id') ||
|
|
32
|
+
undefined
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
export function getEnvironment(env?: Record<string, any>) {
|
|
22
37
|
if (env?.NODE_ENV) return env?.NODE_ENV;
|
|
23
38
|
return env?.IS_LOCAL_DEV ? 'development' : 'production';
|
package/src/log/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type ConsoleLog, createBaseLog } from './baselog';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getCorrelationId,
|
|
4
|
+
getEnvironment,
|
|
5
|
+
getSessionId,
|
|
6
|
+
requestToContext,
|
|
7
|
+
} from './common';
|
|
3
8
|
import {
|
|
4
9
|
AXIOM_AUTH_TOKEN_ENV,
|
|
5
10
|
AXIOM_DATASET_ENV,
|
|
@@ -23,6 +28,7 @@ export function useLog({
|
|
|
23
28
|
body,
|
|
24
29
|
env,
|
|
25
30
|
correlationId: cid,
|
|
31
|
+
sessionId: sid,
|
|
26
32
|
version,
|
|
27
33
|
executionContext,
|
|
28
34
|
logRequest,
|
|
@@ -36,6 +42,7 @@ export function useLog({
|
|
|
36
42
|
logRequest?: boolean | ((raw: ReturnType<typeof requestToContext>) => any);
|
|
37
43
|
body?: any;
|
|
38
44
|
correlationId?: string;
|
|
45
|
+
sessionId?: string;
|
|
39
46
|
version?: string;
|
|
40
47
|
dataset?: string;
|
|
41
48
|
env?: LogBindings;
|
|
@@ -48,6 +55,7 @@ export function useLog({
|
|
|
48
55
|
const environment = _environment || getEnvironment(env);
|
|
49
56
|
// const colorLogs = env?.[LOG_ENV] === '*' || ;
|
|
50
57
|
const correlationId = cid || getCorrelationId(request); //const logger = nodeColorLog;
|
|
58
|
+
const sessionId = sid || getSessionId(request);
|
|
51
59
|
|
|
52
60
|
const axiomToken = env?.[AXIOM_AUTH_TOKEN_ENV];
|
|
53
61
|
|
|
@@ -73,10 +81,12 @@ export function useLog({
|
|
|
73
81
|
app: name || 'default',
|
|
74
82
|
version: version || 'default',
|
|
75
83
|
correlationId,
|
|
84
|
+
sessionId,
|
|
76
85
|
context: {
|
|
77
86
|
...initialContext,
|
|
78
87
|
rootCorrelationId: correlationId,
|
|
79
88
|
correlationId,
|
|
89
|
+
sessionId,
|
|
80
90
|
taskQueue: request?.headers?.get(TASK_QUEUE_HEADER) || undefined,
|
|
81
91
|
workflowId: request?.headers?.get(WORKFLOW_ID_HEADER) || undefined,
|
|
82
92
|
child: undefined as any as string,
|
package/src/log/type.ts
CHANGED
|
@@ -3,6 +3,7 @@ export const CONNECTION_ID_HEADER = 'X-Connection-ID';
|
|
|
3
3
|
export const WORKFLOW_ID_HEADER = 'X-Workflow-ID';
|
|
4
4
|
export const TASK_QUEUE_HEADER = 'X-Task-Queue';
|
|
5
5
|
export const CORRELATION_ID_HEADER = 'X-Correlation-ID';
|
|
6
|
+
export const SESSION_ID_HEADER = 'X-Session-ID';
|
|
6
7
|
export const VERIFICATION_HEADER = 'X-Verification-Key';
|
|
7
8
|
|
|
8
9
|
// Env
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { Log } from '../log';
|
|
2
|
-
export declare class IntercomAPI {
|
|
3
|
-
constructor(token: string, log?: Log);
|
|
4
|
-
private headers;
|
|
5
|
-
private log?;
|
|
6
|
-
private fetch;
|
|
7
|
-
getUserByUserId(userId: string): Promise<{
|
|
8
|
-
type: "list";
|
|
9
|
-
data: {
|
|
10
|
-
id: string;
|
|
11
|
-
}[] | undefined;
|
|
12
|
-
total_count: 0;
|
|
13
|
-
pages: {
|
|
14
|
-
type: "pages";
|
|
15
|
-
page: 1;
|
|
16
|
-
per_page: 10;
|
|
17
|
-
total_pages: 0;
|
|
18
|
-
};
|
|
19
|
-
} | undefined>;
|
|
20
|
-
createUser({ data, userId, }: {
|
|
21
|
-
userId: string;
|
|
22
|
-
data: {
|
|
23
|
-
email: string;
|
|
24
|
-
name: string;
|
|
25
|
-
custom_attributes: Record<string, any>;
|
|
26
|
-
};
|
|
27
|
-
}): Promise<unknown>;
|
|
28
|
-
updateUser({ data, contactId, }: {
|
|
29
|
-
contactId: string;
|
|
30
|
-
data: {
|
|
31
|
-
email?: string;
|
|
32
|
-
name?: string;
|
|
33
|
-
custom_attributes: Record<string, any>;
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<unknown>;
|
|
37
|
-
deleteUser(intercom_contact_id: string): Promise<{
|
|
38
|
-
id: "6657adf56abd0167d9419d1c";
|
|
39
|
-
external_id: "70";
|
|
40
|
-
type: "contact";
|
|
41
|
-
deleted: true;
|
|
42
|
-
} | undefined>;
|
|
43
|
-
createCompanyUser(data: {
|
|
44
|
-
intercom_contact_id: string;
|
|
45
|
-
intercom_company_id: string;
|
|
46
|
-
}): Promise<unknown>;
|
|
47
|
-
deleteCompanyUser({ intercom_company_id, intercom_contact_id, }: {
|
|
48
|
-
intercom_contact_id: string;
|
|
49
|
-
intercom_company_id: string;
|
|
50
|
-
}): Promise<{
|
|
51
|
-
id: "6657adc96abd0167d9419ca7";
|
|
52
|
-
} | undefined>;
|
|
53
|
-
trackEvent(data: {
|
|
54
|
-
user_id: string;
|
|
55
|
-
event_name: string;
|
|
56
|
-
metadata: Record<string, any>;
|
|
57
|
-
}): Promise<unknown>;
|
|
58
|
-
getCompanyByTenantId(tenantId: string): Promise<{
|
|
59
|
-
type: "list";
|
|
60
|
-
data: [{
|
|
61
|
-
type: "company";
|
|
62
|
-
company_id: "remote_companies_scroll_2";
|
|
63
|
-
id: "664df5436abd01f7945e1a78";
|
|
64
|
-
app_id: "this_is_an_id111_that_should_be_at_least_";
|
|
65
|
-
name: "IntercomQATest1";
|
|
66
|
-
remote_created_at: 1716385091;
|
|
67
|
-
created_at: 1716385091;
|
|
68
|
-
updated_at: 1716385091;
|
|
69
|
-
monthly_spend: 0;
|
|
70
|
-
session_count: 0;
|
|
71
|
-
user_count: 4;
|
|
72
|
-
tags: {
|
|
73
|
-
type: "tag.list";
|
|
74
|
-
tags: [];
|
|
75
|
-
};
|
|
76
|
-
segments: {
|
|
77
|
-
type: "segment.list";
|
|
78
|
-
segments: [];
|
|
79
|
-
};
|
|
80
|
-
custom_attributes: Record<string, string>;
|
|
81
|
-
}] | undefined;
|
|
82
|
-
pages: {
|
|
83
|
-
type: "pages";
|
|
84
|
-
next: null;
|
|
85
|
-
page: 1;
|
|
86
|
-
per_page: 15;
|
|
87
|
-
total_pages: 1;
|
|
88
|
-
};
|
|
89
|
-
total_count: 1;
|
|
90
|
-
} | undefined>;
|
|
91
|
-
createCompany({ data, tenantId, }: {
|
|
92
|
-
tenantId: string;
|
|
93
|
-
data: {
|
|
94
|
-
name: string;
|
|
95
|
-
remote_created_at: number;
|
|
96
|
-
custom_attributes: Record<string, any>;
|
|
97
|
-
};
|
|
98
|
-
}): Promise<unknown>;
|
|
99
|
-
updateCompany({ data, companyId, }: {
|
|
100
|
-
companyId: string;
|
|
101
|
-
data: Record<string, any>;
|
|
102
|
-
}): Promise<unknown>;
|
|
103
|
-
deleteCompany(intercom_company_id: string): Promise<{
|
|
104
|
-
id: "6657adc96abd0167d9419ca7";
|
|
105
|
-
object: "company";
|
|
106
|
-
deleted: true;
|
|
107
|
-
} | undefined>;
|
|
108
|
-
}
|
|
109
|
-
export declare function useIntercom(token: string, log?: Log): IntercomAPI;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntercomAPI = void 0;
|
|
4
|
-
exports.useIntercom = useIntercom;
|
|
5
|
-
class IntercomAPI {
|
|
6
|
-
constructor(token, log) {
|
|
7
|
-
this.headers = {
|
|
8
|
-
'Content-Type': 'application/json',
|
|
9
|
-
Accept: 'application/json',
|
|
10
|
-
'Intercom-Version': '2.11',
|
|
11
|
-
Authorization: `Bearer ${token}`,
|
|
12
|
-
};
|
|
13
|
-
this.log = log;
|
|
14
|
-
}
|
|
15
|
-
async fetch(path, options) {
|
|
16
|
-
if (options?.data) {
|
|
17
|
-
options.body = JSON.stringify(options.data);
|
|
18
|
-
options.data = undefined;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const result = await fetch(`https://api.intercom.io${path}`, {
|
|
22
|
-
method: 'GET',
|
|
23
|
-
headers: this.headers,
|
|
24
|
-
...options,
|
|
25
|
-
});
|
|
26
|
-
if (!result.ok) {
|
|
27
|
-
this.log?.info('Failed to fetch from Intercom', {
|
|
28
|
-
result: {
|
|
29
|
-
status: result.status,
|
|
30
|
-
statusText: result.statusText,
|
|
31
|
-
body: await result.text(),
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
if (result.status === 404)
|
|
35
|
-
return undefined;
|
|
36
|
-
if (result.status === 429) {
|
|
37
|
-
console.log('Intercom rate limit exceeded, waiting for 1 minute');
|
|
38
|
-
// X-RateLimit-Reset: 1487332520 => timestamp from header response when resetting
|
|
39
|
-
const reset = Number(result.headers.get('X-RateLimit-Reset'));
|
|
40
|
-
if (reset) {
|
|
41
|
-
const now = Math.floor(Date.now() / 1000);
|
|
42
|
-
const wait = reset - now + 1;
|
|
43
|
-
console.log(`Waiting for ${wait} seconds`);
|
|
44
|
-
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
|
|
45
|
-
return await this.fetch(path, options);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return result.status === 202 ? {} : (await result.json());
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
this.log?.error(error);
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// User
|
|
57
|
-
async getUserByUserId(userId) {
|
|
58
|
-
return await this.fetch('/contacts/search', {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
data: {
|
|
61
|
-
query: {
|
|
62
|
-
field: 'external_id',
|
|
63
|
-
operator: '=',
|
|
64
|
-
value: userId,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async createUser({ data, userId, }) {
|
|
70
|
-
return await this.fetch('/contacts', {
|
|
71
|
-
method: 'POST',
|
|
72
|
-
data: { ...data, external_id: userId },
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async updateUser({ data, contactId, }) {
|
|
76
|
-
return await this.fetch(`/contacts/${contactId}`, {
|
|
77
|
-
method: 'PUT',
|
|
78
|
-
data,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async deleteUser(intercom_contact_id) {
|
|
82
|
-
return await this.fetch(`/contacts/${intercom_contact_id}`, {
|
|
83
|
-
method: 'DELETE',
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async createCompanyUser(data) {
|
|
87
|
-
return await this.fetch(`/contacts/${data.intercom_contact_id}/companies`, {
|
|
88
|
-
method: 'POST',
|
|
89
|
-
data: {
|
|
90
|
-
id: data.intercom_company_id,
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
async deleteCompanyUser({ intercom_company_id, intercom_contact_id, }) {
|
|
95
|
-
return await this.fetch(`/contacts/${intercom_contact_id}/companies/${intercom_company_id}`, {
|
|
96
|
-
method: 'DELETE',
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async trackEvent(data) {
|
|
100
|
-
return await this.fetch('/events', {
|
|
101
|
-
method: 'POST',
|
|
102
|
-
data: {
|
|
103
|
-
created_at: Math.floor(new Date().getTime() / 1000), // to seconds
|
|
104
|
-
...data,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
// Company
|
|
109
|
-
async getCompanyByTenantId(tenantId) {
|
|
110
|
-
return await this.fetch(`/companies?company_id=${tenantId}`, {
|
|
111
|
-
method: 'GET',
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
async createCompany({ data, tenantId, }) {
|
|
115
|
-
return await this.fetch('/companies', {
|
|
116
|
-
method: 'POST',
|
|
117
|
-
data: {
|
|
118
|
-
...data,
|
|
119
|
-
company_id: tenantId,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
async updateCompany({ data, companyId, }) {
|
|
124
|
-
return await this.fetch(`/companies/${companyId}`, {
|
|
125
|
-
method: 'PUT',
|
|
126
|
-
data,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
async deleteCompany(intercom_company_id) {
|
|
130
|
-
return await this.fetch(`/companies/${intercom_company_id}`, {
|
|
131
|
-
method: 'DELETE',
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
exports.IntercomAPI = IntercomAPI;
|
|
136
|
-
function useIntercom(token, log) {
|
|
137
|
-
return new IntercomAPI(token, log);
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=_intercom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_intercom.js","sourceRoot":"src/","sources":["tracking/_intercom.ts"],"names":[],"mappings":";;;AA+PA,kCAEC;AA/PD,MAAa,WAAW;IACtB,YAAY,KAAa,EAAE,GAAS;QAClC,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;YAC1B,kBAAkB,EAAE,MAAM;YAC1B,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC,CAAC;QAEF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAKO,KAAK,CAAC,KAAK,CACjB,IAAY,EACZ,OAAsC;QAEtC,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,0BAA0B,IAAI,EAAE,EAAE;gBAC3D,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,GAAG,OAAO;aACX,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,+BAA+B,EAAE;oBAC9C,MAAM,EAAE;wBACN,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,UAAU,EAAE,MAAM,CAAC,UAAU;wBAC7B,IAAI,EAAE,MAAM,MAAM,CAAC,IAAI,EAAE;qBAC1B;iBACF,CAAC,CAAC;gBAEH,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;oBAAE,OAAO,SAAS,CAAC;gBAE5C,IAAI,MAAM,CAAC,MAAM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GAAG,IAAI,CAAC,EAAE,aAAa;gBAClE,GAAG,IAAI;aACR;SACF,CAAC,CAAC;IACL,CAAC;IAED,UAAU;IACV,KAAK,CAAC,oBAAoB,CAAC,QAAgB;QACzC,OAAO,MAAM,IAAI,CAAC,KAAK,CAoCpB,yBAAyB,QAAQ,EAAE,EAAE;YACtC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,EAClB,IAAI,EACJ,QAAQ,GAQT;QACC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,GAAG,IAAI;gBACP,UAAU,EAAE,QAAQ;aACrB;SACF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,EAClB,IAAI,EACJ,SAAS,GAIV;QACC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,SAAS,EAAE,EAAE;YACjD,MAAM,EAAE,KAAK;YACb,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,mBAA2B;QAC7C,OAAO,MAAM,IAAI,CAAC,KAAK,CAIpB,cAAc,mBAAmB,EAAE,EAAE;YACtC,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;CACF;AA3PD,kCA2PC;AAED,SAAgB,WAAW,CAAC,KAAa,EAAE,GAAS;IAClD,OAAO,IAAI,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type AuthEvent = 'account_signin_completed' | 'account_signup_code_requested' | 'account_signup_code_completed' | 'account_signup_code_failed' | 'account_signup_completed' | 'account_password_reset_requested' | 'account_password_reset_failed' | 'account_password_reset_completed' | 'account_invitation_accepted' | 'account_signed_out';
|
|
2
|
-
type TeamEvent = 'team_added' | 'team_info_updated' | 'team_deleted' | 'team_member_removed';
|
|
3
|
-
type ConnectionEvent = 'connection_created' | 'connection_reconnected' | 'connection_deleted' | 'connection_requested';
|
|
4
|
-
type OwnershipEvent = 'ownership_created' | 'ownership_updated' | 'ownership_deleted';
|
|
5
|
-
type OwnerEvent = 'owner_created' | 'owner_updated' | 'owner_deleted' | 'owner_tax_info_modal_opened' | 'owner_tax_info_modal_submitted';
|
|
6
|
-
type SetupEvent = 'setup_classes_set' | 'setup_accounting_version_completed' | 'setup_accounting_config_completed' | 'setup_owner_imported' | 'setup_listing_imported';
|
|
7
|
-
type AutomationEvent = 'automation_created' | 'automation_updated' | 'automation_deleted';
|
|
8
|
-
type TaxStatementEvent = 'tax_statement_preview_opened' | 'tax_statement_downloaded';
|
|
9
|
-
type GLOwnerStatementEvent = 'gl_owner_statement_preview_opened' | 'gl_owner_statement_downloaded';
|
|
10
|
-
type HyperlineEvent = 'hyperline_invoice_ready' | 'hyperline_invoice_settled' | 'hyperline_trial_started' | 'hyperline_trial_ended' | 'hyperline_subscription_activated' | 'hyperline_subscription_cancelled' | 'hyperline_subscription_created' | 'hyperline_subscription_errored' | 'hyperline_subscription_paused' | 'hyperline_subscription_voided' | 'hyperline_subscription_charged' | 'hyperline_customer_created' | 'hyperline_customer_updated' | 'hyperline_payment_method_created' | 'hyperline_payment_method_errored' | 'hyperline_payment_method_deleted';
|
|
11
|
-
type ListingEvent = 'listing_activated' | 'listing_deactivated';
|
|
12
|
-
type ReportEvent = 'listings_reported';
|
|
13
|
-
type UserEvent = 'update_refresh_accepted' | 'owner_statement_opened';
|
|
14
|
-
type TestEvent = 'test_event' | 'test_error';
|
|
15
|
-
export type TrackingEvent = AuthEvent | TeamEvent | ConnectionEvent | OwnershipEvent | OwnerEvent | SetupEvent | AutomationEvent | TaxStatementEvent | GLOwnerStatementEvent | HyperlineEvent | UserEvent | ListingEvent | ReportEvent | TestEvent;
|
|
16
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventTypes.js","sourceRoot":"src/","sources":["tracking/eventTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { Log } from '../log';
|
|
2
|
-
export declare class IntercomAPI {
|
|
3
|
-
constructor(token: string, log?: Log);
|
|
4
|
-
private headers;
|
|
5
|
-
private log?;
|
|
6
|
-
private fetch;
|
|
7
|
-
getUserByUserId(userId: string): Promise<{
|
|
8
|
-
type: "list";
|
|
9
|
-
data: {
|
|
10
|
-
id: string;
|
|
11
|
-
}[] | undefined;
|
|
12
|
-
total_count: 0;
|
|
13
|
-
pages: {
|
|
14
|
-
type: "pages";
|
|
15
|
-
page: 1;
|
|
16
|
-
per_page: 10;
|
|
17
|
-
total_pages: 0;
|
|
18
|
-
};
|
|
19
|
-
} | undefined>;
|
|
20
|
-
createUser({ data, userId, }: {
|
|
21
|
-
userId: string;
|
|
22
|
-
data: {
|
|
23
|
-
email: string;
|
|
24
|
-
name: string;
|
|
25
|
-
custom_attributes: Record<string, any>;
|
|
26
|
-
};
|
|
27
|
-
}): Promise<unknown>;
|
|
28
|
-
updateUser({ data, contactId, }: {
|
|
29
|
-
contactId: string;
|
|
30
|
-
data: {
|
|
31
|
-
email?: string;
|
|
32
|
-
name?: string;
|
|
33
|
-
custom_attributes: Record<string, any>;
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<unknown>;
|
|
37
|
-
deleteUser(intercom_contact_id: string): Promise<{
|
|
38
|
-
id: "6657adf56abd0167d9419d1c";
|
|
39
|
-
external_id: "70";
|
|
40
|
-
type: "contact";
|
|
41
|
-
deleted: true;
|
|
42
|
-
} | undefined>;
|
|
43
|
-
createCompanyUser(data: {
|
|
44
|
-
intercom_contact_id: string;
|
|
45
|
-
intercom_company_id: string;
|
|
46
|
-
}): Promise<unknown>;
|
|
47
|
-
deleteCompanyUser({ intercom_company_id, intercom_contact_id, }: {
|
|
48
|
-
intercom_contact_id: string;
|
|
49
|
-
intercom_company_id: string;
|
|
50
|
-
}): Promise<{
|
|
51
|
-
id: "6657adc96abd0167d9419ca7";
|
|
52
|
-
} | undefined>;
|
|
53
|
-
trackEvent(data: {
|
|
54
|
-
user_id: string;
|
|
55
|
-
event_name: string;
|
|
56
|
-
metadata: Record<string, any>;
|
|
57
|
-
}): Promise<unknown>;
|
|
58
|
-
getCompanyByTenantId(tenantId: string): Promise<{
|
|
59
|
-
type: "list";
|
|
60
|
-
data: [{
|
|
61
|
-
type: "company";
|
|
62
|
-
company_id: "remote_companies_scroll_2";
|
|
63
|
-
id: "664df5436abd01f7945e1a78";
|
|
64
|
-
app_id: "this_is_an_id111_that_should_be_at_least_";
|
|
65
|
-
name: "IntercomQATest1";
|
|
66
|
-
remote_created_at: 1716385091;
|
|
67
|
-
created_at: 1716385091;
|
|
68
|
-
updated_at: 1716385091;
|
|
69
|
-
monthly_spend: 0;
|
|
70
|
-
session_count: 0;
|
|
71
|
-
user_count: 4;
|
|
72
|
-
tags: {
|
|
73
|
-
type: "tag.list";
|
|
74
|
-
tags: [];
|
|
75
|
-
};
|
|
76
|
-
segments: {
|
|
77
|
-
type: "segment.list";
|
|
78
|
-
segments: [];
|
|
79
|
-
};
|
|
80
|
-
custom_attributes: Record<string, string>;
|
|
81
|
-
}] | undefined;
|
|
82
|
-
pages: {
|
|
83
|
-
type: "pages";
|
|
84
|
-
next: null;
|
|
85
|
-
page: 1;
|
|
86
|
-
per_page: 15;
|
|
87
|
-
total_pages: 1;
|
|
88
|
-
};
|
|
89
|
-
total_count: 1;
|
|
90
|
-
} | undefined>;
|
|
91
|
-
createCompany({ data, tenantId, }: {
|
|
92
|
-
tenantId: string;
|
|
93
|
-
data: {
|
|
94
|
-
name: string;
|
|
95
|
-
remote_created_at: number;
|
|
96
|
-
custom_attributes: Record<string, any>;
|
|
97
|
-
};
|
|
98
|
-
}): Promise<unknown>;
|
|
99
|
-
updateCompany({ data, companyId, }: {
|
|
100
|
-
companyId: string;
|
|
101
|
-
data: Record<string, any>;
|
|
102
|
-
}): Promise<unknown>;
|
|
103
|
-
deleteCompany(intercom_company_id: string): Promise<{
|
|
104
|
-
id: "6657adc96abd0167d9419ca7";
|
|
105
|
-
object: "company";
|
|
106
|
-
deleted: true;
|
|
107
|
-
} | undefined>;
|
|
108
|
-
}
|
|
109
|
-
export declare function useIntercom(token: string, log?: Log): IntercomAPI;
|