Nonstop Brightscript SDK
Amplitude
The SDK performs some internal Amplitude tracking. Since the SDK is embedded inside another app, there are certain parameters which it is responsible for reporting to Amplitude but responsible for creating (e.g. Session Id) or implementing collection of the parameters is out of scope for the moment (e.g. the user's location). Therefore, the containing app will need to supply this information.
AmplitudeConfig
During Initialization of the SDK an AmplitudeConfig node must be passed to the Nonstop instance specifying:
apiKey- the Amplitude API Key the SDK should send events to (omitting this will disable Amplitude tracking)session_id- the Session ID the SDK should track it's events againstdevice_id- the Device ID the SDK should include in it's event tracking
An example of this is shown below:
function startApplication(params as Object)
? "[MainScene] startApplication"
nonstop = m.top.createChild("Nonstop")
nonstop.environment = "dev"
amplitudeConfig = createObject("roSGNode", "amplitudeConfig")
amplitudeConfig.setField("apiKey", "357ab438c26e31f044db2aab0da4d3c9")
amplitudeConfig.setField("session_id", 0)
amplitudeConfig.setField("device_id", "device_id_set")
nonstop.amplitudeConfig = amplitudeConfig
nonstop.callFunc("Initalize")
end function
AmplitudeGeoData
At any point during the application lifecycle, an AmplitudeGeoData node may be supplied to the SDK. This should contain information pertaining to the user's current location which can be sent to Amplitude. From the point this information is supplied to the SDK it will be present on all Amplitude events going forwards. If the information has not been supplied yet and the SDK tracks an event this information will simply be missing from the event.
The data required is:
country- the country the user is currently located in (e.g. Scotland)region- the region the user is currently located in (e.g. East Lothian)city- the city the user is currently located in (e.g. Edinburgh)
An example of this is shown below:
function OnGeoDataObtained(params as Object)
amplitudeGeodata = createObject("roSGNode", "amplitudeGeodata")
amplitudeGeodata.setField("country", params.country)
amplitudeGeodata.setField("region", params.region)
amplitudeGeodata.setField("city", params.city)
m.global.Nonstop.amplitudeGeodata = amplitudeGeodata
end function