Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow omitting properties in trackEvent call #202

Merged
merged 2 commits into from
Dec 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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