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: Use dub.customer.list to issue dual-sided incentives #18452

Merged
merged 21 commits into from
Jan 17, 2025

Conversation

steven-tey
Copy link
Contributor

@steven-tey steven-tey commented Jan 3, 2025

What does this PR do?

This PR uses Dub's customer.list API to get the corresponding discount code for a referred user (if it exists).

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Test the Stripe checkout flow to make sure everything runs as expected.

Copy link

vercel bot commented Jan 3, 2025

@steven-tey is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot requested a review from a team January 3, 2025 06:30
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jan 3, 2025
@graphite-app graphite-app bot requested a review from a team January 3, 2025 06:30
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "[FEAT] Use dub.customer to issue dual-sided incentives". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@dosubot dosubot bot added the ✨ feature New feature or request label Jan 3, 2025
Copy link

graphite-app bot commented Jan 3, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (01/03/25)

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

"Add foundation team as reviewer" took an action on this PR • (01/03/25)

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

"Add community label" took an action on this PR • (01/03/25)

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

@steven-tey steven-tey marked this pull request as draft January 3, 2025 06:47
@steven-tey steven-tey changed the title [FEAT] Use dub.customer to issue dual-sided incentives feat: Use dub.customer to issue dual-sided incentives Jan 3, 2025
yarn.lock Outdated Show resolved Hide resolved
@steven-tey steven-tey marked this pull request as ready for review January 3, 2025 17:46
@steven-tey steven-tey changed the title feat: Use dub.customer to issue dual-sided incentives feat: Use dub.customer.list to issue dual-sided incentives Jan 3, 2025
Copy link
Contributor

github-actions bot commented Jan 3, 2025

E2E results are ready!

Copy link
Contributor

@Praashh Praashh left a comment

Choose a reason for hiding this comment

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

LGTM!, waiting for @zomars and @sean-brydon to review it 🙏 .

Copy link

socket-security bot commented Jan 4, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@PeerRich PeerRich requested a review from zomars January 7, 2025 07:38
Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

LGTM

@zomars zomars enabled auto-merge (squash) January 7, 2025 17:55
zomars
zomars previously requested changes Jan 7, 2025
Copy link
Member

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Seems like we have some failures:

Expand logs

Duplicate value found in common.json keys:   weekly and bookerlayout_week_view
Duplicate value found in common.json keys:   already_have_account and already_have_an_account
Duplicate value found in common.json keys:   timezone_variable and timezone
Duplicate value found in common.json keys:   scheduling_for_your_team and workflow_automation
Duplicate value found in common.json keys:   oauth_form_title and oAuth_client_creation_form
Duplicate value found in common.json keys:   oauth_form_description and oAuth_client_creation_form_description
Duplicate value found in common.json keys:   saml_sso and saml_config
Duplicate value found in common.json keys:   advanced_managed_events_description and unified_billing_description
Duplicate value found in common.json keys:   org_admin_no_slots|heading and org_admin_no_slots|subject
Duplicate value found in common.json keys:   email_team_invite|subject|invited_to_subteam and user_invited_you_to_subteam
Duplicate value found in common.json keys:   email_team_invite|heading|invited_to_regular_team and email_no_user_invite_heading_team
Duplicate value found in common.json keys:   email_team_invite|content|invited_to_regular_team and email_user_invite_subheading_team
Duplicate value found in common.json keys:   create_an_out_of_office and ooo_create_entry_modal
Duplicate value found in common.json keys:   always and always_requires_confirmation
Duplicate value found in common.json keys:   attendee_timezone_info and attendee_timezone_variable
Duplicate value found in common.json keys:   event_start_time_in_attendee_timezone_info and event_start_time_in_attendee_timezone_variable
Duplicate value found in common.json keys:   event_end_time_in_attendee_timezone_info and event_end_time_in_attendee_timezone_variable
(node:7632) [DEP0128] DeprecationWarning: Invalid 'main' field in '/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/billing/package.json' of './index.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)

Error: require() of ES Module /home/runner/actions-runner/_work/***.com/***.com/node_modules/dub/dist/commonjs/index.js from /home/runner/actions-runner/_work/***.com/***.com/packages/features/auth/lib/dub.ts not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/runner/actions-runner/_work/***.com/***.com/node_modules/dub/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).


   at packages/features/auth/lib/dub.ts:7

   5 | });
   6 |
>  7 | // fetch Dub customer using their external ID (ID in our database)
     |            ^
   8 | export const getDubCustomer = async (userId: string) => {
   9 |   if (!process.env.DUB_API_KEY) {
  10 |     return null;

    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/auth/lib/dub.ts:7:12)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/workflows/lib/reminders/utils.ts:7:12)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/workflows/lib/reminders/smsReminderManager.ts:8:14)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/lib/server/repository/workflow.ts:9:27)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/teams/lib/deleteWorkflowRemindersOfRemovedMember.ts:7:17)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/teams/lib/removeMember.ts:11:47)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/lib/server/repository/team.ts:12:44)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/lib/server/queries/teams/index.ts:20:13)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/packages/features/ee/sso/lib/saml.ts:8:14)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)
    at Object.<anonymous> (/home/runner/actions-runner/_work/***.com/***.com/apps/web/playwright/saml.e2e.ts:4:13)
    at mod.require (/home/runner/actions-runner/_work/***.com/***.com/node_modules/next/dist/server/require-hook.js:64:28)


Error: Process completed with exit code 1.

auto-merge was automatically disabled January 7, 2025 23:55

Head branch was pushed to by a user without write access

@steven-tey
Copy link
Contributor Author

@zomars I removed the comment, let's see if it works now

@zomars
Copy link
Member

zomars commented Jan 7, 2025

I don't think it's because the comment. But we'll see...

@PeerRich PeerRich dismissed zomars’s stale review January 8, 2025 16:50

rereview pls

@steven-tey steven-tey requested a review from zomars January 9, 2025 01:17
zomars
zomars previously approved these changes Jan 13, 2025
@emrysal
Copy link
Contributor

emrysal commented Jan 13, 2025

@steven-tey Probably best to focus on the createMany PR first as that kind-off builds on this; but that PR has some build issues with regards to CommonJS - I expect this one has also (but doesn't get to that stage as there are still type errors) - the other PR fixes the type errors in this PR - drafting.

@emrysal emrysal marked this pull request as draft January 13, 2025 19:31
@steven-tey steven-tey marked this pull request as ready for review January 17, 2025 16:19
@dosubot dosubot bot added the api area: API, enterprise API, access token, OAuth label Jan 17, 2025
@emrysal emrysal enabled auto-merge (squash) January 17, 2025 21:13
@emrysal emrysal merged commit f411c6e into calcom:main Jan 17, 2025
70 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth community Created by Linear-GitHub Sync ✨ feature New feature or request ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants