NPM Package Reference

Everything the package has to offer.

#   Constructor

const electrolytic = Electrolytic(options) where options is an object expected with following keys:

Returns: A new electrolytic instance

KeyTypeRequired?DefaultDescription
appKeyStringYes<empty>The Key for your app that can obtained from the dashboard.
envStringNoproductionYou can, optionally, define the environment your app is running in to differentiate between test and production users and analytics.

#   electrolytic

An electrolytic instance returned by the contructor has following methods:

following properties:

and emits following events:

#   electrolytic.on()

You can use this method to attach a listener for the events emitted by the SDK.

Signature: .on(eventName, listener)

Returns: current electrolytic instance

KeyTypeRequired?DefaultDescription
eventNameStringYesundefinedProvide the name of the events from the ones emitted by the SDK
listenerFunctionYesundefinedCallback 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)
      

#   electrolytic.off()

To remove a listener attached by the .on() method

Signature: .off(eventName, listener)

Returns: current electrolytic instance

KeyTypeRequired?DefaultDescription
eventNameStringYesundefinedThe name of the events from the ones emitted by the SDK
listenerFunctionYesundefinedCallback 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)
      

#   electrolytic.analytics

This property has the following methods related to the analytics

#   electrolytic.analytics.enable()

electrolytic.analytics.enable(true)
      

Use this method to enable or disable analytics reporting.

Signature: .analytics.enable(flag)

Returns: .analytics

KeyTypeRequired?DefaultDescription
flagBooleanYesfalseThe flag indicates whether to report analytics for current instance or not.

#   electrolytic.analytics.use()

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

#   electrolytic.analytics.report()

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

#   electrolytic.configs

This property, currently, has only one method related to the configs

#   electrolytic.configs.get()

As the name suggests, to retrieve a or all configs

Signature: .config.get([configID])

#   electrolytic token

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

#   electrolytic push

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.

#   electrolytic config

Emitted when you change a config from our dashboard.

Emit Signature: listener(configObject) - Where configObject has the updated data.

#   electrolytic configObject

{
  "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.