8
n8n 中文网amn8n.com

n8n IPA 大小跟踪工作流

中级

这是一个自动化工作流,包含 11 个节点。主要使用 If, Set, Code, Gmail, HttpRequest 等节点。 使用 Google Sheets 和 Gmail 通知跟踪 iOS 应用大小及趋势警报

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "unl2pTzZ5wjLa1LJ",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa"
  },
  "name": "n8n IPA 大小跟踪工作流",
  "tags": [],
  "nodes": [
    {
      "id": "b359d5db-f75a-4ff6-8563-7760134859a0",
      "name": "每日大小检查",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1696,
        16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 0 0 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "836eb96f-716e-4b0e-a864-608e9d7b4776",
      "name": "应用配置",
      "type": "n8n-nodes-base.set",
      "position": [
        -1488,
        16
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1b05cba9-c860-47d7-8776-4dfb01da6650",
              "name": "app_name",
              "type": "string",
              "value": "APP_NAME"
            },
            {
              "id": "e5ee79ad-87be-4f59-82a4-39f8ef9c73a0",
              "name": "version",
              "type": "string",
              "value": "1.0.0"
            },
            {
              "id": "cc1481ec-2fe3-4c52-af36-706a7cf8a039",
              "name": "build_number",
              "type": "string",
              "value": "1"
            },
            {
              "id": "16a60a31-e728-4f65-8aa6-405cf5751942",
              "name": "ipa_url",
              "type": "string",
              "value": "ENTER_IPA_FILE_DOWNLOAD_URL"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "aee76d66-e1d7-4ed2-9a39-f6ff25a61557",
      "name": "下载 IPA 文件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1280,
        16
      ],
      "parameters": {
        "url": "={{ $json.ipa_url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8381ba6f-b167-4e87-b83a-2534a7e921b7",
      "name": "计算大小",
      "type": "n8n-nodes-base.code",
      "position": [
        -1072,
        16
      ],
      "parameters": {
        "jsCode": "// Get input data from previous nodes\nconst items = $input.all();\nconst results = [];\n\n// Process each item\nfor (const item of items) {\n  // Get file size from binary data\n  const fileSize = item.binary?.data?.fileSize || 0;\n  \n  // Calculate different size units\n  const fileSizeKB = Math.round(fileSize / 1024);\n  const fileSizeMB = Math.round(fileSize / (1024 * 1024) * 100) / 100;\n  \n  // Get current date/time\n  const now = new Date();\n  const currentDate = now.toISOString().split('T')[0]; // YYYY-MM-DD format\n  \n  // Build result object\n  const result = {\n    // Keep original data\n    app_name: item.json.app_name,\n    version: item.json.version,\n    build_number: item.json.build_number,\n    ipa_url: item.json.ipa_url,\n    \n    // Add new calculated data\n    date: currentDate,\n    timestamp: now.toISOString(),\n    file_size_bytes: fileSize,\n    file_size_kb: fileSizeKB,\n    file_size_mb: fileSizeMB\n  };\n  \n  // Add to results array\n  results.push(result);\n  \n  // Log for debugging (check browser console)\n  console.log(`📊 ${item.json.app_name}: ${fileSizeMB} MB`);\n}\n\n// Return results to next node\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "500042b4-327c-4a2c-9c6c-2b75405a6d76",
      "name": "在表格中追加行",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -864,
        16
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "ENTER_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "ENTER_SHEET_ID"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "K51JQLS2WHFWzap5",
          "name": "Google Sheets account 7"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0c53dfec-5e21-4faa-8d0b-5864736d744d",
      "name": "分析大小趋势",
      "type": "n8n-nodes-base.code",
      "position": [
        -656,
        16
      ],
      "parameters": {
        "jsCode": "// Simple trend analysis using thresholds\nconst items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n  const currentSize = item.json.file_size_mb;\n  \n  // Define size thresholds (you can customize these)\n  const SMALL_APP = 50;   // MB\n  const MEDIUM_APP = 150; // MB\n  const LARGE_APP = 300;  // MB\n  \n  // Determine size category\n  let sizeCategory = 'UNKNOWN';\n  let trendStatus = 'NEW_TRACKING'; // First time tracking\n  let alertLevel = 'INFO';\n  \n  if (currentSize < SMALL_APP) {\n    sizeCategory = 'SMALL';\n  } else if (currentSize < MEDIUM_APP) {\n    sizeCategory = 'MEDIUM';\n  } else if (currentSize < LARGE_APP) {\n    sizeCategory = 'LARGE';\n  } else {\n    sizeCategory = 'VERY_LARGE';\n    alertLevel = 'WARNING'; // Large apps always get warnings\n  }\n  \n  // Check if size is unusually large (basic threshold check)\n  if (currentSize > 500) {\n    trendStatus = 'SIZE_ALERT_LARGE';\n    alertLevel = 'CRITICAL';\n  } else if (currentSize > 300) {\n    trendStatus = 'SIZE_WARNING';\n    alertLevel = 'WARNING';\n  } else {\n    trendStatus = 'SIZE_NORMAL';\n  }\n  \n  const result = {\n    ...item.json,\n    size_category: sizeCategory,\n    trend_status: trendStatus,\n    alert_level: alertLevel,\n    analysis_timestamp: new Date().toISOString(),\n    analysis_note: `App size is ${sizeCategory.toLowerCase()} (${currentSize} MB)`\n  };\n  \n  results.push(result);\n  \n  console.log(`📊 Analysis: ${item.json.app_name} = ${currentSize}MB (${sizeCategory})`);\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "d22847f2-81e5-43a9-bfd4-2777f26d05ca",
      "name": "检查警报",
      "type": "n8n-nodes-base.if",
      "position": [
        -448,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bd7ec616-cf77-4fb6-ac2b-92907fe77526",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.trend_status }}",
              "rightValue": "STABLE"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0aca8e1a-519f-4582-81eb-92adbca785b2",
      "name": "发送警报邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -240,
        -128
      ],
      "webhookId": "cf4c5051-69f0-4cf9-886a-321315bab691",
      "parameters": {
        "sendTo": "xyz@gmail.com",
        "message": "=🚨 IPA Size Alert  App: {{ $json['App Name'] }} Current Size: {{ $json['Size(Bytes)'] }} MB Previous Size: {{ $json['Size(Bytes)'] }} MB Trend: {{ $json.trend_status }}  Time: {{ new Date().toLocaleString() }}  This is an automated alert from your IPA Size Tracker.",
        "options": {},
        "subject": "=IPA Size Alert: {{ $json['App Name'] }} - {{ $json.trend_status }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "GsAjl8kiLaQnkjoK",
          "name": "Gmail account 10"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d6fc5d0b-2044-49df-8c37-e95095ac3d8f",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        -112
      ],
      "parameters": {
        "width": 224,
        "height": 80,
        "content": "** 定义要监控的应用及其 IPA 下载链接的中心位置 **"
      },
      "typeVersion": 1
    },
    {
      "id": "8f55147e-3cec-460c-819f-40bf4a979f13",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        176
      ],
      "parameters": {
        "width": 224,
        "height": 80,
        "content": "** 从配置的 URL 获取 IPA 并准备进行大小计算 **"
      },
      "typeVersion": 1
    },
    {
      "id": "3ea7e537-1fa4-49d6-af5b-0f374581f684",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -96
      ],
      "parameters": {
        "width": 256,
        "height": 80,
        "content": "** 将带有时间戳的应用大小数据保存到 Google Sheets 中以进行历史跟踪 **"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5210e3a2-cf62-41b9-a30e-23d961dd9e71",
  "connections": {
    "Calculate Sizes": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Alerts": {
      "main": [
        [
          {
            "node": "Send Alert Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily size check": {
      "main": [
        [
          {
            "node": "App Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "App Configuration": {
      "main": [
        [
          {
            "node": "Download IPA File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download IPA File": {
      "main": [
        [
          {
            "node": "Calculate Sizes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Size Trends": {
      "main": [
        [
          {
            "node": "Check for Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Analyze Size Trends",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量11
分类-
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流