amplitude / amplitude/Amplitude-TypeScript

Track() is not firing any network calls when initializing with createInstance()

オープン
#649 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
TypeScript
スター
180
フォーク
68
平均マージ
3日 1時間
マージ済み PR(30日)
29

説明

## Expected Behavior

In my Vue application, I installed a plugin to modify the event properties of the default `[Amplitude] Page Viewed` event.
Here is the code for the plugin:
```javascript
export const pageViewTrackingEnrichment = () => {
return {
name: "page-view-tracking-enrichment",
type: "enrichment",
setup: async (config, amplitude) => {
console.log("Installing page-view-tracking-enrichment");
return;
},
execute: async (event) => {
if (event.event_type !== "[Amplitude] Page Viewed") {
return event;
}
event.event_properties = {
...event.event_properties,
new_property: 'new_value'
};
return event;
},
};
};
```

This is how I installed the plugin:
```javascript
const amplitudePlugin = {
async install(Vue, store) {

const decryptedAmplitudeKey = store.state.config.vars.decryptedAmplitudeKey;
const instance = amplitude.createInstance();
instance.add(pageViewTrackingEnrichment());
instance.init(decryptedAmplitudeKey, {
identityStorage: "localStorage",
defaultTracking: true,
loggerProvider: {
enable: () => true,
log: (message) => console.log(message),
debug: (message) => console.debug(message),
warn: (message) => console.warn(message),
error: (message) => console.error(message),
disable: () => false,
},
});

Vue.prototype.$analytics = {
track(eventInput, eventProperties, eventOptions) {
console.log("Tracking event", eventInput, eventProperties, eventOptions);
const trackingPromise = amplitude.track(eventInput, eventProperties, eventOptions)
trackingPromise.promise.catch((error) => {
console.error("Error tracking event", error);
}).then(() => {
console.log("Tracked event", eventInput, eventProperties, eventOptions);
});
}
};
},
};

export default amplitudePlugin;
```
I expected that when I used the track(), it would send an analytics event for me. I also expected the default event `[Amplitude] Page Viewed` would also have a new event property

## Current Behavior

Right now the default event `[Amplitude] Page Viewed` would have the new property. This is what I expected. However, when I use the track(), it did not send any events or print out any errors. The first `console.log` would print out the information of the tracking event. But neither the `console.error` in the catch block or the `console.log` in the then block would print out any information of the tracking event. It also does not give me any network calls in my Network tab of my Chrome browser dev tool

## Possible Solution

## Steps to Reproduce

1. Create a sample vue 2 app
2. Get key for amplitude and install this plugin for Vue app
3. Use this.$analytics.track('Sample track events', { hello_world: 'Hello world' })
4. See if events are being sent in the Chrome network tab

## Environment
- JS SDK Version:
- Installation Method:
- Browser and Version:

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。