Skip to content

Commit 72c3cb0

Browse files
committed
relocate metric recording in base.js
1 parent 26f9421 commit 72c3cb0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/subscribers/base.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,6 @@ class Subscriber {
215215
* @returns {Context} either new context or existing
216216
*/
217217
handler(data, ctx) {
218-
if (this.#usageMetricRecorded === false) {
219-
recordSupportabilityMetric({
220-
agent: this.agent,
221-
moduleName: this.packageName,
222-
moduleVersion: data.moduleVersion
223-
})
224-
this.#usageMetricRecorded = true
225-
}
226218
return ctx
227219
}
228220

@@ -246,6 +238,15 @@ class Subscriber {
246238
* @returns {Context} The context after processing the event
247239
*/
248240
const handler = (data) => {
241+
if (this.#usageMetricRecorded === false) {
242+
recordSupportabilityMetric({
243+
agent: this.agent,
244+
moduleName: this.packageName,
245+
moduleVersion: data.moduleVersion
246+
})
247+
this.#usageMetricRecorded = true
248+
}
249+
249250
// only wrap the callback if a subscriber has a callback property defined
250251
if (this.callback !== null) {
251252
this.traceCallback(this.callback, data)

0 commit comments

Comments
 (0)