1. Property Pluginization

Version Requirements

WeChat Mini Program version 1.19.4 and above is required

Property Pluginizationis an advanced function for modifying event properties. Users can use the property pluginization function to add, modify, and delete properties for specified events (or all events).

1.1. Interface Introduction

The SDK provides the registerPropertyPlugin method, which allows the passing of a customized property plugin object to add, modify, or delete properties for specific events.

Introduction to Custom Property Plugin Objects:

Method NameDescriptionExample
properties(data)

Used for modifying properties. The data parameter is the complete data before sending.

The data includes all types of data collected by the SDK:

profile_set,

profile_set_once,

profile_append,

profile_increment,

track,

track_signup.


Enable the addition, deletion, and modification of attributes for the data to be sent in this method.


{ 	properties:function(data){ 	 // 添加 	 // data.properties.hello = 'world' 	 	 // 修改 	 // data.properties.$title = 'new title' 	 	 // 删除 	 // delete data.properties.$screen_width		 	} }
JS


isMatchedWithFilter(data)

Used to filter the data, where data is the complete data before sending.

Same as the above data, including all data types.


If this method is configured, the properties method specified in the configuration will only be executed if this method returns true.


If this method is not configured, the properties method specified in the configuration will always be executed.


{ 	isMatchedWithFilter:function(data){ 		// 筛选事件名为 $SignUp 的事件 		if(data.event === '$SignUp'){ 			return true; 		} 		// 筛选在页面标题为 home 的事件 		if(data.properties.$title === 'home'){ 			return true; 		} 		 		// 其他事件不会执行 properties 方法 		return false; 	} }
JS


1.2. Usage Example

  • Common method: Modify the $title attribute under the $MPViewScreen event name.

    sensors.registerPropertyPlugin({ isMatchedWithFilter:function(data){ 	return data.event === "$MPViewScreen"; } properties:function(data){ 	data.properties['$title'] = 'http://xxx'; } });
    JS


  • Common method: Delete the platform attribute from all events.

    sensors.registerPropertyPlugin({ isMatchedWithFilter:function(data){ 	return data.type === 'track'; } properties:function(data){ 	delete data.properties['platform']; } });
    JS


  • Note: Event filtering should be performed before modifying attributes, as data types like profiles can also be modified.

    sensors.registerPropertyPlugin({ isMatchedWithFilter:function(data){ 	return data.type.slice(0, 7) === 'profile'; } properties:function(data){ 	delete data.properties['aaa'] = 'bbb'; } });
    JS


  • Modify property values for all types of data. Note: This usage is generally incorrect and can lead to unexpected situations where all data (including profiles, etc.) is modified.

    sensors.registerPropertyPlugin({ properties:function(data){ 	data.properties['aaa'] = 'bbb'; } });
    JS


  • Filtering and property modification can also be directly performed in properties.

    sensors.registerPropertyPlugin({ properties:function(data){ 	if(data.event === '$MPViewScreen'){ 		data.properties['$title'] = 'http://xxxx'; 	} } });
    JS

2. Data encryption for event tracking.

To enhance the security of event tracking data, Sensors Analytics supports encrypting event tracking data and storing and sending it in ciphertext form.

  • Using encryption plugin on the SDK side.

Refer to plugin "encryption" for event tracking data encryption.

  • Configurations on the SDK side.
sensors.setPara({ storage_prepare_data_key:''//本地存储 key 值,字符串格式 })
JS
  • This feature requires assistance from the server to enable server-side decryption. Please contact Sensors Analytics customer success or project manager for assistance in enabling server-side decryption.
  • Notes on disabling encryption plugin:
    • When rolling back the main SDK version to a version number greater than or equal to 1.14.27, only the encryption plugin needs to be disabled.
    • When rolling back the main SDK version to a version below 1.14.27, in addition to disabling the encryption plugin, you need to modify the configuration "storage_prepare_data_key".
  • After enabling encryption, if the server does not support decryption, the data cannot be stored in the database and will be lost. There will be no error reported in the event management.

Version Requirements:

  • WeChat Mini Program SDK v1.14.27 or above
  • Edge v0.3.0 or above
  • SDF 2.3 or above

3. Support dynamic disabling/enabling of APIs

// 禁用 API 执行 sensors.disableSDK() // 恢复 API 执行 sensors.enableSDK()
CODE

Note: This must be called after initialization. For more details, refer to disableSDK.

  • This interface is only supported by WeChat Mini Program SDK.

4. Customize encryption for sent data

If you need to customize encryption for sent data, such as using custom encryption plugin