@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.js CHANGED
@@ -2242,6 +2242,31 @@ var BREAKDOWN_FIELDS = [
2242
2242
  "error.type",
2243
2243
  "error.handled"
2244
2244
  ];
2245
+ var GENERIC_SUBJECT_TYPES = ["anon", "session"];
2246
+ var mostSpecificSubject = {
2247
+ $let: {
2248
+ vars: { keys: { $ifNull: ["$subjectKeys", []] } },
2249
+ in: {
2250
+ $ifNull: [
2251
+ {
2252
+ $arrayElemAt: [
2253
+ {
2254
+ $filter: {
2255
+ input: "$$keys",
2256
+ as: "k",
2257
+ cond: {
2258
+ $not: [{ $in: [{ $arrayElemAt: [{ $split: ["$$k", ":"] }, 0] }, GENERIC_SUBJECT_TYPES] }]
2259
+ }
2260
+ }
2261
+ },
2262
+ 0
2263
+ ]
2264
+ },
2265
+ { $arrayElemAt: ["$$keys", 0] }
2266
+ ]
2267
+ }
2268
+ }
2269
+ };
2245
2270
  var typePrefix = (ref) => ({
2246
2271
  $let: {
2247
2272
  vars: { ref },
@@ -2269,7 +2294,7 @@ function dimExpression(dim2) {
2269
2294
  }
2270
2295
  return { $ifNull: [`$${path3}`, null] };
2271
2296
  }
2272
- if (dim2 === "subjectType") return typePrefix({ $arrayElemAt: ["$subjectKeys", 0] });
2297
+ if (dim2 === "subjectType") return typePrefix(mostSpecificSubject);
2273
2298
  if (dim2 === "actorType") return typePrefix("$actor");
2274
2299
  throw badRequest(
2275
2300
  `"${dim2}" is not a dimension. Use "attr:<key>", "field:<path>", "subjectType" or "actorType".`