Skip to content

Conversation

@TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Apr 17, 2025

Changes

  • Send usage events to Lago
    I kept the original implementation from Thomas that allows multiple clients, which can be handy if we ever want to do some integration tests.

  • Only send metrics for paying accounts
    Lago does not reject the events, but we just we to start small

🧪 Tests

  • Go to Lago
  • Create a customer and assign a plan with the external id = account_id
  • Modify .env
LAGO_API_KEY=SHH
FLAG_USAGE_ENABLED=true
  • Trigger an action
  • ??
  • Profit

@linear
Copy link

linear bot commented Apr 17, 2025

@gitguardian
Copy link

gitguardian bot commented Apr 22, 2025

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
16627964 Triggered Username Password 2866989 packages/shared/lib/utils/utils.unit.test.ts View secret
16627965 Triggered Generic Password 2866989 packages/shared/lib/utils/utils.unit.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@bodinsamuel bodinsamuel changed the title feat: POC lago feat: billing with Lago Apr 22, 2025
@bodinsamuel
Copy link
Contributor

Tested the query plan
Before

Screenshot 2025-04-22 at 17 45 13

After
Screenshot 2025-04-22 at 17 03 19

@bodinsamuel bodinsamuel marked this pull request as ready for review April 22, 2025 15:46
@bodinsamuel bodinsamuel self-assigned this Apr 22, 2025
@bodinsamuel bodinsamuel requested a review from a team April 22, 2025 15:47
Copy link
Contributor

@kaposke kaposke left a comment

Choose a reason for hiding this comment

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

Can I get an invite to lago?

Copy link
Collaborator Author

@TBonnin TBonnin left a comment

Choose a reason for hiding this comment

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

made a few tiny comments. lgtm otherwise

report(e);
return Err(e);
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would retry certain errors here like network ones for instance? wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added

const month = referenceDate.getUTCMonth() + 1; // js months are 0-based

const res = await db.readOnly
const q = db.readOnly
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can await the query directly. I think it is a leftover of some early-on debugging

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really mind having it, sometimes its handy but yeah let's change

@TBonnin
Copy link
Collaborator Author

TBonnin commented Apr 23, 2025

made a few tiny comments. lgtm otherwise

I cannot approved my own PR @bodinsamuel so feel free to merge once you have addressed the comments

@bodinsamuel bodinsamuel enabled auto-merge (squash) April 23, 2025 17:19
@bodinsamuel bodinsamuel merged commit 8e06f46 into master Apr 23, 2025
16 checks passed
@bodinsamuel bodinsamuel deleted the tbonnin/NAN-3001/lago-poc branch April 23, 2025 17:20
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.

4 participants