Unverified Commit 0036a3d1 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

fix(next/build): correct payload for plugin telemetry (#38468)

parent 0797b1a6
...@@ -5,8 +5,8 @@ const EVENT_SWC_PLUGIN_PRESENT = 'NEXT_SWC_PLUGIN_DETECTED' ...@@ -5,8 +5,8 @@ const EVENT_SWC_PLUGIN_PRESENT = 'NEXT_SWC_PLUGIN_DETECTED'
type SwcPluginsEvent = { type SwcPluginsEvent = {
eventName: string eventName: string
payload: { payload: {
packageName: string pluginName: string
packageVersion?: string pluginVersion?: string
} }
} }
...@@ -34,8 +34,8 @@ export async function eventSwcPlugins( ...@@ -34,8 +34,8 @@ export async function eventSwcPlugins(
events.push({ events.push({
eventName: EVENT_SWC_PLUGIN_PRESENT, eventName: EVENT_SWC_PLUGIN_PRESENT,
payload: { payload: {
packageName: plugin, pluginName: plugin,
packageVersion: version, pluginVersion: version,
}, },
}) })
......
...@@ -843,19 +843,17 @@ describe('Telemetry CLI', () => { ...@@ -843,19 +843,17 @@ describe('Telemetry CLI', () => {
const regex = /NEXT_SWC_PLUGIN_DETECTED[\s\S]+?{([\s\S]+?)}/g const regex = /NEXT_SWC_PLUGIN_DETECTED[\s\S]+?{([\s\S]+?)}/g
const coverage = regex.exec(stderr).pop() const coverage = regex.exec(stderr).pop()
expect(coverage).toContain( expect(coverage).toContain(`"pluginName": "swc-plugin-coverage-instrument"`)
`"packageName": "swc-plugin-coverage-instrument"` expect(coverage).toContain(`"pluginVersion": "0.0.6"`)
)
expect(coverage).toContain(`"packageVersion": "0.0.6"`)
const relay = regex.exec(stderr).pop() const relay = regex.exec(stderr).pop()
expect(relay).toContain(`"packageName": "@swc/plugin-relay"`) expect(relay).toContain(`"pluginName": "@swc/plugin-relay"`)
expect(relay).toContain(`"packageVersion": "0.2.0"`) expect(relay).toContain(`"pluginVersion": "0.2.0"`)
const absolute = regex.exec(stderr).pop() const absolute = regex.exec(stderr).pop()
expect(absolute).toContain( expect(absolute).toContain(
`"packageName": "/test/absolute_path/plugin.wasm"` `"pluginName": "/test/absolute_path/plugin.wasm"`
) )
expect(absolute).not.toContain(`packageVersion`) expect(absolute).not.toContain(`pluginVersion`)
}) })
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment