@account-kit/logging 4.0.1 → 4.1.0
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/dist/esm/client.js +2 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.js +12 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +14 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/client.ts +2 -1
- package/src/index.ts +11 -4
- package/src/utils.ts +22 -0
- package/src/version.ts +1 -1
package/dist/esm/client.js
CHANGED
|
@@ -5,8 +5,9 @@ import { fetchRemoteWriteKey } from "./fetchRemoteWriteKey.js";
|
|
|
5
5
|
import { noopLogger } from "./noop.js";
|
|
6
6
|
import { ContextAllowlistPlugin } from "./plugins/contextAllowlist.js";
|
|
7
7
|
import { DevDestinationPlugin } from "./plugins/devDestination.js";
|
|
8
|
+
import { isClientDevMode } from "./utils.js";
|
|
8
9
|
export function createClientLogger(context) {
|
|
9
|
-
const isDev =
|
|
10
|
+
const isDev = isClientDevMode();
|
|
10
11
|
if (isDev && !WRITE_IN_DEV) {
|
|
11
12
|
// If we don't have a write key, we don't want to log anything
|
|
12
13
|
// This is useful for dev so we don't log dev metrics
|
package/dist/esm/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,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-next\";\nimport { uuid } from \"uuidv4\";\nimport { WRITE_IN_DEV } from \"./_writeKey.js\";\nimport { fetchRemoteWriteKey } from \"./fetchRemoteWriteKey.js\";\nimport { noopLogger } from \"./noop.js\";\nimport { ContextAllowlistPlugin } from \"./plugins/contextAllowlist.js\";\nimport { DevDestinationPlugin } from \"./plugins/devDestination.js\";\nimport type { EventsSchema, InnerLogger, LoggerContext } from \"./types\";\nimport { isClientDevMode } from \"./utils.js\";\n\nexport function createClientLogger<Schema extends EventsSchema = []>(\n context: LoggerContext\n): InnerLogger<Schema> {\n const isDev = isClientDevMode();\n if (isDev && !WRITE_IN_DEV) {\n // If we don't have a write key, we don't want to log anything\n // This is useful for dev so we don't log dev metrics\n //\n // We also don't allow logging on localhost unless WRITE_IN_DEV is set to true\n // WRITE_IN_DEV is only ever true if you're building from source with env vars set to true\n return noopLogger;\n }\n\n const analytics = new AnalyticsBrowser();\n const writeKey = fetchRemoteWriteKey();\n\n if (!sessionStorage.getItem(\"anonId\")) {\n sessionStorage.setItem(\"anonId\", uuid());\n }\n\n const anonId = sessionStorage.getItem(\"anonId\")!;\n analytics.setAnonymousId(anonId);\n analytics.register(ContextAllowlistPlugin);\n analytics.debug(isDev);\n\n // This lets us log events in the console\n if (isDev) {\n analytics.register(DevDestinationPlugin);\n }\n\n const ready: Promise<unknown> = writeKey.then((writeKey) => {\n if (writeKey == null) {\n return;\n }\n\n analytics.load(\n {\n writeKey,\n // we disable these settings in dev so we don't fetch anything from segment\n cdnSettings: isDev\n ? {\n integrations: {},\n }\n : undefined,\n },\n // further we disable the segment integration dev\n {\n disableClientPersistence: true,\n integrations: {\n \"Segment.io\": !isDev,\n },\n }\n );\n\n return analytics.ready();\n });\n\n return {\n _internal: {\n ready,\n },\n trackEvent: async ({ name, data }) => {\n if (!(await writeKey)) {\n return noopLogger.trackEvent({ name, data });\n }\n\n await analytics.track(name, { ...data, ...context });\n },\n };\n}\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { createClientLogger } from "./client.js";
|
|
2
|
+
import { noopLogger } from "./noop.js";
|
|
2
3
|
import { createServerLogger } from "./server.js";
|
|
3
4
|
export function createLogger(context) {
|
|
4
|
-
const innerLogger =
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const innerLogger = (() => {
|
|
6
|
+
try {
|
|
7
|
+
return typeof window === "undefined"
|
|
8
|
+
? createServerLogger(context)
|
|
9
|
+
: createClientLogger(context);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
console.error("[Safe to ignore] failed to initialize metrics", e);
|
|
13
|
+
return noopLogger;
|
|
14
|
+
}
|
|
15
|
+
})();
|
|
7
16
|
const logger = {
|
|
8
17
|
...innerLogger,
|
|
9
18
|
profiled(name, func) {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AASjD,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AASjD,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE;QACxB,IAAI,CAAC;YACH,OAAO,OAAO,MAAM,KAAK,WAAW;gBAClC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC;gBAC7B,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,CAAC,CAAC,CAAC;YAClE,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,MAAM,GAAgB;QAC1B,GAAG,WAAW;QACd,QAAQ,CACN,IAAY,EACZ,IAA8B;YAE9B,OAAO,UAAqB,GAAG,IAAW;gBACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACzB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACtC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;oBAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;wBACzB,WAAW,CAAC,UAAU,CAAC;4BACrB,IAAI,EAAE,aAAa;4BACnB,IAAI,EAAE;gCACJ,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;gCACnC,YAAY,EAAE,IAAI;6BACnB;yBACF,CAAC,CAAC;wBAEH,OAAO,GAAG,CAAC;oBACb,CAAC,CAAS,CAAC;gBACb,CAAC;gBAED,WAAW,CAAC,UAAU,CAAC;oBACrB,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE;wBACJ,eAAe,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;wBACnC,YAAY,EAAE,IAAI;qBACnB;iBACF,CAAC,CAAC;gBACH,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createClientLogger } from \"./client.js\";\nimport { noopLogger } from \"./noop.js\";\nimport { createServerLogger } from \"./server.js\";\nimport type { EventLogger, EventsSchema, LoggerContext } from \"./types\";\n\nexport type * from \"./types.js\";\n\nexport function createLogger<Schema extends EventsSchema = []>(\n context: LoggerContext\n): EventLogger<Schema>;\n\nexport function createLogger(context: LoggerContext): EventLogger {\n const innerLogger = (() => {\n try {\n return typeof window === \"undefined\"\n ? createServerLogger(context)\n : createClientLogger(context);\n } catch (e) {\n console.error(\"[Safe to ignore] failed to initialize metrics\", e);\n return noopLogger;\n }\n })();\n\n const logger: EventLogger = {\n ...innerLogger,\n profiled<TArgs extends any[], TRet>(\n name: string,\n func: (...args: TArgs) => TRet\n ): (...args: TArgs) => TRet {\n return function (this: any, ...args: TArgs): TRet {\n const start = Date.now();\n const result = func.apply(this, args);\n if (result instanceof Promise) {\n return result.then((res) => {\n innerLogger.trackEvent({\n name: \"performance\",\n data: {\n executionTimeMs: Date.now() - start,\n functionName: name,\n },\n });\n\n return res;\n }) as TRet;\n }\n\n innerLogger.trackEvent({\n name: \"performance\",\n data: {\n executionTimeMs: Date.now() - start,\n functionName: name,\n },\n });\n return result;\n };\n },\n };\n\n return logger;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isClientDevMode(): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isClientDevMode() {
|
|
2
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
if (process.env.NODE_ENV === "development") {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (typeof window !== "undefined" &&
|
|
9
|
+
window.location?.hostname?.includes("localhost")) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe;IAC7B,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,OAAO,MAAM,KAAK,WAAW;QAC7B,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,EAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// just in case we're in a setting that doesn't have these types defined\ndeclare const __DEV__: boolean | undefined;\ndeclare const window: Window | undefined;\n\nexport function isClientDevMode() {\n if (typeof __DEV__ !== \"undefined\" && __DEV__) {\n return true;\n }\n\n if (process.env.NODE_ENV === \"development\") {\n return true;\n }\n\n if (\n typeof window !== \"undefined\" &&\n window.location?.hostname?.includes(\"localhost\")\n ) {\n return true;\n }\n\n return false;\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.0
|
|
1
|
+
export declare const VERSION = "4.1.0";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.1.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxE,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,YAAY,GAAG,EAAE,EACjE,OAAO,EAAE,aAAa,GACrB,WAAW,CAAC,MAAM,CAAC,CAmErB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExE,mBAAmB,YAAY,CAAC;AAEhC,wBAAgB,YAAY,CAAC,MAAM,SAAS,YAAY,GAAG,EAAE,EAC3D,OAAO,EAAE,aAAa,GACrB,WAAW,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,YAiB9B"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.0
|
|
1
|
+
export declare const VERSION = "4.1.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/logging",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Core logging library for Account Kit packages",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@segment/analytics-next": "^1.74.0",
|
|
62
62
|
"uuidv4": "^6.2.13"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f6b6f15f4fe349850995264a549ca53a821859f0"
|
|
65
65
|
}
|
package/src/client.ts
CHANGED
|
@@ -6,11 +6,12 @@ import { noopLogger } from "./noop.js";
|
|
|
6
6
|
import { ContextAllowlistPlugin } from "./plugins/contextAllowlist.js";
|
|
7
7
|
import { DevDestinationPlugin } from "./plugins/devDestination.js";
|
|
8
8
|
import type { EventsSchema, InnerLogger, LoggerContext } from "./types";
|
|
9
|
+
import { isClientDevMode } from "./utils.js";
|
|
9
10
|
|
|
10
11
|
export function createClientLogger<Schema extends EventsSchema = []>(
|
|
11
12
|
context: LoggerContext
|
|
12
13
|
): InnerLogger<Schema> {
|
|
13
|
-
const isDev =
|
|
14
|
+
const isDev = isClientDevMode();
|
|
14
15
|
if (isDev && !WRITE_IN_DEV) {
|
|
15
16
|
// If we don't have a write key, we don't want to log anything
|
|
16
17
|
// This is useful for dev so we don't log dev metrics
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createClientLogger } from "./client.js";
|
|
2
|
+
import { noopLogger } from "./noop.js";
|
|
2
3
|
import { createServerLogger } from "./server.js";
|
|
3
4
|
import type { EventLogger, EventsSchema, LoggerContext } from "./types";
|
|
4
5
|
|
|
@@ -9,10 +10,16 @@ export function createLogger<Schema extends EventsSchema = []>(
|
|
|
9
10
|
): EventLogger<Schema>;
|
|
10
11
|
|
|
11
12
|
export function createLogger(context: LoggerContext): EventLogger {
|
|
12
|
-
const innerLogger =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const innerLogger = (() => {
|
|
14
|
+
try {
|
|
15
|
+
return typeof window === "undefined"
|
|
16
|
+
? createServerLogger(context)
|
|
17
|
+
: createClientLogger(context);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error("[Safe to ignore] failed to initialize metrics", e);
|
|
20
|
+
return noopLogger;
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
16
23
|
|
|
17
24
|
const logger: EventLogger = {
|
|
18
25
|
...innerLogger,
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// just in case we're in a setting that doesn't have these types defined
|
|
2
|
+
declare const __DEV__: boolean | undefined;
|
|
3
|
+
declare const window: Window | undefined;
|
|
4
|
+
|
|
5
|
+
export function isClientDevMode() {
|
|
6
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (process.env.NODE_ENV === "development") {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (
|
|
15
|
+
typeof window !== "undefined" &&
|
|
16
|
+
window.location?.hostname?.includes("localhost")
|
|
17
|
+
) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
}
|
package/src/version.ts
CHANGED