Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

FR: nop when reporting usage for known, but non-metered feature #206

@isaacs

Description

@isaacs

What are you trying to do?

If you push a model like this:

{
  "plans": {
    "plan:x@1": {
      "title": "plan:x@1",
      "features": {
        "feature:x": {
          "title": "only this"
        }
      }
    }
  }
}

then the result is a feature that's not reportable, as if it had "base": 0 set on the feature.

It'd be more explicit/clear if tier pull would present it this way, so every feature has exactly one of either base or tiers.

How should we solve this?

Add "base": 0 in tier pull if the feature definition doesn't have tiers or a base price.

What is the impact of not solving this?

Not much, really. Just means that it's a little less explicit/clear what kind of feature is created by default. Ie, should "feature:x": {} be treated as {"base":0} or {"tiers":[{}]}? (Both are unlimited and free, but only the second is valid for tier report.)

Anything else?

It might be worth considering treating "feature:x":{} as {"tiers":[{}]} instead of {"base":0}, just to avoid the footgun of creating an unlimited feature that isn't a valid argument for tier report.

Additionally, it'd be nice if /v1/limits reported somehow whether a feature is metered or not, so that the SDK can prevent someone from using tier.report(). As it is now, a {"base":n} feature returns usage: [ { feature: 'feature:x', used: 1, limit: 9223372036854776000 } ] from the /v1/limits call, so it looks like tier.report() should work fine.

Alternatively, perhaps tier.report() should just no-op if a feature isn't metered (since usage is unlimited anyway?) but that feels like it might open the door for some confusing behavior.

Metadata

Metadata

Assignees

Labels

frFeature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions