@snowplow/react-native-tracker
Version:
React Native tracker for Snowplow
44 lines (42 loc) • 1.29 kB
JavaScript
;
import { APPLICATION_CONTEXT_SCHEMA, MOBILE_APPLICATION_CONTEXT_SCHEMA } from "../../constants.js";
/**
* Tracks the application context entity with information about the app version.
* If appBuild is provided, a mobile application context is tracked, otherwise the Web equivalent is tracked.
*
* Entity schema if `appBuild` property is set: `iglu:com.snowplowanalytics.mobile/application/jsonschema/1-0-0`
* Entity schema if `appBuild` property is not set: `iglu:com.snowplowanalytics.snowplow/application/jsonschema/1-0-0`
*/
export function newAppContextPlugin(_ref) {
var appVersion = _ref.appVersion,
appBuild = _ref.appBuild;
var contexts = function contexts() {
var entities = [];
if (appVersion) {
// Add application context to all events
if (appBuild) {
entities.push({
schema: MOBILE_APPLICATION_CONTEXT_SCHEMA,
data: {
version: appVersion,
build: appBuild
}
});
} else {
entities.push({
schema: APPLICATION_CONTEXT_SCHEMA,
data: {
version: appVersion
}
});
}
}
return entities;
};
return {
plugin: {
contexts: contexts
}
};
}
//# sourceMappingURL=index.js.map