ในการเริ่มต้นด้วยนิวเคลียสให้สร้างบัญชีที่นิวเคลียสและคว้ารหัสแอพจากนั้นใช้ 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.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 ) ; โดยค่าเริ่มต้นนิวเคลียสลงทะเบียนตัวจัดการสำหรับ ErrorUtils.setGlobalHandler ที่ส่งข้อผิดพลาด 'GlobalError' ไปยัง API หากคุณต้องการปิดการใช้งานพฤติกรรมนี้คุณสามารถตั้งค่า disableErrorReports เป็น true :
Nucleus . init ( 'APP_ID' , { disableErrorReports : true } ) และจับข้อผิดพลาดด้วยตนเองโดยใช้ Nucleus.trackError('an error', errObject)
ระบุผู้ใช้ด้วย ID ที่ไม่ซ้ำกันและตั้งค่าคุณสมบัติที่กำหนดเอง
Nucleus . identify ( '04f8846d-ecca-4a81-8740-f6428ceb7f7b' , { firstName : 'Jordan' , lastName : 'Walke' } ) ;ติดตามการดูหน้าจอด้วยชื่อหน้าจอและพารามิเตอร์เสริม
Nucleus . page ( '/about' , { foo : 'baz' } ) ;เพื่อปิดการติดตาม
Nucleus . disableTracking ( ) ;เพื่อเปิดใช้งานการติดตาม
Nucleus . enableTracking ( ) ; เรามักจะมองหาผลงานจากชุมชน นี่คือวิธีที่คุณสามารถช่วยได้: