Closed nihiser closed 4 years ago
It looks correct to me. Did you add @amplitude/node
package as well?
Hello! having the same issue with AMP. added only @amplitude/node
Could you provide more details about this error? Like which line triggered this?
@haoliu-amp the same as here.
GET
route
Can it be this issue https://stackoverflow.com/questions/45979221/getting-typeerror-listener-argument-must-be-a-function-in-node-js ?
const client = Amplitude.init(config.amplitude.key);
client.logEvent({
event_type: "Node Event",
user_id: "Test",
});
@haoliu-amp did you do any changes to the logEvent
method recently?
maybe there has to be ||
instead of ??
. because as I understand you want to provide a default value. https://github.com/amplitude/Amplitude-Node/blob/7c83bf9e18b9675d4699d221498e8a230bc08124/packages/node/src/nodeClient.ts#L59
@MrAlekhin Which version are you using btw? Also would you mind share the stacktrace too?
@haoliu-amp
version 0.3.1
TypeError: "listener" argument must be a function
at ClientRequest.once (events.js:340:11)
at new ClientRequest (_http_client.js:174:10)
at Object.request (http.js:39:10)
at Object.request (https.js:245:15)
at NodeClient.logEvent (/Users/artem/FitCompete/fitcompete_api_v2/node_modules/@amplitude/node/dist/nodeClient.js:47:25)
at Post.findById.then (/Users/artem/FitCompete/fitcompete_api_v2/server/routes/post_routes.js:84:19)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
@MrAlekhin Thank you! Would you like to try 0.2.0 real quick to see if that version works for you?
@haoliu-amp looks like the same error 🤷♂️
TypeError: "listener" argument must be a function
at ClientRequest.once (events.js:340:11)
at new ClientRequest (_http_client.js:174:10)
at Object.request (http.js:39:10)
at Object.request (https.js:245:15)
at NodeClient.logEvent (/Users/artem/FitCompete/fitcompete_api_v2/node_modules/@amplitude/node/dist/nodeClient.js:31:25)
at Post.findById.then (/Users/artem/FitCompete/fitcompete_api_v2/server/routes/post_routes.js:84:19)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
package.lock
"@amplitude/node": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@amplitude/node/-/node-0.2.0.tgz",
"integrity": "sha512-zod9xiz7So14KyFMYu6/saSLn2iYGpkKxGvdEHOZCXau1yNb/zBcMFSb6FaxkN4sj7ZEaQMI7ATD18Z5Vuk/Mg==",
"requires": {
"tslib": "^1.9.3"
}
},
Wonder what version of node are you using? Mine is v12.16.1. It looks very similar to https://www.reddit.com/r/learnjavascript/comments/fshsy5/how_do_i_fix_typeerror_listener_argument_must_be/
+1 Having the same issue.
@MrAlekhin @nihiser @nihiser What version of node are you guys using? Look like it might be because of the node version compatibility issue.
@haoliu-amp node version 13.9 here
@mc-lovin @MrAlekhin @nihiser Hey all, I published a new version v0.3.2. Mind try it out? Thanks! https://www.npmjs.com/package/@amplitude/node
@haoliu-amp I am on node 13.5.0
. Just updated and working fine! Thanks!
TypeError: The "listener" argument must be of type Function. Received type object
My code block is nearly identical to the example:
I am in a TypeScript project and making the call in
ComponentDidMount
. Additionally, I added the@amplitude/types
package (Should update your README for that).Any assistance would be appreciated!