Both entries have the same version. A web bundle that imports the main entry never holds the server entry.
Send events
1
Install
2
Create the client
Pass your public key. The client refuses a secret key.
3
Identify and track
Call
identify when you know who the person is, and track when something happens. Name events object.action in lower case; Events lists the fields each call takes.4
Forget the person on sign-out
Call
reset() when someone logs out. It forgets the person and starts a new anonymous id.require() on that version. Browsers need nothing extra.
Identity token
When your workspace’s identity verification is on, a call that names a person needs a token your server signs for that person. Give the SDK the token and it sends it for you. Identity verification shows how to sign one.@maqetin/sdk-js newer than 0.2.0.
- The SDK sends the token in the
Maqetin-Identity-Tokenheader with each batch that names its person, never in the events. A batch holds one person’s calls, or anonymous calls only. - It keeps the token in memory only. After a page load it has the person but no token, so it asks
onIdentityTokenExpiringbefore it sends that person’s calls. - It asks 60 seconds before
exp(or at half the time left, for a shorter token), when there is none, and when the gateway refuses one. Return the token, a promise of it, or nothing and callsetIdentityTokenlater. - A refused batch is kept, in order, and sent again with the same message ids when a different token for that person arrives. After
maxRetriesmore refused tokens in a row the calls are dropped and reported toonErrorwith the kindidentity. With noonIdentityTokenExpiring, a refused token drops its batch at once. identifywith a token for another person, or a value that is not a JWT withsubandexp, is refused and reported.reset()forgets the token.- A
trackwithoptions.userIdfor another person goes without a token.
Methods
Good to know:
- The client sends a page view when it starts and when a single-page app moves to a new path (
pushState,replaceState, back and forward). A change of the query string or the fragment alone is not a new page. SetautoPageViews: falseto send page views yourself withpage(). - The first view is sent when the client starts, so its
titlecan be empty if you load the SDK in<head>. Thereferreris the page the visitor came from when the site loaded; in a single-page app it stays the same between routes, because the browser does not change it. - A call is fixed when you make it. Changing the
propertiesobject aftertrackdoes not change the event. - Queued calls are sent when the page closes or goes to the background (
pagehideandvisibilitychange).
Options
Limits
When a call is dropped
Every dropped call is reported toonError as a MaqetinError. No message the SDK reports or writes holds the key; reason text that holds key text is dropped.
The SDK refuses a call alone, and reports it to
onError, when it holds a value JSON cannot hold (a cycle, a BigInt), is over 32 KiB as JSON, has a typed trait of the wrong type, or has a timestamp that is not a valid Date. The rest of its batch is sent.
Send email from your server
The message
Server options
Privacy and device storage
What the SDK collects, and every read and write it makes on the device.
Send through your own domain
Keep events flowing when a blocker list names the Maqetin host.