![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@deriv-com/analytics
Advanced tools
The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack.
@deriv-com/analytics
The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack and GrowthBook.
In this document
Cross-project, connected user tracking events with A/B testing features
To install the package, run the following command:
$ npm i @deriv-com/analytics
To proper initialisation of the package, pass proper keys in special function in special for init functions place:
Analytics?.initialise({
growthbookKey: process.env.GROWTHBOOK_CLIENT_KEY, // optional key to enable A/B tests
growthbookDecryptionKey: process.env.GROWTHBOOK_DECRYPTION_KEY, // optional key to enable A/B tests
// mandatory key to enable userevent tracking
rudderstackKey: RUDDERSTACK_KEY,
growthbookOptions: {
// optional options for overriding growthbook default options
// if you want e.g
antiFlicker: false,
navigateDelay: 0,
antiFlickerTimeout: 3500,
subscribeToChanges: true,
enableDevMode: window?.location.hostname.includes('localhost'),
trackingCallback: (experiment, result) => {
console.log('Tracking callback', experiment, result)
}
navigate: (url) => window.location.href = url,
}
})
To make good strategy for A/B testing we need to create some condition depends on data:
Analytics?.setAttributes({
user_language: getLanguage(),
device_language: navigator?.language,
country: this.country,
})
And you finally can use the tracking events and A/B testing features
To start using it, let's observe on SDK usage examples:
import { Analytics } from '@deriv-com/analytics';
// Tracking features:
Analytics?.identifyEvent() // inentify the user
Analytics?.pageView() // track that page is showed for user
const user_id = Analytics?.getId() // get an user anon or real id
// Track Event
Analytics?.trackEvent('ce_virtual_signup_form', {
action: 'open',
form_name: 'default_diel_deriv',
form_source: document?.referrer,
signup_provider: 'email',
})
// the same as example below, to not to add repetable properties again and again
const analytics_data: Parameters<typeof Analytics.trackEvent>[1] = {
form_name: 'default_diel_deriv',
}
Analytics?.trackEvent('ce_virtual_signup_form', {
action: 'open',
signup_provider: 'email',
...analytics_data
})
Analytics?.trackEvent('ce_virtual_signup_form', {
action: 'close',
signup_provider: 'google',
...analytics_data
})
// A/B testing features
const test_toggle_aa_test = Analytics?.getFeatureState('test-toggle-aa-test') // returns value of experiment
const common_test = Analytics?.getFeatureValue('common-test', 'fallback') // returns feature flag's boolen
If you need to get entire instance directly:
const { ab, tracking } = Analytics?.getInstances()
If you want to check your ID
window.getMyId()
FAQs
The analytics package contains all the utility functions used for tracking user events and sending them to the respective platform such as Rudderstack.
The npm package @deriv-com/analytics receives a total of 3,614 weekly downloads. As such, @deriv-com/analytics popularity was classified as popular.
We found that @deriv-com/analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.