Analytics client initialization issue
jbranson000 opened this issue · comments
Expected Behaviour
Ability to make a call using the aio-lib-analytics and establish connectivity to Analytics via that library.
Actual Behaviour
When running the code below (in the sample code), we both receive a "Swagger is not a constructor" error:
Reproduce Scenario (including but not limited to)
We can consistently reproduce the issue by calling the default sdk.init
function. Since that step is unsuccessful we cannot get any further with it.
Steps to Reproduce
We can consistently replicate this by simply loading the sample code in our sample Firefly app - we were adding it to the Home.js. The same issue happens if we load this same code in our more well-developed prototype.
Environment Info
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
Memory: 3.73 GB / 15.60 GB
Binaries:
Node: 14.16.0 - C:\Bitnami\wampstack8\apache2\node.EXE
Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.10.0 - C:\Bitnami\wampstack8\apache2\npm.CMD
Virtualization:
Docker: 20.10.5 - C:\ProgramData\DockerDesktop\version-bin\docker.EXE
npmGlobalPackages:
@adobe/aio-cli: Not Found
Sample Code that illustrates the problem
import React from 'react'
import { Heading, View } from '@adobe/react-spectrum'
const sdk = require('@adobe/aio-lib-analytics')
const company = 'test'
const apiKey = 'test key'
const token = 'test token'
const rsid = 'test rsid'
async function initAnalyticsSDK (){
sdkClient = await sdk.init(company, apiKey, token)
// any sdk call here
}
initAnalyticsSDK()
.then(res => {
console.log(res)
})
.catch(e => {
console.log(e)
})
export const Home = () => (
<View width='size-6000'>
<Heading level={1}>Welcome to gcoeProjectHexagon!</Heading>
</View>
)
Logs taken while reproducing problem
I don't have any logs at the moment by can try and retrieve them later if necessary.
Thanks for raising the issue @jbranson000 !
You seem to use the SDK directly on the client. The recommendation when building a Firefly App will be to do it within a Runtime action and benefit from our features like secret management, cloud-based persistence and token validation for authorization.
More details in our doc: https://www.adobe.io/apis/experienceplatform/project-firefly/docs.html#!AdobeDocs/project-firefly/master/getting_started/first_app.md
cc @sandeep-paliwal and @shazron for their review and feedback on your reported issue.
The issue is this library is not a general Javscript library, but actually it's a Node-specific one -- now reflected in the README 260b204
@jbranson000 does that answer your question? Do you need further help on how to use the library within a Runtime action?
It does indeed, and I was able to get a portion of it working. Thank you both for the help.