Everything the package has to offer.
const electrolytic = Electrolytic(options) where options is an object expected with following keys:
Returns: A new electrolytic instance
| Key | Type | Required? | Default | Description |
|---|---|---|---|---|
appKey | String | Yes | <empty> | The Key for your app that can obtained from the dashboard. |
env | String | No | production | You can, optionally, define the environment your app is running in to differentiate between test and production users and analytics. |
An electrolytic instance returned by the contructor has following methods:
following properties:
and emits following events:
You can use this method to attach a listener for the events emitted by the SDK.
Signature: .on(eventName, listener)
Returns: current electrolytic instance
| Key | Type | Required? | Default | Description |
|---|---|---|---|---|
eventName | String | Yes | undefined | Provide the name of the events from the ones emitted by the SDK |
listener | Function | Yes | undefined | Callback function that should be called when that event is triggered |
Example listener
const myListener = (token) => {
// got new token for the user
}
electrolytic.on('token', myListener)
To remove a listener attached by the .on() method
Signature: .off(eventName, listener)
Returns: current electrolytic instance
| Key | Type | Required? | Default | Description |
|---|---|---|---|---|
eventName | String | Yes | undefined | The name of the events from the ones emitted by the SDK |
listener | Function | Yes | undefined | Callback function that needs to be removed |
Example of removing a listener
// pass the exact listener function to .off that was used in .on
electrolytic.off('token', myListener)
This property has the following methods related to the analytics
electrolytic.analytics.enable(true)
Use this method to enable or disable analytics reporting.
Signature: .analytics.enable(flag)
Returns: .analytics
| Key | Type | Required? | Default | Description |
|---|---|---|---|---|
flag | Boolean | Yes | false | The flag indicates whether to report analytics for current instance or not. |
const { app } = electron
electrolytic.analytics.use(app)
This method expects an instance of Electron App to retrieve version and name of current app at runtime. The name and version of app is then displayed in analytics. We strongly recommend you use this method.
Signature: .analytics.use(electronApp)
Returns: .analytics
You need to explicitly call this method, ideally during launch, or whenenver you want Electrolytic to send analytics data to its servers. It's called internally, if the feature is enabled, whenever there's a new token.
Signature: .analytics.report()
Returns: .analytics
This property, currently, has only one method related to the configs
As the name suggests, to retrieve a or all configs
Signature: .config.get([configID])
Emitted when the SDK has received a new token for the current app instance/user. You must send this token to your server because it's needed to send a push notification.
Emit Signature: listener(token) - Where token is a 32-character string
Emitted when you send a push notification from your server for any token.
Emit Signature: listener(payload) - Where payload is the data you sent from your server.
Emitted when you change a config from our dashboard.
Emit Signature: listener(configObject) - Where configObject has the updated data.
{
"id": "mdsome3u48hkajdo93",
"name": "first config",
"version": 2,
"config": {
"my": "value",
"another": "value here"
}
}
For any issues, suggestions or questions regarding the docs, please use this repo.