Idea
By default, Devolens already logs events when your users verify licenses or when other license-related actions are performed. This information, on its own, can already be used to understand usage trends (e.g. how much time they spend using your software) and to answer business related queries (e.g. how many of the seats are consumed and if there are any overages). If you would like to get better insights into how your users use your software, for example, which features are popular, you can use Devolens’ event tracking feature. A summary of the results is available in the Feature Usage dashboard, currently in preview.Implementation
In the app
To register an event, you can call the AI.RegisterEvent method. SupplyFeatureName and EventName to describe the activity, and include ProductId and Key so the license contributes to Licenses using this feature in the dashboard. Always supply ProductId when using Key, even if you have only one product.
MachineCode is optional. Events without a license still contribute to event totals, but a machine code alone does not contribute to the reporting-license count.
The code snippet below records that a user started the YearReportGenerator module. Replace the access token, product ID and license key with your own values.
Integration with payment providers
In order to track transactions, we can use the same AI.RegisterEvent method, but supply different set of parameters. To record the value, we can use the parametersValue and Currency. This can either be accomplished by calling the Web API directly or AI.RegisterEvent method (in case your backend is in .NET).
Let’s assume your customer has paid 30 USD for the product. Represent the amount in cents as Value=3000:
ProductId, FeatureName and Key if you want those associations. The Feature Usage dashboard counts recorded events; it does not summarize Value or calculate revenue.
FAQ
How Can I Retry Without Counting an Event Twice?
How Can I Retry Without Counting an Event Twice?
Supply an optional Generate your own GUID instead of reusing the example. An identical retry returns
ClientEventId through the Web API. Generate a new non-empty GUID for each event and retain it with the event until delivery succeeds. Reuse that GUID and the same details after a timeout. SDK versions that do not expose this parameter can use the Web API directly.For example, send this JSON body to POST https://api.cryptolens.io/api/ai/RegisterEvent:{"result":0,"message":""} without adding a row while the original event is retained. Changed details with the same ID return an error. Null and empty strings are equivalent; other text must match exactly. Automatically assigned timestamps and request IP are not compared; an explicitly supplied event time must match.For RegisterEvents, put a separate ClientEventId in each object in the Events JSON array. A conflicting ID or invalid event prevents all new events in that batch from being recorded. Requests without IDs record events again on each successful retry.How Can I Retrieve Recorded Events?
How Can I Retrieve Recorded Events?
Use Get Events with an access token that has GetEvents permission. Results include
Time (when the event happened), ReceivedUtc (when it first reached the server), and ClientEventId when supplied. Both timestamps use Unix seconds. Event IDs and pagination cursors are 64-bit integers.The default page size is 10 and the maximum is 100. To start with the latest recorded rows, set NewestFirst=true and omit the cursors on the first request. Use the last returned event ID as StartingAfter for the next page, keeping NewestFirst=true and the same filters. This sorts by descending ID, not occurrence time; an event can be submitted with an earlier Time. The direct API defaults to ascending ID order when NewestFirst is omitted. EndingBefore always selects lower IDs descending and takes precedence over StartingAfter.If you are upgrading from the previous event history, reset saved cursors: the new history starts fresh and does not include previous events. Subscription eligibility and access-token product/key restrictions still apply.How Can I Retrieve Daily Feature Usage Summaries?
How Can I Retrieve Daily Feature Usage Summaries?
Use Get Daily Feature Usage with an access token that has Usage Analytics permission. It supports GET and POST and returns one row per UTC date, product, feature name, event name and license, with an event count and first/last activity times.Each row includes
KeyId, the global license ID, and Key, the current license key string. Key is empty when there is no associated license or it is no longer available to your account. Historical IDs and counts remain available; use KeyId to count distinct reporting licenses.Filter by ProductId, KeyId or Key, FeatureName, EventName, and inclusive Start/End dates in yyyy-MM-dd format. Supplying Key also requires ProductId. Feature and event names match exactly, including case and whitespace. The default page size is 100, with a maximum of 1000; use the last returned row ID as StartingAfter for the next page.Recent events may take several minutes to appear, and late events can update earlier daily rows. Re-query the date range when refreshing a report: row IDs are pagination cursors, not a way to detect updated counts. To calculate reporting licenses over several days or features, count distinct non-null KeyId values across all matching rows.Set NewestFirst=true to start at the highest summary row IDs, then continue with the last ID as StartingAfter while retaining that setting. The direct API defaults to ascending order. Summary IDs reflect row creation, not the most recent activity or update, so use Start and End for recent activity dates.