@account-kit/logging 4.35.0 → 4.35.1
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.map +1 -1
- package/dist/esm/fetchRemoteWriteKey.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugins/contextAllowlist.js.map +1 -1
- package/dist/esm/server.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- 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/plugins/contextAllowlist.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -6
- package/src/client.ts +3 -3
- package/src/fetchRemoteWriteKey.ts +1 -1
- package/src/index.ts +2 -2
- package/src/plugins/contextAllowlist.ts +7 -4
- package/src/server.ts +1 -1
- package/src/types.ts +3 -3
- package/src/version.ts +1 -1
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,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAIjD,SAAS,iBAAiB;IACxB,IAAI,IAAI,GAAkB,IAAI,CAAC,KAAK,CAClC,YA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AC,oBAAoB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,KAAK,GAAqB,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QACzD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,SAAS,CAAC,IAAI,CACZ;YACE,QAAQ;YACR,2EAA2E;YAC3E,WAAW,EAAE,KAAK;gBAChB,CAAC,CAAC;oBACE,YAAY,EAAE,EAAE;iBACjB;gBACH,CAAC,CAAC,SAAS;SACd;QACD,iDAAiD;QACjD;YACE,wBAAwB,EAAE,IAAI;YAC9B,YAAY,EAAE;gBACZ,YAAY,EAAE,CAAC,KAAK;aACrB;SACF,CACF,CAAC;QAEF,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,SAAS,EAAE;YACT,KAAK;YACL,MAAM;SACP;QACD,UAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACnC,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;gBACtB,OAAO,UAAU,CAAC,UAAU,CAAC;oBAC3B,IAAI;oBACJ,mBAAmB;oBACnB,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;YAED,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AnalyticsBrowser } from \"@segment/analytics-next\";\nimport { v4 as uuid } from \"uuid\";\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\nconst ANON_ID_STORAGE_KEY = \"account-kit:anonId\";\n\ntype AnonId = { id: string; expiresMs: number };\n\nfunction getOrCreateAnonId(): AnonId {\n let anon: AnonId | null = JSON.parse(\n localStorage.getItem(ANON_ID_STORAGE_KEY) ?? \"null\"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAIjD,SAAS,iBAAiB;IACxB,IAAI,IAAI,GAAkB,IAAI,CAAC,KAAK,CAClC,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,MAAM,CACpD,CAAC;IAEF,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACzC,IAAI,GAAG;YACL,EAAE,EAAE,IAAI,EAAE;YACV,oFAAoF;YACpF,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;SACjD,CAAC;QACF,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CA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,EAAE,CAAC,KAAK;aACrB;SACF,CACF,CAAC;QAEF,OAAO,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,SAAS,EAAE;YACT,KAAK;YACL,MAAM;SACP;QACD,UAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACnC,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;gBACtB,OAAO,UAAU,CAAC,UAAU,CAAC;oBAC3B,IAAI;oBACJ,mBAAmB;oBACnB,IAAI;iBACL,CAAC,CAAC;YACL,CAAC;YAED,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { AnalyticsBrowser } from \"@segment/analytics-next\";\nimport { v4 as uuid } from \"uuid\";\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\nconst ANON_ID_STORAGE_KEY = \"account-kit:anonId\";\n\ntype AnonId = { id: string; expiresMs: number };\n\nfunction getOrCreateAnonId(): AnonId {\n let anon: AnonId | null = JSON.parse(\n localStorage.getItem(ANON_ID_STORAGE_KEY) ?? \"null\",\n );\n\n if (!anon || anon.expiresMs < Date.now()) {\n anon = {\n id: uuid(),\n // expires a month from now (30days * 24hrs/day * 60min/hr * 60sec/min * 1000ms/sec)\n expiresMs: Date.now() + 30 * 24 * 60 * 60 * 1000,\n };\n localStorage.setItem(ANON_ID_STORAGE_KEY, JSON.stringify(anon));\n }\n\n return anon;\n}\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 const { id: anonId } = getOrCreateAnonId();\n analytics.setAnonymousId(anonId);\n analytics.register(ContextAllowlistPlugin);\n analytics.debug(isDev);\n\n if (isDev) {\n // Super weird behaviour, but if I don't add some kind of log here,\n // then I don't actually get logs in the console\n console.log(`[Metrics] metrics initialized for ${context.package}`);\n }\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 anonId,\n },\n trackEvent: async ({ name, data }) => {\n if (!(await writeKey)) {\n return noopLogger.trackEvent({\n name,\n // @ts-expect-error\n data,\n });\n }\n\n await analytics.track(name, { ...data, ...context });\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRemoteWriteKey.js","sourceRoot":"","sources":["../../src/fetchRemoteWriteKey.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,8EAA8E,CAC/E,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,QAA8B,CAAC;IAC7C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["export async function fetchRemoteWriteKey(): Promise<string | undefined> {\n try {\n const res = await fetch(\n \"https://ws-accounkit-assets.s3.us-west-1.amazonaws.com/logger_config_v1.json\"
|
|
1
|
+
{"version":3,"file":"fetchRemoteWriteKey.js","sourceRoot":"","sources":["../../src/fetchRemoteWriteKey.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,8EAA8E,CAC/E,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,QAA8B,CAAC;IAC7C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["export async function fetchRemoteWriteKey(): Promise<string | undefined> {\n try {\n const res = await fetch(\n \"https://ws-accounkit-assets.s3.us-west-1.amazonaws.com/logger_config_v1.json\",\n );\n const json = await res.json();\n return json.writeKey as string | undefined;\n } catch (e) {\n console.warn(\"failed to fetch write key\");\n return undefined;\n }\n}\n"]}
|
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,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,kBAAk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,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
|
|
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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextAllowlist.js","sourceRoot":"","sources":["../../../src/plugins/contextAllowlist.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAsB,CAAC,MAAM,CAAU,CAAC;AAEvD,SAAS,YAAY,CAAC,GAAY;IAChC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"contextAllowlist.js","sourceRoot":"","sources":["../../../src/plugins/contextAllowlist.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAsB,CAAC,MAAM,CAAU,CAAC;AAEvD,SAAS,YAAY,CAAC,GAAY;IAChC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,MAAM,CAClC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;QAErC,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAiD,CAClD,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAW;IAC5C,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE,YAAY;IAElB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI;IACpB,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;IAE7B,KAAK,EAAE,YAAY;IACnB,QAAQ,EAAE,YAAY;IACtB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;CACrB,CAAC","sourcesContent":["import type { Context, Plugin } from \"@segment/analytics-next\";\n\nconst allowlist: readonly string[] = [\"page\"] as const;\n\nfunction stripContext(ctx: Context): Context {\n ctx.event.context = allowlist.reduce(\n (acc, key) => {\n acc[key] = ctx.event?.context?.[key];\n\n return acc;\n },\n {} as Record<(typeof allowlist)[number], unknown>,\n );\n\n return ctx;\n}\n\n/**\n * This plugin enforces a context allowlist for all events\n *\n * This is done to make sure that anything Analytics.js sends to Segment is only the data we want to send\n */\nexport const ContextAllowlistPlugin: Plugin = {\n name: \"Enforce Context Allowlist\",\n type: \"enrichment\",\n\n isLoaded: () => true,\n load: () => Promise.resolve(),\n\n track: stripContext,\n identify: stripContext,\n page: stripContext,\n alias: stripContext,\n group: stripContext,\n screen: stripContext,\n};\n"]}
|
package/dist/esm/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,MAAM,UAAU,kBAAkB,CAChC,QAAuB;IAEvB,iGAAiG;IACjG,kHAAkH;IAClH,0CAA0C;IAC1C,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { noopLogger } from \"./noop.js\";\nimport type { EventsSchema, InnerLogger, LoggerContext } from \"./types\";\n\nexport function createServerLogger<Schema extends EventsSchema = []>(\n _context: LoggerContext
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,MAAM,UAAU,kBAAkB,CAChC,QAAuB;IAEvB,iGAAiG;IACjG,kHAAkH;IAClH,0CAA0C;IAC1C,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import { noopLogger } from \"./noop.js\";\nimport type { EventsSchema, InnerLogger, LoggerContext } from \"./types\";\n\nexport function createServerLogger<Schema extends EventsSchema = []>(\n _context: LoggerContext,\n): InnerLogger<Schema> {\n // TODO: there is an analytics js node package that we can use, but we'll come back to that later\n // this is harder than client, because on the client we can filter out events that are originating from localhost,\n // whereas here we can't do that as easily\n return noopLogger;\n}\n"]}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type EventsSchema = readonly {\n EventName: string;\n EventData?: Record<string, any>;\n}[];\n\ntype Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport type TrackEventParameters<Schema extends EventsSchema> = {\n [K in keyof Schema]: Prettify<\n { name: Schema[K][\"EventName\"] } & ([undefined] extends [\n Schema[K][\"EventData\"]
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type EventsSchema = readonly {\n EventName: string;\n EventData?: Record<string, any>;\n}[];\n\ntype Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport type TrackEventParameters<Schema extends EventsSchema> = {\n [K in keyof Schema]: Prettify<\n { name: Schema[K][\"EventName\"] } & ([undefined] extends [\n Schema[K][\"EventData\"],\n ]\n ? { data?: undefined }\n : { data: Schema[K][\"EventData\"] })\n >;\n}[number];\n\nexport interface EventLogger<Schema extends EventsSchema = []> {\n trackEvent(\n params: TrackEventParameters<[...Schema, PerformanceEvent]>,\n ): Promise<void>;\n profiled<TArgs extends any[], TRet>(\n name: string,\n func: (...args: TArgs) => TRet,\n ): (...args: TArgs) => TRet;\n _internal: {\n ready: Promise<unknown>;\n anonId: string;\n };\n}\n\nexport type InnerLogger<Schema extends EventsSchema> = Omit<\n EventLogger<Schema>,\n \"profiled\"\n>;\n\nexport type LoggerContext = {\n package: string;\n version: string;\n [key: string]: string;\n};\n\nexport type PerformanceEvent = {\n EventName: \"performance\";\n EventData: {\n executionTimeMs: number;\n functionName: string;\n };\n};\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.35.
|
|
1
|
+
export declare const VERSION = "4.35.1";
|
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,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.35.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.35.1\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextAllowlist.d.ts","sourceRoot":"","sources":["../../../src/plugins/contextAllowlist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"contextAllowlist.d.ts","sourceRoot":"","sources":["../../../src/plugins/contextAllowlist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAiB/D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAapC,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.35.
|
|
1
|
+
export declare const VERSION = "4.35.1";
|
|
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.35.
|
|
3
|
+
"version": "4.35.1",
|
|
4
4
|
"description": "Core logging library for Account Kit packages",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,9 +42,7 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jsdom": "^21.1.7",
|
|
44
44
|
"jsdom": "^25.0.1",
|
|
45
|
-
"typescript": "
|
|
46
|
-
"typescript-template": "*",
|
|
47
|
-
"vitest": "^2.0.4"
|
|
45
|
+
"typescript-template": "*"
|
|
48
46
|
},
|
|
49
47
|
"publishConfig": {
|
|
50
48
|
"access": "public",
|
|
@@ -59,8 +57,8 @@
|
|
|
59
57
|
},
|
|
60
58
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
61
59
|
"dependencies": {
|
|
62
|
-
"@segment/analytics-next": "
|
|
60
|
+
"@segment/analytics-next": "1.74.0",
|
|
63
61
|
"uuid": "^11.0.2"
|
|
64
62
|
},
|
|
65
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "31e2138c2dd08c5b32cc2d67b3f0d7b2a7d21f4f"
|
|
66
64
|
}
|
package/src/client.ts
CHANGED
|
@@ -14,7 +14,7 @@ type AnonId = { id: string; expiresMs: number };
|
|
|
14
14
|
|
|
15
15
|
function getOrCreateAnonId(): AnonId {
|
|
16
16
|
let anon: AnonId | null = JSON.parse(
|
|
17
|
-
localStorage.getItem(ANON_ID_STORAGE_KEY) ?? "null"
|
|
17
|
+
localStorage.getItem(ANON_ID_STORAGE_KEY) ?? "null",
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
if (!anon || anon.expiresMs < Date.now()) {
|
|
@@ -30,7 +30,7 @@ function getOrCreateAnonId(): AnonId {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function createClientLogger<Schema extends EventsSchema = []>(
|
|
33
|
-
context: LoggerContext
|
|
33
|
+
context: LoggerContext,
|
|
34
34
|
): InnerLogger<Schema> {
|
|
35
35
|
const isDev = isClientDevMode();
|
|
36
36
|
if (isDev && !WRITE_IN_DEV) {
|
|
@@ -82,7 +82,7 @@ export function createClientLogger<Schema extends EventsSchema = []>(
|
|
|
82
82
|
integrations: {
|
|
83
83
|
"Segment.io": !isDev,
|
|
84
84
|
},
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
return analytics.ready();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function fetchRemoteWriteKey(): Promise<string | undefined> {
|
|
2
2
|
try {
|
|
3
3
|
const res = await fetch(
|
|
4
|
-
"https://ws-accounkit-assets.s3.us-west-1.amazonaws.com/logger_config_v1.json"
|
|
4
|
+
"https://ws-accounkit-assets.s3.us-west-1.amazonaws.com/logger_config_v1.json",
|
|
5
5
|
);
|
|
6
6
|
const json = await res.json();
|
|
7
7
|
return json.writeKey as string | undefined;
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { EventLogger, EventsSchema, LoggerContext } from "./types";
|
|
|
6
6
|
export type * from "./types.js";
|
|
7
7
|
|
|
8
8
|
export function createLogger<Schema extends EventsSchema = []>(
|
|
9
|
-
context: LoggerContext
|
|
9
|
+
context: LoggerContext,
|
|
10
10
|
): EventLogger<Schema>;
|
|
11
11
|
|
|
12
12
|
export function createLogger(context: LoggerContext): EventLogger {
|
|
@@ -25,7 +25,7 @@ export function createLogger(context: LoggerContext): EventLogger {
|
|
|
25
25
|
...innerLogger,
|
|
26
26
|
profiled<TArgs extends any[], TRet>(
|
|
27
27
|
name: string,
|
|
28
|
-
func: (...args: TArgs) => TRet
|
|
28
|
+
func: (...args: TArgs) => TRet,
|
|
29
29
|
): (...args: TArgs) => TRet {
|
|
30
30
|
return function (this: any, ...args: TArgs): TRet {
|
|
31
31
|
const start = Date.now();
|
|
@@ -3,11 +3,14 @@ import type { Context, Plugin } from "@segment/analytics-next";
|
|
|
3
3
|
const allowlist: readonly string[] = ["page"] as const;
|
|
4
4
|
|
|
5
5
|
function stripContext(ctx: Context): Context {
|
|
6
|
-
ctx.event.context = allowlist.reduce(
|
|
7
|
-
acc
|
|
6
|
+
ctx.event.context = allowlist.reduce(
|
|
7
|
+
(acc, key) => {
|
|
8
|
+
acc[key] = ctx.event?.context?.[key];
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
return acc;
|
|
11
|
+
},
|
|
12
|
+
{} as Record<(typeof allowlist)[number], unknown>,
|
|
13
|
+
);
|
|
11
14
|
|
|
12
15
|
return ctx;
|
|
13
16
|
}
|
package/src/server.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { noopLogger } from "./noop.js";
|
|
|
2
2
|
import type { EventsSchema, InnerLogger, LoggerContext } from "./types";
|
|
3
3
|
|
|
4
4
|
export function createServerLogger<Schema extends EventsSchema = []>(
|
|
5
|
-
_context: LoggerContext
|
|
5
|
+
_context: LoggerContext,
|
|
6
6
|
): InnerLogger<Schema> {
|
|
7
7
|
// TODO: there is an analytics js node package that we can use, but we'll come back to that later
|
|
8
8
|
// this is harder than client, because on the client we can filter out events that are originating from localhost,
|
package/src/types.ts
CHANGED
|
@@ -10,7 +10,7 @@ type Prettify<T> = {
|
|
|
10
10
|
export type TrackEventParameters<Schema extends EventsSchema> = {
|
|
11
11
|
[K in keyof Schema]: Prettify<
|
|
12
12
|
{ name: Schema[K]["EventName"] } & ([undefined] extends [
|
|
13
|
-
Schema[K]["EventData"]
|
|
13
|
+
Schema[K]["EventData"],
|
|
14
14
|
]
|
|
15
15
|
? { data?: undefined }
|
|
16
16
|
: { data: Schema[K]["EventData"] })
|
|
@@ -19,11 +19,11 @@ export type TrackEventParameters<Schema extends EventsSchema> = {
|
|
|
19
19
|
|
|
20
20
|
export interface EventLogger<Schema extends EventsSchema = []> {
|
|
21
21
|
trackEvent(
|
|
22
|
-
params: TrackEventParameters<[...Schema, PerformanceEvent]
|
|
22
|
+
params: TrackEventParameters<[...Schema, PerformanceEvent]>,
|
|
23
23
|
): Promise<void>;
|
|
24
24
|
profiled<TArgs extends any[], TRet>(
|
|
25
25
|
name: string,
|
|
26
|
-
func: (...args: TArgs) => TRet
|
|
26
|
+
func: (...args: TArgs) => TRet,
|
|
27
27
|
): (...args: TArgs) => TRet;
|
|
28
28
|
_internal: {
|
|
29
29
|
ready: Promise<unknown>;
|
package/src/version.ts
CHANGED