@sentry/junior-memory 0.190.0 → 0.192.0

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/agent.d.ts CHANGED
@@ -64,7 +64,7 @@ declare const createMemoryRequestSchema: z.ZodObject<{
64
64
  eventType: z.ZodString;
65
65
  identifier: z.ZodString;
66
66
  namespace: z.ZodString;
67
- }, z.core.$strict>], "kind">>;
67
+ }, z.core.$strict>], "kind">, unknown>;
68
68
  userId: z.ZodOptional<z.ZodString>;
69
69
  }, z.core.$strict>;
70
70
  sourceContext: z.ZodOptional<z.ZodObject<{
@@ -151,7 +151,7 @@ declare const extractSessionRequestSchema: z.ZodObject<{
151
151
  eventType: z.ZodString;
152
152
  identifier: z.ZodString;
153
153
  namespace: z.ZodString;
154
- }, z.core.$strict>], "kind">>;
154
+ }, z.core.$strict>], "kind">, unknown>;
155
155
  userId: z.ZodOptional<z.ZodString>;
156
156
  }, z.core.$strict>;
157
157
  transcript: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
package/dist/api.d.ts CHANGED
@@ -63,21 +63,36 @@ export declare const memoryListResponseSchema: z.ZodObject<{
63
63
  }, z.core.$strict>;
64
64
  export declare const memoryDashboardResponseSchema: z.ZodObject<{
65
65
  days: z.ZodArray<z.ZodObject<{
66
- date: z.ZodISODate;
66
+ date: z.ZodString;
67
67
  personal: z.ZodNumber;
68
68
  public: z.ZodNumber;
69
69
  }, z.core.$strict>>;
70
70
  extractionDays: z.ZodArray<z.ZodObject<{
71
71
  costUsd: z.ZodNumber;
72
- date: z.ZodISODate;
72
+ date: z.ZodString;
73
73
  events: z.ZodNumber;
74
74
  }, z.core.$strict>>;
75
+ extractionHours: z.ZodOptional<z.ZodArray<z.ZodObject<{
76
+ costUsd: z.ZodNumber;
77
+ date: z.ZodString;
78
+ events: z.ZodNumber;
79
+ }, z.core.$strict>>>;
75
80
  generatedAt: z.ZodISODateTime;
81
+ hours: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ date: z.ZodString;
83
+ personal: z.ZodNumber;
84
+ public: z.ZodNumber;
85
+ }, z.core.$strict>>>;
76
86
  recallDays: z.ZodArray<z.ZodObject<{
77
87
  costUsd: z.ZodNumber;
78
- date: z.ZodISODate;
88
+ date: z.ZodString;
79
89
  events: z.ZodNumber;
80
90
  }, z.core.$strict>>;
91
+ recallHours: z.ZodOptional<z.ZodArray<z.ZodObject<{
92
+ costUsd: z.ZodNumber;
93
+ date: z.ZodString;
94
+ events: z.ZodNumber;
95
+ }, z.core.$strict>>>;
81
96
  stats: z.ZodObject<{
82
97
  active: z.ZodNumber;
83
98
  automatic: z.ZodNumber;
package/dist/index.js CHANGED
@@ -2035,6 +2035,39 @@ async function getMemoryTimeline(db, userId, days) {
2035
2035
  };
2036
2036
  });
2037
2037
  }
2038
+ async function getMemoryTimelineHours(db, userId, hours = 24) {
2039
+ const end = /* @__PURE__ */ new Date();
2040
+ end.setUTCMinutes(0, 0, 0);
2041
+ const startMs = end.getTime() - (hours - 1) * 60 * 60 * 1e3;
2042
+ const rows = await db.select({
2043
+ date: sql3`to_char(to_timestamp(${juniorMemoryMemories.createdAtMs} / 1000.0) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24')`.as(
2044
+ "date"
2045
+ ),
2046
+ private: sql3`count(*) filter (where ${juniorMemoryMemories.scope} = 'private')`.mapWith(
2047
+ Number
2048
+ ),
2049
+ public: sql3`count(*) filter (where ${juniorMemoryMemories.scope} = 'public')`.mapWith(
2050
+ Number
2051
+ )
2052
+ }).from(juniorMemoryMemories).where(
2053
+ and2(
2054
+ visibleScopePredicate2(userId),
2055
+ gt2(juniorMemoryMemories.createdAtMs, startMs - 1)
2056
+ )
2057
+ ).groupBy(
2058
+ sql3`to_char(to_timestamp(${juniorMemoryMemories.createdAtMs} / 1000.0) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24')`
2059
+ );
2060
+ const byHour = new Map(rows.map((row) => [row.date, row]));
2061
+ return Array.from({ length: hours }, (_, index2) => {
2062
+ const date = new Date(startMs + index2 * 60 * 60 * 1e3).toISOString().slice(0, 13);
2063
+ const row = byHour.get(date);
2064
+ return {
2065
+ date,
2066
+ private: row?.private ?? 0,
2067
+ public: row?.public ?? 0
2068
+ };
2069
+ });
2070
+ }
2038
2071
 
