diff --git a/plugin-transpiler/package.json b/plugin-transpiler/package.json index a36609f09fc..91b5c0dc209 100644 --- a/plugin-transpiler/package.json +++ b/plugin-transpiler/package.json @@ -12,10 +12,10 @@ "author": "PostHog Inc.", "license": "MIT", "devDependencies": { - "@babel/standalone": "^7.23.2", - "@types/babel__standalone": "^7.1.6", - "@types/node": "^20.8.9", - "esbuild": "^0.19.5", - "typescript": "^5.2.2" + "@babel/standalone": "^7.26.2", + "@types/babel__standalone": "^7.1.9", + "@types/node": "^22.9.1", + "esbuild": "^0.24.0", + "typescript": "^5.6.3" } } diff --git a/plugin-transpiler/pnpm-lock.yaml b/plugin-transpiler/pnpm-lock.yaml index 4363b1cc475..1e3d4590023 100644 --- a/plugin-transpiler/pnpm-lock.yaml +++ b/plugin-transpiler/pnpm-lock.yaml @@ -6,335 +6,354 @@ settings: devDependencies: '@babel/standalone': - specifier: ^7.23.2 - version: 7.23.2 + specifier: ^7.26.2 + version: 7.26.2 '@types/babel__standalone': - specifier: ^7.1.6 - version: 7.1.6 + specifier: ^7.1.9 + version: 7.1.9 '@types/node': - specifier: ^20.8.9 - version: 20.8.9 + specifier: ^22.9.1 + version: 22.9.1 esbuild: - specifier: ^0.19.5 - version: 0.19.5 + specifier: ^0.24.0 + version: 0.24.0 typescript: - specifier: ^5.2.2 - version: 5.2.2 + specifier: ^5.6.3 + version: 5.6.3 packages: - /@babel/helper-string-parser@7.22.5: - resolution: {integrity: sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==} + /@babel/helper-string-parser@7.25.9: + resolution: {integrity: sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==} engines: {node: '>=6.9.0'} dev: true - /@babel/helper-validator-identifier@7.22.20: - resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} + /@babel/helper-validator-identifier@7.25.9: + resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} engines: {node: '>=6.9.0'} dev: true - /@babel/parser@7.23.0: - resolution: {integrity: sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==} + /@babel/parser@7.26.2: + resolution: {integrity: sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==} engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.26.0 dev: true - /@babel/standalone@7.23.2: - resolution: {integrity: sha512-VJNw7OS26JvB6rE9XpbT6uQeQIEBWU5eeHGS4VR/+/4ZoKdLBXLcy66ZVJ/9IBkK1RMp8B0cohvhzdKWtJAGmg==} + /@babel/standalone@7.26.2: + resolution: {integrity: sha512-i2VbegsRfwa9yq3xmfDX3tG2yh9K0cCqwpSyVG2nPxifh0EOnucAZUeO/g4lW2Zfg03aPJNtPfxQbDHzXc7H+w==} engines: {node: '>=6.9.0'} dev: true - /@babel/types@7.23.0: - resolution: {integrity: sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==} + /@babel/types@7.26.0: + resolution: {integrity: sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-string-parser': 7.22.5 - '@babel/helper-validator-identifier': 7.22.20 - to-fast-properties: 2.0.0 + '@babel/helper-string-parser': 7.25.9 + '@babel/helper-validator-identifier': 7.25.9 dev: true - /@esbuild/android-arm64@0.19.5: - resolution: {integrity: sha512-5d1OkoJxnYQfmC+Zd8NBFjkhyCNYwM4n9ODrycTFY6Jk1IGiZ+tjVJDDSwDt77nK+tfpGP4T50iMtVi4dEGzhQ==} - engines: {node: '>=12'} + /@esbuild/aix-ppc64@0.24.0: + resolution: {integrity: sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm64@0.24.0: + resolution: {integrity: sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==} + engines: {node: '>=18'} cpu: [arm64] os: [android] requiresBuild: true dev: true optional: true - /@esbuild/android-arm@0.19.5: - resolution: {integrity: sha512-bhvbzWFF3CwMs5tbjf3ObfGqbl/17ict2/uwOSfr3wmxDE6VdS2GqY/FuzIPe0q0bdhj65zQsvqfArI9MY6+AA==} - engines: {node: '>=12'} + /@esbuild/android-arm@0.24.0: + resolution: {integrity: sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==} + engines: {node: '>=18'} cpu: [arm] os: [android] requiresBuild: true dev: true optional: true - /@esbuild/android-x64@0.19.5: - resolution: {integrity: sha512-9t+28jHGL7uBdkBjL90QFxe7DVA+KGqWlHCF8ChTKyaKO//VLuoBricQCgwhOjA1/qOczsw843Fy4cbs4H3DVA==} - engines: {node: '>=12'} + /@esbuild/android-x64@0.24.0: + resolution: {integrity: sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==} + engines: {node: '>=18'} cpu: [x64] os: [android] requiresBuild: true dev: true optional: true - /@esbuild/darwin-arm64@0.19.5: - resolution: {integrity: sha512-mvXGcKqqIqyKoxq26qEDPHJuBYUA5KizJncKOAf9eJQez+L9O+KfvNFu6nl7SCZ/gFb2QPaRqqmG0doSWlgkqw==} - engines: {node: '>=12'} + /@esbuild/darwin-arm64@0.24.0: + resolution: {integrity: sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==} + engines: {node: '>=18'} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /@esbuild/darwin-x64@0.19.5: - resolution: {integrity: sha512-Ly8cn6fGLNet19s0X4unjcniX24I0RqjPv+kurpXabZYSXGM4Pwpmf85WHJN3lAgB8GSth7s5A0r856S+4DyiA==} - engines: {node: '>=12'} + /@esbuild/darwin-x64@0.24.0: + resolution: {integrity: sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==} + engines: {node: '>=18'} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /@esbuild/freebsd-arm64@0.19.5: - resolution: {integrity: sha512-GGDNnPWTmWE+DMchq1W8Sd0mUkL+APvJg3b11klSGUDvRXh70JqLAO56tubmq1s2cgpVCSKYywEiKBfju8JztQ==} - engines: {node: '>=12'} + /@esbuild/freebsd-arm64@0.24.0: + resolution: {integrity: sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==} + engines: {node: '>=18'} cpu: [arm64] os: [freebsd] requiresBuild: true dev: true optional: true - /@esbuild/freebsd-x64@0.19.5: - resolution: {integrity: sha512-1CCwDHnSSoA0HNwdfoNY0jLfJpd7ygaLAp5EHFos3VWJCRX9DMwWODf96s9TSse39Br7oOTLryRVmBoFwXbuuQ==} - engines: {node: '>=12'} + /@esbuild/freebsd-x64@0.24.0: + resolution: {integrity: sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==} + engines: {node: '>=18'} cpu: [x64] os: [freebsd] requiresBuild: true dev: true optional: true - /@esbuild/linux-arm64@0.19.5: - resolution: {integrity: sha512-o3vYippBmSrjjQUCEEiTZ2l+4yC0pVJD/Dl57WfPwwlvFkrxoSO7rmBZFii6kQB3Wrn/6GwJUPLU5t52eq2meA==} - engines: {node: '>=12'} + /@esbuild/linux-arm64@0.24.0: + resolution: {integrity: sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==} + engines: {node: '>=18'} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-arm@0.19.5: - resolution: {integrity: sha512-lrWXLY/vJBzCPC51QN0HM71uWgIEpGSjSZZADQhq7DKhPcI6NH1IdzjfHkDQws2oNpJKpR13kv7/pFHBbDQDwQ==} - engines: {node: '>=12'} + /@esbuild/linux-arm@0.24.0: + resolution: {integrity: sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==} + engines: {node: '>=18'} cpu: [arm] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-ia32@0.19.5: - resolution: {integrity: sha512-MkjHXS03AXAkNp1KKkhSKPOCYztRtK+KXDNkBa6P78F8Bw0ynknCSClO/ztGszILZtyO/lVKpa7MolbBZ6oJtQ==} - engines: {node: '>=12'} + /@esbuild/linux-ia32@0.24.0: + resolution: {integrity: sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==} + engines: {node: '>=18'} cpu: [ia32] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-loong64@0.19.5: - resolution: {integrity: sha512-42GwZMm5oYOD/JHqHska3Jg0r+XFb/fdZRX+WjADm3nLWLcIsN27YKtqxzQmGNJgu0AyXg4HtcSK9HuOk3v1Dw==} - engines: {node: '>=12'} + /@esbuild/linux-loong64@0.24.0: + resolution: {integrity: sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==} + engines: {node: '>=18'} cpu: [loong64] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-mips64el@0.19.5: - resolution: {integrity: sha512-kcjndCSMitUuPJobWCnwQ9lLjiLZUR3QLQmlgaBfMX23UEa7ZOrtufnRds+6WZtIS9HdTXqND4yH8NLoVVIkcg==} - engines: {node: '>=12'} + /@esbuild/linux-mips64el@0.24.0: + resolution: {integrity: sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==} + engines: {node: '>=18'} cpu: [mips64el] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-ppc64@0.19.5: - resolution: {integrity: sha512-yJAxJfHVm0ZbsiljbtFFP1BQKLc8kUF6+17tjQ78QjqjAQDnhULWiTA6u0FCDmYT1oOKS9PzZ2z0aBI+Mcyj7Q==} - engines: {node: '>=12'} + /@esbuild/linux-ppc64@0.24.0: + resolution: {integrity: sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==} + engines: {node: '>=18'} cpu: [ppc64] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-riscv64@0.19.5: - resolution: {integrity: sha512-5u8cIR/t3gaD6ad3wNt1MNRstAZO+aNyBxu2We8X31bA8XUNyamTVQwLDA1SLoPCUehNCymhBhK3Qim1433Zag==} - engines: {node: '>=12'} + /@esbuild/linux-riscv64@0.24.0: + resolution: {integrity: sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==} + engines: {node: '>=18'} cpu: [riscv64] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-s390x@0.19.5: - resolution: {integrity: sha512-Z6JrMyEw/EmZBD/OFEFpb+gao9xJ59ATsoTNlj39jVBbXqoZm4Xntu6wVmGPB/OATi1uk/DB+yeDPv2E8PqZGw==} - engines: {node: '>=12'} + /@esbuild/linux-s390x@0.24.0: + resolution: {integrity: sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==} + engines: {node: '>=18'} cpu: [s390x] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/linux-x64@0.19.5: - resolution: {integrity: sha512-psagl+2RlK1z8zWZOmVdImisMtrUxvwereIdyJTmtmHahJTKb64pAcqoPlx6CewPdvGvUKe2Jw+0Z/0qhSbG1A==} - engines: {node: '>=12'} + /@esbuild/linux-x64@0.24.0: + resolution: {integrity: sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==} + engines: {node: '>=18'} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /@esbuild/netbsd-x64@0.19.5: - resolution: {integrity: sha512-kL2l+xScnAy/E/3119OggX8SrWyBEcqAh8aOY1gr4gPvw76la2GlD4Ymf832UCVbmuWeTf2adkZDK+h0Z/fB4g==} - engines: {node: '>=12'} + /@esbuild/netbsd-x64@0.24.0: + resolution: {integrity: sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==} + engines: {node: '>=18'} cpu: [x64] os: [netbsd] requiresBuild: true dev: true optional: true - /@esbuild/openbsd-x64@0.19.5: - resolution: {integrity: sha512-sPOfhtzFufQfTBgRnE1DIJjzsXukKSvZxloZbkJDG383q0awVAq600pc1nfqBcl0ice/WN9p4qLc39WhBShRTA==} - engines: {node: '>=12'} + /@esbuild/openbsd-arm64@0.24.0: + resolution: {integrity: sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.24.0: + resolution: {integrity: sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==} + engines: {node: '>=18'} cpu: [x64] os: [openbsd] requiresBuild: true dev: true optional: true - /@esbuild/sunos-x64@0.19.5: - resolution: {integrity: sha512-dGZkBXaafuKLpDSjKcB0ax0FL36YXCvJNnztjKV+6CO82tTYVDSH2lifitJ29jxRMoUhgkg9a+VA/B03WK5lcg==} - engines: {node: '>=12'} + /@esbuild/sunos-x64@0.24.0: + resolution: {integrity: sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==} + engines: {node: '>=18'} cpu: [x64] os: [sunos] requiresBuild: true dev: true optional: true - /@esbuild/win32-arm64@0.19.5: - resolution: {integrity: sha512-dWVjD9y03ilhdRQ6Xig1NWNgfLtf2o/STKTS+eZuF90fI2BhbwD6WlaiCGKptlqXlURVB5AUOxUj09LuwKGDTg==} - engines: {node: '>=12'} + /@esbuild/win32-arm64@0.24.0: + resolution: {integrity: sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==} + engines: {node: '>=18'} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /@esbuild/win32-ia32@0.19.5: - resolution: {integrity: sha512-4liggWIA4oDgUxqpZwrDhmEfAH4d0iljanDOK7AnVU89T6CzHon/ony8C5LeOdfgx60x5cnQJFZwEydVlYx4iw==} - engines: {node: '>=12'} + /@esbuild/win32-ia32@0.24.0: + resolution: {integrity: sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==} + engines: {node: '>=18'} cpu: [ia32] os: [win32] requiresBuild: true dev: true optional: true - /@esbuild/win32-x64@0.19.5: - resolution: {integrity: sha512-czTrygUsB/jlM8qEW5MD8bgYU2Xg14lo6kBDXW6HdxKjh8M5PzETGiSHaz9MtbXBYDloHNUAUW2tMiKW4KM9Mw==} - engines: {node: '>=12'} + /@esbuild/win32-x64@0.24.0: + resolution: {integrity: sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==} + engines: {node: '>=18'} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /@types/babel__core@7.20.3: - resolution: {integrity: sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA==} + /@types/babel__core@7.20.5: + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} dependencies: - '@babel/parser': 7.23.0 - '@babel/types': 7.23.0 - '@types/babel__generator': 7.6.6 - '@types/babel__template': 7.4.3 - '@types/babel__traverse': 7.20.3 + '@babel/parser': 7.26.2 + '@babel/types': 7.26.0 + '@types/babel__generator': 7.6.8 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.20.6 dev: true - /@types/babel__generator@7.6.6: - resolution: {integrity: sha512-66BXMKb/sUWbMdBNdMvajU7i/44RkrA3z/Yt1c7R5xejt8qh84iU54yUWCtm0QwGJlDcf/gg4zd/x4mpLAlb/w==} + /@types/babel__generator@7.6.8: + resolution: {integrity: sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.26.0 dev: true - /@types/babel__standalone@7.1.6: - resolution: {integrity: sha512-JRVq2H02irW6GDxkHepsdZVjor87SZo4eDsxoBtSbswf7HWtVYNxCmJDBkJbFNFWGOuzsxATZV8xZ2PI9sBiIw==} + /@types/babel__standalone@7.1.9: + resolution: {integrity: sha512-IcCNPLqpevUD7UpV8QB0uwQPOyoOKACFf0YtYWRHcmxcakaje4Q7dbG2+jMqxw/I8Zk0NHvEps66WwS7z/UaaA==} dependencies: - '@types/babel__core': 7.20.3 + '@babel/parser': 7.26.2 + '@babel/types': 7.26.0 + '@types/babel__core': 7.20.5 + '@types/babel__generator': 7.6.8 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.20.6 dev: true - /@types/babel__template@7.4.3: - resolution: {integrity: sha512-ciwyCLeuRfxboZ4isgdNZi/tkt06m8Tw6uGbBSBgWrnnZGNXiEyM27xc/PjXGQLqlZ6ylbgHMnm7ccF9tCkOeQ==} + /@types/babel__template@7.4.4: + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} dependencies: - '@babel/parser': 7.23.0 - '@babel/types': 7.23.0 + '@babel/parser': 7.26.2 + '@babel/types': 7.26.0 dev: true - /@types/babel__traverse@7.20.3: - resolution: {integrity: sha512-Lsh766rGEFbaxMIDH7Qa+Yha8cMVI3qAK6CHt3OR0YfxOIn5Z54iHiyDRycHrBqeIiqGa20Kpsv1cavfBKkRSw==} + /@types/babel__traverse@7.20.6: + resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.26.0 dev: true - /@types/node@20.8.9: - resolution: {integrity: sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==} + /@types/node@22.9.1: + resolution: {integrity: sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==} dependencies: - undici-types: 5.26.5 + undici-types: 6.19.8 dev: true - /esbuild@0.19.5: - resolution: {integrity: sha512-bUxalY7b1g8vNhQKdB24QDmHeY4V4tw/s6Ak5z+jJX9laP5MoQseTOMemAr0gxssjNcH0MCViG8ONI2kksvfFQ==} - engines: {node: '>=12'} + /esbuild@0.24.0: + resolution: {integrity: sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==} + engines: {node: '>=18'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.19.5 - '@esbuild/android-arm64': 0.19.5 - '@esbuild/android-x64': 0.19.5 - '@esbuild/darwin-arm64': 0.19.5 - '@esbuild/darwin-x64': 0.19.5 - '@esbuild/freebsd-arm64': 0.19.5 - '@esbuild/freebsd-x64': 0.19.5 - '@esbuild/linux-arm': 0.19.5 - '@esbuild/linux-arm64': 0.19.5 - '@esbuild/linux-ia32': 0.19.5 - '@esbuild/linux-loong64': 0.19.5 - '@esbuild/linux-mips64el': 0.19.5 - '@esbuild/linux-ppc64': 0.19.5 - '@esbuild/linux-riscv64': 0.19.5 - '@esbuild/linux-s390x': 0.19.5 - '@esbuild/linux-x64': 0.19.5 - '@esbuild/netbsd-x64': 0.19.5 - '@esbuild/openbsd-x64': 0.19.5 - '@esbuild/sunos-x64': 0.19.5 - '@esbuild/win32-arm64': 0.19.5 - '@esbuild/win32-ia32': 0.19.5 - '@esbuild/win32-x64': 0.19.5 + '@esbuild/aix-ppc64': 0.24.0 + '@esbuild/android-arm': 0.24.0 + '@esbuild/android-arm64': 0.24.0 + '@esbuild/android-x64': 0.24.0 + '@esbuild/darwin-arm64': 0.24.0 + '@esbuild/darwin-x64': 0.24.0 + '@esbuild/freebsd-arm64': 0.24.0 + '@esbuild/freebsd-x64': 0.24.0 + '@esbuild/linux-arm': 0.24.0 + '@esbuild/linux-arm64': 0.24.0 + '@esbuild/linux-ia32': 0.24.0 + '@esbuild/linux-loong64': 0.24.0 + '@esbuild/linux-mips64el': 0.24.0 + '@esbuild/linux-ppc64': 0.24.0 + '@esbuild/linux-riscv64': 0.24.0 + '@esbuild/linux-s390x': 0.24.0 + '@esbuild/linux-x64': 0.24.0 + '@esbuild/netbsd-x64': 0.24.0 + '@esbuild/openbsd-arm64': 0.24.0 + '@esbuild/openbsd-x64': 0.24.0 + '@esbuild/sunos-x64': 0.24.0 + '@esbuild/win32-arm64': 0.24.0 + '@esbuild/win32-ia32': 0.24.0 + '@esbuild/win32-x64': 0.24.0 dev: true - /to-fast-properties@2.0.0: - resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==} - engines: {node: '>=4'} - dev: true - - /typescript@5.2.2: - resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} + /typescript@5.6.3: + resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==} engines: {node: '>=14.17'} hasBin: true dev: true - /undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + /undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} dev: true diff --git a/posthog/api/hog_function.py b/posthog/api/hog_function.py index 85e71b3ce6c..21406f3f689 100644 --- a/posthog/api/hog_function.py +++ b/posthog/api/hog_function.py @@ -22,7 +22,7 @@ from posthog.cdp.filters import compile_filters_bytecode, compile_filters_expr from posthog.cdp.services.icons import CDPIconsService from posthog.cdp.templates import HOG_FUNCTION_TEMPLATES_BY_ID from posthog.cdp.validation import compile_hog, generate_template_bytecode, validate_inputs, validate_inputs_schema -from posthog.cdp.transpile import get_transpiled_function +from posthog.cdp.web import get_transpiled_function from posthog.constants import AvailableFeature from posthog.hogql.compiler.javascript import JavaScriptCompiler from posthog.models.activity_logging.activity_log import log_activity, changes_between, Detail diff --git a/posthog/cdp/templates/pineapple/template_pineapple.py b/posthog/cdp/templates/pineapple/template_pineapple.py index f991c6fbe9c..65ecbbb2e82 100644 --- a/posthog/cdp/templates/pineapple/template_pineapple.py +++ b/posthog/cdp/templates/pineapple/template_pineapple.py @@ -9,18 +9,19 @@ template: HogFunctionTemplate = HogFunctionTemplate( icon_url="/static/services/pineapple.png", category=["Custom", "Analytics"], hog=""" +// Run only once export async function onLoad({ inputs, posthog }) { const url = inputs.host console.log('🍍 Loading Pineapple Analytics', { url, inputs }) // await loadScript(url + '/js?t=' + new Date().getTime()) } -// behind the scenes: posthog.on('eventCaptured', (event) => {}) +// Run whenever an event matches filters export function onEvent({ event, person, inputs, posthog }) { const { userId, additionalProperties } = inputs const payload = { event, person, userId, additionalProperties } - console.log('🍍 Sending event', { payload }) + console.log('🍍 Sending event', event, payload) // window.pineappleAnalytics.capture(payload) } """.strip(), diff --git a/posthog/cdp/transpile.py b/posthog/cdp/transpile.py deleted file mode 100644 index dcc230947b9..00000000000 --- a/posthog/cdp/transpile.py +++ /dev/null @@ -1,70 +0,0 @@ -import json - -from posthog.cdp.filters import hog_function_filters_to_expr -from posthog.cdp.validation import transpile_template_code -from posthog.hogql.compiler.javascript import JavaScriptCompiler -from posthog.models.plugin import transpile -from posthog.models.team.team import Team - - -def get_transpiled_function(id: str, source: str, filters: dict, inputs: dict, team: Team) -> str: - # Transpile the plugin TS into JS - transpiled = transpile(source, "site") - - # Wrap in IIFE = Immediately Invoked Function Expression = to avoid polluting global scope - response = "(function() {\n\n" - - response += f"const posthog = window['__$$ph_site_app_{id}'] || window['posthog'];\n" - - # Build a switch statement within a try/catch loop and a static dict - config_switch = "" - config_dict_items: list[str] = [] - - compiler = JavaScriptCompiler() - - for key, input in inputs.items(): - value = input.get("value") - key_string = json.dumps(str(key) or "") - if (isinstance(value, str) and "{" in value) or isinstance(value, dict) or isinstance(value, list): - base_code = transpile_template_code(value, compiler) - config_switch += f"case {key_string}: return {base_code};\n" - config_dict_items.append(f"{key_string}: getInputsKey({json.dumps(key)}, initial)") - else: - config_dict_items.append(f"{key_string}: {json.dumps(value)}") - - filters_expr = hog_function_filters_to_expr(filters, team, None) - filters_code = compiler.visit(filters_expr) - - # Start with the STL functions - response += compiler.get_stl_code() + "\n" - - response += "function getInputs(globals, initial) {\n" - response += "let __getGlobal = (key) => globals[key];\n" - # response += f"__globals = globals || {'{}'};\n" - if config_switch: - response += "function getInputsKey(key, initial) { try { switch (key) {\n\n///// calculated properties\n" - response += config_switch - response += "\ndefault: return null; }\n" - response += "} catch (e) { if(!initial) {console.warn('[POSTHOG-JS] Unable to get config field', key, e);} return null } }\n" - response += "return {\n\n///// config\n" - response += ",\n".join(config_dict_items) - response += "\n\n} }\n" - - response += f"const response = {transpiled}();" - - response += "if ('onLoad' in response) { response.onLoad({ inputs: getInputs({}, true), posthog: posthog }); }" - response += "if ('onEvent' in response) {" - response += "posthog.on('eventCaptured', (event) => { " - response += "const person = { properties: posthog.get_property('$stored_person_properties') }; " - response += "const inputs = getInputs({ event, person });" - - response += "let __globals = { ...event, person };" - response += "let __getGlobal = (key) => __globals[key];\n" - response += f"const filterMatches = {filters_code};" - - response += "if (filterMatches) { response.onEvent({ event, person, inputs, posthog }); } " - response += "} ) }" - - response += "\n\n})();" - - return response diff --git a/posthog/cdp/web.py b/posthog/cdp/web.py new file mode 100644 index 00000000000..ac4de5b8a38 --- /dev/null +++ b/posthog/cdp/web.py @@ -0,0 +1,81 @@ +import json + +from posthog.cdp.filters import hog_function_filters_to_expr +from posthog.cdp.validation import transpile_template_code +from posthog.hogql.compiler.javascript import JavaScriptCompiler +from posthog.models.plugin import transpile +from posthog.models.team.team import Team + + +def get_transpiled_function(id: str, source: str, filters: dict, inputs: dict, team: Team) -> str: + # Wrap in IIFE = Immediately Invoked Function Expression = to avoid polluting global scope + response = "(function() {\n\n" + + # PostHog-JS adds itself to the window object for us to use + response += f"const posthog = window['__$$ph_site_app_{id}'] || window['posthog'];\n" + + # Build the inputs in three parts: + # 1) a simple object with constants/scalars + inputs_object: list[str] = [] + # 2) a function with a switch + try/catch that calculates the input from globals + inputs_switch = "" + # 3) code that adds all calculated inputs to the inputs object + inputs_append: list[str] = [] + + compiler = JavaScriptCompiler() + + # TODO: somehow reorder inputs to make dependencies work + for key, input in inputs.items(): + value = input.get("value") + key_string = json.dumps(str(key) or "") + if (isinstance(value, str) and "{" in value) or isinstance(value, dict) or isinstance(value, list): + base_code = transpile_template_code(value, compiler) + inputs_switch += f"case {key_string}: return {base_code};\n" + inputs_append.append(f"inputs[{key_string}] = getInputsKey({json.dumps(key)});") + else: + inputs_object.append(f"{key_string}: {json.dumps(value)}") + + # Convert the filters to code + filters_expr = hog_function_filters_to_expr(filters, team, None) + filters_code = compiler.visit(filters_expr) + + # Start with the STL functions + response += compiler.get_stl_code() + "\n" + + # A function to calculate the inputs from globals. If "initial" is true, no errors are logged. + response += "function buildInputs(globals, initial) {\n" + + # Add all constant inputs directly + response += "let inputs = {\n" + (",\n".join(inputs_object)) + "};\n" + + # Transpiled Hog code needs "__getGlobal" to be in scope to access globals + response += "let __getGlobal = (key) => key === 'inputs' ? inputs : globals[key];\n" + + if inputs_switch: + response += "function getInputsKey(key, initial) { try { switch (key) {\n" + response += inputs_switch + response += "default: return null; }\n" + response += "} catch (e) { if(!initial) {console.error('[POSTHOG-JS] Unable to compute value for inputs', key, e);} return null } }\n" + response += "\n".join(inputs_append) + "\n" + response += "return inputs;}\n" + + # See plugin-transpiler/src/presets.ts + # transpile(..., 'site') == `(function () {let exports={};${code};return exports;})` + response += f"const response = {transpile(source, 'site')}();" + response += "if ('onLoad' in response) { response.onLoad({ inputs: buildInputs({}, true), posthog: posthog }); }" + response += "if ('onEvent' in response) {" + response += "posthog.on('eventCaptured', (event) => { " + + # TODO: get a better person object from posthog-js directly + response += "const person = { properties: posthog.get_property('$stored_person_properties') }; " + # TODO: add groups + response += "const inputs = buildInputs({ event, person });" + + response += "let __globals = { ...event, person, inputs };" + response += "let __getGlobal = (key) => __globals[key];\n" + response += f"const filterMatches = {filters_code};" + response += "if (filterMatches) { response.onEvent({ event, person, inputs, posthog }); } " + response += "})}" + response += "\n\n})();" + + return response diff --git a/posthog/hogql/compiler/javascript_stl.py b/posthog/hogql/compiler/javascript_stl.py index b1e53d24110..9c4681dac42 100644 --- a/posthog/hogql/compiler/javascript_stl.py +++ b/posthog/hogql/compiler/javascript_stl.py @@ -825,11 +825,8 @@ function __like(str, pattern, caseInsensitive = false) { """ function __getProperty(objectOrArray, key, nullish) { if ((nullish && !objectOrArray) || key === 0) { return null } - if (Array.isArray(objectOrArray)) { - return key > 0 ? objectOrArray[key - 1] : objectOrArray[objectOrArray.length + key] - } else { - return objectOrArray[key] - } + if (Array.isArray(objectOrArray)) { return key > 0 ? objectOrArray[key - 1] : objectOrArray[objectOrArray.length + key] } + else { return objectOrArray[key] } } """, [], @@ -837,15 +834,8 @@ function __getProperty(objectOrArray, key, nullish) { "__setProperty": [ """ function __setProperty(objectOrArray, key, value) { - if (Array.isArray(objectOrArray)) { - if (key > 0) { - objectOrArray[key - 1] = value - } else { - objectOrArray[objectOrArray.length + key] = value - } - } else { - objectOrArray[key] = value - } + if (Array.isArray(objectOrArray)) { if (key > 0) { objectOrArray[key - 1] = value } else { objectOrArray[objectOrArray.length + key] = value } } + else { objectOrArray[key] = value } return objectOrArray } """,