Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(UVE): Add Analytics to track Mode changes and Calendar usage #31580

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

zJaaal
Copy link
Contributor

@zJaaal zJaaal commented Mar 11, 2025

WIP

@zJaaal zJaaal linked an issue Mar 11, 2025 that may be closed by this pull request
5 tasks
@zJaaal zJaaal requested review from rjvelazco and fmontes and removed request for rjvelazco March 11, 2025 16:27
@zJaaal zJaaal marked this pull request as draft March 11, 2025 16:30
#http = inject(HttpClient);
#window = inject(WINDOW);

track<T>(event: EVENT_TYPES, payload: T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we are duplicating all this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just

@Injectable({
  providedIn: 'root'
})
export class DotAnalyticsService {
   #analytics: DotAnalytics;

  constructor() {
    // Initialize analytics service with configuration
    this.analytics = initializeContentAnalytics({
      key: xxxx,
      host: dotcms
    });
  }

  /**
   * Track a custom event
   * @param eventName Name of the event to track
   * @param data Additional data for the event
   */
  trackEvent(eventName: string, data: Record<string, unknown> = {}): void {
    this.analytics.track(eventName, data);
  }
}

an use it:

@Component({
  selector: 'dot-feature',
  standalone: true,
  template: `<button (click)="onButtonClick()">See Details →</button>`
})
export class FeatureComponent {
  private readonly analyticsService = inject(DotAnalyticsService);
  
  onButtonClick(): void {
    // Track button click event with custom properties
    this.analyticsService.track('btn-click', {
      title: 'Feature Title',
      urlTitle: 'feature-title',
      section: 'main-content'
    });
  }
}

@zJaaal zJaaal force-pushed the 31521-uve-add-analytics-for-modes-and-future-time-machine-calendar branch from 0f31e9b to c5d39a9 Compare March 11, 2025 20:38
@zJaaal zJaaal marked this pull request as ready for review March 12, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ UVE: Add Analytics for "modes" and Future Time Machine Calendar
3 participants