@slnka/compat-mixpanel
v1.0.0-beta.1
Published
Drop-in replacement for Mixpanel JS SDK - sovereign analytics for LinkSouverain.ma
Maintainers
Readme
@slnka/compat-mixpanel
Drop-in replacement for the Mixpanel JS SDK that routes all analytics data to the SLNK sovereign platform.
Quick Start
// Before (Mixpanel)
import mixpanel from 'mixpanel-browser';
mixpanel.init('YOUR_MIXPANEL_TOKEN');
// After (SLNK) - just change the import and token
import mixpanel from '@slnka/compat-mixpanel';
mixpanel.init('lsk_live_YOUR_KEY', { api_host: 'https://your-instance.slnk.ma' }); // api_host is requiredSupported API
mixpanel.init(token, config)- Initialize the SDKmixpanel.track(event, properties)- Track eventsmixpanel.identify(userId)- Identify usersmixpanel.alias(alias, originalId)- Create aliasesmixpanel.register(superProps)- Register super propertiesmixpanel.register_once(superProps)- Register super properties (once only)mixpanel.unregister(key)- Remove a super propertymixpanel.time_event(eventName)- Start timing an eventmixpanel.reset()- Reset identitymixpanel.get_distinct_id()- Get current distinct IDmixpanel.get_property(key)- Get a super property valuemixpanel.people.set(properties)- Set user profile propertiesmixpanel.people.set_once(properties)- Set user profile properties (once only)mixpanel.people.increment(property, by)- Increment a numeric propertymixpanel.people.append(property, value)- Append to a list propertymixpanel.people.union(property, values)- Union values to a list propertymixpanel.people.unset(properties)- Remove profile propertiesmixpanel.people.delete_user()- Delete user profilemixpanel.group.set(groupKey, groupId, properties)- Set group propertiesmixpanel.group.set_once(groupKey, groupId, properties)- Set group properties (once)mixpanel.group.union(groupKey, groupId, property, values)- Union to group listmixpanel.group.unset(groupKey, groupId, properties)- Remove group propertiesmixpanel.group.delete_group(groupKey, groupId)- Delete groupmixpanel.opt_in_tracking()- Grant consent (CNDP)mixpanel.opt_out_tracking()- Revoke consent (CNDP)
Dual-Write Mode
During migration, send events to both SLNK and Mixpanel simultaneously:
mixpanel.init('lsk_live_YOUR_KEY', {
dual_write: true,
mixpanel_token: 'YOUR_MIXPANEL_TOKEN',
});CNDP Compliance
By default, the SDK operates in CNDP-compliant mode (Law 09-08). No events are sent until consent is granted:
// User grants consent
mixpanel.opt_in_tracking();
// User revokes consent
mixpanel.opt_out_tracking();