Skip to content

Commit

Permalink
fix(next/build): correct payload for plugin telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jul 9, 2022
1 parent 5155a88 commit 373d52a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/next/telemetry/events/swc-plugins.ts
Expand Up @@ -5,8 +5,8 @@ const EVENT_SWC_PLUGIN_PRESENT = 'NEXT_SWC_PLUGIN_DETECTED'
type SwcPluginsEvent = {
eventName: string
payload: {
packageName: string
packageVersion?: string
pluginName: string
pluginVersion?: string
}
}

Expand Down Expand Up @@ -34,8 +34,8 @@ export async function eventSwcPlugins(
events.push({
eventName: EVENT_SWC_PLUGIN_PRESENT,
payload: {
packageName: plugin,
packageVersion: version,
pluginName: plugin,
pluginVersion: version,
},
})

Expand Down
14 changes: 6 additions & 8 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -843,19 +843,17 @@ describe('Telemetry CLI', () => {
const regex = /NEXT_SWC_PLUGIN_DETECTED[\s\S]+?{([\s\S]+?)}/g

const coverage = regex.exec(stderr).pop()
expect(coverage).toContain(
`"packageName": "swc-plugin-coverage-instrument"`
)
expect(coverage).toContain(`"packageVersion": "0.0.6"`)
expect(coverage).toContain(`"pluginName": "swc-plugin-coverage-instrument"`)
expect(coverage).toContain(`"pluginVersion": "0.0.6"`)

const relay = regex.exec(stderr).pop()
expect(relay).toContain(`"packageName": "@swc/plugin-relay"`)
expect(relay).toContain(`"packageVersion": "0.2.0"`)
expect(relay).toContain(`"pluginName": "@swc/plugin-relay"`)
expect(relay).toContain(`"pluginVersion": "0.2.0"`)

const absolute = regex.exec(stderr).pop()
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`)
})
})

0 comments on commit 373d52a

Please sign in to comment.