|
1 | 1 | /** |
2 | | - * Copyright 2024-2025 Wingify Software Pvt. Ltd. |
| 2 | + * Copyright 2024-2026 Wingify Software Pvt. Ltd. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
15 | 15 | */ |
16 | 16 | package com.vwo; |
17 | 17 |
|
18 | | -import com.vwo.packages.logger.enums.LogLevelEnum; |
19 | | -import com.vwo.services.LoggerService; |
| 18 | +import com.vwo.models.user.GetFlag; |
20 | 19 | import com.vwo.models.user.VWOInitOptions; |
21 | | -import com.vwo.utils.LogMessageUtil; |
22 | | -import com.vwo.utils.UUIDUtils; |
| 20 | +import com.wingify.Wingify; |
| 21 | +import com.wingify.WingifyBuilder; |
| 22 | +import com.wingify.models.user.WingifyUserContext; |
23 | 23 |
|
| 24 | +/** |
| 25 | + * Backward-compatible entry point for the SDK. |
| 26 | + * Existing integrations using {@code com.vwo.VWO} continue to work without code changes. |
| 27 | + * |
| 28 | + * @deprecated Use {@link com.wingify.Wingify} instead. |
| 29 | + */ |
| 30 | +@Deprecated |
| 31 | +public class VWO extends Wingify { |
24 | 32 |
|
25 | | -public class VWO extends VWOClient { |
26 | | - |
27 | | - /** |
28 | | - * Constructor for the VWO class. |
29 | | - * Initializes a new instance of VWO with the provided options. |
30 | | - * @param settings - Settings string for the VWO instance. |
31 | | - * @param vwoBuilder - VWO builder instance containing configuration options. |
32 | | - */ |
33 | | - public VWO(String settings, VWOBuilder vwoBuilder) { |
34 | | - super(settings, vwoBuilder); |
| 33 | + VWO(String settings, WingifyBuilder wingifyBuilder) { |
| 34 | + super(settings, wingifyBuilder); |
35 | 35 | } |
36 | 36 |
|
37 | 37 | /** |
38 | | - * Sets the singleton instance of VWO. |
39 | | - * Configures and builds the VWO instance using the provided options. |
40 | | - * @param options - Configuration options for setting up VWO. |
41 | | - * @return A CompletableFuture resolving to the configured VWO instance. |
| 38 | + * Initializes the SDK using {@link VWOInitOptions}. |
| 39 | + * |
| 40 | + * @deprecated Use {@link com.wingify.Wingify#init(com.wingify.models.user.WingifyInitOptions)} instead. |
42 | 41 | */ |
43 | | - private static VWO setInstance(VWOInitOptions options) { |
44 | | - VWOBuilder vwoBuilder; |
45 | | - if (options.getVwoBuilder() != null) { |
46 | | - vwoBuilder = options.getVwoBuilder(); |
47 | | - } else { |
48 | | - vwoBuilder = new VWOBuilder(options); |
49 | | - } |
50 | | - vwoBuilder |
51 | | - .setLogger() // Sets up logging for debugging and monitoring. |
52 | | - .setSettingsManager() // Sets the settings manager for configuration management. |
53 | | - .setStorage() // Configures storage for data persistence. |
54 | | - .setNetworkManager() // Configures network management for API communication. |
55 | | - .initPolling() // Initializes the polling mechanism for fetching settings. |
56 | | - .initUsageStats(); |
57 | | - |
58 | | - String settings = vwoBuilder.getSettings(false); |
59 | | - vwoBuilder.initBatching(); |
60 | | - VWO vwoInstance = new VWO(settings, vwoBuilder); |
61 | | - // Set VWOClient instance in VWOBuilder |
62 | | - vwoBuilder.setVWOClient(vwoInstance); |
63 | | - |
64 | | - vwoBuilder.getLoggerService().log(LogLevelEnum.INFO, "CLIENT_INITIALIZED", null); |
65 | | - return vwoInstance; |
66 | | - } |
67 | | - |
| 42 | + @Deprecated |
68 | 43 | public static VWO init(VWOInitOptions options) { |
69 | | - if (options == null || options.getSdkKey() == null || options.getSdkKey().isEmpty()) { |
70 | | - String message = "[ERROR]: VWO-SDK Please provide the sdkKey in the options and should be a of type string"; |
71 | | - System.err.println(message); |
72 | | - } |
73 | | - |
74 | | - if (options == null || options.getAccountId() == null || options.getAccountId().toString().isEmpty()) { |
75 | | - String message = "[ERROR]: VWO-SDK Please provide VWO account ID in the options and should be a of type string|number"; |
76 | | - System.err.println(message); |
77 | | - } |
78 | | - |
79 | | - if (options == null ||options.getIsAliasingEnabled() && (options.getGatewayService() == null || options.getGatewayService().isEmpty())) { |
80 | | - String message = "[ERROR]: VWO-SDK Please provide a valid gateway service url in the options when aliasing is enabled"; |
81 | | - System.err.println(message); |
82 | | - } |
83 | | - //start timer |
84 | | - long initStartTime = System.currentTimeMillis(); |
85 | | - VWO instance = VWO.setInstance(options); |
86 | | - long initTime = System.currentTimeMillis() - initStartTime; |
87 | | - // send sdk init event |
88 | | - instance.sendSdkInitAndUsageStatsEvent(initTime); |
89 | | - return instance; |
| 44 | + options.setIsViaVWO(true); |
| 45 | + return (VWO) Wingify.init(options, VWO::new); |
90 | 46 | } |
91 | 47 |
|
92 | 48 | /** |
93 | | - * Generate a deterministic UUID for a given user and account combination. |
| 49 | + * Returns the feature flag result as {@link GetFlag} for backward compatibility. |
94 | 50 | * |
95 | | - * @param userId The user's ID (must be a non-empty string). |
96 | | - * @param accountId The account ID (must be a non-empty string). |
97 | | - * @return UUID without dashes in uppercase, or null on invalid input or error. |
| 51 | + * @deprecated Use {@link com.wingify.WingifyClient#getFlag(String, com.wingify.models.user.WingifyUserContext)} instead. |
98 | 52 | */ |
99 | | - public static String getUUID(String userId, String accountId) { |
100 | | - String apiName = "getUUID"; |
101 | | - try { |
102 | | - // Validate userId |
103 | | - if (userId == null || userId.isEmpty()) { |
104 | | - System.out.println("userId passed to " + apiName + " API is not of valid type."); |
105 | | - return null; |
106 | | - } |
107 | | - |
108 | | - // Validate accountId |
109 | | - if (accountId == null || accountId.isEmpty()) { |
110 | | - System.out.println("accountId passed to " + apiName + " API is not of valid type."); |
111 | | - return null; |
112 | | - } |
113 | | - |
114 | | - // Call the UUID utility function |
115 | | - return UUIDUtils.getUUID(userId, accountId); |
116 | | - |
117 | | - } catch (Exception error) { |
118 | | - System.out.println("API - " + apiName + " failed to execute. Trace: " + error); |
119 | | - return null; |
120 | | - } |
| 53 | + @Deprecated |
| 54 | + @Override |
| 55 | + public GetFlag getFlag(String featureKey, WingifyUserContext context) { |
| 56 | + return new GetFlag(super.getFlag(featureKey, context)); |
121 | 57 | } |
122 | 58 | } |
0 commit comments