@jeffjassky/telemetry 0.8.0 → 0.8.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/index.cjs CHANGED
@@ -2251,6 +2251,31 @@ var BREAKDOWN_FIELDS = [
2251
2251
  "error.type",
2252
2252
  "error.handled"
2253
2253
  ];
2254
+ var GENERIC_SUBJECT_TYPES = ["anon", "session"];
2255
+ var mostSpecificSubject = {
2256
+ $let: {
2257
+ vars: { keys: { $ifNull: ["$subjectKeys", []] } },
2258
+ in: {
2259
+ $ifNull: [
2260
+ {
2261
+ $arrayElemAt: [
2262
+ {
2263
+ $filter: {
2264
+ input: "$$keys",
2265
+ as: "k",
2266
+ cond: {
2267
+ $not: [{ $in: [{ $arrayElemAt: [{ $split: ["$$k", ":"] }, 0] }, GENERIC_SUBJECT_TYPES] }]
2268
+ }
2269
+ }
2270
+ },
2271
+ 0
2272
+ ]
2273
+ },
2274
+ { $arrayElemAt: ["$$keys", 0] }
2275
+ ]
2276
+ }
2277
+ }
2278
+ };
2254
2279
  var typePrefix = (ref) => ({
2255
2280
  $let: {
2256
2281
  vars: { ref },
@@ -2278,7 +2303,7 @@ function dimExpression(dim2) {
2278
2303
  }
2279
2304
  return { $ifNull: [`$${path3}`, null] };
2280
2305
  }
2281
- if (dim2 === "subjectType") return typePrefix({ $arrayElemAt: ["$subjectKeys", 0] });
2306
+ if (dim2 === "subjectType") return typePrefix(mostSpecificSubject);
2282
2307
  if (dim2 === "actorType") return typePrefix("$actor");
2283
2308
  throw badRequest(
2284
2309
  `"${dim2}" is not a dimension. Use "attr:<key>", "field:<path>", "subjectType" or "actorType".`