@equinor/mad-insights 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @equinor/mad-insights
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - b2b8572: feat: should now be possible to run `track` before app insights is initialized
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  ### Patch Changes
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AppInsightsInitializer
3
- } from "./chunk-UEUCDD3L.js";
4
- import "./chunk-A36VBZRX.js";
5
- import "./chunk-UBOLTVAF.js";
3
+ } from "./chunk-BWK4IRL4.js";
4
+ import "./chunk-G4C2PBQE.js";
5
+ import "./chunk-BFIJGTYR.js";
6
6
  import "./chunk-Q2JGSIYU.js";
7
7
  export {
8
8
  AppInsightsInitializer
@@ -16,7 +16,7 @@ import {
16
16
  trackNavigation,
17
17
  trackShortTerm,
18
18
  validateAppInsightsInit
19
- } from "./chunk-UBOLTVAF.js";
19
+ } from "./chunk-BFIJGTYR.js";
20
20
  import "./chunk-Q2JGSIYU.js";
21
21
  export {
22
22
  addTelemetryInitializer,
@@ -16,6 +16,8 @@ var hasBeenInitialized = false;
16
16
  var reactPluginWeb;
17
17
  var useSHA1;
18
18
  var envelopeBacklog = [];
19
+ var trackShortTermBacklog = [];
20
+ var trackLongTermBacklog = [];
19
21
  var appInsightsInit = (config) => {
20
22
  var _a, _b;
21
23
  const { connectionString, instrumentationKey } = config;
@@ -76,6 +78,8 @@ var appInsightsInit = (config) => {
76
78
  appInsightsMain.loadAppInsights();
77
79
  }
78
80
  envelopeBacklog.forEach(addTelemetryInitializer);
81
+ trackShortTermBacklog.forEach((item) => trackEvent(item.event, item.customProperties));
82
+ trackLongTermBacklog.forEach((item) => trackEventLongTerm(item.event, item.customProperties));
79
83
  void track("Application STARTED" /* APP_STARTED */);
80
84
  };
81
85
  var appInsightsHasBeenInitialized = () => hasBeenInitialized;
@@ -100,12 +104,17 @@ var setUsername = (username, userIdentifier) => {
100
104
  }
101
105
  };
102
106
  var trackEvent = (event, customProperties) => {
103
- validateAppInsightsInit();
107
+ if (!appInsightsMain) {
108
+ trackShortTermBacklog.push({ event, customProperties });
109
+ return;
110
+ }
104
111
  appInsightsMain.trackEvent(event, customProperties);
105
112
  };
106
113
  var trackEventLongTerm = (event, customProperties) => {
107
- if (!appInsightsLongTermLog)
108
- throw "No long term log set up";
114
+ if (!appInsightsLongTermLog) {
115
+ trackLongTermBacklog.push({ event, customProperties });
116
+ return;
117
+ }
109
118
  appInsightsLongTermLog.trackEvent(event, customProperties);
110
119
  };
111
120
  var track = (eventName, eventStatus, extraText, extraData) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useAppInsights
3
- } from "./chunk-A36VBZRX.js";
3
+ } from "./chunk-G4C2PBQE.js";
4
4
 
5
5
  // src/AppInsightsInitializer.ts
6
6
  var AppInsightsInitializer = ({ children, config }) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  appInsightsHasBeenInitialized,
3
3
  appInsightsInit
4
- } from "./chunk-UBOLTVAF.js";
4
+ } from "./chunk-BFIJGTYR.js";
5
5
 
6
6
  // src/useAppInsights.ts
7
7
  import { useEffect } from "react";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AppInsightsInitializer
3
- } from "./chunk-UEUCDD3L.js";
3
+ } from "./chunk-BWK4IRL4.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
  import {
6
6
  useAppInsights
7
- } from "./chunk-A36VBZRX.js";
7
+ } from "./chunk-G4C2PBQE.js";
8
8
  import {
9
9
  addTelemetryInitializer,
10
10
  appInsightsHasBeenInitialized,
@@ -23,7 +23,7 @@ import {
23
23
  trackNavigation,
24
24
  trackShortTerm,
25
25
  validateAppInsightsInit
26
- } from "./chunk-UBOLTVAF.js";
26
+ } from "./chunk-BFIJGTYR.js";
27
27
  import "./chunk-Q2JGSIYU.js";
28
28
  export {
29
29
  AppInsightsInitializer,
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ITelemetryItem } from "@microsoft/applicationinsights-web";
1
+ import { ICustomProperties, IEventTelemetry, ITelemetryItem } from "@microsoft/applicationinsights-web";
2
2
  export type AppInsightsInitConfig = ({
3
3
  connectionString: string;
4
4
  instrumentationKey?: undefined;
@@ -21,3 +21,7 @@ export type AppInsightsInitConfig = ({
21
21
  };
22
22
  };
23
23
  export type Envelope = (item: ITelemetryItem) => boolean | void;
24
+ export type TrackEventPayload = {
25
+ event: IEventTelemetry;
26
+ customProperties?: ICustomProperties | undefined;
27
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useAppInsights
3
- } from "./chunk-A36VBZRX.js";
4
- import "./chunk-UBOLTVAF.js";
3
+ } from "./chunk-G4C2PBQE.js";
4
+ import "./chunk-BFIJGTYR.js";
5
5
  import "./chunk-Q2JGSIYU.js";
6
6
  export {
7
7
  useAppInsights
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/mad-insights",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Application Insights implementation for the mad team",
5
5
  "type": "module",
6
6
  "keywords": [