@eventra_dev/eventra-cli 2.0.1 → 2.0.2

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.
@@ -92,7 +92,28 @@ function resolvePropertyAccess(node, checker, context, visited, evaluationCache,
92
92
  }
93
93
  }
94
94
  if (typescript_1.default.isIdentifier(targetExpression)) {
95
- const symbol = checker.getSymbolAtLocation(targetExpression);
95
+ let symbol = checker.getSymbolAtLocation(targetExpression);
96
+ if (symbol) {
97
+ symbol = (0, exportResolver_1.resolveExportedSymbol)(symbol, checker, exportCache) ?? symbol;
98
+ }
99
+ // enum EVENTS {
100
+ // LOGIN = "login"
101
+ // }
102
+ if (symbol) {
103
+ const declarations = symbol.getDeclarations() ?? [];
104
+ for (const declaration of declarations) {
105
+ if (!typescript_1.default.isEnumDeclaration(declaration)) {
106
+ continue;
107
+ }
108
+ for (const member of declaration.members) {
109
+ const memberName = typescript_1.default.isIdentifier(member.name) ? member.name.text : typescript_1.default.isStringLiteral(member.name) ? member.name.text : null;
110
+ if (memberName !== propertyName || !member.initializer) {
111
+ continue;
112
+ }
113
+ return resolveNodeValue(member.initializer, checker, context, visited, evaluationCache, resolvedCallCache, returnPropagationCache, exportCache);
114
+ }
115
+ }
116
+ }
96
117
  // const EVENTS = {
97
118
  // LOGIN: "login"
98
119
  // }
@@ -6,13 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerEventraSdkPlugin = registerEventraSdkPlugin;
7
7
  const typescript_1 = __importDefault(require("typescript"));
8
8
  const isEventraTrackCall_1 = require("../../analysis/sdk/isEventraTrackCall");
9
+ const utils_1 = require("../../analysis/shared/utils");
9
10
  /** SDK: track(name: string, options?) — event name is always the first argument. */
10
11
  function extractTrackedArguments(call) {
11
12
  if (call.arguments.length === 0) {
12
13
  return [];
13
14
  }
14
15
  const first = call.arguments[0];
15
- if (typescript_1.default.isObjectLiteralExpression(first)) {
16
+ // A cast/non-null/parens around a misused object literal (e.g.
17
+ // `track({ event: "x" } as any)`) must not defeat this guard — it's still
18
+ // the wrong API shape for `track(name: string, options?)`.
19
+ if (typescript_1.default.isObjectLiteralExpression((0, utils_1.unwrapExpression)(first))) {
16
20
  return [];
17
21
  }
18
22
  return [{ index: 0, propertyPath: [] }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Static analytics event extraction CLI powered by the TypeScript compiler API",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",