@vrplatform/log 2.0.29 → 2.0.33
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 +8 -1
- package/build/main/log/baselog.js +10 -2
- package/build/main/log/baselog.js.map +1 -1
- package/build/main/log/index.d.ts +3 -1
- package/build/main/log/index.js +9 -3
- package/build/main/log/index.js.map +1 -1
- package/build/main/log/type.d.ts +1 -0
- package/build/main/tracking/index.d.ts +6 -0
- package/build/main/tracking/index.js +83 -6
- package/build/main/tracking/index.js.map +1 -1
- package/build/main/tracking/types.d.ts +3 -0
- 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 +8 -1
- package/build/module/log/baselog.js +10 -2
- package/build/module/log/baselog.js.map +1 -1
- package/build/module/log/index.d.ts +3 -1
- package/build/module/log/index.js +9 -3
- package/build/module/log/index.js.map +1 -1
- package/build/module/log/type.d.ts +1 -0
- package/build/module/tracking/index.d.ts +6 -0
- package/build/module/tracking/index.js +85 -8
- package/build/module/tracking/index.js.map +1 -1
- package/build/module/tracking/types.d.ts +3 -0
- 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 +3 -1
- package/src/log/baselog.ts +22 -10
- package/src/log/index.ts +12 -3
- package/src/log/type.ts +2 -0
- package/src/tracking/index.ts +112 -6
- package/src/tracking/types.ts +3 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"src/","sources":["common.ts"],"names":[],"mappings":"AAEA,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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AAC,GAAG;SAClB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC;QACnC,OAAe,CAAC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACjE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,oBAAoB,CAAC;QACxC,OAAe,CAAC,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3E,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"src/","sources":["index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { BaseLog } from './type';
|
|
2
|
+
export type ConsoleLogFn = (arg: {
|
|
3
|
+
formatted: string;
|
|
4
|
+
message: string;
|
|
5
|
+
additionalContext: Record<string, any>;
|
|
6
|
+
level: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
export type ConsoleLog = boolean | 'color' | ConsoleLogFn;
|
|
2
9
|
export declare function createBaseLog({ token, orgId, dataset, consoleLog, }: {
|
|
3
10
|
token?: string;
|
|
4
11
|
orgId?: string;
|
|
5
12
|
dataset?: string;
|
|
6
|
-
consoleLog?:
|
|
13
|
+
consoleLog?: ConsoleLog;
|
|
7
14
|
}, { environment, workerId, app, version, context, type, correlationId, executionContext, }: {
|
|
8
15
|
correlationId?: string;
|
|
9
16
|
environment?: 'development' | 'production';
|
|
@@ -57,7 +57,15 @@ export function createBaseLog({ token, orgId = 'vrplatform-mv6k', dataset, conso
|
|
|
57
57
|
lastMessageTimestamp = now;
|
|
58
58
|
error = message instanceof Error ? message : error;
|
|
59
59
|
message = message instanceof Error ? message.message : message;
|
|
60
|
-
|
|
60
|
+
const formatted = `[${lev}] [${name}]${cid ? ` [${cid}]` : ''} ${message}`;
|
|
61
|
+
if (typeof consoleLog === 'function')
|
|
62
|
+
consoleLog({
|
|
63
|
+
formatted,
|
|
64
|
+
level,
|
|
65
|
+
message,
|
|
66
|
+
additionalContext,
|
|
67
|
+
});
|
|
68
|
+
else if (consoleLog === 'color')
|
|
61
69
|
logger
|
|
62
70
|
.dim()
|
|
63
71
|
.append(`${diff}`)
|
|
@@ -75,7 +83,7 @@ export function createBaseLog({ token, orgId = 'vrplatform-mv6k', dataset, conso
|
|
|
75
83
|
.append(message)
|
|
76
84
|
.log();
|
|
77
85
|
else
|
|
78
|
-
console.log(
|
|
86
|
+
console.log(formatted, additionalContext);
|
|
79
87
|
if (error)
|
|
80
88
|
console.error(error);
|
|
81
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baselog.js","sourceRoot":"src/","sources":["log/baselog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D,IAAI,oBAAoB,GAAuB,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"baselog.js","sourceRoot":"src/","sources":["log/baselog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D,IAAI,oBAAoB,GAAuB,SAAS,CAAC;AAUzD,MAAM,UAAU,aAAa,CAC3B,EACE,KAAK,EACL,KAAK,GAAG,iBAAiB,EACzB,OAAO,EACP,UAAU,GAMX,EACD,EACE,WAAW,EACX,QAAQ,EACR,GAAG,EACH,OAAO,EAC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,EAAE,IAAI,IAAI,OAAO,CAAC;gBAC/C,MAAM,CAAC,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;gBACxD,OAAO,OAAO,CACZ,OAAO,EACP,CAAC,EACD,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1C,CAAC,CACF,CAAC;YACJ,CAAC;YACD,KAAK,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;YACzD,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;YACvD,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;SACxD,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,aAAa,EAAoB,CAAC;IAClD,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE;QACnB,IAAI,gBAAgB,IAAI,KAAK,EAAE,CAAC;YAC9B,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { type ConsoleLog } from './baselog';
|
|
1
2
|
import { requestToContext } from './common';
|
|
2
3
|
import { type LogBindings, type RequestLike, type WorkerLog } from './type';
|
|
3
4
|
export * from './common';
|
|
4
5
|
export * from './baselog';
|
|
5
6
|
export * from './type';
|
|
6
|
-
export declare function useLog({ environment: _environment, name, request, body, env, correlationId: cid, version, executionContext, logRequest, dataset: _dataset, context: initialContext, }: {
|
|
7
|
+
export declare function useLog({ environment: _environment, name, request, body, env, correlationId: cid, version, executionContext, logRequest, consoleLog: _consoleLog, dataset: _dataset, context: initialContext, }: {
|
|
7
8
|
environment?: string;
|
|
8
9
|
name: string;
|
|
9
10
|
request?: RequestLike & {
|
|
@@ -16,6 +17,7 @@ export declare function useLog({ environment: _environment, name, request, body,
|
|
|
16
17
|
dataset?: string;
|
|
17
18
|
env?: LogBindings;
|
|
18
19
|
context?: Record<string, any>;
|
|
20
|
+
consoleLog?: ConsoleLog;
|
|
19
21
|
executionContext?: {
|
|
20
22
|
waitUntil(promise: Promise<any>): void;
|
|
21
23
|
};
|
|
@@ -4,16 +4,22 @@ import { AXIOM_AUTH_TOKEN_ENV, AXIOM_DATASET_ENV, AXIOM_ORG_ID_ENV, LOG_ENV, TAS
|
|
|
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, dataset: _dataset, context: initialContext = {}, }) {
|
|
7
|
+
export function useLog({ environment: _environment, name, request, body, env, correlationId: cid, version, executionContext, logRequest, consoleLog: _consoleLog, dataset: _dataset, context: initialContext = {}, }) {
|
|
8
8
|
const environment = _environment || getEnvironment(env);
|
|
9
|
-
const colorLogs =
|
|
9
|
+
// const colorLogs = env?.[LOG_ENV] === '*' || ;
|
|
10
10
|
const correlationId = cid || getCorrelationId(request); //const logger = nodeColorLog;
|
|
11
11
|
const axiomToken = env?.[AXIOM_AUTH_TOKEN_ENV];
|
|
12
|
+
const isNodeJsCompat = typeof process !== 'undefined';
|
|
13
|
+
const isDev = environment === 'development';
|
|
14
|
+
const isLogEnabled = env?.[LOG_ENV] === '*';
|
|
15
|
+
const consoleLog = !axiomToken || isDev || isLogEnabled;
|
|
16
|
+
const colorLog = consoleLog && isNodeJsCompat;
|
|
12
17
|
const axiom = createBaseLog({
|
|
13
18
|
token: axiomToken,
|
|
14
19
|
orgId: env?.[AXIOM_ORG_ID_ENV],
|
|
15
20
|
dataset: _dataset || env?.[AXIOM_DATASET_ENV] || 'default',
|
|
16
|
-
|
|
21
|
+
// color log on development and if env is *
|
|
22
|
+
consoleLog: _consoleLog || (colorLog ? 'color' : consoleLog),
|
|
17
23
|
}, {
|
|
18
24
|
environment,
|
|
19
25
|
type: 'worker',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["log/index.ts"],"names":[],"mappings":"AAAA,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,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,OAAO,EAGP,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,QAAQ,CAAC;AAEhB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AAEvB,MAAM,UAAU,MAAM,CAAC,EACrB,WAAW,EAAE,YAAY,EACzB,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,GAAG,EACH,aAAa,EAAE,GAAG,EAClB,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,cAAc,GAAG,EAAE,GAgB7B;IACC,MAAM,WAAW,GAAG,YAAY,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,iDAAiD;IACjD,MAAM,aAAa,GAAG,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B;IAEtF,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,oBAAoB,CAAC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C,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"}
|
|
@@ -7,6 +7,7 @@ export declare const AXIOM_AUTH_TOKEN_ENV = "AXIOM_AUTH_TOKEN";
|
|
|
7
7
|
export declare const AXIOM_ORG_ID_ENV = "AXIOM_ORG_ID";
|
|
8
8
|
export declare const AXIOM_DATASET_ENV = "AXIOM_DATASET";
|
|
9
9
|
export declare const LOG_ENV = "LOG";
|
|
10
|
+
export type LogLevel = 'info' | 'log' | 'error' | 'debug' | 'warn';
|
|
10
11
|
export type LogBindings = {
|
|
11
12
|
[LOG_ENV]?: string;
|
|
12
13
|
[AXIOM_AUTH_TOKEN_ENV]?: string;
|
|
@@ -85,7 +85,9 @@ declare module 'intercom-client' {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
import { Analytics } from '@june-so/analytics-node';
|
|
88
89
|
import { Intercom } from 'intercom-client';
|
|
90
|
+
import { PostHog } from 'posthog-node';
|
|
89
91
|
import { type LogBindings, type WorkerLog } from '../log';
|
|
90
92
|
import type { GroupProps, IdentifyProps, TrackProps, TrackingEvent } from './types';
|
|
91
93
|
export * from './types';
|
|
@@ -97,6 +99,8 @@ export type UseTracking = {
|
|
|
97
99
|
dataset: string;
|
|
98
100
|
env: {
|
|
99
101
|
INTERCOM_TOKEN?: string;
|
|
102
|
+
JUNESO_TOKEN?: string;
|
|
103
|
+
POSTHOG_TOKEN?: string;
|
|
100
104
|
HASURA_GRAPHQL_ADMIN_SECRET?: string;
|
|
101
105
|
HASURA_ADMIN_SECRET?: string;
|
|
102
106
|
} & LogBindings;
|
|
@@ -108,5 +112,7 @@ export declare const useTracking: ({ dataset, env, name }: UseTracking, isDev?:
|
|
|
108
112
|
group: (props: GroupProps) => Promise<void>;
|
|
109
113
|
shutdown: () => Promise<any>;
|
|
110
114
|
log: WorkerLog;
|
|
115
|
+
june?: Analytics;
|
|
111
116
|
intercom?: Intercom;
|
|
117
|
+
posthog?: PostHog;
|
|
112
118
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useHasuraClient } from '@finalytic/graphql';
|
|
2
|
+
import { Analytics } from '@june-so/analytics-node';
|
|
2
3
|
import { Intercom } from 'intercom-client';
|
|
4
|
+
import { PostHog } from 'posthog-node';
|
|
3
5
|
import { useLog } from '../log';
|
|
4
|
-
import { isTest } from '../utils';
|
|
6
|
+
import { convertKeysToSnakeCase, isTest } from '../utils';
|
|
5
7
|
import { convertValuesToString } from '../utils/convertValuesToString';
|
|
6
8
|
export * from './types';
|
|
7
9
|
export * from 'intercom-client';
|
|
8
10
|
export * from '../utils';
|
|
9
11
|
export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
10
12
|
const client = env.HASURA_GRAPHQL_ADMIN_SECRET
|
|
11
|
-
?
|
|
13
|
+
? useHasuraClient({
|
|
12
14
|
secret: env.HASURA_ADMIN_SECRET || env.HASURA_GRAPHQL_ADMIN_SECRET,
|
|
13
15
|
})
|
|
14
16
|
: undefined;
|
|
@@ -23,6 +25,12 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
23
25
|
// }),
|
|
24
26
|
})
|
|
25
27
|
: undefined;
|
|
28
|
+
const june = env.JUNESO_TOKEN ? new Analytics(env.JUNESO_TOKEN) : undefined;
|
|
29
|
+
const posthog = env.POSTHOG_TOKEN
|
|
30
|
+
? new PostHog(env.POSTHOG_TOKEN, {
|
|
31
|
+
host: 'https://app.posthog.com',
|
|
32
|
+
})
|
|
33
|
+
: undefined;
|
|
26
34
|
return {
|
|
27
35
|
// General
|
|
28
36
|
track: async ({ userId, anonymousId, groupId, event, packageName, properties, timestamp = new Date(), }) => {
|
|
@@ -38,7 +46,48 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
38
46
|
packageName,
|
|
39
47
|
},
|
|
40
48
|
}).id);
|
|
41
|
-
if (
|
|
49
|
+
if (anonymousId) {
|
|
50
|
+
posthog?.capture({
|
|
51
|
+
distinctId: anonymousId,
|
|
52
|
+
event,
|
|
53
|
+
groups: {
|
|
54
|
+
tenant: groupId,
|
|
55
|
+
},
|
|
56
|
+
timestamp,
|
|
57
|
+
properties: convertKeysToSnakeCase(properties),
|
|
58
|
+
});
|
|
59
|
+
june?.track({
|
|
60
|
+
anonymousId,
|
|
61
|
+
event,
|
|
62
|
+
properties,
|
|
63
|
+
timestamp,
|
|
64
|
+
context: { groupId },
|
|
65
|
+
}, (err) => {
|
|
66
|
+
if (err)
|
|
67
|
+
console.error(err);
|
|
68
|
+
});
|
|
69
|
+
// no intercom for anonymous
|
|
70
|
+
}
|
|
71
|
+
else if (userId) {
|
|
72
|
+
posthog?.capture({
|
|
73
|
+
distinctId: userId,
|
|
74
|
+
event,
|
|
75
|
+
groups: {
|
|
76
|
+
tenant: groupId,
|
|
77
|
+
},
|
|
78
|
+
timestamp,
|
|
79
|
+
properties: convertKeysToSnakeCase(properties),
|
|
80
|
+
});
|
|
81
|
+
june?.track({
|
|
82
|
+
userId,
|
|
83
|
+
event,
|
|
84
|
+
properties,
|
|
85
|
+
timestamp,
|
|
86
|
+
context: { groupId },
|
|
87
|
+
}, (err) => {
|
|
88
|
+
if (err)
|
|
89
|
+
console.error(err);
|
|
90
|
+
});
|
|
42
91
|
try {
|
|
43
92
|
await intercom?.dataEvents.create({
|
|
44
93
|
body: {
|
|
@@ -54,9 +103,19 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
54
103
|
}
|
|
55
104
|
}
|
|
56
105
|
},
|
|
57
|
-
identify: async ({ traits, userId }) => {
|
|
106
|
+
identify: async ({ traits, userId, disableGeoip, timestamp = new Date(), }) => {
|
|
58
107
|
if (isDev || isTest(userId))
|
|
59
108
|
return;
|
|
109
|
+
posthog?.identify({
|
|
110
|
+
distinctId: userId,
|
|
111
|
+
properties: convertKeysToSnakeCase(traits),
|
|
112
|
+
disableGeoip,
|
|
113
|
+
});
|
|
114
|
+
june?.identify({
|
|
115
|
+
userId,
|
|
116
|
+
traits,
|
|
117
|
+
timestamp,
|
|
118
|
+
}, (err) => (err ? console.error(err) : {}));
|
|
60
119
|
// upsert intercom user
|
|
61
120
|
try {
|
|
62
121
|
const data = {
|
|
@@ -93,7 +152,7 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
93
152
|
console.error(e);
|
|
94
153
|
}
|
|
95
154
|
},
|
|
96
|
-
group: async ({ traits = {}, groupId, userId, anonymousId, }) => {
|
|
155
|
+
group: async ({ traits = {}, groupId, userId, anonymousId, timestamp = new Date(), }) => {
|
|
97
156
|
if (isDev || isTest(userId || anonymousId || '', groupId))
|
|
98
157
|
return;
|
|
99
158
|
// add teamId to traits
|
|
@@ -145,7 +204,23 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
145
204
|
catch (e) {
|
|
146
205
|
console.error(e);
|
|
147
206
|
}
|
|
148
|
-
if (
|
|
207
|
+
if (anonymousId) {
|
|
208
|
+
posthog?.groupIdentify({
|
|
209
|
+
groupKey: groupId,
|
|
210
|
+
groupType: 'tenant',
|
|
211
|
+
properties: convertKeysToSnakeCase(traits),
|
|
212
|
+
distinctId: anonymousId,
|
|
213
|
+
});
|
|
214
|
+
june?.group({ anonymousId, groupId, traits, timestamp }, (err) => err ? console.error(err) : {});
|
|
215
|
+
}
|
|
216
|
+
else if (userId) {
|
|
217
|
+
posthog?.groupIdentify({
|
|
218
|
+
groupKey: groupId,
|
|
219
|
+
groupType: 'tenant',
|
|
220
|
+
properties: convertKeysToSnakeCase(traits),
|
|
221
|
+
distinctId: userId,
|
|
222
|
+
});
|
|
223
|
+
june?.group({ userId, groupId, traits, timestamp }, (err) => err ? console.error(err) : {});
|
|
149
224
|
// attach intercom user to intercom company
|
|
150
225
|
try {
|
|
151
226
|
const intercomUser = (await intercom?.contacts.search({
|
|
@@ -165,9 +240,11 @@ export const useTracking = ({ dataset, env, name }, isDev) => {
|
|
|
165
240
|
}
|
|
166
241
|
}
|
|
167
242
|
},
|
|
168
|
-
shutdown: async () => log?.flush(),
|
|
243
|
+
shutdown: async () => Promise.all([posthog?.shutdown(), june?.closeAndFlush(), log?.flush()]),
|
|
169
244
|
// export dependencies
|
|
170
245
|
intercom,
|
|
246
|
+
posthog,
|
|
247
|
+
june,
|
|
171
248
|
log,
|
|
172
249
|
};
|
|
173
250
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAoGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["tracking/index.ts"],"names":[],"mappings":"AAoGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAoC,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAQvE,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AAgBzB,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAe,EACnC,KAAe,EAUf,EAAE;IACF,MAAM,MAAM,GAAG,GAAG,CAAC,2BAA2B;QAC5C,CAAC,CAAC,eAAe,CAAC;YACd,MAAM,EAAE,GAAG,CAAC,mBAAmB,IA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QACJ,GAAG;KACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -24,6 +24,8 @@ export type IdentifyProps = {
|
|
|
24
24
|
role?: UserRole;
|
|
25
25
|
[key: string]: string | number | boolean | null | undefined;
|
|
26
26
|
};
|
|
27
|
+
disableGeoip?: boolean;
|
|
28
|
+
timestamp?: Date;
|
|
27
29
|
};
|
|
28
30
|
export type GroupProps = OptionalUser<{
|
|
29
31
|
groupId: string;
|
|
@@ -50,6 +52,7 @@ export type GroupProps = OptionalUser<{
|
|
|
50
52
|
trialUntil?: string;
|
|
51
53
|
[key: string]: string | number | boolean | null | undefined;
|
|
52
54
|
};
|
|
55
|
+
timestamp?: Date;
|
|
53
56
|
}>;
|
|
54
57
|
export type TrackingEventProps = {
|
|
55
58
|
account_invitation_accepted: AccountInvitationAcceptedProps;
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrplatform/log",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.33",
|
|
4
4
|
"main": "build/main/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@axiomhq/js": "1.0.0-rc.3",
|
|
21
21
|
"@finalytic/graphql": "1.12.133",
|
|
22
|
+
"@june-so/analytics-node": "8.0.0",
|
|
22
23
|
"intercom-client": "6.0.0-beta.3",
|
|
24
|
+
"posthog-node": "4.0.1",
|
|
23
25
|
"serialize-error": "11.0.3"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
package/src/log/baselog.ts
CHANGED
|
@@ -2,10 +2,18 @@ import { Axiom } from '@axiomhq/js';
|
|
|
2
2
|
import { serializeError } from 'serialize-error';
|
|
3
3
|
import { logger } from './color';
|
|
4
4
|
import { getCorrelationId, requestToContext } from './common';
|
|
5
|
-
import type { BaseLog, ChildLogOptions, Log } from './type';
|
|
5
|
+
import type { BaseLog, ChildLogOptions, Log, LogLevel } from './type';
|
|
6
6
|
|
|
7
7
|
let lastMessageTimestamp: number | undefined = undefined;
|
|
8
8
|
|
|
9
|
+
export type ConsoleLogFn = (arg: {
|
|
10
|
+
formatted: string;
|
|
11
|
+
message: string;
|
|
12
|
+
additionalContext: Record<string, any>;
|
|
13
|
+
level: string;
|
|
14
|
+
}) => void;
|
|
15
|
+
export type ConsoleLog = boolean | 'color' | ConsoleLogFn;
|
|
16
|
+
|
|
9
17
|
export function createBaseLog(
|
|
10
18
|
{
|
|
11
19
|
token,
|
|
@@ -16,7 +24,7 @@ export function createBaseLog(
|
|
|
16
24
|
token?: string;
|
|
17
25
|
orgId?: string;
|
|
18
26
|
dataset?: string;
|
|
19
|
-
consoleLog?:
|
|
27
|
+
consoleLog?: ConsoleLog;
|
|
20
28
|
},
|
|
21
29
|
{
|
|
22
30
|
environment,
|
|
@@ -63,7 +71,7 @@ export function createBaseLog(
|
|
|
63
71
|
: undefined;
|
|
64
72
|
|
|
65
73
|
function ingest(
|
|
66
|
-
level:
|
|
74
|
+
level: LogLevel,
|
|
67
75
|
message: string,
|
|
68
76
|
additionalFields: Record<string, any> = {}
|
|
69
77
|
) {
|
|
@@ -82,7 +90,7 @@ export function createBaseLog(
|
|
|
82
90
|
childContext.request = requestToContext(arg.request);
|
|
83
91
|
}
|
|
84
92
|
const baseLog = (
|
|
85
|
-
level:
|
|
93
|
+
level: LogLevel,
|
|
86
94
|
message: any,
|
|
87
95
|
additionalContext: Record<string, any> = {},
|
|
88
96
|
error?: Error
|
|
@@ -110,7 +118,15 @@ export function createBaseLog(
|
|
|
110
118
|
|
|
111
119
|
error = message instanceof Error ? message : error;
|
|
112
120
|
message = message instanceof Error ? message.message : message;
|
|
113
|
-
|
|
121
|
+
const formatted = `[${lev}] [${name}]${cid ? ` [${cid}]` : ''} ${message}`;
|
|
122
|
+
if (typeof consoleLog === 'function')
|
|
123
|
+
consoleLog({
|
|
124
|
+
formatted,
|
|
125
|
+
level,
|
|
126
|
+
message,
|
|
127
|
+
additionalContext,
|
|
128
|
+
});
|
|
129
|
+
else if (consoleLog === 'color')
|
|
114
130
|
logger
|
|
115
131
|
.dim()
|
|
116
132
|
.append(`${diff}`)
|
|
@@ -127,11 +143,7 @@ export function createBaseLog(
|
|
|
127
143
|
.reset()
|
|
128
144
|
.append(message)
|
|
129
145
|
.log();
|
|
130
|
-
else
|
|
131
|
-
console.log(
|
|
132
|
-
`[${lev}] [${name}]${cid ? ` [${cid}]` : ''} ${message}`,
|
|
133
|
-
additionalContext
|
|
134
|
-
);
|
|
146
|
+
else console.log(formatted, additionalContext);
|
|
135
147
|
|
|
136
148
|
if (error) console.error(error);
|
|
137
149
|
}
|
package/src/log/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createBaseLog } from './baselog';
|
|
1
|
+
import { type ConsoleLog, createBaseLog } from './baselog';
|
|
2
2
|
import { getCorrelationId, getEnvironment, requestToContext } from './common';
|
|
3
3
|
import {
|
|
4
4
|
AXIOM_AUTH_TOKEN_ENV,
|
|
@@ -26,6 +26,7 @@ export function useLog({
|
|
|
26
26
|
version,
|
|
27
27
|
executionContext,
|
|
28
28
|
logRequest,
|
|
29
|
+
consoleLog: _consoleLog,
|
|
29
30
|
dataset: _dataset,
|
|
30
31
|
context: initialContext = {},
|
|
31
32
|
}: {
|
|
@@ -39,22 +40,30 @@ export function useLog({
|
|
|
39
40
|
dataset?: string;
|
|
40
41
|
env?: LogBindings;
|
|
41
42
|
context?: Record<string, any>;
|
|
43
|
+
consoleLog?: ConsoleLog;
|
|
42
44
|
executionContext?: {
|
|
43
45
|
waitUntil(promise: Promise<any>): void;
|
|
44
46
|
};
|
|
45
47
|
}): WorkerLog {
|
|
46
48
|
const environment = _environment || getEnvironment(env);
|
|
47
|
-
const colorLogs =
|
|
49
|
+
// const colorLogs = env?.[LOG_ENV] === '*' || ;
|
|
48
50
|
const correlationId = cid || getCorrelationId(request); //const logger = nodeColorLog;
|
|
49
51
|
|
|
50
52
|
const axiomToken = env?.[AXIOM_AUTH_TOKEN_ENV];
|
|
51
53
|
|
|
54
|
+
const isNodeJsCompat = typeof process !== 'undefined';
|
|
55
|
+
const isDev = environment === 'development';
|
|
56
|
+
const isLogEnabled = env?.[LOG_ENV] === '*';
|
|
57
|
+
const consoleLog = !axiomToken || isDev || isLogEnabled;
|
|
58
|
+
const colorLog = consoleLog && isNodeJsCompat;
|
|
59
|
+
|
|
52
60
|
const axiom = createBaseLog(
|
|
53
61
|
{
|
|
54
62
|
token: axiomToken,
|
|
55
63
|
orgId: env?.[AXIOM_ORG_ID_ENV],
|
|
56
64
|
dataset: _dataset || env?.[AXIOM_DATASET_ENV] || 'default',
|
|
57
|
-
|
|
65
|
+
// color log on development and if env is *
|
|
66
|
+
consoleLog: _consoleLog || (colorLog ? 'color' : consoleLog),
|
|
58
67
|
},
|
|
59
68
|
{
|
|
60
69
|
environment,
|
package/src/log/type.ts
CHANGED
|
@@ -11,6 +11,8 @@ export const AXIOM_ORG_ID_ENV = 'AXIOM_ORG_ID';
|
|
|
11
11
|
export const AXIOM_DATASET_ENV = 'AXIOM_DATASET';
|
|
12
12
|
export const LOG_ENV = 'LOG';
|
|
13
13
|
|
|
14
|
+
export type LogLevel = 'info' | 'log' | 'error' | 'debug' | 'warn';
|
|
15
|
+
|
|
14
16
|
export type LogBindings = {
|
|
15
17
|
[LOG_ENV]?: string;
|
|
16
18
|
[AXIOM_AUTH_TOKEN_ENV]?: string;
|