Skip to content

Conversation

jkaho
Copy link
Contributor

@jkaho jkaho commented Jul 24, 2025

Add support for the Algolia Insights API optional authenticatedUserToken field.

Add support for the Segment Product List Viewed event.

Related doc change: segmentio/segment-docs#7791

Testing

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

@joe-ayoub-segment
Copy link
Contributor

Thanks for the PR @jkaho . I'll schedule time to review.

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho I had a quick scan. Did you mean to include the file at this location? packages/browser-destinations/destinations/algolia-plugins/src/algoliaInsights/generated-types.ts

@jkaho
Copy link
Contributor Author

jkaho commented Jul 24, 2025

Thanks @joe-ayoub-segment! Sorry, I missed that–no I did not mean to include it. Removed 👍

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho please run this command and commit the changes

yarn types

@joe-ayoub-segment
Copy link
Contributor

Hi again @jkaho , I reviewed the PR.

Regarding adding the new field authenticatedUserToken:

  • Looks like this field is to capture an identifier for a user when the user is known to the customer. Does this mean that the userToken field was always intended to capture an anonymous user's anonymous identifier? because it used to try and capture the main identifier and only fell back to the anonymous one.
  • How will this change affect customers who are already sending the Segment userId (which is the id for users who are known to the customer) to the userToken field? They won't be populating the authenticatedUserToken field (so it will be undefined).
  • Are you able to provide evidence of testing this please?

Regarding the new Action:

  • I don't think the default mapping used for ObjectIds field will work. Have you tested it locally?
  • Are you able to provide evidence of testing this please?

Best regards,
Joe

@joe-ayoub-segment
Copy link
Contributor

hi again @jkaho can you please also run yarn types and commit the updated file please?

@jkaho
Copy link
Contributor Author

jkaho commented Aug 12, 2025

Hey @joe-ayoub-segment, appreciate the review!

  • We added the authenticatedUserToken field a couple of years ago now, before which the userToken field was intended to capture either the auth or anon token. The addition of the new auth field meant we changed the way we recommend users send us user identifiers, though this wasn't a breaking change. If users don't set the auth token field, we will take the value from the user token field (which is required). Again, this change was made a little while ago now and neglecting to add support for it to our Segment connector was an oversight on our part. Is there anything you would recommend in terms of documentation to mitigate potential confusion?
  • I have tested the object IDs mapping via the Actions Tester, and it does seem to map the correct values as per the highlighted portions in the screenshot below. Have I misinterpreted something here? Though, I am noticing that the input badge doesn't show in the user configuration UI..
Screenshot 2025-08-12 at 10 32 37 am

@joe-ayoub-segment
Copy link
Contributor

Hey @joe-ayoub-segment, appreciate the review!

  • We added the authenticatedUserToken field a couple of years ago now, before which the userToken field was intended to capture either the auth or anon token. The addition of the new auth field meant we changed the way we recommend users send us user identifiers, though this wasn't a breaking change. If users don't set the auth token field, we will take the value from the user token field (which is required). Again, this change was made a little while ago now and neglecting to add support for it to our Segment connector was an oversight on our part. Is there anything you would recommend in terms of documentation to mitigate potential confusion?
  • I have tested the object IDs mapping via the Actions Tester, and it does seem to map the correct values as per the highlighted portions in the screenshot below. Have I misinterpreted something here? Though, I am noticing that the input badge doesn't show in the user configuration UI..
Screenshot 2025-08-12 at 10 32 37 am

Hi @jkaho , that's correct, the 'badge' contains the mapping details the user gets to see in the UI. Our UI doesn't support this type of mapping, so while the mapping itself might work, it breaks the UI.

I suggest changing the mapping to something like this

{
        '@path': '$.properties.products.product_ids'
}

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho thanks for explaining the history of userToken and authenticatedUserToken.
I think the change is safe. i.e it will continue to work for customers who already have the Integration set up. And it will work for customers who set it up from the post deployment of this PR.

If you like, you could add a note to the Algolia Insights Integration's docs page to explain this change in a little more details.

Just add a new header and paragraph explaining what customers need to know. Our docs team will review and deploy the change.

Best regads,
Joe

@jkaho
Copy link
Contributor Author

jkaho commented Aug 14, 2025

@joe-ayoub-segment

{
       '@path': '$.properties.products.product_ids'
}

Hm, this doesn't conform to Segment's ecommerce spec though, right? I've updated the product ID mapping to be the same as the conversion events (purchase, add to cart) where we map the products object array and then apply a custom transformation after the payload is resolved. I feel like this approach might be preferable as it's consistent with our other event mappings.
Screenshot 2025-08-14 at 6 07 29 pm

Also pushed a change to the docs PR regarding the user tokens.

Let me know what you think!

@joe-ayoub-segment
Copy link
Contributor

Thanks @jkaho this looks good. Only a nit issue left. Please see the comments.
Best regards,
Joe

@jkaho
Copy link
Contributor Author

jkaho commented Aug 18, 2025

@joe-ayoub-segment thanks Joe, comments resolved. Let me know if any other changes are required.

@joe-ayoub-segment
Copy link
Contributor

Thanks @jkaho I've labelled it for deployment. I'll notify you once it's out. It might be up to 7 days, as we usually only deploy this repo weekly and we missed this week's deployment.

@jkaho
Copy link
Contributor Author

jkaho commented Aug 19, 2025

@joe-ayoub-segment is there anything for me to action with the failing CI?

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho yes looks like snapshot tests are failing. Can you run this command and commit the changes please?

yarn types

FAIL src/destinations/algolia-insights/productListViewedEvents/tests/snapshot.test.ts
● Testing snapshot for AlgoliaInsights's productListViewedEvents destination action: › required fields

  expect(received).toMatchSnapshot()

  Snapshot name: `Testing snapshot for AlgoliaInsights's productListViewedEvents destination action: required fields 1`

  - Snapshot  - 0
  + Received  + 5

  @@ -6,10 +6,15 @@
          "eventType": "view",
          "index": "lx7Lx",
          "objectIDs": Array [
            "lx7Lx",
          ],
  +       "products": Array [
  +         Object {
  +           "product_id": "lx7Lx",
  +         },
  +       ],
          "timestamp": 1674843786677,
          "userToken": "lx7Lx",
        },
      ],
    }

@jkaho
Copy link
Contributor Author

jkaho commented Aug 19, 2025

@joe-ayoub-segment ah right, sorry I missed that. Running yarn types didn't seem to change anything, but I updated the snapshot.

@jkaho
Copy link
Contributor Author

jkaho commented Aug 25, 2025

@joe-ayoub-segment if you're around, it would be awesome if we were able to get this out in the next deployment (which I believe is tomorrow?) 🙏

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho yes this has been labelled for deploy - should go out tomorrow.

@joe-ayoub-segment joe-ayoub-segment merged commit f090092 into segmentio:main Aug 25, 2025
10 of 12 checks passed
@jkaho
Copy link
Contributor Author

jkaho commented Aug 27, 2025

Hey @joe-ayoub-segment, I noticed that there was no deployment yesterday. All good but wondering when the next one is scheduled so we can communicate this to our customers who are waiting for this update. Thanks!

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho You're absolutely right, I should have messaged you. Please extend my apologies to the customer.

@joe-ayoub-segment
Copy link
Contributor

I'll roll out the change now.

@joe-ayoub-segment
Copy link
Contributor

Hi @jkaho the PR has been deployed. Please confirm you are happy with the update.

@jkaho
Copy link
Contributor Author

jkaho commented Aug 28, 2025

@joe-ayoub-segment appreciate it Joe! Looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants