@adobe/ccweb-add-on-analytics 0.1.0

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.
Files changed (60) hide show
  1. package/.c8rc.json +14 -0
  2. package/.mocharc.json +5 -0
  3. package/CODE_OF_CONDUCT.md +79 -0
  4. package/CONTRIBUTING.md +47 -0
  5. package/LICENSE +21 -0
  6. package/README.md +13 -0
  7. package/dist/app/AnalyticsConsent.d.ts +40 -0
  8. package/dist/app/AnalyticsConsent.d.ts.map +1 -0
  9. package/dist/app/AnalyticsConsent.js +25 -0
  10. package/dist/app/AnalyticsService.d.ts +47 -0
  11. package/dist/app/AnalyticsService.d.ts.map +1 -0
  12. package/dist/app/AnalyticsService.js +25 -0
  13. package/dist/app/WxpAnalyticsConsent.d.ts +54 -0
  14. package/dist/app/WxpAnalyticsConsent.d.ts.map +1 -0
  15. package/dist/app/WxpAnalyticsConsent.js +113 -0
  16. package/dist/app/WxpAnalyticsService.d.ts +60 -0
  17. package/dist/app/WxpAnalyticsService.d.ts.map +1 -0
  18. package/dist/app/WxpAnalyticsService.js +112 -0
  19. package/dist/app/index.d.ts +28 -0
  20. package/dist/app/index.d.ts.map +1 -0
  21. package/dist/app/index.js +28 -0
  22. package/dist/config/index.d.ts +26 -0
  23. package/dist/config/index.d.ts.map +1 -0
  24. package/dist/config/index.js +26 -0
  25. package/dist/config/inversify.config.d.ts +27 -0
  26. package/dist/config/inversify.config.d.ts.map +1 -0
  27. package/dist/config/inversify.config.js +32 -0
  28. package/dist/config/inversify.types.d.ts +28 -0
  29. package/dist/config/inversify.types.d.ts.map +1 -0
  30. package/dist/config/inversify.types.js +28 -0
  31. package/dist/constants.d.ts +33 -0
  32. package/dist/constants.d.ts.map +1 -0
  33. package/dist/constants.js +33 -0
  34. package/dist/index.d.ts +28 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +28 -0
  37. package/dist/models/CLIProgram.d.ts +44 -0
  38. package/dist/models/CLIProgram.d.ts.map +1 -0
  39. package/dist/models/CLIProgram.js +47 -0
  40. package/dist/models/index.d.ts +25 -0
  41. package/dist/models/index.d.ts.map +1 -0
  42. package/dist/models/index.js +25 -0
  43. package/dist/tsconfig.tsbuildinfo +1 -0
  44. package/package.json +45 -0
  45. package/src/app/AnalyticsConsent.ts +41 -0
  46. package/src/app/AnalyticsService.ts +50 -0
  47. package/src/app/WxpAnalyticsConsent.ts +119 -0
  48. package/src/app/WxpAnalyticsService.ts +120 -0
  49. package/src/app/index.ts +28 -0
  50. package/src/config/index.ts +26 -0
  51. package/src/config/inversify.config.ts +37 -0
  52. package/src/config/inversify.types.ts +28 -0
  53. package/src/constants.ts +33 -0
  54. package/src/index.ts +28 -0
  55. package/src/models/CLIProgram.ts +49 -0
  56. package/src/models/index.ts +25 -0
  57. package/src/test/app/WxpAnalyticsConsent.spec.ts +190 -0
  58. package/src/test/app/WxpAnalyticsService.spec.ts +162 -0
  59. package/src/test/models/CLIProgram.spec.ts +41 -0
  60. package/tsconfig.json +31 -0
