@datarangers/sdk-mp
TypeScript icon, indicating that this package has built-in type declarations

2.14.4 • Public • Published

DataRangers SDK - mp

Sample

1. Initialize the SDK in app.js

const $$SDK = require('@datarangers/sdk-mp');

$$SDK.init({
  app_id: 0000, // Replace it with the "APP_ID"
  auto_report: true,
  log: true, // Whether to print the log
});

$$SDK.config({
  xxx: 'abc',
});

$$SDK.send(); // Setup complete and now events can be sent.

App({
  onLaunch: function () {
    this.$$SDK = $$SDK; // Bind to the global app function to be called by other pages.

    //……
  },
});

2. Report custom user behavior events

// Take reporting the "video clicked" behavior of users for example
app.$$SDK.event('play_video', {
  title: 'Here is the video title',
});

3. Report the unique identifier of the currently logged in user

// Set "user_unique_id" after a user logs in and the user's unique identifier is retrieved.
setTimeout(() => {
  app.$$SDK.config({
    user_unique_id: 'zhangsan', //Unique user identifier, can be "open_id".
  });
}, 1000);

Readme

Keywords

none

Package Sidebar

Install

npm i @datarangers/sdk-mp

Weekly Downloads

41

Version

2.14.4

License

MIT

Unpacked Size

2.03 MB

Total Files

143

Last publish

Collaborators

  • zlrs
  • tangseng
  • bytednpm
  • ljl_jerry
  • zqk
  • logsdk-robot