@account-kit/logging 4.3.0 → 4.3.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.
@@ -1,5 +1,5 @@
1
1
  import { AnalyticsBrowser } from "@segment/analytics-next";
2
- import { uuid } from "uuidv4";
2
+ import { v4 as uuid } from "uuid";
3
3
  import { WRITE_IN_DEV } from "./_writeKey.js";
4
4
  import { fetchRemoteWriteKey } from "./fetchRemoteWriteKey.js";
5
5
  import { noopLogger } from "./noop.js";
@@ -25,6 +25,11 @@ export function createClientLogger(context) {
25
25
  analytics.setAnonymousId(anonId);
26
26
  analytics.register(ContextAllowlistPlugin);
27
27
  analytics.debug(isDev);
28
+ if (isDev) {
29
+ // Super weird behaviour, but if I don't add some kind of log here,
30
+ // then I don't actually get logs in the console
31
+ console.log(`[Metrics] metrics initialized for ${context.package}`);
32
+ }
28
33
  // This lets us log events in the console
29
34
  if (isDev) {
30
35
  analytics.register(DevDestinationPlugin);
@@ -54,10 +59,15 @@ export function createClientLogger(context) {
54
59
  return {
55
60
  _internal: {
56
61
  ready,
62
+ anonId,
57
63
  },
58
64
  trackEvent: async ({ name, data }) => {
59
65
  if (!(await writeKey)) {
60
- return noopLogger.trackEvent({ name, data });
66
+ return noopLogger.trackEvent({
67
+ name,
68
+ // @ts-expect-error
69
+ data,
70
+ });
61
71
  }
62
72
  await analytics.track(name, { ...data, ...context });
63
73
  },
@@ -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,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,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AAC,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;SACN;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,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/C,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 { 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"]}
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,UAAU,kBAAkB,CAChC,OAAsB;IAEtB,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3B,8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EF,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\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 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"]}
package/dist/esm/noop.js CHANGED
@@ -2,6 +2,7 @@ export const noopLogger = {
2
2
  trackEvent: async () => { },
3
3
  _internal: {
4
4
  ready: Promise.resolve(),
5
+ anonId: "",
5
6
  },
6
7
  };
7
8
  //# sourceMappingURL=noop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/noop.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAqB;IAC1C,UAAU,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;IAC1B,SAAS,EAAE;QACT,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE;KACzB;CACF,CAAC","sourcesContent":["import type { InnerLogger } from \"./types\";\n\nexport const noopLogger: InnerLogger<any> = {\n trackEvent: async () => {},\n _internal: {\n ready: Promise.resolve(),\n },\n};\n"]}
1
+ {"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/noop.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAqB;IAC1C,UAAU,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;IAC1B,SAAS,EAAE;QACT,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE;QACxB,MAAM,EAAE,EAAE;KACX;CACF,CAAC","sourcesContent":["import type { InnerLogger } from \"./types\";\n\nexport const noopLogger: InnerLogger<any> = {\n trackEvent: async () => {},\n _internal: {\n ready: Promise.resolve(),\n anonId: \"\",\n },\n};\n"]}
@@ -8,7 +8,9 @@ type Prettify<T> = {
8
8
  export type TrackEventParameters<Schema extends EventsSchema> = {
9
9
  [K in keyof Schema]: Prettify<{
10
10
  name: Schema[K]["EventName"];
11
- } & (Schema[K]["EventData"] extends undefined ? {
11
+ } & ([undefined] extends [
12
+ Schema[K]["EventData"]
13
+ ] ? {
12
14
  data?: undefined;
13
15
  } : {
14
16
  data: Schema[K]["EventData"];
@@ -19,6 +21,7 @@ export interface EventLogger<Schema extends EventsSchema = []> {
19
21
  profiled<TArgs extends any[], TRet>(name: string, func: (...args: TArgs) => TRet): (...args: TArgs) => TRet;
20
22
  _internal: {
21
23
  ready: Promise<unknown>;
24
+ anonId: string;
22
25
  };
23
26
  }
24
27
  export type InnerLogger<Schema extends EventsSchema> = Omit<EventLogger<Schema>, "profiled">;
@@ -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\"] } & (Schema[K][\"EventData\"] extends undefined\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 };\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"]}
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"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.3.0";
1
+ export declare const VERSION = "4.3.1";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.3.0";
3
+ export const VERSION = "4.3.1";
4
4
  //# sourceMappingURL=version.js.map
@@ -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.3.0\";\n"]}
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.3.1\";\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;AAGxE,wBAAgB,kBAAkB,CAAC,MAAM,SAAS,YAAY,GAAG,EAAE,EACjE,OAAO,EAAE,aAAa,GACrB,WAAW,CAAC,MAAM,CAAC,CAmErB"}
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,CA8ErB"}
@@ -1 +1 @@
1
- {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/noop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,GAAG,CAKvC,CAAC"}
1
+ {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/noop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,GAAG,CAMvC,CAAC"}
@@ -8,7 +8,9 @@ type Prettify<T> = {
8
8
  export type TrackEventParameters<Schema extends EventsSchema> = {
9
9
  [K in keyof Schema]: Prettify<{
10
10
  name: Schema[K]["EventName"];
11
- } & (Schema[K]["EventData"] extends undefined ? {
11
+ } & ([undefined] extends [
12
+ Schema[K]["EventData"]
13
+ ] ? {
12
14
  data?: undefined;
13
15
  } : {
14
16
  data: Schema[K]["EventData"];
@@ -19,6 +21,7 @@ export interface EventLogger<Schema extends EventsSchema = []> {
19
21
  profiled<TArgs extends any[], TRet>(name: string, func: (...args: TArgs) => TRet): (...args: TArgs) => TRet;
20
22
  _internal: {
21
23
  ready: Promise<unknown>;
24
+ anonId: string;
22
25
  };
23
26
  }
24
27
  export type InnerLogger<Schema extends EventsSchema> = Omit<EventLogger<Schema>, "profiled">;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC,EAAE,CAAC;AAEJ,KAAK,QAAQ,CAAC,CAAC,IAAI;KAChB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC;AAEP,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,YAAY,IAAI;KAC7D,CAAC,IAAI,MAAM,MAAM,GAAG,QAAQ,CAC3B;QAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;KAAE,GAAG,CAAC,MAAM,CAAC,CA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B,UAAU,CACX,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE;QACT,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.3.0";
1
+ export declare const VERSION = "4.3.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.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "Core logging library for Account Kit packages",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
60
60
  "dependencies": {
61
61
  "@segment/analytics-next": "^1.74.0",
62
- "uuidv4": "^6.2.13"
62
+ "uuid": "^11.0.2"
63
63
  },
64
- "gitHead": "78c86103afeee309748c9d604af58bc7707c8b16"
64
+ "gitHead": "68052c506336d4c7eee1d2ee78e9b07892488351"
65
65
  }
package/src/client.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AnalyticsBrowser } from "@segment/analytics-next";
2
- import { uuid } from "uuidv4";
2
+ import { v4 as uuid } from "uuid";
3
3
  import { WRITE_IN_DEV } from "./_writeKey.js";
4
4
  import { fetchRemoteWriteKey } from "./fetchRemoteWriteKey.js";
5
5
  import { noopLogger } from "./noop.js";
@@ -33,6 +33,12 @@ export function createClientLogger<Schema extends EventsSchema = []>(
33
33
  analytics.register(ContextAllowlistPlugin);
34
34
  analytics.debug(isDev);
35
35
 
36
+ if (isDev) {
37
+ // Super weird behaviour, but if I don't add some kind of log here,
38
+ // then I don't actually get logs in the console
39
+ console.log(`[Metrics] metrics initialized for ${context.package}`);
40
+ }
41
+
36
42
  // This lets us log events in the console
37
43
  if (isDev) {
38
44
  analytics.register(DevDestinationPlugin);
@@ -68,10 +74,15 @@ export function createClientLogger<Schema extends EventsSchema = []>(
68
74
  return {
69
75
  _internal: {
70
76
  ready,
77
+ anonId,
71
78
  },
72
79
  trackEvent: async ({ name, data }) => {
73
80
  if (!(await writeKey)) {
74
- return noopLogger.trackEvent({ name, data });
81
+ return noopLogger.trackEvent({
82
+ name,
83
+ // @ts-expect-error
84
+ data,
85
+ });
75
86
  }
76
87
 
77
88
  await analytics.track(name, { ...data, ...context });
package/src/noop.ts CHANGED
@@ -4,5 +4,6 @@ export const noopLogger: InnerLogger<any> = {
4
4
  trackEvent: async () => {},
5
5
  _internal: {
6
6
  ready: Promise.resolve(),
7
+ anonId: "",
7
8
  },
8
9
  };
package/src/types.ts CHANGED
@@ -9,7 +9,9 @@ type Prettify<T> = {
9
9
 
10
10
  export type TrackEventParameters<Schema extends EventsSchema> = {
11
11
  [K in keyof Schema]: Prettify<
12
- { name: Schema[K]["EventName"] } & (Schema[K]["EventData"] extends undefined
12
+ { name: Schema[K]["EventName"] } & ([undefined] extends [
13
+ Schema[K]["EventData"]
14
+ ]
13
15
  ? { data?: undefined }
14
16
  : { data: Schema[K]["EventData"] })
15
17
  >;
@@ -25,6 +27,7 @@ export interface EventLogger<Schema extends EventsSchema = []> {
25
27
  ): (...args: TArgs) => TRet;
26
28
  _internal: {
27
29
  ready: Promise<unknown>;
30
+ anonId: string;
28
31
  };
29
32
  }
30
33
 
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.3.0";
3
+ export const VERSION = "4.3.1";