-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathnext.js
31 lines (25 loc) · 953 Bytes
/
next.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/
'use strict';
// See "lib/instrumentation/modules/next/README.md".
const semver = require('semver');
module.exports = function (mod, agent, { version, enabled }) {
if (!enabled) {
return mod;
}
if (
!semver.satisfies(version, '>=12.0.0 <13.3.0', { includePrerelease: true })
) {
agent.logger.debug('next version %s not supported, skipping', version);
return mod;
}
// This isn't perfect. Which framework the agent will report with a
// custom Next.js server using another framework, e.g.
// https://github.com/vercel/next.js/blob/canary/examples/custom-server-fastify/server.js
// depends on which is *imported* first.
agent.setFramework({ name: 'Next.js', version, overwrite: false });
return mod;
};