Skip to content

Commit

Permalink
Merge pull request #202 from bmourat/fix/allow-null-properties
Browse files Browse the repository at this point in the history
Allow omitting properties in trackEvent call
  • Loading branch information
dhei authored Dec 20, 2017
2 parents 5a35da9 + aae6419 commit bdab91c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions TestApp/AnalyticsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export default class AnalyticsScreen extends React.Component {
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Event without properties')}>
<Text style={SharedStyles.button}>
Track Event without properties
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Button press', { propertyValueTooLong: '12345678901234567890123456789012345678901234567890123456789012345' })}>
<Text style={SharedStyles.button}>
Track Event - event property value truncated after 64 characters
Expand Down
6 changes: 6 additions & 0 deletions TestApp34/AnalyticsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export default class AnalyticsScreen extends React.Component {
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Event without properties')}>
<Text style={SharedStyles.button}>
Track Event without properties
</Text>
</TouchableOpacity>

<TouchableOpacity onPress={() => Analytics.trackEvent('Button press', { propertyValueTooLong: '12345678901234567890123456789012345678901234567890123456789012345' })}>
<Text style={SharedStyles.button}>
Track Event - event property value truncated after 64 characters
Expand Down
5 changes: 4 additions & 1 deletion appcenter-analytics/Analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ module.exports = {
}
};

function sanitizeProperties(props) {
function sanitizeProperties(props = null) {
// Only string:string mappings are supported currently.

const result = {};
if (props === null) {
return result;
}
Object.keys(props).forEach((key) => {
switch (typeof props[key]) {
case 'string':
Expand Down

0 comments on commit bdab91c

Please sign in to comment.