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

feat: Add framework to send all events fired for embed to Analytics Apps #15173

Conversation

hariombalhara
Copy link
Member

@hariombalhara hariombalhara commented May 23, 2024

What does this PR do?

Now, we can simply add the support of pushing any event to any analytics app by defining a pushEventScript prop in config.json. This would work for any analytics app that support sending an event with any payload.

Any event fired through sdkActionManager.fire call will reach the enabled analytic app if it has pushEventScript prop defined

  • Added support for GTM app pushEvent
  • Added 2 new events bookingSuccessfulV2 and rescheduleBookingSuccessfulV2. Also, deprecated bookingSuccessful and rescheduleBookingSuccessful
bookingSuccessfulV2: {
    uid: string | undefined;
    title: string | undefined;
    startTime: string | undefined;
    endTime: string | undefined;
    eventTypeId: number | null | undefined;
    status: string | undefined;
    paymentRequired: boolean;
  };

rescheduleBookingSuccessfulV2: {
    uid: string | undefined;
    title: string | undefined;
    startTime: string | undefined;
    endTime: string | undefined;
    eventTypeId: number | null | undefined;
    status: string | undefined;
    paymentRequired: boolean;
  };

Fixes #15168
Fixes CAL-3785

GTM dataLayer event demo

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • I have added a Docs issue here if this PR makes changes that would require a documentation change
  • I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

NOTE:
For apps like fathom which just supports _value as an event prop and recommends event name to be dynamic as well, GTM(or some other tag manager) is better suited to listen to the event and send that specific event based on the dataLayer variables.

Copy link

vercel bot commented May 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 10:17am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview May 30, 2024 10:17am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview May 30, 2024 10:17am

Copy link
Contributor

github-actions bot commented May 23, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@keithwillcode keithwillcode added consumer core area: core, team members only labels May 23, 2024
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @hariombalhara and the rest of your teammates on Graphite Graphite

@hariombalhara hariombalhara changed the title feat: Start sending all events fired for embed to Analytics Apps(GTM Support added) feat: Add framework to send all events fired for embed to Analytics Apps May 23, 2024
Copy link

linear bot commented May 23, 2024

Copy link
Contributor

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌


import type { appDataSchemas } from "./apps.schemas.generated";

const PushEventPrefix = "cal_analytics_app_";
Copy link
Member Author

@hariombalhara hariombalhara May 30, 2024

Choose a reason for hiding this comment

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

A global function is defined starting with this string for each analytics app.

@hariombalhara hariombalhara force-pushed the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch from 3e64d6c to 6a0142d Compare May 30, 2024 08:31
Comment on lines +9 to +10
startTime: string;
endTime: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

The response of a regular fetch request can't have Date as value for any prop, so we accordingly adjust the types.

@@ -2253,7 +2253,7 @@ async function handler(
req.statusCode = 201;
// TODO: Refactor better so this booking object is not passed
// all around and instead the individual fields are sent as args.
const bookingReponse = {
const bookingResponse = {
Copy link
Member Author

Choose a reason for hiding this comment

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

Typo fix.

@@ -1636,8 +1636,8 @@ async function handler(
...newBooking.user,
email: null,
},
paymentRequired: false,
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this prop to easily differentiate the case where payment is required.

@hariombalhara hariombalhara force-pushed the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch from 6a0142d to b3f3140 Compare May 30, 2024 10:04
@hariombalhara hariombalhara force-pushed the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch from b3f3140 to d48815d Compare May 30, 2024 10:05
@hariombalhara hariombalhara force-pushed the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch from d48815d to ca98c6d Compare May 30, 2024 10:12
@hariombalhara hariombalhara force-pushed the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch from ca98c6d to b67dad6 Compare May 30, 2024 10:14
@hariombalhara hariombalhara marked this pull request as ready for review May 30, 2024 10:14
@graphite-app graphite-app bot requested a review from a team May 30, 2024 10:14
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking embed area: embed, widget, react embed ✨ feature New feature or request labels May 30, 2024
@dosubot dosubot bot added this to the v4.2 milestone May 30, 2024
Copy link

graphite-app bot commented May 30, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (05/30/24)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

Code looks good 🙏

@CarinaWolli CarinaWolli added this pull request to the merge queue May 31, 2024
Merged via the queue into main with commit 1730ef7 May 31, 2024
25 checks passed
@CarinaWolli CarinaWolli deleted the 05-23-feat_start_sending_all_events_fired_for_embed_to_analytics_apps_gtm_support_added_ branch May 31, 2024 16:29
p6l-richard pushed a commit to p6l-richard/cal.com-fork that referenced this pull request Jul 22, 2024
…pps (calcom#15173)

* Send all events to analytics apps

* feat: Start sending all events fired for embed to Analytics Apps(GTM Support added)

* Add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working consumer core area: core, team members only embed area: embed, widget, react embed ✨ feature New feature or request High priority Created by Linear-GitHub Sync organizations area: organizations, orgs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CAL-3785] Analytics Apps: Track "Confirm" as an event (GTM, Fathom, etc.)
3 participants