package/.c8rc.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "all": true,
3
+ "include": ["src/**/*.ts"],
4
+ "exclude": [
5
+ "src/**/*.spec.ts",
6
+ "src/**/*Types.ts",
7
+ "src/**/index.ts",
8
+ "src/config/*",
9
+ "src/constants.ts",
10
+ "**/*.d.ts"
11
+ ],
12
+ "reporter": ["html", "text", "text-summary"],
13
+ "report-dir": "coverage"
14
+ }
package/.mocharc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extension": ["ts"],
3
+ "node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm", "no-warnings"],
4
+ "spec": ["src/test/**/*.spec.ts"]
5
+ }
@@ -0,0 +1,79 @@
1
+ # Adobe Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contribute to a positive environment for our project and community include:
12
+
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ - Focusing on what is best, not just for us as individuals but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ - The use of sexualized language or imagery, and sexual attention or advances of any kind
22
+ - Trolling, insulting or derogatory comments, and personal or political attacks
23
+ - Public or private harassment
24
+ - Publishing others’ private information, such as a physical or email address, without their explicit permission
25
+ - Other conduct which could reasonably be considered inappropriate in a professional setting
26
+
27
+ ## Our Responsibilities
28
+
29
+ Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any instances of unacceptable behavior.
30
+
31
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
32
+
33
+ ## Scope
34
+
35
+ This Code of Conduct applies when an individual is representing the project or its community both within project spaces and in public spaces. Examples of representing a project or community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
36
+
37
+ ## Enforcement
38
+
39
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by first contacting the project team. Oversight of Adobe projects is handled by the Adobe Open Source Office, which has final say in any violations and enforcement of this Code of Conduct and can be reached at Grp-opensourceoffice@adobe.com. All complaints will be reviewed and investigated promptly and fairly.
40
+
41
+ The project team must respect the privacy and security of the reporter of any incident.
42
+
43
+ Project maintainers who do not follow or enforce the Code of Conduct may face temporary or permanent repercussions as determined by other members of the project's leadership or the Adobe Open Source Office.
44
+
45
+ ## Enforcement Guidelines
46
+
47
+ Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem to be in violation of this Code of Conduct:
48
+
49
+ **1. Correction**
50
+
51
+ Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
52
+
53
+ Consequence: A private, written warning from project maintainers describing the violation and why the behavior was unacceptable. A public apology may be requested from the violator before any further involvement in the project by violator.
54
+
55
+ **2. Warning**
56
+
57
+ Community Impact: A relatively minor violation through a single incident or series of actions.
58
+
59
+ Consequence: A written warning from project maintainers that includes stated consequences for continued unacceptable behavior. Violator must refrain from interacting with the people involved for a specified period of time as determined by the project maintainers, including, but not limited to, unsolicited interaction with those enforcing the Code of Conduct through channels such as community spaces and social media. Continued violations may lead to a temporary or permanent ban.
60
+
61
+ **3. Temporary Ban**
62
+
63
+ Community Impact: A more serious violation of community standards, including sustained unacceptable behavior.
64
+
65
+ Consequence: A temporary ban from any interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Failure to comply with the temporary ban may lead to a permanent ban.
66
+
67
+ **4. Permanent Ban**
68
+
69
+ Community Impact: Demonstrating a consistent pattern of violation of community standards or an egregious violation of community standards, including, but not limited to, sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
70
+
71
+ Consequence: A permanent ban from any interaction with the community.
72
+
73
+ ## Attribution
74
+
75
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
76
+ available at [http://contributor-covenant.org/version/2/1][version]
77
+
78
+ [homepage]: http://contributor-covenant.org
79
+ [version]: http://contributor-covenant.org/version/2/1
@@ -0,0 +1,47 @@
1
+ # Contributing
2
+
3
+ Thanks for choosing to contribute!
4
+
5
+ The following are a set of guidelines to follow when contributing to this project.
6
+
7
+ ## Code Of Conduct
8
+
9
+ This project adheres to the Adobe [code of conduct](../CODE_OF_CONDUCT.md). By participating,
10
+ you are expected to uphold this code. Please report unacceptable behavior to
11
+ [Grp-opensourceoffice@adobe.com](mailto:Grp-opensourceoffice@adobe.com).
12
+
13
+ ## Have A Question?
14
+
15
+ Start by filing an issue. The existing committers on this project work to reach
16
+ consensus around project direction and issue solutions within issue threads
17
+ (when appropriate).
18
+
19
+ ## Contributor License Agreement
20
+
21
+ All third-party contributions to this project must be accompanied by a signed contributor
22
+ license agreement. This gives Adobe permission to redistribute your contributions
23
+ as part of the project. [Sign our CLA](https://opensource.adobe.com/cla.html). You
24
+ only need to submit an Adobe CLA one time, so if you have submitted one previously,
25
+ you are good to go!
26
+
27
+ ## Code Reviews
28
+
29
+ All submissions should come in the form of pull requests and need to be reviewed
30
+ by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/)
31
+ for more information on sending pull requests.
32
+
33
+ Lastly, please follow the [pull request template](PULL_REQUEST_TEMPLATE.md) when
34
+ submitting a pull request!
35
+
36
+ ## From Contributor To Committer
37
+
38
+ We love contributions from our community! If you'd like to go a step beyond contributor
39
+ and become a committer with full write access and a say in the project, you must
40
+ be invited to the project. The existing committers employ an internal nomination
41
+ process that must reach lazy consensus (silence is approval) before invitations
42
+ are issued. If you feel you are qualified and want to get more deeply involved,
43
+ feel free to reach out to existing committers to have a conversation about that.
44
+
45
+ ## Security Issues
46
+
47
+ Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ © Copyright 2023 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @adobe/ccweb-add-on-analytics
2
+
3
+ [![Version](https://img.shields.io/npm/v/@adobe/ccweb-add-on-analytics.svg)](https://npmjs.org/package/@adobe/ccweb-add-on-analytics)
4
+ [![Downloads/week](https://img.shields.io/npm/dw/@adobe/ccweb-add-on-analytics.svg)](https://npmjs.org/package/@adobe/ccweb-add-on-analytics)
5
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit)
6
+
7
+ ## Description
8
+
9
+ This package provides libraries for capturing analytics events from [@adobe/create-ccweb-add-on](https://www.npmjs.com/package/@adobe/create-ccweb-add-on) runs and sending those to Adobe, therefore providing invaluable insights on usage of the application. With this, Adobe can further improve the experience it provides to its developers.
10
+
11
+ Please be assured that no confidential information is captured or shared. Besides, analytics events are captured only when you provide consent. If at any point of time, you decide to revoke your consent, you may do so by running any of the `ccweb-add-on` commands with the flag `--analytics off`. Similarly, if you wish to turn it back on, you may use the flag `--analytics on`.
12
+
13
+ For more information about developing Adobe Express add-ons, check out the [documentation](https://developer.adobe.com/express/add-ons/).
@@ -0,0 +1,40 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ /**
25
+ * Contract to get and set user's consent
26
+ * on allowing the application to collect and send analytics to Adobe.
27
+ */
28
+ export interface AnalyticsConsent {
29
+ /**
30
+ * Get user consent to collect and send analytics to Adobe.
31
+ * @returns Promise of boolean value representing whether the user has provided consent.
32
+ */
33
+ get(): Promise<boolean>;
34
+ /**
35
+ * Set user consent to collect and send analytics to Adobe.
36
+ * @param consent - Boolean value representing whether the user has provided consent.
37
+ */
38
+ set(consent: boolean): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=AnalyticsConsent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsConsent.d.ts","sourceRoot":"","sources":["../../src/app/AnalyticsConsent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;OAGG;IACH,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAExB;;;OAGG;IACH,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC"}
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ export {};
25
+ //# sourceMappingURL=AnalyticsConsent.js.map
@@ -0,0 +1,47 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ import { CLIProgram } from "../models/index.js";
25
+ /**
26
+ * Analytics service contracts.
27
+ */
28
+ export interface AnalyticsService {
29
+ /**
30
+ * Set the program which is being executed.
31
+ * @param program - {@link CLIProgram} reference.
32
+ */
33
+ set program(program: CLIProgram);
34
+ /**
35
+ * Set the start time of an operation.
36
+ */
37
+ set startTime(time: number);
38
+ /**
39
+ * Post an event to Adobe analytics service.
40
+ * @param eventType - Event type, either a SUCCESS, or an ERROR.
41
+ * @param eventData - Event data.
42
+ * @param isSuccess - Does the event represent a successful operation.
43
+ * @returns Promise.
44
+ */
45
+ postEvent(eventType: string, eventData: string, isSuccess: boolean): Promise<void>;
46
+ }
47
+ //# sourceMappingURL=AnalyticsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnalyticsService.d.ts","sourceRoot":"","sources":["../../src/app/AnalyticsService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;OAGG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE;IAEjC;;OAEG;IACH,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE;IAE5B;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtF"}
@@ -0,0 +1,25 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ export {};
25
+ //# sourceMappingURL=AnalyticsService.js.map
@@ -0,0 +1,54 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ import type { Logger, Preferences } from "@adobe/ccweb-add-on-core";
25
+ import "reflect-metadata";
26
+ import type { AnalyticsConsent } from "./AnalyticsConsent.js";
27
+ /**
28
+ * Implementation class to get and set user's consent
29
+ * on allowing the application to collect and send analytics to Adobe.
30
+ */
31
+ export declare class WxpAnalyticsConsent implements AnalyticsConsent {
32
+ private readonly _preferences;
33
+ private readonly _logger;
34
+ /**
35
+ * Instantiate {@link WxpAnalyticsConsent}.
36
+ * @param preferences - {@link Preferences} reference.
37
+ * @param logger - {@link Logger} reference.
38
+ * @returns Reference to a new {@link WxpAnalyticsConsent} instance.
39
+ */
40
+ constructor(preferences: Preferences, logger: Logger);
41
+ /**
42
+ * Get user consent to collect and send analytics to Adobe.
43
+ * @returns Promise of boolean value representing whether the user has provided consent.
44
+ */
45
+ get(): Promise<boolean>;
46
+ /**
47
+ * Set user consent to collect and send analytics to Adobe.
48
+ * @param consent - Boolean value representing whether the user has provided consent.
49
+ */
50
+ set(consent: boolean): Promise<void>;
51
+ private _promptMessage;
52
+ private _promptMessageOption;
53
+ }
54
+ //# sourceMappingURL=WxpAnalyticsConsent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WxpAnalyticsConsent.d.ts","sourceRoot":"","sources":["../../src/app/WxpAnalyticsConsent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKpE,OAAO,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;GAGG;AACH,qBACa,mBAAoB,YAAW,gBAAgB;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC;;;;;OAKG;gBACyC,WAAW,EAAE,WAAW,EAA6B,MAAM,EAAE,MAAM;IAK/G;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;IAqC7B;;;OAGG;IACG,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,oBAAoB;CAG/B"}
@@ -0,0 +1,113 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ import { __decorate, __metadata, __param } from "tslib";
25
+ import { ITypes as ICoreTypes } from "@adobe/ccweb-add-on-core";
26
+ import chalk from "chalk";
27
+ import { inject, injectable } from "inversify";
28
+ import prompts from "prompts";
29
+ import "reflect-metadata";
30
+ /**
31
+ * Implementation class to get and set user's consent
32
+ * on allowing the application to collect and send analytics to Adobe.
33
+ */
34
+ let WxpAnalyticsConsent = class WxpAnalyticsConsent {
35
+ _preferences;
36
+ _logger;
37
+ /**
38
+ * Instantiate {@link WxpAnalyticsConsent}.
39
+ * @param preferences - {@link Preferences} reference.
40
+ * @param logger - {@link Logger} reference.
41
+ * @returns Reference to a new {@link WxpAnalyticsConsent} instance.
42
+ */
43
+ constructor(preferences, logger) {
44
+ this._preferences = preferences;
45
+ this._logger = logger;
46
+ }
47
+ /**
48
+ * Get user consent to collect and send analytics to Adobe.
49
+ * @returns Promise of boolean value representing whether the user has provided consent.
50
+ */
51
+ async get() {
52
+ // Always get the preference from cache
53
+ // for checking the analytics consent
54
+ // to avoid a file IO operation.
55
+ const preferenceData = this._preferences.get(true);
56
+ if (preferenceData.hasTelemetryConsent !== undefined) {
57
+ return preferenceData.hasTelemetryConsent;
58
+ }
59
+ this._logger.warning(LOGS.toolCollectsAnalytics, { prefix: LOGS.newLine });
60
+ const choices = [
61
+ {
62
+ title: this._promptMessageOption(LOGS.yesSendAnalytics),
63
+ value: true
64
+ },
65
+ {
66
+ title: this._promptMessageOption(LOGS.noDontSendAnalytics),
67
+ value: false
68
+ }
69
+ ];
70
+ const response = await prompts.prompt({
71
+ type: "select",
72
+ name: "analyticsConsent",
73
+ message: this._promptMessage(LOGS.sendToAdobe),
74
+ choices,
75
+ initial: 0
76
+ });
77
+ if (!response || response.analyticsConsent === undefined) {
78
+ return process.exit(0);
79
+ }
80
+ await this.set(response.analyticsConsent);
81
+ return response.analyticsConsent;
82
+ }
83
+ /**
84
+ * Set user consent to collect and send analytics to Adobe.
85
+ * @param consent - Boolean value representing whether the user has provided consent.
86
+ */
87
+ async set(consent) {
88
+ const preferenceData = this._preferences.get();
89
+ preferenceData.hasTelemetryConsent = consent;
90
+ this._preferences.set(preferenceData);
91
+ }
92
+ _promptMessage(message) {
93
+ return chalk.hex("#E59400")(message);
94
+ }
95
+ _promptMessageOption(message) {
96
+ return chalk.green.bold(message);
97
+ }
98
+ };
99
+ WxpAnalyticsConsent = __decorate([
100
+ injectable(),
101
+ __param(0, inject(ICoreTypes.Preferences)),
102
+ __param(1, inject(ICoreTypes.Logger)),
103
+ __metadata("design:paramtypes", [Object, Object])
104
+ ], WxpAnalyticsConsent);
105
+ export { WxpAnalyticsConsent };
106
+ const LOGS = {
107
+ newLine: "\n",
108
+ yesSendAnalytics: "Yes, send analytics to Adobe",
109
+ noDontSendAnalytics: "No, don't send analytics to Adobe",
110
+ toolCollectsAnalytics: "This tool collects and sends analytics to help Adobe improve its products.",
111
+ sendToAdobe: "Do you want to allow sending analytics to Adobe"
112
+ };
113
+ //# sourceMappingURL=WxpAnalyticsConsent.js.map
@@ -0,0 +1,60 @@
1
+ /********************************************************************************
2
+ * MIT License
3
+
4
+ * © Copyright 2023 Adobe. All rights reserved.
5
+
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ ********************************************************************************/
24
+ import type { Preferences } from "@adobe/ccweb-add-on-core";
25
+ import "reflect-metadata";
26
+ import { CLIProgram } from "../models/index.js";
27
+ import type { AnalyticsService } from "./AnalyticsService";
28
+ /**
29
+ * Analytics service implementation.
30
+ */
31
+ export declare class WxpAnalyticsService implements AnalyticsService {
32
+ private readonly _preferences;
33
+ private _program;
34
+ private _startTime;
35
+ /**
36
+ * Instantiate {@link WxpAnalyticsService}.
37
+ * @param preferences - {@link Preferences} reference.
38
+ * @returns Reference to a new {@link WxpAnalyticsService} instance.
39
+ */
40
+ constructor(preferences: Preferences);
41
+ /**
42
+ * Set the program which is being executed.
43
+ * @param program - {@link CLIProgram} reference.
44
+ */
45
+ set program(program: CLIProgram);
46
+ /**
47
+ * Set the start time of an operation.
48
+ */
49
+ set startTime(time: number);
50
+ /**
51
+ * Post an event to Adobe analytics service.
52
+ * @param eventType - Event type, either a SUCCESS, or an ERROR.
53
+ * @param eventData - Event data.
54
+ * @param isSuccess - Does the event represent a successful operation.
55
+ * @returns Promise.
56
+ */
57
+ postEvent(eventType: string, eventData: string, isSuccess: boolean): Promise<void>;
58
+ private _getClientId;
59
+ }
60
+ //# sourceMappingURL=WxpAnalyticsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WxpAnalyticsService.d.ts","sourceRoot":"","sources":["../../src/app/WxpAnalyticsService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;kFAsBkF;AAElF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAK5D,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,qBACa,mBAAoB,YAAW,gBAAgB;IACxD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAE3C,OAAO,CAAC,QAAQ,CAAa;IAE7B,OAAO,CAAC,UAAU,CAAS;IAE3B;;;;OAIG;gBACyC,WAAW,EAAE,WAAW;IAQpE;;;OAGG;IACH,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAE9B;IAED;;OAEG;IACH,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAEzB;IAED;;;;;;OAMG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BxF,OAAO,CAAC,YAAY;CASvB"}