للبدء في Nucleus ، قم بإنشاء حساب في Nucleus والاستيلاء على معرف التطبيق ، ثم استخدم SDK لبدء تتبع الأحداث.
تحتوي هذه الحزمة على @react-native-async-storage/async-storage و @react-native-community/netinfo كتبعيات من الأقران. قم بتثبيتها أولاً إذا لم يكن لديك
yarn add @react-native-async-storage/async-storage @react-native-community/netinfo ثم تابع تثبيت nucleus-rn كحزمة NPM (موصى بها)
# with yarn
yarn add nucleus-rn import Nucleus from 'nucleus-rn' ;
Nucleus . init ( 'YOUR_APP_ID' ) ; استبدل 'YOUR_APP_ID' بالمعرف الفريد لتطبيقك. يمكنك الحصول عليها هنا.
يمكنك التحقق من الأمثلة مع أطر مختلفة هنا.
تدعم Nucleus تمرير الخيارات التالية كوسيطة ثانية إلى طريقة Nucleus.init() :
Nucleus . init ( 'APP_ID' , {
appVersion : '0.0.0' , // the version of your application
endpoint : 'wss://app.nucleus.sh' , // only option, we don't allow self hosting yet :(
disableInDev : true , // disable in development mode. We recommend not to call
// `init` method, as that will be more reliable.
debug : false , // if set to `true`, will log a bunch of things.
disableTracking : false , // will not track anything. You can also use `Nucleus.disableTracking()`.
// note that some events will still be added to the queue, so if you call
// Nucleus.enableTracking() again, they will be sent to the server.
reportInterval : 2 * 1000 , // at which interval the events are sent to the server.
sessionTimeout : 60 * 30 * 1000 , // time after which the session is ended
cutoff : 60 * 60 * 48 * 1000 , // time after which event that were not sent yet are deleted
disableErrorReports : false , // wether to disable error tracking
} )تتبع الأحداث ببيانات مخصصة اختيارية
Nucleus . track ( "click" , { foo : 'bar' } ) ;تتبع الأخطاء مع اسم وكائن الخطأ.
Nucleus . trackError ( name , error ) ; بشكل افتراضي ، تقوم Nucleus بتسجيل معالج لـ ErrorUtils.setGlobalHandler الذي يرسل أخطاء 'GlobalError' إلى واجهة برمجة التطبيقات. إذا كنت ترغب في تعطيل هذا السلوك ، فيمكنك تعيين disableErrorReports إلى true :
Nucleus . init ( 'APP_ID' , { disableErrorReports : true } ) والتقاط الأخطاء يدويًا باستخدام Nucleus.trackError('an error', errObject) .
حدد المستخدم بمعرف فريد وتعيين خصائص مخصصة اختياريًا.
Nucleus . identify ( '04f8846d-ecca-4a81-8740-f6428ceb7f7b' , { firstName : 'Jordan' , lastName : 'Walke' } ) ;تتبع طرق عرض الشاشة مع اسم الشاشة والمعلمات الاختيارية.
Nucleus . page ( '/about' , { foo : 'baz' } ) ;لتعطيل التتبع
Nucleus . disableTracking ( ) ;لتمكين التتبع
Nucleus . enableTracking ( ) ; نحن نبحث دائمًا عن مساهمات من المجتمع. إليك كيف يمكنك المساعدة: