algolia / search-insights-gtm

Google Tag Manager template for detecting front-end Algolia search metrics
Apache License 2.0
6 stars 5 forks source link

fix: allow number in formatValueToList #14

Closed eunjae-lee closed 2 years ago

eunjae-lee commented 2 years ago

Summary

When users send integer as variable, formatValueToList fails. This PR allows the integer value to become an array of it as-is.

This can happen when users send data via dataLayer (not via data-* attributes on the DOM).

eunjae-lee commented 2 years ago

should fix the issue encountered however in that case as we also use formatValueToList for objectIDs it may lead in some cases of an array of int while we expect an array of string. May be not an issue but we should ensure that everything works fine

@jcohonner Not sure if I get your point correctly, but formatValueToList makes an array, but tries not to do casting on its own. So we have code like this:

https://github.com/algolia/search-insights-gtm/blob/d968716363d16c0a02921331b140342e0e0c2d6b/src/template.js#L197:L198

What do you think?

jcohonner commented 2 years ago

I was just wondering what would happen is we send the ObjectID as a number instead of a string But you're right that function is just about getting the value as an array

eunjae-lee commented 2 years ago

I was just wondering what would happen is we send the ObjectID as a number instead of a string But you're right that function is just about getting the value as an array

In that specific case, the engine will turn it into a string.

eunjae-lee commented 2 years ago

@jcohonner Thanks! :)