2039
2072
  // src/api.ts
2040
2073
  var memoryApiSchema = z5.object({
@@ -2052,21 +2085,25 @@ var memoryListResponseSchema = z5.object({
2052
2085
  memories: z5.array(memoryApiSchema),
2053
2086
  nextCursor: z5.string().min(1).optional()
2054
2087
  }).strict();
2088
+ var memoryBucketSchema = z5.string().regex(/^\d{4}-\d{2}-\d{2}(T\d{2})?$/);
2055
2089
  var memoryDashboardDaySchema = z5.object({
2056
- date: z5.iso.date(),
2090
+ date: memoryBucketSchema,
2057
2091
  personal: z5.number().int().min(0),
2058
2092
  public: z5.number().int().min(0)
2059
2093
  }).strict();
2060
2094
  var memoryCostDaySchema = z5.object({
2061
2095
  costUsd: z5.number().finite().nonnegative(),
2062
- date: z5.iso.date(),
2096
+ date: memoryBucketSchema,
2063
2097
  events: z5.number().int().min(0)
2064
2098
  }).strict();
2065
2099
  var memoryDashboardResponseSchema = z5.object({
2066
2100
  days: z5.array(memoryDashboardDaySchema).length(90),
2067
2101
  extractionDays: z5.array(memoryCostDaySchema).length(90),
2102
+ extractionHours: z5.array(memoryCostDaySchema).length(24).optional(),
2068
2103
  generatedAt: z5.iso.datetime(),
2104
+ hours: z5.array(memoryDashboardDaySchema).length(24).optional(),
2069
2105
  recallDays: z5.array(memoryCostDaySchema).length(90),
2106
+ recallHours: z5.array(memoryCostDaySchema).length(24).optional(),
2070
2107
  stats: z5.object({
2071
2108
  active: z5.number().int().min(0),
2072
2109
  automatic: z5.number().int().min(0),
@@ -2134,16 +2171,31 @@ function createMemoryApi(options) {
2134
2171
  const userId = viewer.id;
2135
2172
  try {
2136
2173
  if (isDashboard && isRead) {
2137
- const [stats, days, extractionDays, recallDays] = await Promise.all([
2174
+ const [
2175
+ stats,
2176
+ days,
2177
+ hours,
2178
+ extractionDays,
2179
+ extractionHours,
2180
+ recallDays,
2181
+ recallHours
2182
+ ] = await Promise.all([
2138
2183
  getMemoryStats(options.db, userId),
2139
2184
  getMemoryTimeline(options.db, userId, 90),
2185
+ getMemoryTimelineHours(options.db, userId, 24),
2140
2186
  options.eventStats.costsByDay({
2141
2187
  days: 90,
2142
2188
  eventName: "memories_captured"
2143
2189
  }),
2190
+ options.eventStats.costsByHour({
2191
+ eventName: "memories_captured"
2192
+ }),
2144
2193
  options.eventStats.costsByDay({
2145
2194
  days: 90,
2146
2195
  eventName: "memories_recalled"
2196
+ }),
2197
+ options.eventStats.costsByHour({
2198
+ eventName: "memories_recalled"
2147
2199
  })
2148
2200
  ]);
2149
2201
  const { private: personal, ...dashboardStats } = stats;
@@ -2153,8 +2205,14 @@ function createMemoryApi(options) {
2153
2205
  personal: personal2
2154
2206
  })),
2155
2207
  extractionDays,
2208
+ extractionHours,
2156
2209
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2210
+ hours: hours.map(({ private: personal2, ...day }) => ({
2211
+ ...day,
2212
+ personal: personal2
2213
+ })),
2157
2214
  recallDays,
2215
+ recallHours,
2158
2216
  stats: { ...dashboardStats, personal }
2159
2217
  });
2160
2218
  return request.method === "HEAD" ? new Response(null, {
@@ -3310,7 +3368,7 @@ async function buildMemoryOperationalReport(args) {
3310
3368
  public: day.public
3311
3369
  }
3312
3370
  })),
3313
- description: "Memories stored per day by scope",
3371
+ description: "Memories stored by scope",
3314
3372
  id: "memories-created",
3315
3373
  series: [
3316
3374
  { key: "private", label: "Private" },