Skip to main content
Version: 3.7.0

Native

Integration Guide

The current version only supports mini program projects developed using the official WeChat/Douyin Developer Tools.

  • For WeChat Mini Program integration: Unzip BonreeSDK_TDEM_MP_Wechat.zip and add BonreeSDK_MP_Wechat.min.js to your project.
    For Douyin Mini Program integration: Unzip BonreeSDK_TDEM_MP_Tiktok.zip and add BonreeSDK_MP_Tiktok.min.js to your project.
    The WeChat Mini Program integration is illustrated below:

image

  • For public cloud platform usage: Add the data reporting domain to the server domain whitelist in the WeChat/Douyin Mini Program Admin Console. The example shows the public cloud data reporting domain https://oneupload.bonree.com. For private deployment environments, configure the domain according to your actual deployment or contact technical support.

image

Implementation

  • Import the agent file in app.js:

    For WeChat Mini Programs:

    const BonreeSDK = require('./BonreeSDK_MP_Wechat.min.js')

    For Douyin Mini Programs:

    const BonreeSDK = require('./BonreeSDK_MP_Tiktok.min.js')
  • Initialize the mini program agent by setting the Config address and AppID in the configuration parameters:

<#Config Address#> and <#AppID#> can be obtained from the platform. Refer to How to Query AppID and Config Address? for details. Contact technical support if needed.

const BRSAgent = BonreeSDK.start({
configAddress: "<#Config Address#>",
appId: "<#AppID#>"
})
  • Export the SDK instance for use in other files:
module.exports = BRSAgent

Complete example:

// app.js
const BonreeSDK = require('./BonreeSDK_MP_Wechat.min.js') // WeChat Mini Program
// const BonreeSDK = require('./BonreeSDK_MP_Tiktok.min.js')// Douyin Mini Program

const BRSAgent = BonreeSDK.start({
configAddress: '<#Config Address#>',
appId: '<#AppID#>',
})
module.exports = BRSAgent

App({
onLaunch() {
// App launch logic
},
onShow() {
// App show logic
},
globalData: {}
})

After running, check the Network in the WeChat/Douyin Developer Tools debugger. If there is a config request result output and the rc field in the response is 10000, it indicates successful integration. The following figure shows the response result in WeChat Developer Tools:

image