Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with bento.V1.track: realFetch.call is not a function #4

Closed
ashleemboyer opened this issue May 16, 2024 · 1 comment · Fixed by #5
Closed

Error with bento.V1.track: realFetch.call is not a function #4

ashleemboyer opened this issue May 16, 2024 · 1 comment · Fixed by #5

Comments

@ashleemboyer
Copy link

I reported this in the Discord on May 5th, and creating an issue as requested. 😊

When attempting to use this sdk in a Next.js Server Action passed into a <form> (related docs), I get a realFetch.call is not a function error.

Here's the code:

'use server';

import { Analytics } from '@bentonow/bento-node-sdk';

const bento = new Analytics({
  authentication: {
    publishableKey: process.env.BENTO_PUBLISHABLE_KEY,
    secretKey: process.env.BENTO_SECRET_KEY,
  },
  logErrors: false,
  siteUuid: process.env.BENTO_SITE_UUID,
});

const submitFormAction = async (formData: FormData) => {
  await bento.V1.track({
    type: 'test-node-sdk',
    email: '[email protected]',
    fields: {},
  })
    .then((res) => {
      console.log('RESULT', res);
    })
    .catch((err) => {
      console.log('ERROR', err);
    });
};

Here's the trace from the track call:

ERROR TypeError: realFetch.call is not a function
    at module.exports (webpack-internal:///(action-browser)/./node_modules/isomorphic-fetch/fetch-npm-node.js:8:19)
    at eval (webpack-internal:///(action-browser)/./node_modules/@bentonow/bento-node-sdk/dist/bento-node-sdk.esm.js:1357:62)
    at new Promise (<anonymous>)
    at BentoClient.post (webpack-internal:///(action-browser)/./node_modules/@bentonow/bento-node-sdk/dist/bento-node-sdk.esm.js:1354:12)
    at BentoBatch._callee2$
    at tryCatch
    at Generator.invoke [as _invoke]
    at Generator.eval [as next]
    at asyncGeneratorStep
    at _next
    at eval
    at new Promise (<anonymous>)
    at BentoBatch.eval
    at BentoBatch.importEvents
    at BentoAPIV1._callee6$
    at tryCatch
    at Generator.invoke [as _invoke]
    at Generator.eval [as next]
    at asyncGeneratorStep
    at _next
    at eval
    at new Promise (<anonymous>)
    at BentoAPIV1.eval
    at BentoAPIV1.track

This is an issue with breadcrumbs for fixing: matthew-andrews/isomorphic-fetch#194

@jessehanley
Copy link
Collaborator

@ashleemboyer the wonderful @connorlindsey has fixed this for ya!

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

Successfully merging a pull request may close this issue.

2 participants