Skip to content

Commit 21e51c0

Browse files
committed
Added a warning log when trackEvent is called with invalid parameters
1 parent 69a994a commit 21e51c0

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.2
2+
3+
- Added a warning log when trackEvent is called with invalid parameters
4+
15
## 0.3.1
26

37
- Fixed an issue where the `appBuildNumber` would sometimes be sent as a number instead of a string

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function Counter() {
5757
}
5858
```
5959

60-
**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.
60+
**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.
6161

6262
A few important notes:
6363

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aptabase/react-native",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"private": false,
55
"description": "React Native SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
66
"sideEffects": false,

src/track.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,15 @@ export function trackEvent(
5151
eventName: string,
5252
props?: Record<string, string | number | boolean>
5353
) {
54+
if (!!props && !isPlainObject(props)) {
55+
console.warn(
56+
`Aptabase: trackEvent was called with invalid properties. The second parameter must be an object.`
57+
);
58+
return;
59+
}
60+
5461
_client?.trackEvent(eventName, props);
5562
}
63+
64+
const isPlainObject = (val: any) =>
65+
typeof val === "object" && val.constructor === Object;

0 commit comments

Comments
 (0)