MCPcopy Index your code
hub / github.com/simstudioai/sim / maybeNotifyStorageLimit

Function maybeNotifyStorageLimit

apps/sim/lib/billing/storage/tracking.ts:36–62  ·  view source on GitHub ↗

* Best-effort storage threshold evaluation after a usage change. Re-reads the * (now updated) usage and plan limit, then delegates dedup + send to * maybeNotifyLimit. Never throws. * * The caller passes the subscription it already resolved for the increment/ * decrement, so the whole pa

(
  userId: string,
  workspaceId: string,
  sub: HighestPrioritySubscription | null,
  rearmOnly = false
)

Source from the content-addressed store, hash-verified

34 * threshold re-arms but never sends (a drop is not a fresh crossing).
35 */
36async function maybeNotifyStorageLimit(
37 userId: string,
38 workspaceId: string,
39 sub: HighestPrioritySubscription | null,
40 rearmOnly = false
41): Promise<void> {
42 try {
43 const [usage, limit] = await Promise.all([
44 getUserStorageUsage(userId, sub),
45 getUserStorageLimit(userId, sub),
46 ])
47
48 await maybeNotifyLimit({
49 category: 'storage',
50 billedUserId: userId,
51 workspaceId,
52 currentUsage: usage,
53 limit,
54 usageLabel: formatGb(usage, 2),
55 limitLabel: formatGb(limit, 0),
56 rearmOnly,
57 subscription: sub,
58 })
59 } catch (error) {
60 logger.error('Error evaluating storage limit notification:', error)
61 }
62}
63
64/**
65 * Increment storage usage after successful file upload

Callers 2

incrementStorageUsageFunction · 0.85
decrementStorageUsageFunction · 0.85

Calls 5

getUserStorageUsageFunction · 0.90
getUserStorageLimitFunction · 0.90
maybeNotifyLimitFunction · 0.90
formatGbFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected