@equinor/mad-insights 0.1.1 → 0.1.3

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,17 @@
1
1
  # @equinor/mad-insights
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 6349528: `addTelemetryInitializer`: should no longer crash if long term log is not initialized
8
+
9
+ ## 0.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - b2b8572: feat: should now be possible to run `track` before app insights is initialized
14
+
3
15
  ## 0.1.1
4
16
 
5
17
  ### 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-GCHDCY5M.js";
4
+ import "./chunk-VNYFCEDH.js";
5
+ import "./chunk-ZP5UXSLZ.js";
6
6
  import "./chunk-Q2JGSIYU.js";
7
7
  export {
8
8
  AppInsightsInitializer
@@ -2,7 +2,7 @@ import { ReactPlugin } from "@microsoft/applicationinsights-react-js";
2
2
  import { ApplicationInsights, ICustomProperties } from "@microsoft/applicationinsights-web";
3
3
  import { AppInsightsInitConfig, Envelope } from "./types";
4
4
  declare let appInsightsMain: ApplicationInsights;
5
- declare let appInsightsLongTermLog: ApplicationInsights;
5
+ declare let appInsightsLongTermLog: ApplicationInsights | undefined;
6
6
  declare let reactPluginWeb: ReactPlugin;
7
7
  /**
8
8
  * Initialize appInsights. This should be called at app startup (useEffect inside App.tsx might be a good place to put it).
@@ -16,7 +16,7 @@ import {
16
16
  trackNavigation,
17
17
  trackShortTerm,
18
18
  validateAppInsightsInit
19
- } from "./chunk-UBOLTVAF.js";
19
+ } from "./chunk-ZP5UXSLZ.js";
20
20
  import "./chunk-Q2JGSIYU.js";
21
21
  export {
22
22
  addTelemetryInitializer,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useAppInsights
3
- } from "./chunk-A36VBZRX.js";
3
+ } from "./chunk-VNYFCEDH.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-ZP5UXSLZ.js";
5
5
 
6
6
  // src/useAppInsights.ts
7
7
  import { useEffect } from "react";
@@ -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) => {
@@ -123,7 +132,7 @@ var addTelemetryInitializer = (envelope) => {
123
132
  return;
124
133
  }
125
134
  appInsightsMain.addTelemetryInitializer(envelope);
126
- appInsightsLongTermLog.addTelemetryInitializer(envelope);
135
+ appInsightsLongTermLog == null ? void 0 : appInsightsLongTermLog.addTelemetryInitializer(envelope);
127
136
  };
128
137
  var excludeLogFilter = (eventString, excludeStrings) => excludeStrings.some((excludeString) => eventString.includes(excludeString));
129
138
  var trackShortTerm = (eventName, eventStatus, extraText, extraData) => {
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AppInsightsInitializer
3
- } from "./chunk-UEUCDD3L.js";
3
+ } from "./chunk-GCHDCY5M.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
  import {
6
6
  useAppInsights
7
- } from "./chunk-A36VBZRX.js";
7
+ } from "./chunk-VNYFCEDH.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-ZP5UXSLZ.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-VNYFCEDH.js";
4
+ import "./chunk-ZP5UXSLZ.js";
5
5
  import "./chunk-Q2JGSIYU.js";
6
6
  export {
7
7
  useAppInsights
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
1
  {
2
- "name": "@equinor/mad-insights",
3
- "version": "0.1.1",
4
- "description": "Application Insights implementation for the mad team",
5
- "type": "module",
6
- "keywords": [
7
- "react native",
8
- "tracking",
9
- "logging",
10
- "typescript"
11
- ],
12
- "author": {
13
- "name": "Equinor Mobile App Delivery team (MAD)"
14
- },
15
- "license": "MIT",
16
- "bugs": {
17
- "url": "https://github.com/equinor/mad/issues"
18
- },
19
- "homepage": "https://github.com/equinor/mad/",
20
- "main": "./dist/index.js",
21
- "types": "./dist/index.d.ts",
22
- "peerDependencies": {
23
- "react": ">=18.0",
24
- "react-dom": ">=18.0",
25
- "react-native": ">=0.70",
26
- "react-native-device-info": "^10.8.0"
27
- },
28
- "dependencies": {
29
- "@microsoft/applicationinsights-react-js": "^17.0.0",
30
- "@microsoft/applicationinsights-react-native": "^4.0.2",
31
- "@microsoft/applicationinsights-web": "^3.0.2",
32
- "crypto-js": "^4.1.1",
33
- "history": "^5.3.0"
34
- },
35
- "devDependencies": {
36
- "@types/crypto-js": "^4.1.2",
37
- "@equinor/eslint-config-mad": "0.3.1"
38
- },
39
- "files": [
40
- "CODE_OF_CONDUCT.md",
41
- "LICENSE",
42
- "CHANGELOG.md",
43
- "dist"
44
- ],
45
- "scripts": {
46
- "build": "tsup-node && echo '\n ⚙️ Generating typescript declarations..' && tsc --project tsconfig.json --emitDeclarationOnly --declaration",
47
- "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js",
48
- "dev": "tsup-node --watch --clean=false",
49
- "lint": "eslint src/",
50
- "clean": "rm -rf node_modules/ && rm -rf dist/"
51
- }
2
+ "name": "@equinor/mad-insights",
3
+ "version": "0.1.3",
4
+ "description": "Application Insights implementation for the mad team",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "tsup-node && echo '\n ⚙️ Generating typescript declarations..' && tsc --project tsconfig.json --emitDeclarationOnly --declaration",
8
+ "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js",
9
+ "dev": "tsup-node --watch --clean=false",
10
+ "lint": "eslint src/",
11
+ "clean": "rm -rf node_modules/ && rm -rf dist/"
12
+ },
13
+ "keywords": [
14
+ "react native",
15
+ "tracking",
16
+ "logging",
17
+ "typescript"
18
+ ],
19
+ "author": {
20
+ "name": "Equinor Mobile App Delivery team (MAD)"
21
+ },
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/equinor/mad/issues"
25
+ },
26
+ "homepage": "https://github.com/equinor/mad/",
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "peerDependencies": {
30
+ "react": ">=18.0",
31
+ "react-dom": ">=18.0",
32
+ "react-native": ">=0.70",
33
+ "react-native-device-info": "^10.8.0"
34
+ },
35
+ "dependencies": {
36
+ "@microsoft/applicationinsights-react-js": "^17.0.0",
37
+ "@microsoft/applicationinsights-react-native": "^4.0.2",
38
+ "@microsoft/applicationinsights-web": "^3.0.2",
39
+ "crypto-js": "^4.1.1",
40
+ "history": "^5.3.0"
41
+ },
42
+ "devDependencies": {
43
+ "@equinor/eslint-config-mad": "*",
44
+ "@types/crypto-js": "^4.1.2"
45
+ },
46
+ "files": [
47
+ "CODE_OF_CONDUCT.md",
48
+ "LICENSE",
49
+ "CHANGELOG.md",
50
+ "dist"
51
+ ]
52
52
  }