Skip to content

Commit

Permalink
feat(analytics-core): add telemetry plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmartDOTin committed Feb 15, 2024
1 parent 2730e59 commit 5c5dfa1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/analytics-core/src/telemetry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import AvAnalyticsPlugin from './plugin';

declare class AvTelemetryAnalytics extends AvAnalyticsPlugin {
constructor(AvLogMessages: any, enabled?: boolean);

trackEvent(properties: any): any;

trackPageView(url: string): any;
}

export default AvTelemetryAnalytics;
17 changes: 17 additions & 0 deletions packages/analytics-core/src/telemetry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import AvAnalyticsPlugin from './plugin';

export default class AvTelemetryAnalytics extends AvAnalyticsPlugin {
constructor(AvLogMessages, enabled) {
super(enabled);
this.AvLogMessages = AvLogMessages;
}

trackEvent(properties) {
properties.telemetryBody.level = properties.telemetryBody.level || 'info';
return this.AvLogMessages[properties.telemetryBody.level](properties);
}

trackPageView(url) {
return this.trackEvent({ telemetryBody: { entries: { event: 'page', label: url } } });
}
}

0 comments on commit 5c5dfa1

Please sign in to comment.