Skip to content

Commit

Permalink
Added a warning log when trackEvent is called with invalid parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Sep 29, 2023
1 parent 69a994a commit 21e51c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2

- Added a warning log when trackEvent is called with invalid parameters

## 0.3.1

- Fixed an issue where the `appBuildNumber` would sometimes be sent as a number instead of a string
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function Counter() {
}
```

**Note for Expo apps:** Events sent during development while running on Expo Go will not have the `App Version` property because native modules are not available in Expo Go. However, when you build your app and run it on a real device, the `App Version` property will be available. Alternatively, you can also set the `appVersion` during the `init` call so that it's available during development as well.
**Note for Expo apps:** Events sent during development while running on Expo Go will not have the `App Version` property because native modules are not available in Expo Go. However, when you build your app and run it on a real device, the `App Version` property will be available. Alternatively, you can also set the `appVersion` during the `AptabaseProvider` initialization so that it's available during development as well.

A few important notes:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aptabase/react-native",
"version": "0.3.1",
"version": "0.3.2",
"private": false,
"description": "React Native SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
"sideEffects": false,
Expand Down
10 changes: 10 additions & 0 deletions src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ export function trackEvent(
eventName: string,
props?: Record<string, string | number | boolean>
) {
if (!!props && !isPlainObject(props)) {
console.warn(
`Aptabase: trackEvent was called with invalid properties. The second parameter must be an object.`
);
return;
}

_client?.trackEvent(eventName, props);
}

const isPlainObject = (val: any) =>
typeof val === "object" && val.constructor === Object;

0 comments on commit 21e51c0

Please sign in to comment.