amplitude / Amplitude-JavaScript

JavaScript SDK for Amplitude
MIT License
316 stars 133 forks source link

Export "getInstance" was not found in "amplitude-js" #607

Open bureaug opened 1 year ago

bureaug commented 1 year ago

Summary

I have been using amplitude with Angular up to V11 with no problems. After upgrading to Angular 15.2.9 and trying to compile the project I get the following error:

./libs/***/analytics.service.ts:6:22-43 - Error: export 'getInstance' (imported as 'amplitude') was not found in 'amplitude-js' (possible exports: default)

./libs/***/analytics.service.ts:40:25-43 - Error: export 'Identify' (imported as 'amplitude') was not found in 'amplitude-js' (possible exports: default)

The analytics.service.ts looks like this:

import { Injectable } from '@angular/core';
import * as amplitude from 'amplitude-js';

@Injectable()
export class AnalyticsService {

    private amInstance = amplitude.getInstance();
        [...]

Here is an excerpt from my package.json


    "dependencies": {
        "@angular/animations": "15.2.9",
        "@angular/cdk": "15.2.9",
        "@angular/common": "15.2.9",
        "@angular/compiler": "15.2.9",
        "@angular/core": "15.2.9",
        "@angular/forms": "15.2.9",
        "@angular/platform-browser": "15.2.9",
        "@angular/platform-browser-dynamic": "15.2.9",
        "@angular/router": "15.2.9",
        "amplitude-js": "^8.21.9",
        "reflect-metadata": "^0.1.10",
        "rxjs": "~6.6.3",
        "tslib": "^2.0.0",
        "zone.js": "0.12.0"
    },

Thanks for any tips!

bureaug commented 1 year ago

Moved to "@amplitude/analytics-browser": "^2.3.0" package, everything works fine now.