Comments (1)
Hey @MaxInMoon, you can wrap this with your own wrapper object, and make sure to use that object everywhere. That's what we do in our production app as well.
import RNAmplitute from 'react-native-amplitude-analytics';
module.exports = { // cached singleton instance
instance: null,
getInstance(key, eventPrefix) {
if (this.instance != null) {
return this.instance;
}
if (key) {
return this.create(key, true, eventPrefix);
}
throw new Error('Found no Amplitude instance, please specify a key. Either run .getInstance(key) or .create(key).');
},
create(key, eventPrefix, trackEvents = true) {
if (this.instance === null) {
const amplitude = new RNAmplitute(key, trackEvents, eventPrefix);
this.instance = amplitude;
}
return this.instance;
},
};
Then you could use it like so:
Analytics.getInstance().logEvent(...);
from react-native-amplitude-analytics.
Related Issues (20)
- 'Amplitude.h' file not found HOT 11
- NPM install / setUserPropertyOnce is not a function HOT 2
- hard coded buildToolsVersion causing warning after upgrading to RN 0.57 HOT 1
- Updating Amplitude SDK to 4.3.1 ? HOT 2
- convertArrayToJson is missing on Android HOT 4
- Add append and prepend methods HOT 4
- Trouble building the app HOT 11
- Ошибка сборки кастомного presenter HOT 3
- TypeScript typings HOT 1
- [iOS] Not finding Amplitude-iOS SDK when building with manual SDK HOT 9
- Doubt about pod install in iOS HOT 3
- [Android] com.amplitude.api.AmplitudeClient: Invalid API key, make sure your API key is correct in initialize() HOT 3
- 0.60.x problems on Android HOT 2
- [Question]: How do I disable IDFA HOT 6
- Add setSessionId method HOT 3
- [Question] Initialization in several components HOT 2
- Support TrackLocation HOT 1
- Raw SQL queries used for SQLLite database HOT 1
- Deprecate this repository in favor of @amplitude/react-native
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-amplitude-analytics.