Skip to content

Commit 691286f

Browse files
committed
Add console warnings for non-string type key values
1 parent a5c767a commit 691286f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/index.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ export namespace OneSignal {
440440

441441
// forces values to be string types
442442
if (typeof value !== 'string') {
443+
console.warn(
444+
'OneSignal: addTag: tag value must be of type string; attempting to convert'
445+
);
443446
value = String(value);
444447
}
445448

@@ -463,8 +466,12 @@ export namespace OneSignal {
463466

464467
const convertedTags = tags as { [key: string]: any };
465468
Object.keys(tags).forEach(function (key) {
466-
// forces values to be string types
467-
convertedTags[key] = String(convertedTags[key]);
469+
if (typeof convertedTags[key] !== 'string') {
470+
console.warn(
471+
'OneSignal: addTags: tag value for key ' + key + ' must be of type string; attempting to convert'
472+
);
473+
convertedTags[key] = String(convertedTags[key]);
474+
}
468475
});
469476

470477
RNOneSignal.addTags(tags);

0 commit comments

Comments
 (0)