analytics.js-core icon indicating copy to clipboard operation
analytics.js-core copied to clipboard

[TypeScript] explicitly defines call patterns for page method

Open dimitropoulos opened this issue 5 years ago • 2 comments
trafficstars

I noticed that the type for page previously required all arguments, but this doesn't match the behavior described in the tests or the library itself.

I made what is here by looking at the tests (and not the library source code) because I had quite a hard time thinking through all the combinations the library source code allows (and, after all, the tests already seem to have done that).

dimitropoulos avatar Aug 10 '20 21:08 dimitropoulos

should be all set. I will note that calling with just name is, now, the only way to call page this without a callback. Is that correct or is the callback (as a last argument) always optional?

dimitropoulos avatar Aug 13 '20 14:08 dimitropoulos

@dimitropoulos Ah, the callback is always optional. We'll definitely want the types to reflect that. From our docs

An optional function that is executed after a short timeout, giving the browser time to make outbound requests first.

This is true for any type of call (Track, Identity, etc)

bryanmikaelian avatar Aug 17 '20 15:08 bryanmikaelian